Skip to content

Commit bd98d24

Browse files
committed
A few bug fixes
1 parent 31d83e6 commit bd98d24

File tree

12 files changed

+132
-79
lines changed

12 files changed

+132
-79
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
.DS_Store
2-
test/*
2+
mytest/*
33
others/*
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<VariablesViewState
3+
version = "1.0">
4+
<ContextStates>
5+
<ContextState
6+
contextName = "ojph::local::ojph_decode_codeblock(unsigned char*, int*, int, int, int, int, int, int, int):ojph_block_decoder.cpp">
7+
<PersistentStrings>
8+
<PersistentString
9+
value = "sigma1[0]">
10+
</PersistentString>
11+
<PersistentString
12+
value = "mbr1[0]">
13+
</PersistentString>
14+
<PersistentString
15+
value = "sigma2[0]">
16+
</PersistentString>
17+
<PersistentString
18+
value = "mbr2[0]">
19+
</PersistentString>
20+
</PersistentStrings>
21+
</ContextState>
22+
</ContextStates>
23+
</VariablesViewState>

src/apps/apps.xcodeproj/xcshareddata/xcschemes/ojph_compress.xcscheme

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
2828
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
2929
shouldUseLaunchSchemeArgsEnv = "YES">
30-
<Testables>
31-
</Testables>
3230
<MacroExpansion>
3331
<BuildableReference
3432
BuildableIdentifier = "primary"
@@ -38,16 +36,16 @@
3836
ReferencedContainer = "container:apps.xcodeproj">
3937
</BuildableReference>
4038
</MacroExpansion>
41-
<AdditionalOptions>
42-
</AdditionalOptions>
39+
<Testables>
40+
</Testables>
4341
</TestAction>
4442
<LaunchAction
4543
buildConfiguration = "Debug"
4644
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
4745
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
4846
launchStyle = "0"
4947
useCustomWorkingDirectory = "YES"
50-
customWorkingDirectory = "/Users/aous/Google Drive/OpenJPH/test"
48+
customWorkingDirectory = "/Users/aous/Google Drive/OpenJPH/mytest"
5149
ignoresPersistentStateOnLaunch = "NO"
5250
debugDocumentVersioning = "YES"
5351
debugServiceExtension = "internal"
@@ -64,9 +62,33 @@
6462
</BuildableProductRunnable>
6563
<CommandLineArguments>
6664
<CommandLineArgument
67-
argument = "-i ARRI_AlexaDrums_3840x2160p_24_8b_P3_444_00000.ppm"
65+
argument = "-i ARRI_AlexaDrums_3840x2160p_24_8b_P3_444_00000.ppm -o test.j2c -num_decomps 5 -block_size \{64,64\} -precincts \{1024,2\} -prog_order CPRL -colour_trans true -tile_size \{343,121\} -image_offset \{37,21\} -tile_offset \{2,11\}"
66+
isEnabled = "NO">
67+
</CommandLineArgument>
68+
<CommandLineArgument
69+
argument = "-i ARRI_AlexaDrums_3840x2160p_24_8b_P3_444_00000.ppm -o test.j2c -num_decomps 5 -block_size \{64,64\} -precincts \{128,128\},\{256,256\}"
6870
isEnabled = "YES">
6971
</CommandLineArgument>
72+
<CommandLineArgument
73+
argument = "-i t5-334.pgm -o test.j2c -num_decomps 2 -block_size \{64,64\} -precincts \{1024,2\} -prog_order CPRL -image_offset \{1717,374\} -tile_offset \{1717,374\} -tile_size \{343,121\}"
74+
isEnabled = "NO">
75+
</CommandLineArgument>
76+
<CommandLineArgument
77+
argument = "-i t5-334.pgm -o test.j2c -num_decomps 2 -block_size \{64,64\} -precincts \{1024,2\} -prog_order CPRL -image_offset \{1717,374\} -tile_offset \{1717,374\}"
78+
isEnabled = "NO">
79+
</CommandLineArgument>
80+
<CommandLineArgument
81+
argument = "-i lena.pgm -o test.j2c -num_decomps 1 -block_size \{8,8\} -prog_order CPRL -image_offset \{37,21\} -precincts \{16,16\}"
82+
isEnabled = "NO">
83+
</CommandLineArgument>
84+
<CommandLineArgument
85+
argument = "-i lena.pgm -o test.j2c -num_decomps 1 -block_size \{8,8\} -prog_order CPRL -image_offset \{37,21\} -precincts \{16,16\}"
86+
isEnabled = "NO">
87+
</CommandLineArgument>
88+
<CommandLineArgument
89+
argument = "-i ARRI_AlexaDrums_3840x2160p_24_8b_P3_444_00000.ppm"
90+
isEnabled = "NO">
91+
</CommandLineArgument>
7092
<CommandLineArgument
7193
argument = "-i VQEG_CrowdRun_3840x2160p_50_10b_bt709_422_07111.yuv"
7294
isEnabled = "NO">
@@ -145,11 +167,11 @@
145167
</CommandLineArgument>
146168
<CommandLineArgument
147169
argument = "-o test.j2c"
148-
isEnabled = "YES">
170+
isEnabled = "NO">
149171
</CommandLineArgument>
150172
<CommandLineArgument
151173
argument = "-num_decomps 5"
152-
isEnabled = "YES">
174+
isEnabled = "NO">
153175
</CommandLineArgument>
154176
<CommandLineArgument
155177
argument = "-num_decomps 2"
@@ -173,7 +195,7 @@
173195
</CommandLineArgument>
174196
<CommandLineArgument
175197
argument = "-prog_order RPCL"
176-
isEnabled = "YES">
198+
isEnabled = "NO">
177199
</CommandLineArgument>
178200
<CommandLineArgument
179201
argument = "-prog_order PCRL"
@@ -185,7 +207,11 @@
185207
</CommandLineArgument>
186208
<CommandLineArgument
187209
argument = "-block_size \{4,1024\}"
188-
isEnabled = "YES">
210+
isEnabled = "NO">
211+
</CommandLineArgument>
212+
<CommandLineArgument
213+
argument = "-block_size \{64,64\}"
214+
isEnabled = "NO">
189215
</CommandLineArgument>
190216
<CommandLineArgument
191217
argument = "-block_size \{1024,4\}"
@@ -236,8 +262,6 @@
236262
isEnabled = "NO">
237263
</CommandLineArgument>
238264
</CommandLineArguments>
239-
<AdditionalOptions>
240-
</AdditionalOptions>
241265
</LaunchAction>
242266
<ProfileAction
243267
buildConfiguration = "Release"

src/apps/apps.xcodeproj/xcshareddata/xcschemes/ojph_expand.xcscheme

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
2828
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
2929
shouldUseLaunchSchemeArgsEnv = "YES">
30-
<Testables>
31-
</Testables>
3230
<MacroExpansion>
3331
<BuildableReference
3432
BuildableIdentifier = "primary"
@@ -38,16 +36,16 @@
3836
ReferencedContainer = "container:apps.xcodeproj">
3937
</BuildableReference>
4038
</MacroExpansion>
41-
<AdditionalOptions>
42-
</AdditionalOptions>
39+
<Testables>
40+
</Testables>
4341
</TestAction>
4442
<LaunchAction
4543
buildConfiguration = "Debug"
4644
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
4745
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
4846
launchStyle = "0"
4947
useCustomWorkingDirectory = "YES"
50-
customWorkingDirectory = "/Users/aous/Google Drive/OpenJPH/test"
48+
customWorkingDirectory = "/Users/aous/Google Drive/OpenJPH/mytest"
5149
ignoresPersistentStateOnLaunch = "NO"
5250
debugDocumentVersioning = "YES"
5351
debugServiceExtension = "internal"
@@ -80,8 +78,6 @@
8078
isEnabled = "NO">
8179
</CommandLineArgument>
8280
</CommandLineArguments>
83-
<AdditionalOptions>
84-
</AdditionalOptions>
8581
</LaunchAction>
8682
<ProfileAction
8783
buildConfiguration = "Release"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Bucket
3+
uuid = "92C6DAC5-480B-4E33-888F-488026E2EFC1"
34
type = "1"
45
version = "2.0">
56
</Bucket>

src/apps/ojph_compress/ojph_compress.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ int main(int argc, char * argv[]) {
532532

533533
ojph::param_cod_t cod = codestream.access_cod();
534534
cod.set_num_decomposition(num_decompositions);
535-
cod.set_block_dims((ojph::ui8)block_size.w, (ojph::ui8)block_size.h);
535+
cod.set_block_dims(block_size.w, block_size.h);
536536
if (num_precints != -1)
537537
cod.set_precinct_size(num_precints, precinct_size);
538538
cod.set_progression_order(prog_order);
@@ -639,7 +639,7 @@ int main(int argc, char * argv[]) {
639639

640640
ojph::param_cod_t cod = codestream.access_cod();
641641
cod.set_num_decomposition(num_decompositions);
642-
cod.set_block_dims((ojph::ui8)block_size.w, (ojph::ui8)block_size.h);
642+
cod.set_block_dims(block_size.w, block_size.h);
643643
if (num_precints != -1)
644644
cod.set_precinct_size(num_precints, precinct_size);
645645
cod.set_progression_order(prog_order);

src/core/codestream/ojph_codestream.cpp

Lines changed: 49 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ namespace ojph {
237237
tile_rect.org.x += index.x * sz.get_tile_size().w;
238238
t = tile_rect.org.x + sz.get_tile_size().w; //end of tile
239239
//restrict tile
240-
tile_rect.org.x =ojph_max(tile_rect.org.x,sz.get_image_offset().x);
240+
tile_rect.org.x = ojph_max(tile_rect.org.x,sz.get_image_offset().x);
241241
tile_rect.siz.w = ojph_min(t, sz.get_image_extent().x);
242242
tile_rect.siz.w -= tile_rect.org.x;
243243

@@ -376,7 +376,7 @@ namespace ojph {
376376
if (!qcd.write(file))
377377
throw "Error writing to file";
378378

379-
char buf[] = " OpenJPH Ver 0.1.0";
379+
char buf[] = " OpenJPH Ver 0.1.1";
380380
size_t len = strlen(buf);
381381
*(ui16*)buf = swap_byte(JP2K_MARKER::COM);
382382
*(ui16*)(buf + 2) = swap_byte((ui16)(len - 2));
@@ -795,8 +795,7 @@ namespace ojph {
795795
comp_rects[i].siz.w = tcx1 - tcx0;
796796
comp_rects[i].siz.h = tcy1 - tcy0;
797797

798-
comps[i].finalize_alloc(codestream, this, i, comp_rects[i],
799-
tile_rect);
798+
comps[i].finalize_alloc(codestream, this, i, comp_rects[i]);
800799
width = ojph_max(width, comp_rects[i].siz.w);
801800

802801
num_bits[i] = sz.get_bit_depth(i);
@@ -1239,8 +1238,7 @@ namespace ojph {
12391238

12401239
//////////////////////////////////////////////////////////////////////////
12411240
void tile_comp::finalize_alloc(codestream *codestream, tile *parent,
1242-
int comp_num, const rect& comp_rect,
1243-
const rect& tile_rect)
1241+
int comp_num, const rect& comp_rect)
12441242
{
12451243
mem_fixed_allocator* allocator = codestream->get_allocator();
12461244

@@ -1256,7 +1254,7 @@ namespace ojph {
12561254
this->comp_num = comp_num;
12571255
res = allocator->post_alloc_obj<resolution>(1);
12581256
res->finalize_alloc(codestream, comp_rect, num_decomps, comp_downsamp,
1259-
this, NULL, tile_rect);
1257+
this, NULL);
12601258
}
12611259

12621260
//////////////////////////////////////////////////////////////////////////
@@ -1489,8 +1487,7 @@ namespace ojph {
14891487
const rect& res_rect, int res_num,
14901488
point comp_downsamp,
14911489
tile_comp *parent_tile,
1492-
resolution *parent_res,
1493-
const rect& tile_rect)
1490+
resolution *parent_res)
14941491
{
14951492
mem_fixed_allocator* allocator = codestream->get_allocator();
14961493
elastic = codestream->get_elastic_alloc();
@@ -1501,7 +1498,6 @@ namespace ojph {
15011498
this->parent = parent_tile;
15021499
this->parent_res = parent_res;
15031500
this->res_rect = res_rect;
1504-
this->tile_rect = tile_rect;
15051501
this->res_num = res_num;
15061502
//finalize next resolution
15071503
if (res_num > 0)
@@ -1519,8 +1515,7 @@ namespace ojph {
15191515
next_res_rect.siz.h = try1 - try0;
15201516

15211517
child_res->finalize_alloc(codestream, next_res_rect, res_num - 1,
1522-
comp_downsamp, parent_tile, this,
1523-
tile_rect);
1518+
comp_downsamp, parent_tile, this);
15241519
}
15251520
else
15261521
child_res = NULL;
@@ -1555,7 +1550,7 @@ namespace ojph {
15551550
}
15561551

15571552
//finalize precincts
1558-
size log_PP = cd.get_log_precinct_size(res_num);
1553+
log_PP = cd.get_log_precinct_size(res_num);
15591554
num_precincts.w = (trx1 + (1<<log_PP.w) - 1) >> log_PP.w;
15601555
num_precincts.w -= trx0 >> log_PP.w;
15611556
num_precincts.h = (try1 + (1<<log_PP.h) - 1) >> log_PP.h;
@@ -1564,7 +1559,9 @@ namespace ojph {
15641559
memset(precincts, 0, sizeof(precinct) * num_precincts.area());
15651560

15661561
int x_lower_bound = (trx0 >> log_PP.w) << log_PP.w;
1567-
int y_lower_bound = (try0 >> log_PP.w) << log_PP.w;
1562+
int y_lower_bound = (try0 >> log_PP.h) << log_PP.h;
1563+
bool test_x = x_lower_bound != trx0;
1564+
bool test_y = y_lower_bound != try0;
15681565

15691566
point proj_factor;
15701567
proj_factor.x = comp_downsamp.x * (1<<(num_decomps - res_num));
@@ -1578,6 +1575,8 @@ namespace ojph {
15781575
int ppx0 = x_lower_bound + (x << log_PP.w);
15791576
pp->img_point.x = proj_factor.x * ppx0;
15801577
pp->img_point.y = proj_factor.y * ppy0;
1578+
pp->special_x = test_x && x == 0;
1579+
pp->special_y = test_y && y == 0;
15811580
pp->num_bands = num_bands;
15821581
pp->bands = bands;
15831582
}
@@ -2054,7 +2053,9 @@ namespace ojph {
20542053
int idx = cur_precinct_loc.x + cur_precinct_loc.y * num_precincts.w;
20552054
if (idx < (int)num_precincts.area())
20562055
{
2057-
top_left = precincts[idx].img_point;
2056+
point t = precincts[idx].img_point;
2057+
top_left.x = precincts[idx].special_x ? 0 : t.x;
2058+
top_left.y = precincts[idx].special_y ? 0 : t.y;
20582059
return true;
20592060
}
20602061
return false;
@@ -2902,42 +2903,47 @@ namespace ojph {
29022903
num_blocks.h = (tby1 + (1 << ycb_prime) - 1) >> ycb_prime;
29032904
num_blocks.h -= tby0 >> ycb_prime;
29042905

2905-
blocks = allocator->post_alloc_obj<codeblock>(num_blocks.w);
2906-
//allocate codeblock headers
2907-
coded_cb_header *cp = coded_cbs =
2908-
allocator->post_alloc_obj<coded_cb_header>(num_blocks.area());
2909-
memset(coded_cbs, 0, sizeof(coded_cb_header) * num_blocks.area());
2910-
for (int i = (int)num_blocks.area(); i > 0; --i, ++cp)
2911-
cp->Kmax = K_max;
2912-
2913-
int x_lower_bound = (tbx0 >> xcb_prime) << xcb_prime;
2914-
int y_lower_bound = (tby0 >> ycb_prime) << ycb_prime;
2915-
2916-
size cb_size;
2917-
cb_size.h = ojph_min(tby1, y_lower_bound + nominal.h) - tby0;
2918-
cur_cb_height = cb_size.h;
2919-
int line_offset = 0;
2920-
for (int i = 0; i < num_blocks.w; ++i)
2906+
if (num_blocks.area())
29212907
{
2922-
int cbx0 = ojph_max(tbx0, x_lower_bound + i * nominal.w);
2923-
int cbx1 = ojph_min(tbx1, x_lower_bound + (i + 1) * nominal.w);
2924-
cb_size.w = cbx1 - cbx0;
2925-
blocks[i].finalize_alloc(codestream, this, nominal, cb_size,
2926-
coded_cbs + i, K_max, line_offset);
2927-
line_offset += cb_size.w;
2928-
}
2908+
blocks = allocator->post_alloc_obj<codeblock>(num_blocks.w);
2909+
//allocate codeblock headers
2910+
coded_cb_header *cp = coded_cbs =
2911+
allocator->post_alloc_obj<coded_cb_header>(num_blocks.area());
2912+
memset(coded_cbs, 0, sizeof(coded_cb_header) * num_blocks.area());
2913+
for (int i = (int)num_blocks.area(); i > 0; --i, ++cp)
2914+
cp->Kmax = K_max;
2915+
2916+
int x_lower_bound = (tbx0 >> xcb_prime) << xcb_prime;
2917+
int y_lower_bound = (tby0 >> ycb_prime) << ycb_prime;
2918+
2919+
size cb_size;
2920+
cb_size.h = ojph_min(tby1, y_lower_bound + nominal.h) - tby0;
2921+
cur_cb_height = cb_size.h;
2922+
int line_offset = 0;
2923+
for (int i = 0; i < num_blocks.w; ++i)
2924+
{
2925+
int cbx0 = ojph_max(tbx0, x_lower_bound + i * nominal.w);
2926+
int cbx1 = ojph_min(tbx1, x_lower_bound + (i + 1) * nominal.w);
2927+
cb_size.w = cbx1 - cbx0;
2928+
blocks[i].finalize_alloc(codestream, this, nominal, cb_size,
2929+
coded_cbs + i, K_max, line_offset);
2930+
line_offset += cb_size.w;
2931+
}
29292932

2930-
//allocate lines
2931-
lines = allocator->post_alloc_obj<line_buf>(1);
2932-
//allocate line_buf
2933-
int width = band_rect.siz.w + 1;
2934-
lines->wrap(allocator->post_alloc_data<si32>(width,1),width,1);
2933+
//allocate lines
2934+
lines = allocator->post_alloc_obj<line_buf>(1);
2935+
//allocate line_buf
2936+
int width = band_rect.siz.w + 1;
2937+
lines->wrap(allocator->post_alloc_data<si32>(width,1),width,1);
2938+
}
29352939
}
29362940

29372941
//////////////////////////////////////////////////////////////////////////
29382942
void subband::get_cb_indices(const size& num_precincts,
29392943
precinct *precincts)
29402944
{
2945+
if (num_precincts.area() == 0)
2946+
return;
29412947
rect res_rect = parent->get_rect();
29422948
int trx0 = res_rect.org.x;
29432949
int try0 = res_rect.org.y;

0 commit comments

Comments
 (0)