Skip to content

Commit

Permalink
Starting adding support for up to 32bit lossless precision encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
aous72 committed Oct 22, 2024
1 parent 77aae49 commit 82ee92f
Show file tree
Hide file tree
Showing 14 changed files with 70 additions and 41 deletions.
2 changes: 1 addition & 1 deletion src/apps/common/ojph_img_io.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ namespace ojph {
////////////////////////////////////////////////////////////////////////////
// defined elsewhere
class mem_fixed_allocator;
struct line_buf;
class line_buf;

////////////////////////////////////////////////////////////////////////////
//
Expand Down
2 changes: 1 addition & 1 deletion src/core/codestream/ojph_codeblock.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ namespace ojph {

////////////////////////////////////////////////////////////////////////////
//defined elsewhere
struct line_buf;
class line_buf;
class mem_elastic_allocator;
class codestream;
struct coded_lists;
Expand Down
2 changes: 1 addition & 1 deletion src/core/codestream/ojph_codestream_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ namespace ojph {

////////////////////////////////////////////////////////////////////////////
//defined elsewhere
struct line_buf;
class line_buf;
class mem_fixed_allocator;
class mem_elastic_allocator;
class codestream;
Expand Down
2 changes: 1 addition & 1 deletion src/core/codestream/ojph_resolution.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ namespace ojph {

////////////////////////////////////////////////////////////////////////////
//defined elsewhere
struct line_buf;
class line_buf;
class mem_elastic_allocator;
class codestream;

Expand Down
2 changes: 1 addition & 1 deletion src/core/codestream/ojph_subband.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ namespace ojph {

////////////////////////////////////////////////////////////////////////////
//defined elsewhere
struct line_buf;
class line_buf;
class mem_elastic_allocator;
class codestream;

Expand Down
2 changes: 1 addition & 1 deletion src/core/codestream/ojph_tile.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ namespace ojph {

////////////////////////////////////////////////////////////////////////////
//defined elsewhere
struct line_buf;
class line_buf;
class codestream;

namespace local {
Expand Down
2 changes: 1 addition & 1 deletion src/core/codestream/ojph_tile_comp.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ namespace ojph {

////////////////////////////////////////////////////////////////////////////
//defined elsewhere
struct line_buf;
class line_buf;
class codestream;

namespace local {
Expand Down
2 changes: 1 addition & 1 deletion src/core/common/ojph_codestream.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ namespace ojph {
class comment_exchange;
class mem_fixed_allocator;
struct point;
struct line_buf;
class line_buf;
class outfile_base;
class infile_base;

Expand Down
24 changes: 20 additions & 4 deletions src/core/common/ojph_mem.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,23 @@ namespace ojph {
};

/////////////////////////////////////////////////////////////////////////////
struct line_buf
class line_buf
{
line_buf() : size(0), pre_size(0), i32(0) {}
public:
enum line_buf_type {
LFT_UNDEFINED = 0x00, // Type is undefined/uninitialized
// These flags reflects data size in bytes
LFT_BYTE = 0x01, // Set when data is 1 byte
LFT_SHORT = 0x02, // Set when data is 2 bytes
LFT_INTEGER = 0x04, // Set when data is 4 bytes
LFT_LONG = 0x08, // Set when data is 8 bytes
LFT_REVERSIBLE = 0x10, // Set when data is used for reversible coding
// Not all combinations are useful
LFT_SIZE_MASK = 0x0F, // To extract data size
};

public:
line_buf() : size(0), pre_size(0), flags(LFT_UNDEFINED), i32(0) {}

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

size_t size;
ui32 pre_size;
line_buf_type flags;
union {
si32* i32;
float* f32;
si32* i32; // 32bit integer type, used for lossless compression
float* f32; // float type, used for lossy compression
void* p; // not type is associated with the pointer
};
};

Expand Down
29 changes: 17 additions & 12 deletions src/core/transform/ojph_colour.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,45 +39,50 @@

#include "ojph_defs.h"
#include "ojph_arch.h"
#include "ojph_mem.h"
#include "ojph_colour.h"
#include "ojph_colour_local.h"

namespace ojph {

// defined elsewhere
class line_buf;

namespace local {

//////////////////////////////////////////////////////////////////////////
void (*cnvrt_si32_to_si32_shftd)
(const si32 *sp, si32 *dp, int shift, ui32 width) = NULL;
(const line_buf* src, line_buf* dst, int shift, ui32 width) = NULL;

//////////////////////////////////////////////////////////////////////////
void (*cnvrt_si32_to_si32_nlt_type3)
(const si32* sp, si32* dp, int shift, ui32 width) = NULL;
(const line_buf* src, line_buf* dst, int shift, ui32 width) = NULL;

//////////////////////////////////////////////////////////////////////////
void (*cnvrt_si32_to_float_shftd)
(const si32 *sp, float *dp, float mul, ui32 width) = NULL;
(const line_buf* src, line_buf* dst, float mul, ui32 width) = NULL;

//////////////////////////////////////////////////////////////////////////
void (*cnvrt_si32_to_float)
(const si32 *sp, float *dp, float mul, ui32 width) = NULL;
(const line_buf* src, line_buf* dst, float mul, ui32 width) = NULL;

//////////////////////////////////////////////////////////////////////////
void (*cnvrt_float_to_si32_shftd)
(const float *sp, si32 *dp, float mul, ui32 width) = NULL;
(const line_buf* sp, line_buf* dp, float mul, ui32 width) = NULL;

//////////////////////////////////////////////////////////////////////////
void (*cnvrt_float_to_si32)
(const float *sp, si32 *dp, float mul, ui32 width) = NULL;
(const line_buf* sp, line_buf* dp, float mul, ui32 width) = NULL;

//////////////////////////////////////////////////////////////////////////
void (*rct_forward)
(const si32 *r, const si32 *g, const si32 *b,
si32 *y, si32 *cb, si32 *cr, ui32 repeat) = NULL;
(const line_buf* r, const line_buf* g, const line_buf* b,
line_buf* y, line_buf* cb, line_buf* cr, ui32 repeat) = NULL;

//////////////////////////////////////////////////////////////////////////
void (*rct_backward)
(const si32 *y, const si32 *cb, const si32 *cr,
si32 *r, si32 *g, si32 *b, ui32 repeat) = NULL;
(const line_buf* r, const line_buf* g, const line_buf* b,
line_buf* y, line_buf* cb, line_buf* cr, ui32 repeat) = NULL;

//////////////////////////////////////////////////////////////////////////
void (*ict_forward)
Expand All @@ -86,8 +91,8 @@ namespace ojph {

//////////////////////////////////////////////////////////////////////////
void (*ict_backward)
(const float *y, const float *cb, const float *cr,
float *r, float *g, float *b, ui32 repeat) = NULL;
(const line_buf* y, const line_buf* cb, const line_buf* cr,
line_buf* r, line_buf* g, line_buf* b, ui32 repeat) = NULL;

//////////////////////////////////////////////////////////////////////////
static bool colour_transform_functions_initialized = false;
Expand Down
28 changes: 14 additions & 14 deletions src/core/transform/ojph_colour.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,47 +47,47 @@ namespace ojph {

////////////////////////////////////////////////////////////////////////////
extern void (*cnvrt_si32_to_si32_shftd)
(const si32 *sp, si32 *dp, int shift, ui32 width);
(const line_buf* sp, line_buf* dp, int shift, ui32 width);

////////////////////////////////////////////////////////////////////////////
extern void (*cnvrt_si32_to_si32_nlt_type3)
(const si32 *sp, si32 *dp, int shift, ui32 width);
(const line_buf *sp, line_buf *dp, int shift, ui32 width);

////////////////////////////////////////////////////////////////////////////
extern void (*cnvrt_si32_to_float_shftd)
(const si32 *sp, float *dp, float mul, ui32 width);
(const line_buf *sp, line_buf *dp, float mul, ui32 width);

////////////////////////////////////////////////////////////////////////////
extern void (*cnvrt_si32_to_float)
(const si32 *sp, float *dp, float mul, ui32 width);
(const line_buf *sp, line_buf *dp, float mul, ui32 width);

////////////////////////////////////////////////////////////////////////////
extern void (*cnvrt_float_to_si32_shftd)
(const float *sp, si32 *dp, float mul, ui32 width);
(const line_buf *sp, line_buf *dp, float mul, ui32 width);

////////////////////////////////////////////////////////////////////////////
extern void (*cnvrt_float_to_si32)
(const float *sp, si32 *dp, float mul, ui32 width);
(const line_buf *sp, line_buf *dp, float mul, ui32 width);

////////////////////////////////////////////////////////////////////////////
extern void (*rct_forward)
(const si32 *r, const si32 *g, const si32 *b,
si32 *y, si32 *cb, si32 *cr, ui32 repeat);
(const line_buf *r, const line_buf *g, const line_buf *b,
line_buf *y, line_buf *cb, line_buf *cr, ui32 repeat);

////////////////////////////////////////////////////////////////////////////
extern void (*rct_backward)
(const si32 *y, const si32 *cb, const si32 *cr,
si32 *r, si32 *g, si32 *b, ui32 repeat);
(const line_buf *y, const line_buf *cb, const line_buf *cr,
line_buf *r, line_buf *g, line_buf *b, ui32 repeat);

////////////////////////////////////////////////////////////////////////////
extern void (*ict_forward)
(const float *r, const float *g, const float *b,
float *y, float *cb, float *cr, ui32 repeat);
(const line_buf *r, const line_buf *g, const line_buf *b,
line_buf *y, line_buf *cb, line_buf *cr, ui32 repeat);

////////////////////////////////////////////////////////////////////////////
extern void (*ict_backward)
(const float *y, const float *cb, const float *cr,
float *r, float *g, float *b, ui32 repeat);
(const line_buf *y, const line_buf *cb, const line_buf *cr,
line_buf *r, line_buf *g, line_buf *b, ui32 repeat);
}
}

Expand Down
4 changes: 3 additions & 1 deletion src/core/transform/ojph_transform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@
#include "../codestream/ojph_params_local.h"

namespace ojph {
struct line_buf;

// defined elsewhere
class line_buf;

namespace local {

Expand Down
5 changes: 4 additions & 1 deletion src/core/transform/ojph_transform.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@
#include "ojph_defs.h"

namespace ojph {
struct line_buf;

// defined elsewhere
class line_buf;

namespace local {
union lifting_step;
struct param_atk;
Expand Down
5 changes: 4 additions & 1 deletion src/core/transform/ojph_transform_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@
#include "ojph_defs.h"

namespace ojph {
struct line_buf;

// defined elsewhere
class line_buf;

namespace local {
struct param_atk;
union lifting_step;
Expand Down

0 comments on commit 82ee92f

Please sign in to comment.