Skip to content

Commit b009615

Browse files
committed
Release 1.0.29
* Implemented simple compressor for Wavefront OBJ files. * Fixed bug in determining file size for Unix-like systems. * Several optimizations of standard compression algorithm. * Fixed bug in associativity of add, sub, mul, div and bit-and expressions. * Added MacOS CI builds. * Updated module versions in dependencies.
2 parents 4660d1a + 7480807 commit b009615

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+99254
-456
lines changed

.github/workflows/build.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,3 +188,25 @@ jobs:
188188
- name: Run unit tests
189189
shell: msys2 {0}
190190
run: .build/target/${{env.ARTIFACT}}/${{env.ARTIFACT}}-test.exe utest --verbose --jobs 1
191+
macos_stable:
192+
runs-on: macos-latest
193+
steps:
194+
- name: Update repositories
195+
run: brew update
196+
- name: Install dependencies
197+
run: brew install make pkgconf cairo freetype
198+
- uses: actions/checkout@v3
199+
- name: Configure project
200+
run: gmake config TEST=1 STRICT=1 DEBUG=1 ASAN=1
201+
- name: Fetch project dependencies
202+
run: gmake fetch
203+
- name: Build project
204+
run: gmake VERBOSE=1
205+
- name: Run unit tests
206+
run: .build/target/${{env.ARTIFACT}}/${{env.ARTIFACT}}-test utest --verbose --jobs 1
207+
- name: Run unit tests with memcheck
208+
run: |
209+
for test in $(.build/target/${{env.ARTIFACT}}/${{env.ARTIFACT}}-test utest --list --suppress); do \
210+
echo "***** MEMCHECK $test *****"; \
211+
.build/target/${{env.ARTIFACT}}/${{env.ARTIFACT}}-test utest --verbose --jobs 1 --nofork --debug $test; \
212+
done

CHANGELOG

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22
* RECENT CHANGES
33
*******************************************************************************
44

5+
=== 1.0.29 ===
6+
* Implemented simple compressor for Wavefront OBJ files.
7+
* Fixed bug in determining file size for Unix-like systems.
8+
* Several optimizations of standard compression algorithm.
9+
* Fixed bug in associativity of add, sub, mul, div and bit-and expressions.
10+
* Added MacOS CI builds.
11+
* Updated module versions in dependencies.
12+
513
=== 1.0.28 ===
614
* Reduced poll interval for ipc::NativeExecutor to 20 milliseconds.
715
* Fixed invalid access to missing built-in resources.
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
/*
2+
* Copyright (C) 2025 Linux Studio Plugins Project <https://lsp-plug.in/>
3+
* (C) 2025 Vladimir Sadovnikov <[email protected]>
4+
*
5+
* This file is part of lsp-runtime-lib
6+
* Created on: 23 июл. 2025 г.
7+
*
8+
* lsp-runtime-lib is free software: you can redistribute it and/or modify
9+
* it under the terms of the GNU Lesser General Public License as published by
10+
* the Free Software Foundation, either version 3 of the License, or
11+
* any later version.
12+
*
13+
* lsp-runtime-lib is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
* GNU Lesser General Public License for more details.
17+
*
18+
* You should have received a copy of the GNU Lesser General Public License
19+
* along with lsp-runtime-lib. If not, see <https://www.gnu.org/licenses/>.
20+
*/
21+
22+
#ifndef LSP_PLUG_IN_FMT_OBJ_COMPRESSOR_H_
23+
#define LSP_PLUG_IN_FMT_OBJ_COMPRESSOR_H_
24+
25+
#include <lsp-plug.in/runtime/version.h>
26+
#include <lsp-plug.in/io/File.h>
27+
#include <lsp-plug.in/io/IOutStream.h>
28+
#include <lsp-plug.in/io/OutBitStream.h>
29+
30+
#include <lsp-plug.in/fmt/obj/const.h>
31+
#include <lsp-plug.in/fmt/obj/IObjHandler.h>
32+
33+
namespace lsp
34+
{
35+
namespace obj
36+
{
37+
/**
38+
* OBJ format compressor
39+
*/
40+
class Compressor: public IObjHandler
41+
{
42+
protected:
43+
io::OutBitStream *pOut;
44+
45+
union
46+
{
47+
float *vFloatBuf;
48+
uint32_t *vIntBuf;
49+
};
50+
51+
uint32_t nFloatHead;
52+
uint32_t nFloatSize;
53+
uint32_t nFloatCap;
54+
uint32_t nFloatBits;
55+
56+
uint32_t nLastEvent;
57+
58+
size_t nWFlags;
59+
60+
protected:
61+
status_t do_wrap(io::OutBitStream * & obs, size_t flags = WRAP_CLOSE | WRAP_DELETE);
62+
status_t write_varint(size_t value);
63+
status_t write_varint_icount(size_t value);
64+
status_t write_float(float value);
65+
inline status_t write_indices(const index_t *value, size_t count);
66+
inline status_t write_event(uint32_t event);
67+
inline status_t write_utf8(const char *text);
68+
static bool has_nonempty_index(const index_t *v, size_t count);
69+
static bool has_equal_indices(const index_t *v, size_t count);
70+
71+
public:
72+
Compressor();
73+
Compressor(const Compressor &) = delete;
74+
Compressor(Compressor &&) = delete;
75+
virtual ~Compressor() override;
76+
77+
Compressor & operator = (const Compressor &) = delete;
78+
Compressor & operator = (Compressor &&) = delete;
79+
80+
public:
81+
status_t open(const char *path, size_t mode);
82+
status_t open(const LSPString *path, size_t mode);
83+
status_t open(const io::Path *path, size_t mode);
84+
85+
status_t wrap(FILE *fd, bool close);
86+
status_t wrap_native(fhandle_t fd, bool close);
87+
status_t wrap(io::File *fd, size_t flags = 0);
88+
status_t wrap(io::IOutStream *os, size_t flags = 0);
89+
status_t wrap(io::OutBitStream *obs, size_t flags = 0);
90+
91+
status_t close();
92+
93+
public:
94+
/**
95+
* Set buffer size
96+
* @param float_bits
97+
* @return status of operation
98+
*/
99+
status_t set_buffer_size(size_t float_bits);
100+
101+
public:
102+
virtual status_t begin_object(const char *name) override;
103+
virtual status_t begin_object(const LSPString *name) override;
104+
virtual status_t end_object() override;
105+
virtual status_t end_of_data() override;
106+
virtual ssize_t add_vertex(float x, float y, float z, float w) override;
107+
virtual ssize_t add_param_vertex(float x, float y, float z, float w) override;
108+
virtual ssize_t add_normal(float nx, float ny, float nz, float nw) override;
109+
virtual ssize_t add_texture_vertex(float u, float v, float w) override;
110+
virtual ssize_t add_face(const index_t *vv, const index_t *vn, const index_t *vt, size_t n) override;
111+
virtual ssize_t add_points(const index_t *vv, size_t n) override;
112+
virtual ssize_t add_line(const index_t *vv, const index_t *vt, size_t n) override;
113+
};
114+
115+
} /* namespace obj */
116+
} /* namespace lsp */
117+
118+
119+
120+
#endif /* LSP_PL;UG_IN_FMT_OBJ_COMPRESSOR_H_ */
Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
/*
2+
* Copyright (C) 2025 Linux Studio Plugins Project <https://lsp-plug.in/>
3+
* (C) 2025 Vladimir Sadovnikov <[email protected]>
4+
*
5+
* This file is part of lsp-runtime-lib
6+
* Created on: 26 июл. 2025 г.
7+
*
8+
* lsp-runtime-lib is free software: you can redistribute it and/or modify
9+
* it under the terms of the GNU Lesser General Public License as published by
10+
* the Free Software Foundation, either version 3 of the License, or
11+
* any later version.
12+
*
13+
* lsp-runtime-lib is distributed in the hope that it will be useful,
14+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
* GNU Lesser General Public License for more details.
17+
*
18+
* You should have received a copy of the GNU Lesser General Public License
19+
* along with lsp-runtime-lib. If not, see <https://www.gnu.org/licenses/>.
20+
*/
21+
22+
#ifndef LSP_PLUG_IN_FMT_OBJ_DECOMPRESSOR_H_
23+
#define LSP_PLUG_IN_FMT_OBJ_DECOMPRESSOR_H_
24+
25+
#include <lsp-plug.in/runtime/version.h>
26+
#include <lsp-plug.in/fmt/obj/const.h>
27+
#include <lsp-plug.in/fmt/obj/PullParser.h>
28+
#include <lsp-plug.in/fmt/obj/IObjHandler.h>
29+
#include <lsp-plug.in/io/InBitStream.h>
30+
31+
namespace lsp
32+
{
33+
namespace obj
34+
{
35+
36+
class Decompressor
37+
{
38+
protected:
39+
io::InBitStream sStream;
40+
union
41+
{
42+
float *vFloatBuf;
43+
uint32_t *vIntBuf;
44+
};
45+
46+
uint32_t nFloatHead;
47+
uint32_t nFloatSize;
48+
uint32_t nFloatCap;
49+
uint32_t nFloatBits;
50+
51+
compressed_event_type_t nLastEvent;
52+
53+
protected:
54+
status_t parse_data(IObjHandler *handler);
55+
status_t parse_header();
56+
void clear_state();
57+
status_t read_event(compressed_event_type_t *event);
58+
status_t parse_vertex(IObjHandler *handler, size_t coords);
59+
status_t parse_pvertex(IObjHandler *handler, size_t coords);
60+
status_t parse_normal(IObjHandler *handler, size_t coords);
61+
status_t parse_texcoord(IObjHandler *handler, size_t coords);
62+
status_t parse_face(IObjHandler *handler, bool texcoords, bool normals, bool fill);
63+
status_t parse_line(IObjHandler *handler, bool texcoords);
64+
status_t parse_points(IObjHandler *handler);
65+
status_t parse_object(IObjHandler *handler);
66+
status_t read_float(float *dst);
67+
status_t read_varint(size_t *dst);
68+
status_t read_varint_icount(size_t *dst);
69+
status_t read_indices(index_t *dst, size_t count, bool read);
70+
status_t read_utf8(LSPString *dst);
71+
72+
public:
73+
explicit Decompressor();
74+
Decompressor(const Decompressor &) = delete;
75+
Decompressor(Decompressor &&) = delete;
76+
virtual ~Decompressor();
77+
78+
Decompressor & operator = (const Decompressor &) = delete;
79+
Decompressor & operator = (Decompressor &&) = delete;
80+
81+
public:
82+
/**
83+
* Parse compressed OBJ file
84+
* @param handler Wavefront Object file handler
85+
* @param path UTF-8 path to the file
86+
* @param charset character set encoding of the file
87+
* @return status of operation
88+
*/
89+
status_t parse_file(IObjHandler *handler, const char *path);
90+
91+
/**
92+
* Parse compressed OBJ file
93+
* @param handler Wavefront Object file handler
94+
* @param path path to the file
95+
* @param charset character set encoding of the file
96+
* @return status of operation
97+
*/
98+
status_t parse_file(IObjHandler *handler, const LSPString *path);
99+
100+
/**
101+
* Parse compressed OBJ file
102+
* @param handler Wavefront Object file handler
103+
* @param path path to the file
104+
* @param charset character set encoding of the file
105+
* @return status of operation
106+
*/
107+
status_t parse_file(IObjHandler *handler, const io::Path *path);
108+
109+
/**
110+
* Parse compressed OBJ data from input stream
111+
* @param handler Wavefront Object file handler
112+
* @param is input stream
113+
* @param flags wrap flags
114+
* @param charset character set
115+
* @return status of operation
116+
*/
117+
status_t parse_data(IObjHandler *handler, io::IInStream *is, size_t flags = WRAP_NONE);
118+
119+
/**
120+
* Parse compressed OBJ data from memory
121+
* @param handler Wavefront Object file handler
122+
* @param data byte buffer
123+
* @param size size of byte buffer
124+
* @return status of operation
125+
*/
126+
status_t parse_data(IObjHandler *handler, const void *data, size_t size);
127+
};
128+
129+
} /* namespace obj */
130+
} /* namespace lsp */
131+
132+
133+
134+
#endif /* LSP_PLUG_IN_FMT_OBJ_DECOMPRESSOR_H_ */

include/lsp-plug.in/fmt/obj/PullParser.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ namespace lsp
4949
lsp_wchar_t *pBuffer; // Buffer for character data
5050
size_t nBufOff; // Buffer offset
5151
size_t nBufLen; // Buffer length
52-
bool bSkipLF; // Skip line-feed character
5352
size_t nLines; // Number of lines read
5453

5554
event_t sEvent;

include/lsp-plug.in/fmt/obj/PushParser.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ namespace lsp
3636
protected:
3737
PullParser sParser;
3838

39-
public:
39+
protected:
4040
status_t parse_document(IObjHandler *handler);
4141

4242
public:

include/lsp-plug.in/fmt/obj/const.h

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
2-
* Copyright (C) 2020 Linux Studio Plugins Project <https://lsp-plug.in/>
3-
* (C) 2020 Vladimir Sadovnikov <[email protected]>
2+
* Copyright (C) 2025 Linux Studio Plugins Project <https://lsp-plug.in/>
3+
* (C) 2025 Vladimir Sadovnikov <[email protected]>
44
*
55
* This file is part of lsp-runtime-lib
66
* Created on: 21 апр. 2020 г.
@@ -23,6 +23,8 @@
2323
#define LSP_PLUG_IN_FMT_OBJ_CONST_H_
2424

2525
#include <lsp-plug.in/runtime/version.h>
26+
#include <lsp-plug.in/runtime/LSPString.h>
27+
#include <lsp-plug.in/common/endian.h>
2628
#include <lsp-plug.in/common/types.h>
2729
#include <lsp-plug.in/common/status.h>
2830

@@ -45,6 +47,35 @@ namespace lsp
4547
EV_POINT, ///< Point event
4648
};
4749

50+
enum compressed_event_type_t
51+
{
52+
CEV_OBJECT,
53+
CEV_VERTEX2,
54+
CEV_VERTEX3,
55+
CEV_VERTEX4,
56+
CEV_PVERTEX2,
57+
CEV_PVERTEX3,
58+
CEV_PVERTEX4,
59+
CEV_NORMAL2,
60+
CEV_NORMAL3,
61+
CEV_NORMAL4,
62+
CEV_TEXCOORD1,
63+
CEV_TEXCOORD2,
64+
CEV_TEXCOORD3,
65+
CEV_FACE,
66+
CEV_FACE_T,
67+
CEV_FACE_N,
68+
CEV_FACE_NF,
69+
CEV_FACE_TN,
70+
CEV_FACE_TNF,
71+
CEV_LINE,
72+
CEV_LINE_T,
73+
CEV_POINT,
74+
CEV_EOF,
75+
76+
CEV_BITS = 5,
77+
};
78+
4879
typedef ssize_t index_t;
4980

5081
typedef struct event_t
@@ -63,8 +94,22 @@ namespace lsp
6394
lltl::darray<index_t> inormal; // Indexes of normals
6495
lltl::darray<index_t> itexcoord; // Indexes of texture coordinates
6596
} event_t;
66-
}
67-
}
97+
98+
#pragma pack(push, 1)
99+
typedef struct compressed_header_t
100+
{
101+
uint32_t signature;
102+
uint8_t version;
103+
uint8_t float_bits;
104+
uint8_t pad[2];
105+
} compressed_header_t;
106+
#pragma pack(pop)
107+
108+
constexpr uint32_t COMPRESSED_SIGNATURE = __IF_LEBE(0x4a424f43, 0x434f424a); /* COBJ */
109+
constexpr size_t MIN_FLOAT_BUF_BITS = 4;
110+
constexpr size_t MAX_FLOAT_BUF_BITS = 16;
111+
} /* namesoace obj */
112+
} /* namespace lsp */
68113

69114

70115
#endif /* LSP_PLUG_IN_FMT_OBJ_CONST_H_ */

0 commit comments

Comments
 (0)