Skip to content

Commit 82ee92f

Browse files
committed
Starting adding support for up to 32bit lossless precision encoding
1 parent 77aae49 commit 82ee92f

File tree

14 files changed

+70
-41
lines changed

14 files changed

+70
-41
lines changed

src/apps/common/ojph_img_io.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ namespace ojph {
5454
////////////////////////////////////////////////////////////////////////////
5555
// defined elsewhere
5656
class mem_fixed_allocator;
57-
struct line_buf;
57+
class line_buf;
5858

5959
////////////////////////////////////////////////////////////////////////////
6060
//

src/core/codestream/ojph_codeblock.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ namespace ojph {
4848

4949
////////////////////////////////////////////////////////////////////////////
5050
//defined elsewhere
51-
struct line_buf;
51+
class line_buf;
5252
class mem_elastic_allocator;
5353
class codestream;
5454
struct coded_lists;

src/core/codestream/ojph_codestream_local.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ namespace ojph {
4646

4747
////////////////////////////////////////////////////////////////////////////
4848
//defined elsewhere
49-
struct line_buf;
49+
class line_buf;
5050
class mem_fixed_allocator;
5151
class mem_elastic_allocator;
5252
class codestream;

src/core/codestream/ojph_resolution.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ namespace ojph {
4545

4646
////////////////////////////////////////////////////////////////////////////
4747
//defined elsewhere
48-
struct line_buf;
48+
class line_buf;
4949
class mem_elastic_allocator;
5050
class codestream;
5151

src/core/codestream/ojph_subband.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ namespace ojph {
4545

4646
////////////////////////////////////////////////////////////////////////////
4747
//defined elsewhere
48-
struct line_buf;
48+
class line_buf;
4949
class mem_elastic_allocator;
5050
class codestream;
5151

src/core/codestream/ojph_tile.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ namespace ojph {
4747

4848
////////////////////////////////////////////////////////////////////////////
4949
//defined elsewhere
50-
struct line_buf;
50+
class line_buf;
5151
class codestream;
5252

5353
namespace local {

src/core/codestream/ojph_tile_comp.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ namespace ojph {
4848

4949
////////////////////////////////////////////////////////////////////////////
5050
//defined elsewhere
51-
struct line_buf;
51+
class line_buf;
5252
class codestream;
5353

5454
namespace local {

src/core/common/ojph_codestream.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ namespace ojph {
6161
class comment_exchange;
6262
class mem_fixed_allocator;
6363
struct point;
64-
struct line_buf;
64+
class line_buf;
6565
class outfile_base;
6666
class infile_base;
6767

src/core/common/ojph_mem.h

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,23 @@ namespace ojph {
132132
};
133133

134134
/////////////////////////////////////////////////////////////////////////////
135-
struct line_buf
135+
class line_buf
136136
{
137-
line_buf() : size(0), pre_size(0), i32(0) {}
137+
public:
138+
enum line_buf_type {
139+
LFT_UNDEFINED = 0x00, // Type is undefined/uninitialized
140+
// These flags reflects data size in bytes
141+
LFT_BYTE = 0x01, // Set when data is 1 byte
142+
LFT_SHORT = 0x02, // Set when data is 2 bytes
143+
LFT_INTEGER = 0x04, // Set when data is 4 bytes
144+
LFT_LONG = 0x08, // Set when data is 8 bytes
145+
LFT_REVERSIBLE = 0x10, // Set when data is used for reversible coding
146+
// Not all combinations are useful
147+
LFT_SIZE_MASK = 0x0F, // To extract data size
148+
};
149+
150+
public:
151+
line_buf() : size(0), pre_size(0), flags(LFT_UNDEFINED), i32(0) {}
138152

139153
template<typename T>
140154
void pre_alloc(mem_fixed_allocator *p, size_t num_ele, ui32 pre_size)
@@ -153,9 +167,11 @@ namespace ojph {
153167

154168
size_t size;
155169
ui32 pre_size;
170+
line_buf_type flags;
156171
union {
157-
si32* i32;
158-
float* f32;
172+
si32* i32; // 32bit integer type, used for lossless compression
173+
float* f32; // float type, used for lossy compression
174+
void* p; // not type is associated with the pointer
159175
};
160176
};
161177

src/core/transform/ojph_colour.cpp

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -39,45 +39,50 @@
3939

4040
#include "ojph_defs.h"
4141
#include "ojph_arch.h"
42+
#include "ojph_mem.h"
4243
#include "ojph_colour.h"
4344
#include "ojph_colour_local.h"
4445

4546
namespace ojph {
47+
48+
// defined elsewhere
49+
class line_buf;
50+
4651
namespace local {
4752

4853
//////////////////////////////////////////////////////////////////////////
4954
void (*cnvrt_si32_to_si32_shftd)
50-
(const si32 *sp, si32 *dp, int shift, ui32 width) = NULL;
55+
(const line_buf* src, line_buf* dst, int shift, ui32 width) = NULL;
5156

5257
//////////////////////////////////////////////////////////////////////////
5358
void (*cnvrt_si32_to_si32_nlt_type3)
54-
(const si32* sp, si32* dp, int shift, ui32 width) = NULL;
59+
(const line_buf* src, line_buf* dst, int shift, ui32 width) = NULL;
5560

5661
//////////////////////////////////////////////////////////////////////////
5762
void (*cnvrt_si32_to_float_shftd)
58-
(const si32 *sp, float *dp, float mul, ui32 width) = NULL;
63+
(const line_buf* src, line_buf* dst, float mul, ui32 width) = NULL;
5964

6065
//////////////////////////////////////////////////////////////////////////
6166
void (*cnvrt_si32_to_float)
62-
(const si32 *sp, float *dp, float mul, ui32 width) = NULL;
67+
(const line_buf* src, line_buf* dst, float mul, ui32 width) = NULL;
6368

6469
//////////////////////////////////////////////////////////////////////////
6570
void (*cnvrt_float_to_si32_shftd)
66-
(const float *sp, si32 *dp, float mul, ui32 width) = NULL;
71+
(const line_buf* sp, line_buf* dp, float mul, ui32 width) = NULL;
6772

6873
//////////////////////////////////////////////////////////////////////////
6974
void (*cnvrt_float_to_si32)
70-
(const float *sp, si32 *dp, float mul, ui32 width) = NULL;
75+
(const line_buf* sp, line_buf* dp, float mul, ui32 width) = NULL;
7176

7277
//////////////////////////////////////////////////////////////////////////
7378
void (*rct_forward)
74-
(const si32 *r, const si32 *g, const si32 *b,
75-
si32 *y, si32 *cb, si32 *cr, ui32 repeat) = NULL;
79+
(const line_buf* r, const line_buf* g, const line_buf* b,
80+
line_buf* y, line_buf* cb, line_buf* cr, ui32 repeat) = NULL;
7681

7782
//////////////////////////////////////////////////////////////////////////
7883
void (*rct_backward)
79-
(const si32 *y, const si32 *cb, const si32 *cr,
80-
si32 *r, si32 *g, si32 *b, ui32 repeat) = NULL;
84+
(const line_buf* r, const line_buf* g, const line_buf* b,
85+
line_buf* y, line_buf* cb, line_buf* cr, ui32 repeat) = NULL;
8186

8287
//////////////////////////////////////////////////////////////////////////
8388
void (*ict_forward)
@@ -86,8 +91,8 @@ namespace ojph {
8691

8792
//////////////////////////////////////////////////////////////////////////
8893
void (*ict_backward)
89-
(const float *y, const float *cb, const float *cr,
90-
float *r, float *g, float *b, ui32 repeat) = NULL;
94+
(const line_buf* y, const line_buf* cb, const line_buf* cr,
95+
line_buf* r, line_buf* g, line_buf* b, ui32 repeat) = NULL;
9196

9297
//////////////////////////////////////////////////////////////////////////
9398
static bool colour_transform_functions_initialized = false;

0 commit comments

Comments
 (0)