Skip to content

Commit 9e0b51c

Browse files
committed
Merge branch 'feature/add-openexr-support' of https://github.com/michaeldsmith/OpenJPH into feature/add-openexr-support
2 parents 4946caf + d88d5f1 commit 9e0b51c

16 files changed

+114
-101
lines changed

src/core/codestream/ojph_codeblock.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ namespace ojph {
6464

6565
const param_siz* sz = codestream->get_siz();
6666
const param_cod* cd = codestream->get_cod(comp_num);
67-
ui32 precision = cd->propose_implementation_precision(sz);
67+
ui32 precision = cd->propose_precision(sz, comp_num);
6868
if (precision <= 32)
6969
allocator->pre_alloc_data<ui32>(nominal.h * (size_t)stride, 0);
7070
else
@@ -87,7 +87,7 @@ namespace ojph {
8787
ui32 comp_num = parent->get_parent()->get_comp_num();
8888
const param_siz* sz = codestream->get_siz();
8989
const param_cod* cd = codestream->get_cod(comp_num);
90-
ui32 bit_depth = cd->propose_implementation_precision(sz);
90+
ui32 bit_depth = cd->propose_precision(sz, comp_num);
9191
if (bit_depth <= 32) {
9292
precision = BUF32;
9393
this->buf32 = allocator->post_alloc_data<ui32>(this->buf_size, 0);

src/core/codestream/ojph_codeblock_fun.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,8 @@ namespace ojph {
158158
tx_from_cb64 = NULL;
159159
}
160160
encode_cb64 = ojph_encode_codeblock64;
161+
bool result = initialize_block_encoder_tables();
162+
assert(result); ojph_unused(result);
161163

162164
#ifndef OJPH_DISABLE_SIMD
163165

src/core/codestream/ojph_params.cpp

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

779779
//////////////////////////////////////////////////////////////////////////
780780
ui32
781-
param_cod::propose_implementation_precision(const param_siz* siz) const
781+
param_cod::propose_precision(const param_siz* siz, ui32 comp_num) const
782782
{
783783
bool employing_color_transform = is_employing_color_transform() ? 1 : 0;
784784
bool reversible = atk->is_reversible();

src/core/codestream/ojph_params_local.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ namespace ojph {
524524
}
525525

526526
////////////////////////////////////////
527-
ui32 propose_implementation_precision(const param_siz* siz) const;
527+
ui32 propose_precision(const param_siz* siz, ui32 comp_num) const;
528528

529529
////////////////////////////////////////
530530
bool write(outfile_base *file);
@@ -578,11 +578,11 @@ namespace ojph {
578578
cod_SGcod SGCod; // Used in COD and copied to COC
579579
cod_SPcod SPcod; // serves as SPcod and SPcoc
580580
const param_cod* next;// to chain coc parameters to cod
581+
const param_atk* atk; // used to read transform information
581582

582583
private: // COC only variables
583584
param_cod* parent; // parent COD structure
584585
ui16 comp_num; // component index of this COC structure
585-
const param_atk* atk; // useful when SPcod.wavelet_trans > 1
586586
};
587587

588588
///////////////////////////////////////////////////////////////////////////

src/core/codestream/ojph_resolution.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ namespace ojph {
200200
}
201201

202202
const param_siz* szp = codestream->get_siz();
203-
ui32 precision = cdp->propose_implementation_precision(szp);
203+
ui32 precision = cdp->propose_precision(szp, comp_num);
204204

205205
//allocate lines
206206
if (skipped_res_for_recon == false)
@@ -449,7 +449,7 @@ namespace ojph {
449449
cur_precinct_loc = point(0, 0);
450450

451451
const param_siz* szp = codestream->get_siz();
452-
ui32 precision = cdp->propose_implementation_precision(szp);
452+
ui32 precision = cdp->propose_precision(szp, comp_num);
453453

454454
//allocate lines
455455
if (skipped_res_for_recon == false)

src/core/codestream/ojph_subband.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ namespace ojph {
9898
//allocate line_buf
9999
ui32 width = band_rect.siz.w + 1;
100100
const param_siz* szp = codestream->get_siz();
101-
ui32 precision = cdp->propose_implementation_precision(szp);
101+
ui32 precision = cdp->propose_precision(szp, comp_num);
102102
if (precision <= 32)
103103
allocator->pre_alloc_data<si32>(width, 1);
104104
else
@@ -141,7 +141,8 @@ namespace ojph {
141141
if (dfs != NULL)
142142
dfs = dfs->get_dfs(cdp->get_dfs_index());
143143
}
144-
param_qcd* qcd = codestream->access_qcd(parent->get_comp_num());
144+
ui32 comp_num = parent->get_comp_num();
145+
param_qcd* qcd = codestream->access_qcd(comp_num);
145146
ui32 num_decomps = cdp->get_num_decompositions();
146147
this->K_max = qcd->get_Kmax(dfs, num_decomps, this->res_num, band_num);
147148
if (!reversible)
@@ -198,7 +199,7 @@ namespace ojph {
198199
//allocate line_buf
199200
ui32 width = band_rect.siz.w + 1;
200201
const param_siz* szp = codestream->get_siz();
201-
ui32 precision = cdp->propose_implementation_precision(szp);
202+
ui32 precision = cdp->propose_precision(szp, comp_num);
202203
if (precision <= 32)
203204
lines->wrap(allocator->post_alloc_data<si32>(width, 1), width, 1);
204205
else

src/core/coding/ojph_block_decoder32.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@ namespace ojph {
578578
/** @brief State structure for reading and unstuffing of forward-growing
579579
* bitstreams; these are: MagSgn and SPP bitstreams
580580
*/
581-
struct frwd_struct {
581+
struct frwd_struct32 {
582582
const ui8* data; //!<pointer to bitstream
583583
ui64 tmp; //!<temporary buffer of read data
584584
ui32 bits; //!<number of bits stored in tmp
@@ -601,12 +601,12 @@ namespace ojph {
601601
* Reading can go beyond the end of buffer by up to 3 bytes.
602602
*
603603
* @tparam X is the value fed in when the bitstream is exhausted
604-
* @param [in] msp is a pointer to frwd_struct structure
604+
* @param [in] msp is a pointer to frwd_struct32 structure
605605
*
606606
*/
607607
template<int X>
608608
static inline
609-
void frwd_read(frwd_struct *msp)
609+
void frwd_read(frwd_struct32 *msp)
610610
{
611611
assert(msp->bits <= 32); // assert that there is a space for 32 bits
612612

@@ -653,17 +653,17 @@ namespace ojph {
653653
}
654654

655655
//************************************************************************/
656-
/** @brief Initialize frwd_struct struct and reads some bytes
656+
/** @brief Initialize frwd_struct32 struct and reads some bytes
657657
*
658658
* @tparam X is the value fed in when the bitstream is exhausted.
659659
* See frwd_read regarding the template
660-
* @param [in] msp is a pointer to frwd_struct
660+
* @param [in] msp is a pointer to frwd_struct32
661661
* @param [in] data is a pointer to the start of data
662662
* @param [in] size is the number of byte in the bitstream
663663
*/
664664
template<int X>
665665
static inline
666-
void frwd_init(frwd_struct *msp, const ui8* data, int size)
666+
void frwd_init(frwd_struct32 *msp, const ui8* data, int size)
667667
{
668668
msp->data = data;
669669
msp->tmp = 0;
@@ -689,29 +689,29 @@ namespace ojph {
689689
}
690690

691691
//************************************************************************/
692-
/** @brief Consume num_bits bits from the bitstream of frwd_struct
692+
/** @brief Consume num_bits bits from the bitstream of frwd_struct32
693693
*
694-
* @param [in] msp is a pointer to frwd_struct
694+
* @param [in] msp is a pointer to frwd_struct32
695695
* @param [in] num_bits is the number of bit to consume
696696
*/
697697
static inline
698-
void frwd_advance(frwd_struct *msp, ui32 num_bits)
698+
void frwd_advance(frwd_struct32 *msp, ui32 num_bits)
699699
{
700700
assert(num_bits <= msp->bits);
701701
msp->tmp >>= num_bits; // consume num_bits
702702
msp->bits -= num_bits;
703703
}
704704

705705
//************************************************************************/
706-
/** @brief Fetches 32 bits from the frwd_struct bitstream
706+
/** @brief Fetches 32 bits from the frwd_struct32 bitstream
707707
*
708708
* @tparam X is the value fed in when the bitstream is exhausted.
709709
* See frwd_read regarding the template
710-
* @param [in] msp is a pointer to frwd_struct
710+
* @param [in] msp is a pointer to frwd_struct32
711711
*/
712712
template<int X>
713713
static inline
714-
ui32 frwd_fetch(frwd_struct *msp)
714+
ui32 frwd_fetch(frwd_struct32 *msp)
715715
{
716716
if (msp->bits < 32)
717717
{
@@ -1099,7 +1099,7 @@ namespace ojph {
10991099
const int v_n_size = 512 + 4;
11001100
ui32 v_n_scratch[v_n_size] = {0}; // 2+ kB
11011101

1102-
frwd_struct magsgn;
1102+
frwd_struct32 magsgn;
11031103
frwd_init<0xFF>(&magsgn, coded_data, lcup - scup);
11041104

11051105
ui16 *sp = scratch;
@@ -1368,7 +1368,7 @@ namespace ojph {
13681368
// We add an extra 8 entries, just in case we need more
13691369
ui16 prev_row_sig[256 + 8] = {0}; // 528 Bytes
13701370

1371-
frwd_struct sigprop;
1371+
frwd_struct32 sigprop;
13721372
frwd_init<0>(&sigprop, coded_data + lengths1, (int)lengths2);
13731373

13741374
for (ui32 y = 0; y < height; y += 4)

src/core/coding/ojph_block_decoder64.cpp

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ namespace ojph {
530530
/** @brief State structure for reading and unstuffing of forward-growing
531531
* bitstreams; these are: MagSgn and SPP bitstreams
532532
*/
533-
struct frwd_struct {
533+
struct frwd_struct64 {
534534
const ui8* data; //!<pointer to bitstream
535535
ui64 tmp; //!<temporary buffer of read data
536536
ui32 bits; //!<number of bits stored in tmp
@@ -553,12 +553,12 @@ namespace ojph {
553553
* Reading can go beyond the end of buffer by up to 3 bytes.
554554
*
555555
* @tparam X is the value fed in when the bitstream is exhausted
556-
* @param [in] msp is a pointer to frwd_struct structure
556+
* @param [in] msp is a pointer to frwd_struct64 structure
557557
*
558558
*/
559559
template<int X>
560560
static inline
561-
void frwd_read(frwd_struct *msp)
561+
void frwd_read(frwd_struct64 *msp)
562562
{
563563
assert(msp->bits <= 32); // assert that there is a space for 32 bits
564564

@@ -617,12 +617,12 @@ namespace ojph {
617617
* MSB of the next byte is set 0 and must be ignored during decoding.
618618
*
619619
* @tparam X is the value fed in when the bitstream is exhausted
620-
* @param [in] msp is a pointer to frwd_struct structure
620+
* @param [in] msp is a pointer to frwd_struct64 structure
621621
*
622622
*/
623623
template<ui8 X>
624624
static inline
625-
void frwd_read8(frwd_struct *msp)
625+
void frwd_read8(frwd_struct64 *msp)
626626
{
627627
ui8 val = X;
628628
if (msp->size > 0) {
@@ -640,17 +640,17 @@ namespace ojph {
640640
}
641641

642642
//************************************************************************/
643-
/** @brief Initialize frwd_struct struct and reads some bytes
643+
/** @brief Initialize frwd_struct64 struct and reads some bytes
644644
*
645645
* @tparam X is the value fed in when the bitstream is exhausted.
646646
* See frwd_read regarding the template
647-
* @param [in] msp is a pointer to frwd_struct
647+
* @param [in] msp is a pointer to frwd_struct64
648648
* @param [in] data is a pointer to the start of data
649649
* @param [in] size is the number of byte in the bitstream
650650
*/
651651
template<int X>
652652
static inline
653-
void frwd_init(frwd_struct *msp, const ui8* data, int size)
653+
void frwd_init(frwd_struct64 *msp, const ui8* data, int size)
654654
{
655655
msp->data = data;
656656
msp->tmp = 0;
@@ -676,17 +676,17 @@ namespace ojph {
676676
}
677677

678678
//************************************************************************/
679-
/** @brief Initialize frwd_struct struct and reads some bytes
679+
/** @brief Initialize frwd_struct64 struct and reads some bytes
680680
*
681681
* @tparam X is the value fed in when the bitstream is exhausted.
682682
* See frwd_read regarding the template
683-
* @param [in] msp is a pointer to frwd_struct
683+
* @param [in] msp is a pointer to frwd_struct64
684684
* @param [in] data is a pointer to the start of data
685685
* @param [in] size is the number of byte in the bitstream
686686
*/
687687
template<ui8 X>
688688
static inline
689-
void frwd_init8(frwd_struct *msp, const ui8* data, int size)
689+
void frwd_init8(frwd_struct64 *msp, const ui8* data, int size)
690690
{
691691
msp->data = data;
692692
msp->tmp = 0;
@@ -697,29 +697,29 @@ namespace ojph {
697697
}
698698

699699
//************************************************************************/
700-
/** @brief Consume num_bits bits from the bitstream of frwd_struct
700+
/** @brief Consume num_bits bits from the bitstream of frwd_struct64
701701
*
702-
* @param [in] msp is a pointer to frwd_struct
702+
* @param [in] msp is a pointer to frwd_struct64
703703
* @param [in] num_bits is the number of bit to consume
704704
*/
705705
static inline
706-
void frwd_advance(frwd_struct *msp, ui32 num_bits)
706+
void frwd_advance(frwd_struct64 *msp, ui32 num_bits)
707707
{
708708
assert(num_bits <= msp->bits);
709709
msp->tmp >>= num_bits; // consume num_bits
710710
msp->bits -= num_bits;
711711
}
712712

713713
//************************************************************************/
714-
/** @brief Fetches 32 bits from the frwd_struct bitstream
714+
/** @brief Fetches 32 bits from the frwd_struct64 bitstream
715715
*
716716
* @tparam X is the value fed in when the bitstream is exhausted.
717717
* See frwd_read regarding the template
718-
* @param [in] msp is a pointer to frwd_struct
718+
* @param [in] msp is a pointer to frwd_struct64
719719
*/
720720
template<int X>
721721
static inline
722-
ui32 frwd_fetch(frwd_struct *msp)
722+
ui32 frwd_fetch(frwd_struct64 *msp)
723723
{
724724
if (msp->bits < 32)
725725
{
@@ -731,15 +731,15 @@ namespace ojph {
731731
}
732732

733733
//************************************************************************/
734-
/** @brief Fetches up to 64 bits from the frwd_struct bitstream
734+
/** @brief Fetches up to 64 bits from the frwd_struct64 bitstream
735735
*
736736
* @tparam X is the value fed in when the bitstream is exhausted.
737737
* See frwd_read regarding the template
738-
* @param [in] msp is a pointer to frwd_struct
738+
* @param [in] msp is a pointer to frwd_struct64
739739
*/
740740
template<ui8 X>
741741
static inline
742-
ui64 frwd_fetch64(frwd_struct *msp)
742+
ui64 frwd_fetch64(frwd_struct64 *msp)
743743
{
744744
while (msp->bits <= 56)
745745
frwd_read8<X>(msp);
@@ -1147,7 +1147,7 @@ namespace ojph {
11471147
const int v_n_size = 512 + 4;
11481148
ui64 v_n_scratch[v_n_size] = {0}; // 4+ kB
11491149

1150-
frwd_struct magsgn;
1150+
frwd_struct64 magsgn;
11511151
frwd_init8<0xFF>(&magsgn, coded_data, lcup - scup);
11521152

11531153
const ui16 *sp = scratch;
@@ -1415,7 +1415,7 @@ namespace ojph {
14151415
// We add an extra 8 entries, just in case we need more
14161416
ui16 prev_row_sig[256 + 8] = {0}; // 528 Bytes
14171417

1418-
frwd_struct sigprop;
1418+
frwd_struct64 sigprop;
14191419
frwd_init<0>(&sigprop, coded_data + lengths1, (int)lengths2);
14201420

14211421
for (ui32 y = 0; y < height; y += 4)

0 commit comments

Comments
 (0)