diff --git a/source/Tier2/finalize_packet.m b/source/Tier2/finalize_packet.m index 5c3ea45..5a6ca35 100644 --- a/source/Tier2/finalize_packet.m +++ b/source/Tier2/finalize_packet.m @@ -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(); diff --git a/source/Tier2/read_codestream.m b/source/Tier2/read_codestream.m index 5dac557..070b481 100644 --- a/source/Tier2/read_codestream.m +++ b/source/Tier2/read_codestream.m @@ -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(); diff --git a/source/Tier2/read_packet.m b/source/Tier2/read_packet.m index 4308ced..919a687 100644 --- a/source/Tier2/read_packet.m +++ b/source/Tier2/read_packet.m @@ -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 diff --git a/source/Tier2/simulate_packet.m b/source/Tier2/simulate_packet.m index 219a691..ed71bd4 100644 --- a/source/Tier2/simulate_packet.m +++ b/source/Tier2/simulate_packet.m @@ -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(); diff --git a/source/box/convert_uint32_to_char.m b/source/box/convert_uint32_to_char.m index c809922..c33e22c 100644 --- a/source/box/convert_uint32_to_char.m +++ b/source/box/convert_uint32_to_char.m @@ -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); diff --git a/source/box/jp2_color_conversion.m b/source/box/jp2_color_conversion.m index bf4d56f..3b96621 100644 --- a/source/box/jp2_color_conversion.m +++ b/source/box/jp2_color_conversion.m @@ -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))); @@ -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 @@ -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; diff --git a/source/coding_units/jp2_tile.m b/source/coding_units/jp2_tile.m index c7ad991..4c3126b 100644 --- a/source/coding_units/jp2_tile.m +++ b/source/coding_units/jp2_tile.m @@ -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(); diff --git a/source/utils/get_CSF_weight.m b/source/utils/get_CSF_weight.m index 88f889c..5147d2c 100644 --- a/source/utils/get_CSF_weight.m +++ b/source/utils/get_CSF_weight.m @@ -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) = [; ... diff --git a/source/utils/jp2_inputArguments.m b/source/utils/jp2_inputArguments.m index fd3fa6a..37738ea 100644 --- a/source/utils/jp2_inputArguments.m +++ b/source/utils/jp2_inputArguments.m @@ -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