Skip to content

Commit

Permalink
A bug fix. Still buggy.
Browse files Browse the repository at this point in the history
  • Loading branch information
aous72 committed Apr 4, 2024
1 parent 12c3bf5 commit 4dc10b6
Show file tree
Hide file tree
Showing 5 changed files with 116 additions and 38 deletions.
12 changes: 7 additions & 5 deletions src/core/codestream/ojph_codeblock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,14 @@ namespace ojph {
cb_size.w, cb_size.h, stride, stripe_causal);

if (result == false)
{
if (resilient == true)
zero_block = true;
else
OJPH_ERROR(0x000300A1, "Error decoding a codeblock\n");
{
if (resilient == true) {
OJPH_INFO(0x000300A1, "Error decoding a codeblock\n");
zero_block = true;
}
else
OJPH_ERROR(0x000300A1, "Error decoding a codeblock\n");
}
}
else
zero_block = true;
Expand Down
23 changes: 13 additions & 10 deletions src/core/codestream/ojph_resolution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,7 @@ namespace ojph {
aug->line->wrap(allocator->post_alloc_data<si32>(width, 1), width, 1);

cur_line = 0;
rows_to_produce = res_rect.siz.h;
vert_even = (res_rect.org.y & 1) == 0;
horz_even = (res_rect.org.x & 1) == 0;
}
Expand Down Expand Up @@ -406,7 +407,6 @@ namespace ojph {
return;
}

bool finished;
do
{
//vertical transform
Expand All @@ -423,39 +423,41 @@ namespace ojph {
lifting_buf t = *aug; *aug = ssp[i]; ssp[i] = *sig; *sig = t;
}

finished = true;
if (aug->active) {
rev_horz_ana(atk, bands[2].get_line(),
bands[3].get_line(), aug->line, width, horz_even);
bands[2].push_line();
bands[3].push_line();
aug->active = false;
finished = false;
--rows_to_produce;
}
if (sig->active) {
rev_horz_ana(atk, child_res->get_line(),
bands[1].get_line(), sig->line, width, horz_even);
bands[1].push_line();
child_res->push_line();
sig->active = false;
finished = false;
--rows_to_produce;
};
vert_even = !vert_even;
} while (cur_line >= res_rect.siz.h && !finished);
} while (cur_line >= res_rect.siz.h && rows_to_produce > 0);
}
else
{
if (vert_even) {
// horizontal transform
rev_horz_ana(atk, child_res->get_line(),
bands[1].get_line(), sig->line, width, horz_even);
bands[1].push_line();
child_res->push_line();
}
else
{
// vertical transform
si32* sp = aug->line->i32;
for (ui32 i = width; i > 0; --i)
*sp++ <<= 1;
// horizontal transform
rev_horz_ana(atk, bands[2].get_line(),
bands[3].get_line(), aug->line, width, horz_even);
bands[2].push_line();
Expand All @@ -472,7 +474,6 @@ namespace ojph {
return;
}

bool finished;
do
{
//vertical transform
Expand All @@ -489,7 +490,6 @@ namespace ojph {
lifting_buf t = *aug; *aug = ssp[i]; ssp[i] = *sig; *sig = t;
}

finished = true;
if (aug->active) {
const float K = atk->get_K();
irv_vert_times_K(K, aug->line, width);
Expand All @@ -499,7 +499,7 @@ namespace ojph {
bands[2].push_line();
bands[3].push_line();
aug->active = false;
finished = false;
--rows_to_produce;
}
if (sig->active) {
const float K_inv = 1.0f / atk->get_K();
Expand All @@ -510,24 +510,27 @@ namespace ojph {
bands[1].push_line();
child_res->push_line();
sig->active = false;
finished = false;
--rows_to_produce;
};
vert_even = !vert_even;
} while (cur_line >= res_rect.siz.h && !finished);
} while (cur_line >= res_rect.siz.h && rows_to_produce > 0);
}
else
{
if (vert_even) {
// horizontal transform
irv_horz_ana(atk, child_res->get_line(),
bands[1].get_line(), sig->line, width, horz_even);
bands[1].push_line();
child_res->push_line();
}
else
{
// vertical transform
float* sp = aug->line->f32;
for (ui32 i = width; i > 0; --i)
*sp++ *= 2.0f;
// horizontal transform
irv_horz_ana(atk, bands[2].get_line(),
bands[3].get_line(), aug->line, width, horz_even);
bands[2].push_line();
Expand Down
1 change: 1 addition & 0 deletions src/core/codestream/ojph_resolution.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ namespace ojph {
param_dfs::dfs_dwt_type downsampling_style;
//wavelet machinery
ui32 cur_line;
ui32 rows_to_produce;
bool vert_even, horz_even;
mem_elastic_allocator *elastic;
};
Expand Down
70 changes: 69 additions & 1 deletion tests/test_executables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1015,6 +1015,40 @@ TEST(TestExecutables, SimpleEncIrv9732x128) {
"Malamute.ppm", "", 3, mse, pae);
}

///////////////////////////////////////////////////////////////////////////////
// Test ojph_compress with codeblocks when the irv97 wavelet is used.
// We test by comparing MSE and PAE of decoded images.
// The compressed file is obtained using these command-line options:
// -o simple_enc_irv97_64x64_tiles_33x33_d5.j2c -qstep 0.01 -tile_size {33,33}
// -num_decomps 5
TEST(TestExecutables, SimpleEncIrv9764x64Tiles33x33D5) {
double mse[3] = { 46.2004, 43.622, 56.7452};
int pae[3] = { 48, 46, 52};
run_ojph_compress("Malamute.ppm",
"simple_enc_irv97_64x64_tiles_33x33_d5", "", "j2c",
"-qstep 0.01 -tile_size \"{33,33}\" -num_decomps 5");
run_ojph_compress_expand("simple_enc_irv97_64x64_tiles_33x33_d5", "j2c", "ppm");
run_mse_pae("simple_enc_irv97_64x64_tiles_33x33_d5", "ppm",
"Malamute.ppm", "", 3, mse, pae);
}

///////////////////////////////////////////////////////////////////////////////
// Test ojph_compress with codeblocks when the irv97 wavelet is used.
// We test by comparing MSE and PAE of decoded images.
// The compressed file is obtained using these command-line options:
// -o simple_enc_irv97_64x64_tiles_33x33_d6.j2c -qstep 0.01 -tile_size {33,33}
// -num_decomps 6
TEST(TestExecutables, SimpleEncIrv9764x64Tiles33x33D6) {
double mse[3] = { 46.2004, 43.622, 56.7452};
int pae[3] = { 48, 46, 52};
run_ojph_compress("Malamute.ppm",
"simple_enc_irv97_64x64_tiles_33x33_d6", "", "j2c",
"-qstep 0.01 -tile_size \"{33,33}\" -num_decomps 6");
run_ojph_compress_expand("simple_enc_irv97_64x64_tiles_33x33_d6", "j2c", "ppm");
run_mse_pae("simple_enc_irv97_64x64_tiles_33x33_d6", "ppm",
"Malamute.ppm", "", 3, mse, pae);
}

///////////////////////////////////////////////////////////////////////////////
// Test ojph_compress with codeblocks when the irv97 wavelet is used.
// We test by comparing MSE and PAE of decoded images.
Expand Down Expand Up @@ -1159,6 +1193,40 @@ TEST(TestExecutables, SimpleEncRev534x1024) {
"Malamute.ppm", "", 3, mse, pae);
}

///////////////////////////////////////////////////////////////////////////////
// Test ojph_compress with codeblocks when the rev53 wavelet is used.
// We test by comparing MSE and PAE of decoded images.
// The compressed file is obtained using these command-line options:
// -o simple_enc_rev53_64x64_tiles_33x33.j2c -reversible true -tile_size
// {32,32} -num_decomps 5
TEST(TestExecutables, SimpleEncRev5364x64Tiles33x33D5) {
double mse[3] = { 0, 0, 0};
int pae[3] = { 0, 0, 0};
run_ojph_compress("Malamute.ppm",
"simple_enc_rev53_64x64_tiles_33x33_d5", "", "j2c",
"-reversible true -tile_size \"{32,32}\" -num_decomps 5");
run_ojph_compress_expand("simple_enc_rev53_64x64_tiles_33x33_d5", "j2c", "ppm");
run_mse_pae("simple_enc_rev53_64x64_tiles_33x33_d5", "ppm",
"Malamute.ppm", "", 3, mse, pae);
}

///////////////////////////////////////////////////////////////////////////////
// Test ojph_compress with codeblocks when the rev53 wavelet is used.
// We test by comparing MSE and PAE of decoded images.
// The compressed file is obtained using these command-line options:
// -o simple_enc_rev53_64x64_tiles_33x33.j2c -reversible true -tile_size
// {32,32} -num_decomps 6
TEST(TestExecutables, SimpleEncRev5364x64Tiles33x33D6) {
double mse[3] = { 0, 0, 0};
int pae[3] = { 0, 0, 0};
run_ojph_compress("Malamute.ppm",
"simple_enc_rev53_64x64_tiles_33x33_d6", "", "j2c",
"-reversible true -tile_size \"{32,32}\" -num_decomps 6");
run_ojph_compress_expand("simple_enc_rev53_64x64_tiles_33x33_d6", "j2c", "ppm");
run_mse_pae("simple_enc_rev53_64x64_tiles_33x33_d6", "ppm",
"Malamute.ppm", "", 3, mse, pae);
}

///////////////////////////////////////////////////////////////////////////////
// Test ojph_compress with codeblocks when the irv97 wavelet is used.
// We test by comparing MSE and PAE of decoded images.
Expand Down Expand Up @@ -1220,7 +1288,7 @@ TEST(TestExecutables, SimpleEncIrv97TallNarrow) {
// The compressed file is obtained using these command-line options:
// -o simple_enc_irv97_tall_narrow1.j2c -image_offset {1,0} -qstep 0.1
TEST(TestExecutables, SimpleEncIrv97TallNarrow1) {
double mse[3] = { 100.905762, 76.113037, 72.834717};
double mse[3] = { 100.906, 76.113, 72.8347};
int pae[3] = { 39, 35, 34};
run_ojph_compress("tall_narrow.ppm",
"simple_enc_irv97_tall_narrow1", "", "j2c",
Expand Down
Loading

0 comments on commit 4dc10b6

Please sign in to comment.