1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-24 03:35:53 +01:00

API cleanup

This commit is contained in:
Martin Tůma 2024-05-20 19:10:56 +02:00
parent 6ef6644260
commit 11677f5e35
3 changed files with 23 additions and 29 deletions

View File

@ -138,16 +138,11 @@ QList<const DEMTile*> DEMFile::tiles(const RectC &rect, int level) const
int DEMFile::level(const Zoom &zoom) const
{
/*
for (int i = 0; i < _levels.size(); i++)
if (_levels.at(i).level >= zoom.level())
return i;
return _levels.size() - 1;
*/
Q_UNUSED(zoom);
return 0;
}
MapData::Elevation *DEMFile::elevations(Handle &hdl, int level,
@ -170,7 +165,7 @@ MapData::Elevation *DEMFile::elevations(Handle &hdl, int level,
quint16 lim = limit(tile, l.factor);
Matrix<qint16> m(tile->h(), tile->w());
JLS jls(tile->diff(), l.factor, tile->w());
JLS jls(tile->diff(), l.factor);
if (jls.decode(this, hdl, m)) {
for (int i = 0; i < m.size(); i++) {
if (m.at(i) >= lim)

View File

@ -21,10 +21,8 @@ static const int J[] = {
4, 4, 5, 5, 6, 6, 7, 7, 8, 9, 10, 11, 12, 13, 14, 15
};
JLS::JLS(quint16 diff, quint16 factor, quint16 cols)
: _data((cols + 3) * 2)
JLS::JLS(quint16 diff, quint16 factor)
{
_w = cols;
_maxval = diff;
_near = factor;
@ -33,21 +31,6 @@ JLS::JLS(quint16 diff, quint16 factor, quint16 cols)
quint8 bpp = max(2, ceil(log2(_maxval + 1)));
quint8 LIMIT = 2 * (bpp + max(8, bpp));
_limit = LIMIT - _qbpp - 1;
_runIndex = 0;
_rk = 0;
_rg = 1;
_lrk = 0;
quint16 A = max(2, (_range + 32) / 64);
for (int i = 0; i < 4; i++) {
_a[i] = A;
_b[i] = 0;
_n[i] = 1;
}
_last = _data.data();
_current = _data.data() + (cols + 3);
}
bool JLS::processRunMode(BitStream &bs, quint16 col, quint16 &samples)
@ -308,11 +291,28 @@ bool JLS::decode(const SubFile *file, SubFile::Handle &hdl, Matrix<qint16> &img)
if (!bs.init())
return false;
_w = img.w();
_data = QVector<quint16>((_w + 3) * 2);
_last = _data.data();
_current = _data.data() + (_w + 3);
_runIndex = 0;
_rk = 0;
_rg = 1;
_lrk = 0;
quint16 A = max(2, (_range + 32) / 64);
for (int i = 0; i < 4; i++) {
_a[i] = A;
_b[i] = 0;
_n[i] = 1;
}
for (int i = 0; i < img.h(); i++) {
if (!readLine(bs))
return false;
memcpy(&img.at(i, 0), _current + 1, img.w() * sizeof(quint16));
memcpy(&img.at(i, 0), _current + 1, _w * sizeof(quint16));
quint16 *tmp = _last;
_last = _current;

View File

@ -10,7 +10,7 @@ namespace IMG {
class JLS
{
public:
JLS(quint16 diff, quint16 factor, quint16 cols);
JLS(quint16 diff, quint16 factor);
bool decode(const SubFile *file, SubFile::Handle &hdl, Matrix<qint16> &img);
@ -36,7 +36,7 @@ private:
_value <<= bits;
_shift += bits;
while (-1 < (char)_shift) {
while (-1 < (qint8)_shift) {
if (!_file->readByte(_hdl, &data))
return false;
@ -60,10 +60,8 @@ private:
bool processRunMode(BitStream &bs, quint16 col, quint16 &samples);
bool decodeError(BitStream &bs, quint8 limit, quint8 k, uint &MErrval);
quint16 _w;
quint16 _maxval;
quint16 _near;
quint16 _range;
quint8 _qbpp;
quint8 _limit;
@ -76,6 +74,7 @@ private:
qint16 _b[4];
quint8 _lrk;
quint16 _w;
QVector<quint16> _data;
quint16 *_current;
quint16 *_last;