Skip to content

Commit

Permalink
Added COC. ATK is used for wavelet transform. Modified wavelet synthe…
Browse files Browse the repository at this point in the history
…sis (no acceleration yet). Wavelet analysis is broken. Close to enabling DFS in synthesis.
  • Loading branch information
aous72 committed Apr 2, 2024
1 parent fc377de commit 1c08cf3
Show file tree
Hide file tree
Showing 14 changed files with 839 additions and 404 deletions.
15 changes: 14 additions & 1 deletion src/core/codestream/ojph_codestream_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,19 @@ namespace ojph {
{ return &siz; }
ojph::param_cod access_cod() //return externally wrapped cod
{ return ojph::param_cod(&cod); }
const param_cod* get_cod() //return internal code
const param_cod* get_cod() //return internal code
{ return &cod; }
const param_cod* get_cod(ui32 comp_num) //return internal code
{
if (used_coc_fields == 0)
return &cod;
else {
for (int i = 0; i < used_coc_fields; ++i)
if (coc[i].get_comp_num() == comp_num)
return coc + i;
return &cod;
}
}
param_qcd* access_qcd(ui32 comp_num)
{
if (used_qcc_fields > 0)
Expand All @@ -92,6 +103,8 @@ namespace ojph {
return qcc + v;
return &qcd;
}
const param_dfs* access_dfs()
{ if (dfs.exists()) return &dfs; else return NULL; }
mem_fixed_allocator* get_allocator() { return allocator; }
mem_elastic_allocator* get_elastic_alloc() { return elastic_alloc; }
outfile_base* get_file() { return outfile; }
Expand Down
10 changes: 4 additions & 6 deletions src/core/codestream/ojph_params.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -824,12 +824,12 @@ namespace ojph {
ui8 t;
if (file->read(&t, 1) != 1)
OJPH_ERROR(0x00050122, "error reading COC segment");
comp_idx = t;
comp_num = t;
}
else {
if (file->read(&comp_idx, 2) != 2)
if (file->read(&comp_num, 2) != 2)
OJPH_ERROR(0x00050123, "error reading COC segment");
comp_idx = swap_byte(comp_idx);
comp_num = swap_byte(comp_num);
}
if (file->read(&Scod, 1) != 1)
OJPH_ERROR(0x00050124, "error reading COC segment");
Expand Down Expand Up @@ -1393,8 +1393,6 @@ namespace ojph {
//////////////////////////////////////////////////////////////////////////
param_dfs::dfs_dwt_type param_dfs::get_dwt_type(ui32 decomp_level) const
{
assert(decomp_level > 0 && decomp_level <= Ids);

decomp_level = ojph_min(decomp_level, Ids);
ui32 d = decomp_level - 1; // decomp_level starts from 1
ui32 idx = d >> 2; // complete bytes
Expand Down Expand Up @@ -1605,7 +1603,7 @@ namespace ojph {
if (Natk > max_steps) {
if (d != d_store) // was this allocated -- very unlikely
delete[] d;
d = new data[Natk];
d = new lifting_step[Natk];
max_steps = Natk;
}

Expand Down
44 changes: 26 additions & 18 deletions src/core/codestream/ojph_params_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,10 @@ namespace ojph {
ui16 get_dfs_index() const // cannot be more than 15
{ return SPcod.num_decomp & 0xF; }

////////////////////////////////////////
ui32 get_comp_num()
{ assert(type == COC_MAIN); return comp_num; }

private: // Common variables
cod_type type; // The type of this cod structure
ui16 Lcod; // serves as Lcod and Scod
Expand All @@ -524,7 +528,7 @@ namespace ojph {

private: // COC only variables
param_cod* parent; // parent COD structure
ui16 comp_idx; // component index of this COC structure
ui16 comp_num; // component index of this COC structure
const param_atk* atk; // useful when SPcod.wavelet_trans > 1
};

Expand Down Expand Up @@ -788,16 +792,9 @@ namespace ojph {
//
//
///////////////////////////////////////////////////////////////////////////
struct param_atk
{
// Limitations:
// Arbitrary filters (ARB) are not supported
// Up to 6 steps are supported -- more than 6 are not supported
// Only one coefficient per step -- first order filter
// Only even-indexed subsequence in first reconstruction step,
// m_init = 0 is supported
// data structures used by param_atk

public: // data structures used by this object
union lifting_step {
struct irv_data {
// si8 Oatk; // only for arbitrary filter
// ui8 LCatk; // number of lifting coefficients in a step
Expand All @@ -812,10 +809,18 @@ namespace ojph {
si16 Aatk; // lifting coefficient
};

union data {
irv_data irv;
rev_data rev;
};
irv_data irv;
rev_data rev;
};

struct param_atk
{
// Limitations:
// Arbitrary filters (ARB) are not supported
// Up to 6 steps are supported -- more than 6 are not supported
// Only one coefficient per step -- first order filter
// Only even-indexed subsequence in first reconstruction step,
// m_init = 0 is supported

public: // member functions
param_atk() { init(); }
Expand All @@ -835,7 +840,7 @@ namespace ojph {
void init(bool clear_all = true) {
if (clear_all)
memset(this, 0, sizeof(param_atk));
d = d_store; max_steps = sizeof(d_store) / sizeof(data);
d = d_store; max_steps = sizeof(d_store) / sizeof(lifting_step);
}
void init_irv97();
void init_rev53();
Expand All @@ -849,16 +854,19 @@ namespace ojph {
bool is_m_init0() const { return (Satk & 0x2000) == 0; }
bool is_using_ws_extension() const { return (Satk & 0x4000) != 0; }
const param_atk* get_atk(int index) const;
const data* get_step(ui32 s) const { assert(s < Natk); return d + s; }
const lifting_step* get_step(ui32 s) const
{ assert(s < Natk); return d + s; }
const ui32 get_num_steps() const { return Natk; }
const float get_K() const { return Katk; }

private: // member variables
ui16 Latk; // structure length
ui16 Satk; // carries a variety of information
float Katk; // only for irreversible scaling factor K
ui8 Natk; // number of lifting steps
data* d; // pointer to data, initialized to d_store
lifting_step* d; // pointer to data, initialized to d_store
int max_steps; // maximum number of steps without memory allocation
data d_store[6]; // step coefficient
lifting_step d_store[6]; // lifting step coefficient
param_atk* next; // used for chaining if more than one atk segment
// exist in the codestream
bool alloced_next; // true if next was allocated, not just set to an
Expand Down
Loading

0 comments on commit 1c08cf3

Please sign in to comment.