| 1 |
/* |
| 2 |
Copyright (c) 1993-2008, Cognitive Technologies |
| 3 |
All rights reserved. |
| 4 |
|
| 5 |
Разрешается повторное распространение и использование как в виде исходного кода, |
| 6 |
так и в двоичной форме, с изменениями или без, при соблюдении следующих условий: |
| 7 |
|
| 8 |
* При повторном распространении исходного кода должны оставаться указанное |
| 9 |
выше уведомление об авторском праве, этот список условий и последующий |
| 10 |
отказ от гарантий. |
| 11 |
* При повторном распространении двоичного кода в документации и/или в |
| 12 |
других материалах, поставляемых при распространении, должны сохраняться |
| 13 |
указанная выше информация об авторском праве, этот список условий и |
| 14 |
последующий отказ от гарантий. |
| 15 |
* Ни название Cognitive Technologies, ни имена ее сотрудников не могут |
| 16 |
быть использованы в качестве средства поддержки и/или продвижения |
| 17 |
продуктов, основанных на этом ПО, без предварительного письменного |
| 18 |
разрешения. |
| 19 |
|
| 20 |
ЭТА ПРОГРАММА ПРЕДОСТАВЛЕНА ВЛАДЕЛЬЦАМИ АВТОРСКИХ ПРАВ И/ИЛИ ДРУГИМИ ЛИЦАМИ "КАК |
| 21 |
ОНА ЕСТЬ" БЕЗ КАКОГО-ЛИБО ВИДА ГАРАНТИЙ, ВЫРАЖЕННЫХ ЯВНО ИЛИ ПОДРАЗУМЕВАЕМЫХ, |
| 22 |
ВКЛЮЧАЯ ГАРАНТИИ КОММЕРЧЕСКОЙ ЦЕННОСТИ И ПРИГОДНОСТИ ДЛЯ КОНКРЕТНОЙ ЦЕЛИ, НО НЕ |
| 23 |
ОГРАНИЧИВАЯСЬ ИМИ. НИ ВЛАДЕЛЕЦ АВТОРСКИХ ПРАВ И НИ ОДНО ДРУГОЕ ЛИЦО, КОТОРОЕ |
| 24 |
МОЖЕТ ИЗМЕНЯТЬ И/ИЛИ ПОВТОРНО РАСПРОСТРАНЯТЬ ПРОГРАММУ, НИ В КОЕМ СЛУЧАЕ НЕ |
| 25 |
НЕСЁТ ОТВЕТСТВЕННОСТИ, ВКЛЮЧАЯ ЛЮБЫЕ ОБЩИЕ, СЛУЧАЙНЫЕ, СПЕЦИАЛЬНЫЕ ИЛИ |
| 26 |
ПОСЛЕДОВАВШИЕ УБЫТКИ, СВЯЗАННЫЕ С ИСПОЛЬЗОВАНИЕМ ИЛИ ПОНЕСЕННЫЕ ВСЛЕДСТВИЕ |
| 27 |
НЕВОЗМОЖНОСТИ ИСПОЛЬЗОВАНИЯ ПРОГРАММЫ (ВКЛЮЧАЯ ПОТЕРИ ДАННЫХ, ИЛИ ДАННЫЕ, |
| 28 |
СТАВШИЕ НЕГОДНЫМИ, ИЛИ УБЫТКИ И/ИЛИ ПОТЕРИ ДОХОДОВ, ПОНЕСЕННЫЕ ИЗ-ЗА ДЕЙСТВИЙ |
| 29 |
ТРЕТЬИХ ЛИЦ И/ИЛИ ОТКАЗА ПРОГРАММЫ РАБОТАТЬ СОВМЕСТНО С ДРУГИМИ ПРОГРАММАМИ, |
| 30 |
НО НЕ ОГРАНИЧИВАЯСЬ ЭТИМИ СЛУЧАЯМИ), НО НЕ ОГРАНИЧИВАЯСЬ ИМИ, ДАЖЕ ЕСЛИ ТАКОЙ |
| 31 |
ВЛАДЕЛЕЦ ИЛИ ДРУГОЕ ЛИЦО БЫЛИ ИЗВЕЩЕНЫ О ВОЗМОЖНОСТИ ТАКИХ УБЫТКОВ И ПОТЕРЬ. |
| 32 |
|
| 33 |
Redistribution and use in source and binary forms, with or without modification, |
| 34 |
are permitted provided that the following conditions are met: |
| 35 |
|
| 36 |
* Redistributions of source code must retain the above copyright notice, |
| 37 |
this list of conditions and the following disclaimer. |
| 38 |
* Redistributions in binary form must reproduce the above copyright notice, |
| 39 |
this list of conditions and the following disclaimer in the documentation |
| 40 |
and/or other materials provided with the distribution. |
| 41 |
* Neither the name of the Cognitive Technologies nor the names of its |
| 42 |
contributors may be used to endorse or promote products derived from this |
| 43 |
software without specific prior written permission. |
| 44 |
|
| 45 |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
| 46 |
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 47 |
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 48 |
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE |
| 49 |
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 50 |
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| 51 |
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| 52 |
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
| 53 |
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 54 |
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 55 |
*/ |
| 56 |
|
| 57 |
#include "lnslang.h" |
| 58 |
|
| 59 |
#ifndef __FLTBUF_H |
| 60 |
# include "fltbuf.h" |
| 61 |
#endif |
| 62 |
|
| 63 |
#ifndef __MEMOPS_H |
| 64 |
# include "memops.h" |
| 65 |
#endif |
| 66 |
#ifndef __XMACROS_H |
| 67 |
# include "xmacros.h" |
| 68 |
#endif |
| 69 |
TFltBuf::TFltBuf( int width_dword ) |
| 70 |
{ |
| 71 |
x16 = NULL; |
| 72 |
if ( (int32_t)32 * sizeof(int32_t) * (int32_t)width_dword > (int32_t)0xFFF0){ |
| 73 |
// size of buffer > 64K |
| 74 |
return; |
| 75 |
}; |
| 76 |
|
| 77 |
x16 = (int32_t *)(malloc( (int32_t)32 * (int32_t)sizeof(int32_t) * (int32_t)width_dword )); |
| 78 |
if (x16 == NULL) { |
| 79 |
return; |
| 80 |
}; |
| 81 |
widthDWord = width_dword; |
| 82 |
x8 = x16 + 16*widthDWord; |
| 83 |
x4 = x8 + 8 *widthDWord; |
| 84 |
x2 = x4 + 4 *widthDWord; |
| 85 |
cur16 = x2 + 2 *widthDWord; |
| 86 |
last16 = cur16 + widthDWord; |
| 87 |
|
| 88 |
nCurLine = 0; |
| 89 |
|
| 90 |
} |
| 91 |
|
| 92 |
void TFltBuf::destroy( void ) |
| 93 |
{ |
| 94 |
if (x16!=NULL) { |
| 95 |
free( (void*)x16 ); |
| 96 |
x16 = NULL; |
| 97 |
}; |
| 98 |
} |
| 99 |
|
| 100 |
void TFltBuf::addLine( void* new_line ) |
| 101 |
{ |
| 102 |
memmove( (void*)(x16+widthDWord*nCurLine), new_line, widthDWord*4 ); |
| 103 |
nCurLine++; |
| 104 |
} |
| 105 |
|
| 106 |
/***********************/ |
| 107 |
#define A_B_to_AB() { memcpy(curAB, curA, wdw<<2); CopyOR(curAB, curB, wdw); } |
| 108 |
/***********************/ |
| 109 |
|
| 110 |
void TFltBuf::preBuffer( void ) |
| 111 |
{ |
| 112 |
int wdw = widthDWord; |
| 113 |
int32_t* curA; |
| 114 |
int32_t* curB; |
| 115 |
int32_t* curAB; |
| 116 |
int i=0; |
| 117 |
|
| 118 |
curA = (int32_t*)x16; |
| 119 |
curB = (int32_t*)x16 + wdw; |
| 120 |
curAB = (int32_t*)x8; |
| 121 |
for( i = 0; i < 8; i++ ){ |
| 122 |
A_B_to_AB(); |
| 123 |
curAB += wdw; |
| 124 |
curA += wdw*2; |
| 125 |
curB += wdw*2; |
| 126 |
}; |
| 127 |
|
| 128 |
curA = (int32_t*)x8; |
| 129 |
curB = (int32_t*)x8 + wdw; |
| 130 |
curAB = (int32_t*)x4; |
| 131 |
for( i = 0; i < 4; i++ ){ |
| 132 |
A_B_to_AB(); |
| 133 |
curAB += wdw; |
| 134 |
curA += wdw*2; |
| 135 |
curB += wdw*2; |
| 136 |
}; |
| 137 |
|
| 138 |
curA = (int32_t*)x4; |
| 139 |
curB = (int32_t*)x4 + wdw; |
| 140 |
curAB = (int32_t*)x2; |
| 141 |
for( i = 0; i < 2; i++ ){ |
| 142 |
A_B_to_AB(); |
| 143 |
curAB += wdw; |
| 144 |
curA += wdw*2; |
| 145 |
curB += wdw*2; |
| 146 |
}; |
| 147 |
|
| 148 |
curA = (int32_t*)x2; |
| 149 |
curB = (int32_t*)x2 + wdw; |
| 150 |
curAB = (int32_t*)cur16; |
| 151 |
A_B_to_AB(); |
| 152 |
|
| 153 |
nCurLine = 0; |
| 154 |
} |
| 155 |
|
| 156 |
void TFltBuf::updateByLine( void* new_line ) |
| 157 |
{ |
| 158 |
int wdw = widthDWord; |
| 159 |
int32_t* curA; |
| 160 |
int32_t* curB; |
| 161 |
int32_t* curAB; |
| 162 |
int32_t n_cur = nCurLine; |
| 163 |
|
| 164 |
|
| 165 |
swap( last16, cur16 ); |
| 166 |
|
| 167 |
curA = (int32_t*)x16+wdw*n_cur; |
| 168 |
memmove( (void*)curA, new_line, wdw*4 ); |
| 169 |
curB = (n_cur & (int32_t)1) ? |
| 170 |
(int32_t*)x16+wdw*(n_cur - 1): // odd - get previous |
| 171 |
(int32_t*)x16+wdw*(n_cur + 1); // even - get next |
| 172 |
n_cur >>= 1; |
| 173 |
curAB = (int32_t*)x8 + wdw*n_cur; |
| 174 |
A_B_to_AB(); |
| 175 |
|
| 176 |
curA = (int32_t*)x8+wdw*n_cur; |
| 177 |
curB = (n_cur & (int32_t)1) ? |
| 178 |
(int32_t*)x8+wdw*(n_cur - 1): // odd - get previous |
| 179 |
(int32_t*)x8+wdw*(n_cur + 1); // even - get next |
| 180 |
n_cur >>= 1; |
| 181 |
curAB = (int32_t*)x4 + wdw*n_cur; |
| 182 |
A_B_to_AB(); |
| 183 |
|
| 184 |
curA = (int32_t*)x4+wdw*n_cur; |
| 185 |
curB = (n_cur & (int32_t)1) ? |
| 186 |
(int32_t*)x4+wdw*(n_cur - 1): // odd - get previous |
| 187 |
(int32_t*)x4+wdw*(n_cur + 1); // even - get next |
| 188 |
n_cur >>= 1; |
| 189 |
curAB = (int32_t*)x2 + wdw*n_cur; |
| 190 |
A_B_to_AB(); |
| 191 |
|
| 192 |
curA = (int32_t*)x2+wdw*n_cur; |
| 193 |
curB = (n_cur & (int32_t)1) ? |
| 194 |
(int32_t*)x2+wdw*(n_cur - 1): // odd - get previous |
| 195 |
(int32_t*)x2+wdw*(n_cur + 1); // even - get next |
| 196 |
n_cur >>= 1; |
| 197 |
assert( n_cur == 0 ); |
| 198 |
curAB = (int32_t*)cur16; // + wdw*n_cur; |
| 199 |
A_B_to_AB(); |
| 200 |
|
| 201 |
nCurLine++; |
| 202 |
if (nCurLine > 15) |
| 203 |
nCurLine = 0; |
| 204 |
} |