Skip to content

Commit

Permalink
Merge pull request #3 from osamu620/fix-parsing_encodeparams
Browse files Browse the repository at this point in the history
Fixed incorrect parsing of input argument for encode_HTJ2K
  • Loading branch information
osamu620 authored Jul 24, 2020
2 parents 7f890d7 + 1f117e5 commit 0f91791
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 8 deletions.
1 change: 1 addition & 0 deletions source/Tier2/finalize_packet.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
total_bytes_of_packet_header = 0;

codingStyle = get_coding_Styles(main_header, hTile.header);
c_NL = zeros(1, main_header.SIZ.Csiz);
for c = 0:main_header.SIZ.Csiz - 1
[codingStyle, codingStyleComponent] = get_coding_Styles(main_header, hTile.header, c);
c_NL(c + M_OFFSET) = codingStyleComponent.get_number_of_decomposition_levels();
Expand Down
1 change: 1 addition & 0 deletions source/Tier2/read_codestream.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ function read_codestream(currentTile, main_header, PPM_header)
ty1 = currentTile.tile_pos_y + int32(currentTile.tile_size_y);

codingStyle = get_coding_Styles(main_header, currentTile.header);
c_NL = zeros(1, main_header.SIZ.Csiz);
for c = 0:main_header.SIZ.Csiz - 1
[codingStyle, codingStyleComponent] = get_coding_Styles(main_header, currentTile.header, c);
c_NL(c + M_OFFSET) = codingStyleComponent.get_number_of_decomposition_levels();
Expand Down
1 change: 1 addition & 0 deletions source/Tier2/read_packet.m
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
for b = 1:currentResolution.num_band
currentPband = currentPrecinct.precinct_subbands(b);
if currentPband.size_x * currentPband.size_y ~= 0
number_of_bytes = zeros(1, currentPband.numCblksX * currentPband.numCblksY);
for idx = 0:currentPband.numCblksX * currentPband.numCblksY - 1
number_of_bytes(count) = parse_packet_header(packetHeader, l, currentPband, currentPband.Cblks(idx + M_OFFSET), main_header.Cap15_b14_15);
if DEBUG == 1
Expand Down
1 change: 1 addition & 0 deletions source/Tier2/simulate_packet.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
total_bytes_of_packet_header = SOTlength + SODlength;

codingStyle = get_coding_Styles(main_header, hTile.header);
c_NL = zeros(1, main_header.SIZ.Csiz);
for c = 0:main_header.SIZ.Csiz - 1
[codingStyle, codingStyleComponent] = get_coding_Styles(main_header, hTile.header, c);
c_NL(c + M_OFFSET) = codingStyleComponent.get_number_of_decomposition_levels();
Expand Down
2 changes: 2 additions & 0 deletions source/box/convert_uint32_to_char.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

assert(isa(in, 'uint32'));

tmp = zeros(1, 4, 'uint32');

tmp(4) = bitand(in, 255);
in = bitshift(in, -8);
tmp(3) = bitand(in, 255);
Expand Down
7 changes: 5 additions & 2 deletions source/box/jp2_color_conversion.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
alpha = [];
num_non_alpha = 0;
if isempty(jp2Boxes.headerBox.cdef) == false
tmp = zeros([size(buf), main_header.SIZ.Csiz]);
for c = 0:main_header.SIZ.Csiz - 1
if jp2Boxes.headerBox.cdef.Typ_i(c + M_OFFSET) == 1
alpha = buf(:, :, jp2Boxes.headerBox.cdef.Cn_i(c + M_OFFSET) + M_OFFSET) / max(max(buf(:, :, jp2Boxes.headerBox.cdef.Cn_i(c + M_OFFSET) + M_OFFSET)));
Expand Down Expand Up @@ -41,9 +42,10 @@
case {'GREY', 'GRAY'}
fprintf('INFO: Embedde icc profile indicates Grayscale.\n');
cform = makecform('graytrc', iccProfile, 'Direction', 'inverse');
XYZ(:, :, 1) = zeros(size(composite_in));
XYZ = zeros([size(composite_in), 3]);
%XYZ(:, :, 1) = zeros(size(composite_in));
XYZ(:, :, 2) = composite_in;
XYZ(:, :, 3) = zeros(size(composite_in));
%XYZ(:, :, 3) = zeros(size(composite_in));
composite_out = applycform(XYZ / 2^(BPC + 1), cform);
composite_out = round(composite_out .* 2^(BPC + 1));
end
Expand All @@ -68,6 +70,7 @@
case 18 % sYCC
Lmin = 0;
Lmax = 255;
composite_tmp = zeros(size(composite_in));
composite_tmp(:, :, 1) = composite_in(:, :, 1) / Lmax;
composite_tmp(:, :, 2) = (composite_in(:, :, 2) - 128) / Lmax;
composite_tmp(:, :, 3) = (composite_in(:, :, 3) - 128) / Lmax;
Expand Down
4 changes: 4 additions & 0 deletions source/coding_units/jp2_tile.m
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@
end
function composite_out = put_tile_into_composite_output(inObj, main_header, composite_out, reduce_NL)
M_OFFSET = 1;
c_tx0 = zeros(1, main_header.SIZ.Csiz);
c_tx1 = zeros(1, main_header.SIZ.Csiz);
c_ty0 = zeros(1, main_header.SIZ.Csiz);
c_ty1 = zeros(1, main_header.SIZ.Csiz);
for c = 0:main_header.SIZ.Csiz - 1
[~, codingStyleComponent] = get_coding_Styles(main_header, inObj.header, c);
c_NL = codingStyleComponent.get_number_of_decomposition_levels();
Expand Down
2 changes: 2 additions & 0 deletions source/utils/get_CSF_weight.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
function val = get_CSF_weight(c, nb, b)

CSF_table = zeros(6, 3, 3);

% The following example value has been generated by Marcus Nadenau at EPFL.
% for a viewing distance of 15 cm and a display resolution of 300 DPI.
CSF_table(:, :, 3) = [; ...
Expand Down
17 changes: 11 additions & 6 deletions source/utils/jp2_inputArguments.m
Original file line number Diff line number Diff line change
Expand Up @@ -576,12 +576,17 @@
end
main_header = j2k_main_header;
[numTiles_x, numTiles_y, use_SOP, use_PPM, use_TLM, use_PPT, use_PLT] = main_header.create(inObj);
for i = 0:length(tilepart_header) - 1
tilepart_header(i + M_OFFSET).create_COD(inObj);
tilepart_header(i + M_OFFSET).create_QCD(inObj);
tilepart_header(i + M_OFFSET).create_COC(inObj, i, inObj.numComponents, main_header);
tilepart_header(i + M_OFFSET).create_QCC(inObj, i, inObj.numComponents, main_header);
tilepart_header(i + M_OFFSET).create_POC(inObj, main_header);
if isempty(tilepart_header) == false
for i = 0:length(tilepart_header) - 1
tilepart_header(i + M_OFFSET).create_COD(inObj);
tilepart_header(i + M_OFFSET).create_QCD(inObj);
tilepart_header(i + M_OFFSET).create_COC(inObj, i, inObj.numComponents, main_header);
tilepart_header(i + M_OFFSET).create_QCC(inObj, i, inObj.numComponents, main_header);
tilepart_header(i + M_OFFSET).create_POC(inObj, main_header);
end
else % just create a SOT if no optional parameters were given
tilepart_header = j2k_tile_part_header(0);
tilepart_header(1).idx = 0;
end
end
end
Expand Down

0 comments on commit 0f91791

Please sign in to comment.