48#include "../transform/ojph_colour.h"
49#include "../transform/ojph_transform.h"
50#include "../coding/ojph_block_decoder.h"
51#include "../coding/ojph_block_encoder.h"
131 ui32 skipped_res_for_recon)
134 skipped_res_for_recon);
185 return (
ui16)((t << 8) | (t >> 8));
198 : precinct_scratch(NULL), allocator(NULL), elastic_alloc(NULL)
251 OJPH_ERROR(0x00030011,
"number of tiles cannot exceed 65535");
257 rect tile_rect, recon_tile_rect;
259 for (index.y = 0; index.y <
num_tiles.
h; ++index.y)
273 - recon_tile_rect.
org.
y;
275 for (index.x = 0; index.x <
num_tiles.
w; ++index.x)
289 - recon_tile_rect.
org.
x;
325 for (
ui32 r = 0; r <= num_decomps; ++r)
328 log_PP.
w -= (r ? 1 : 0);
329 log_PP.
h -= (r ? 1 : 0);
334 max_ratio = 1 << max_ratio;
343 4 * ((max_ratio * max_ratio * 4 + 2) / 3);
361 rect tile_rect, recon_tile_rect;
364 for (index.y = 0; index.y <
num_tiles.
h; ++index.y)
378 - recon_tile_rect.
org.
y;
381 for (index.x = 0; index.x <
num_tiles.
w; ++index.x)
395 - recon_tile_rect.
org.
x;
400 offset += recon_tile_rect.
siz.
w;
452 bool imf2k = !reversible, imf4k = !reversible, imf8k = !reversible;
453 bool imf2kls = reversible, imf4kls = reversible, imf8kls = reversible;
458 if (ext.
x <= 2048 && ext.
y <= 1556)
460 if (ext.
x <= 4096 && ext.
y <= 3112)
462 if (ext.
x <= 8192 && ext.
y <= 6224)
465 if (!imf2kls && !imf4kls && !imf8kls)
467 "Image dimensions do not meet any of the lossless IMF profiles");
472 if (ext.
x <= 2048 && ext.
y <= 1556)
474 if (ext.
x <= 4096 && ext.
y <= 3112)
476 if (ext.
x <= 8192 && ext.
y <= 6224)
479 if (!imf2k && !imf4k && !imf8k)
481 "Image dimensions do not meet any of the lossy IMF profiles");
487 "For IMF profile, image offset (XOsiz, YOsiz) has to be 0.");
490 "For IMF profile, tile offset (XTOsiz, YTOsiz) has to be 0.");
493 "For IMF profile, the number of components has to be less "
495 bool test_ds1 =
true, test_ds2 =
true;
499 test_ds1 &= downsamping.
y == 1;
500 test_ds2 &= downsamping.
y == 1;
502 test_ds1 &= downsamping.
x == 1;
503 if (i == 1 || i == 2)
504 test_ds2 &= downsamping.
x == 2;
506 test_ds2 &= downsamping.
x == 1;
508 if (!test_ds1 && !test_ds2)
510 "For IMF profile, either no component downsampling is used,"
511 " or the x-dimension of the 2nd and 3rd components is downsampled"
519 test_bd &= bit_depth >= 8 && bit_depth <= 16 && is_signed ==
false;
523 "For IMF profile, compnent bit_depth has to be between"
524 " 8 and 16 bits inclusively, and the samples must be unsigned");
528 "For IMF profile, codeblock dimensions are restricted."
529 " Use \"-block_size {32,32}\" at the commandline");
534 for (
ui32 i = 1; i <= num_decomps; ++i)
539 "For IMF profile, precinct sizes are restricted."
540 " Use \"-precincts {128,128},{256,256}\" at the commandline");
544 "For IMF profile, the CPRL progression order must be used."
545 " Use \"-prog_order CPRL\".");
547 imf2k &= num_decomps <= 5;
548 imf2kls &= num_decomps <= 5;
549 imf4k &= num_decomps <= 6;
550 imf4kls &= num_decomps <= 6;
551 imf8k &= num_decomps <= 7;
552 imf8kls &= num_decomps <= 7;
554 if (num_decomps == 0 ||
555 (!imf2k && !imf4k && !imf8k && !imf2kls && !imf4kls && !imf8kls))
557 "Number of decompositions does not match the IMF profile"
558 " dictated by wavelet reversibility and image dimensions.");
564 ui32 total_tiles = tiles_w * tiles_h;
570 "Lossy IMF profile must have one tile.");
573 imf2kls &= (tt.
w == 1024 && tt.
h == 1024);
574 imf2kls &= (tt.
w >= 1024 && num_decomps <= 4)
575 || (tt.
w >= 2048 && num_decomps <= 5);
576 imf4kls &= (tt.
w == 1024 && tt.
h == 1024)
577 || (tt.
w == 2048 && tt.
h == 2048);
578 imf4kls &= (tt.
w >= 1024 && num_decomps <= 4)
579 || (tt.
w >= 2048 && num_decomps <= 5)
580 || (tt.
w >= 4096 && num_decomps <= 6);
581 imf8kls &= (tt.
w == 1024 && tt.
h == 1024)
582 || (tt.
w == 2048 && tt.
h == 2048)
583 || (tt.
w == 4096 && tt.
h == 4096);
584 imf8kls &= (tt.
w >= 1024 && num_decomps <= 4)
585 || (tt.
w >= 2048 && num_decomps <= 5)
586 || (tt.
w >= 4096 && num_decomps <= 6)
587 || (tt.
w >= 8192 && num_decomps <= 7);
588 if (!imf2kls && !imf4kls && !imf8kls)
590 "Number of decompositions does not match the IMF profile"
591 " dictated by wavelet reversibility and image dimensions and"
605 "For broadcast profile, image offset (XOsiz, YOsiz) has to be 0.");
608 "For broadcast profile, tile offset (XTOsiz, YTOsiz) has to be 0.");
611 "For broadcast profile, the number of components has to be less "
613 bool test_ds1 =
true, test_ds2 =
true;
617 test_ds1 &= downsamping.
y == 1;
618 test_ds2 &= downsamping.
y == 1;
620 test_ds1 &= downsamping.
x == 1;
621 if (i == 1 || i == 2)
622 test_ds2 &= downsamping.
x == 2;
624 test_ds2 &= downsamping.
x == 1;
626 if (!test_ds1 && !test_ds2)
628 "For broadcast profile, either no component downsampling is used,"
629 " or the x-dimension of the 2nd and 3rd components is downsampled"
637 test_bd &= bit_depth >= 8 && bit_depth <= 12 && is_signed ==
false;
641 "For broadcast profile, compnent bit_depth has to be between"
642 " 8 and 12 bits inclusively, and the samples must be unsigned");
645 if (num_decomps == 0 || num_decomps > 5)
647 "For broadcast profile, number of decompositions has to be between"
648 "1 and 5 inclusively.");
652 "For broadcast profile, codeblock dimensions are restricted such"
653 " that codeblock width has to be either 32, 64, or 128.");
657 "For broadcast profile, codeblock dimensions are restricted such"
658 " that codeblock height has to be either 32, 64, or 128.");
662 for (
ui32 i = 1; i <= num_decomps; ++i)
667 "For broadcast profile, precinct sizes are restricted."
668 " Use \"-precincts {128,128},{256,256}\" at the commandline");
672 "For broadcast profile, the CPRL progression order must be used."
673 " Use \"-prog_order CPRL\".");
679 ui32 total_tiles = tiles_w * tiles_h;
681 if (total_tiles != 1 && total_tiles != 4)
683 "The broadcast profile can only have 1 or 4 tiles");
708 "the planar interface option cannot be used when colour "
709 "transform is employed");
720 if (file->
write(&t, 2) != 2)
721 OJPH_ERROR(0x00030022,
"Error writing to file");
724 OJPH_ERROR(0x00030023,
"Error writing to file");
727 OJPH_ERROR(0x00030024,
"Error writing to file");
730 OJPH_ERROR(0x00030025,
"Error writing to file");
733 OJPH_ERROR(0x00030026,
"Error writing to file");
735 char buf[] =
" OpenJPH Ver "
739 size_t len = strlen(buf);
744 if (file->
write(buf, len) != len)
745 OJPH_ERROR(0x00030027,
"Error writing to file");
756 size_t num_bytes = f->
read(&new_char, 1);
759 if (new_char == 0xFF)
761 size_t num_bytes = f->
read(&new_char, 1);
766 for (
int i = 0; i < list_len; ++i)
767 if (new_char == (char_list[i] & 0xFF))
777 const char *msg,
int msg_level,
bool resilient)
781 if (file->
read(&com_len, 2) != 2)
786 OJPH_ERROR(0x00030041,
"error reading marker");
819 int received_markers = 0;
822 marker_idx =
find_marker(file, marker_list + 2, 15);
825 else if (marker_idx == 1)
828 else if (marker_idx == 2)
831 else if (marker_idx == 3)
832 {
cod.
read(file); received_markers |= 1; }
833 else if (marker_idx == 4)
834 skip_marker(file,
"COC",
"COC is not supported yet",
836 else if (marker_idx == 5)
837 {
qcd.
read(file); received_markers |= 2; }
838 else if (marker_idx == 6)
848 else if (marker_idx == 7)
849 skip_marker(file,
"RGN",
"RGN is not supported yet",
851 else if (marker_idx == 8)
852 skip_marker(file,
"POC",
"POC is not supported yet",
854 else if (marker_idx == 9)
855 skip_marker(file,
"PPM",
"PPM is not supported yet",
857 else if (marker_idx == 10)
860 else if (marker_idx == 11)
863 else if (marker_idx == 12)
865 skip_marker(file,
"CRG",
"CRG has been ignored; CRG is related to"
866 " where the Cb and Cr colour components are co-sited or located"
867 " with respect to the Y' luma component. Perhaps, it is better"
868 " to get the indivdual components and assemble the samples"
869 " according to your needs",
871 else if (marker_idx == 13)
873 else if (marker_idx == 14)
876 OJPH_ERROR(0x00030051,
"File ended before finding a tile segment");
879 if (received_markers != 3)
880 OJPH_ERROR(0x00030052,
"markers error, COD and QCD are required");
888 ui32 skipped_res_for_recon)
892 "skipped_resolution for data %d must be equal or smaller than "
893 " skipped_resolution for reconstruction %d\n",
897 "skipped_resolution for data %d must be smaller than "
898 " the number of decomposition levels %d\n",
910 OJPH_ERROR(0x000300A3,
"Codestream resilience must be enabled before"
911 " reading file headers.\n");
931 OJPH_INFO(0x00030061,
"wrong tile index")
943 "error in tile part number, should be smaller than total"
944 " number of tile parts")
947 "error in tile part number, should be smaller than total"
948 " number of tile parts")
951 bool sod_found =
false;
960 "POC in a tile is not supported yet",
962 else if (marker_idx == 1)
964 "PPT in a tile is not supported yet",
966 else if (marker_idx == 2)
970 else if (marker_idx == 3)
973 else if (marker_idx == 4)
979 if (marker_idx == -1)
983 "File terminated early before start of data is found"
984 " for tile indexed %d and tile part %d",
988 "File terminated early before start of data is found"
989 " for tile indexed %d and tile part %d",
997 "File terminated during marker segment skipping")
1000 "File terminated during marker segment skipping")
1006 tile_start_location);
1010 bool sod_found =
false;
1018 if (marker_idx == 0)
1020 "COD in a tile is not supported yet",
1022 else if (marker_idx == 1)
1024 "COC in a tile is not supported yet",
1026 else if (marker_idx == 2)
1028 "QCD in a tile is not supported yet",
1030 else if (marker_idx == 3)
1032 "QCC in a tile is not supported yet",
1034 else if (marker_idx == 4)
1036 "RGN in a tile is not supported yet",
1038 else if (marker_idx == 5)
1040 "POC in a tile is not supported yet",
1042 else if (marker_idx == 6)
1044 "PPT in a tile is not supported yet",
1046 else if (marker_idx == 7)
1050 else if (marker_idx == 8)
1053 else if (marker_idx == 9)
1059 if (marker_idx == -1)
1063 "File terminated early before start of data is found"
1064 " for tile indexed %d and tile part %d",
1068 "File terminated early before start of data is found"
1069 " for tile indexed %d and tile part %d",
1077 "File terminated during marker segment skipping")
1080 "File terminated during marker segment skipping")
1086 tile_start_location);
1094 if (marker_idx == -1)
1096 OJPH_INFO(0x00030067,
"File terminated early");
1099 else if (marker_idx == 0)
1101 else if (marker_idx == 1)
1115 size_t len = strlen(s);
1121 OJPH_ERROR(0x000300A1,
"unkownn or unsupported profile");
1128 for (
si32 i = 0; i < repeat; ++i)
1129 tiles[i].prepare_for_flush();
1132 for (
si32 i = 0; i < repeat; ++i)
1136 for (
si32 i = 0; i < repeat; ++i)
1140 OJPH_ERROR(0x00030071,
"Error writing to file");
1157 bool success =
false;
1206 bool success =
false;
1248 return lines + comp_num;
1261 const rect& recon_tile_rect)
1306 comp_rect.
org.
x = tcx0;
1307 comp_rect.
org.
y = tcy0;
1308 comp_rect.
siz.
w = tcx1 - tcx0;
1309 comp_rect.
siz.
h = tcy1 - tcy0;
1311 rect recon_comp_rect;
1312 recon_comp_rect.
org.
x = recon_tcx0;
1313 recon_comp_rect.
org.
y = recon_tcy0;
1314 recon_comp_rect.
siz.
w = recon_tcx1 - recon_tcx0;
1315 recon_comp_rect.
siz.
h = recon_tcy1 - recon_tcy0;
1325 for (
int i = 0; i < 3; ++i)
1332 const rect& recon_tile_rect,
1415 for (
int i = 0; i < 3; ++i)
1444 int shift = 1 << (
num_bits[comp_num] - 1);
1448 memcpy(dp, sp, comp_width *
sizeof(
si32));
1454 float mul = 1.0f / (float)(1<<
num_bits[comp_num]);
1456 float *dp = tc->
f32;
1469 int shift = 1 << (
num_bits[comp_num] - 1);
1473 memcpy(dp, sp, comp_width *
sizeof(
si32));
1479 comps[0].get_line()->i32,
1480 comps[1].get_line()->i32,
1481 comps[2].get_line()->i32, comp_width);
1489 float mul = 1.0f / (float)(1<<
num_bits[comp_num]);
1499 comps[0].get_line()->f32,
1500 comps[1].get_line()->f32,
1501 comps[2].get_line()->f32, comp_width);
1527 int shift = 1 << (
num_bits[comp_num] - 1);
1528 const si32 *sp = src_line->
i32;
1531 memcpy(dp, sp, comp_width *
sizeof(
si32));
1537 float mul = (float)(1 <<
num_bits[comp_num]);
1538 const float *sp = src_line->
f32;
1555 lines[2].i32, comp_width);
1559 lines[2].f32, comp_width);
1563 int shift = 1 << (
num_bits[comp_num] - 1);
1571 memcpy(dp, sp, comp_width *
sizeof(
si32));
1577 float mul = (float)(1 <<
num_bits[comp_num]);
1626 ui32 max_decompositions = 0;
1628 max_decompositions =
ojph_max(max_decompositions,
1629 comps[c].get_num_decompositions());
1635 OJPH_ERROR(0x00030081,
"Error writing to file");
1639 if (!file->
write(&t, 2))
1640 OJPH_ERROR(0x00030082,
"Error writing to file");
1647 for (
ui32 r = 0; r <= max_decompositions; ++r)
1649 comps[c].write_precincts(r, file);
1653 for (
ui32 r = 0; r <= max_decompositions; ++r)
1659 point smallest(INT_MAX, INT_MAX), cur;
1662 if (!
comps[c].get_top_left_precinct(r, cur))
1667 if (cur.
y < smallest.y)
1668 { smallest = cur; comp_num = c; }
1669 else if (cur.
y == smallest.y && cur.
x < smallest.x)
1670 { smallest = cur; comp_num = c; }
1686 point smallest(INT_MAX, INT_MAX), cur;
1691 if (!
comps[c].get_top_left_precinct(r, cur))
1696 if (cur.
y < smallest.y)
1697 { smallest = cur; comp_num = c; res_num = r; }
1698 else if (cur.
y == smallest.y && cur.
x < smallest.x)
1699 { smallest = cur; comp_num = c; res_num = r; }
1700 else if (cur.
y == smallest.y && cur.
x == smallest.x &&
1702 { smallest = cur; comp_num = c; res_num = r; }
1703 else if (cur.
y == smallest.y && cur.
x == smallest.x &&
1704 c == comp_num && r < res_num)
1705 { smallest = cur; comp_num = c; res_num = r; }
1722 OJPH_ERROR(0x00030083,
"Error writing to file");
1726 if (!file->
write(&t, 2))
1727 OJPH_ERROR(0x00030084,
"Error writing to file");
1734 point smallest(INT_MAX, INT_MAX), cur;
1735 for (
ui32 r = 0; r <= max_decompositions; ++r)
1737 if (!
comps[c].get_top_left_precinct(r, cur))
1742 if (cur.
y < smallest.y)
1743 { smallest = cur; res_num = r; }
1744 else if (cur.
y == smallest.y && cur.
x < smallest.x)
1745 { smallest = cur; res_num = r; }
1761 const ui64& tile_start_location)
1766 OJPH_INFO(0x00030091,
"wrong tile part index")
1768 OJPH_ERROR(0x00030091,
"wrong tile part index")
1776 data_left -= (
ui32)((
ui64)file->
tell() - tile_start_location);
1781 ui32 max_decompositions = 0;
1783 max_decompositions =
ojph_max(max_decompositions,
1784 comps[c].get_num_decompositions());
1792 for (
ui32 r = 0; r <= max_decompositions; ++r)
1800 for (
ui32 r = 0; r <= max_decompositions; ++r)
1806 point smallest(INT_MAX, INT_MAX), cur;
1809 if (!
comps[c].get_top_left_precinct(r, cur))
1814 if (cur.
y < smallest.y)
1815 { smallest = cur; comp_num = c; }
1816 else if (cur.
y == smallest.y && cur.
x < smallest.x)
1817 { smallest = cur; comp_num = c; }
1819 if (found ==
true && data_left > 0)
1833 point smallest(INT_MAX, INT_MAX), cur;
1838 if (!
comps[c].get_top_left_precinct(r, cur))
1843 if (cur.
y < smallest.y)
1844 { smallest = cur; comp_num = c; res_num = r; }
1845 else if (cur.
y == smallest.y && cur.
x < smallest.x)
1846 { smallest = cur; comp_num = c; res_num = r; }
1847 else if (cur.
y == smallest.y && cur.
x == smallest.x &&
1849 { smallest = cur; comp_num = c; res_num = r; }
1850 else if (cur.
y == smallest.y && cur.
x == smallest.x &&
1851 c == comp_num && r < res_num)
1852 { smallest = cur; comp_num = c; res_num = r; }
1855 if (found ==
true && data_left > 0)
1869 point smallest(INT_MAX, INT_MAX), cur;
1870 for (
ui32 r = 0; r <= max_decompositions; ++r)
1872 if (!
comps[c].get_top_left_precinct(r, cur))
1877 if (cur.
y < smallest.y)
1878 { smallest = cur; res_num = r; }
1879 else if (cur.
y == smallest.y && cur.
x < smallest.x)
1880 { smallest = cur; res_num = r; }
1882 if (found ==
true && data_left > 0)
1893 catch (
const char *
error)
1913 const rect& recon_comp_rect)
1927 ui32 comp_num,
const rect& comp_rect,
1928 const rect& recon_comp_rect)
1975 while (res_num > 0 && r != NULL)
1990 while (res_num > 0 && r != NULL)
2007 while (res_num > 0 && r != NULL)
2023 while (res_num > 0 && r != NULL)
2040 while (res_num > 0 && r != NULL)
2063 assert(line1->
size == line2->
size &&
2081 assert(line1->
size == line2->
size &&
2102 const rect& recon_res_rect,
ui32 res_num)
2120 next_res_rect.
org.
x = trx0;
2121 next_res_rect.
org.
y = try0;
2122 next_res_rect.
siz.
w = trx1 - trx0;
2123 next_res_rect.
siz.
h = try1 - try0;
2137 for (
ui32 i = 1; i < 4; ++i)
2139 ui32 tbx0 = (trx0 - (i&1) + 1) >> 1;
2140 ui32 tbx1 = (trx1 - (i&1) + 1) >> 1;
2141 ui32 tby0 = (try0 - (i>>1) + 1) >> 1;
2142 ui32 tby1 = (try1 - (i>>1) + 1) >> 1;
2145 band_rect.
org.
x = tbx0;
2146 band_rect.
org.
y = tby0;
2147 band_rect.
siz.
w = tbx1 - tbx0;
2148 band_rect.
siz.
h = tby1 - tby0;
2158 if (trx0 != trx1 && try0 != try1)
2182 const rect& res_rect,
2183 const rect& recon_res_rect,
2185 point comp_downsamp,
2214 next_res_rect.
org.
x = trx0;
2215 next_res_rect.
org.
y = try0;
2216 next_res_rect.
siz.
w = trx1 - trx0;
2217 next_res_rect.
siz.
h = try1 - try0;
2235 for (
ui32 i = 1; i < 4; ++i)
2237 ui32 tbx0 = (trx0 - (i&1) + 1) >> 1;
2238 ui32 tbx1 = (trx1 - (i&1) + 1) >> 1;
2239 ui32 tby0 = (try0 - (i>>1) + 1) >> 1;
2240 ui32 tby1 = (try1 - (i>>1) + 1) >> 1;
2243 band_rect.
org.
x = tbx0;
2244 band_rect.
org.
y = tby0;
2245 band_rect.
siz.
w = tbx1 - tbx0;
2246 band_rect.
siz.
h = tby1 - tby0;
2259 if (trx0 != trx1 && try0 != try1)
2267 for (
ui64 i = 0; i < num; ++i)
2287 point t(proj_factor.
x * ppx0, proj_factor.
y * ppy0);
2288 t.x = t.x > tile_top_left.
x ? t.x : tile_top_left.
x;
2289 t.y = t.y > tile_top_left.
y ? t.y : tile_top_left.
y;
2302 for (
int i = 1; i < 4; ++i)
2316 for (
ui32 i = 1; i <= max_num_levels; ++i, val >>= 2)
2428 for (
ui32 i = width; i > 0; --i)
2452 lines + 1, 0, width);
2455 lines + 2, 1, width);
2458 lines + 3, 2, width);
2461 lines + 4, 3, width);
2494 lines + 1, 2, width);
2497 lines + 2, 3, width);
2530 lines + 1, 1, width);
2533 lines + 2, 2, width);
2536 lines + 3, 3, width);
2542 lines + 1, 3, width);
2673 for (
ui32 i = width; i > 0; --i)
2714 lines + 1, 7, width);
2718 lines + 2, 6, width);
2722 lines + 3, 5, width);
2726 lines + 4, 4, width);
2751 for (
ui32 i = width; i > 0; --i)
2765 ui32 used_bytes = 0;
2770 for (
si32 i = 0; i < repeat; ++i)
2875 assert(cur_coded_list == NULL);
2877 bbp->
ccl = cur_coded_list;
2908 cur_coded_list = cur_coded_list->
next_list;
2921 for (
int i = num_bits - 1; i >= 0; --i)
2922 bb_put_bit(bbp, data >> i, elastic, cur_coded_list, ph_bytes);
2961 levs[i] = buf + lev_idx[i];
2977 return levs[lev] + (x + y * ((
width + (1 << lev) - 1) >> lev));
2988 return t + (x & (x - 1) ? 1 : 0);
3001 int num_skipped_subbands = 0;
3002 for (
int s = sst; s < send; ++s)
3007 ui32 num_levels = 1 +
3011 tag_tree inc_tag, inc_tag_flags, mmsb_tag, mmsb_tag_flags;
3014 lev_idx, num_levels,
cb_idxs[s].siz, 0);
3016 lev_idx, num_levels,
cb_idxs[s].siz, 255);
3017 mmsb_tag_flags.
init(
scratch + (tag_tree_size<<1) + tag_tree_size,
3018 lev_idx, num_levels,
cb_idxs[s].siz, 0);
3032 for (
ui32 lev = 1; lev < num_levels; ++lev)
3036 for (
ui32 y = 0; y < height; ++y)
3038 for (
ui32 x = 0; x < width; ++x)
3042 *inc_tag.
get((x<<1) + 1, y<<1, lev-1));
3043 t2 =
ojph_min(*inc_tag.
get(x<<1, (y<<1) + 1, lev-1),
3044 *inc_tag.
get((x<<1) + 1, (y<<1) + 1, lev-1));
3046 *inc_tag_flags.
get(x, y, lev) = 0;
3048 *mmsb_tag.
get((x<<1) + 1, y<<1, lev-1));
3049 t2 =
ojph_min(*mmsb_tag.
get(x<<1, (y<<1) + 1, lev-1),
3050 *mmsb_tag.
get((x<<1) + 1, (y<<1) + 1, lev-1));
3052 *mmsb_tag_flags.
get(x, y, lev) = 0;
3056 *inc_tag.
get(0,0,num_levels) = 0;
3057 *inc_tag_flags.
get(0,0,num_levels) = 0;
3058 *mmsb_tag.
get(0,0,num_levels) = 0;
3059 *mmsb_tag_flags.
get(0,0,num_levels) = 0;
3060 if (*inc_tag.
get(0, 0, num_levels-1) != 0)
3063 bb_put_bits(&bb, 0, 1, elastic, cur_coded_list, ph_bytes);
3065 ++num_skipped_subbands;
3071 bb_init(&bb, elastic, cur_coded_list);
3072 coded = cur_coded_list;
3074 bb_put_bit(&bb, 1, elastic, cur_coded_list, ph_bytes);
3078 bb_put_bits(&bb, 0, num_skipped_subbands, elastic, cur_coded_list,
3080 num_skipped_subbands = 0;
3085 for (
ui32 y = 0; y < height; ++y)
3089 for (
ui32 x = 0; x < width; ++x, ++cp)
3092 for (
ui32 cur_lev = num_levels; cur_lev > 0; --cur_lev)
3094 ui32 levm1 = cur_lev - 1;
3096 if (*inc_tag_flags.
get(x>>levm1, y>>levm1, levm1) == 0)
3098 ui32 skipped = *inc_tag.
get(x>>levm1, y>>levm1, levm1);
3099 skipped -= *inc_tag.
get(x>>cur_lev, y>>cur_lev, cur_lev);
3100 assert(skipped <= 1);
3102 elastic, cur_coded_list, ph_bytes);
3103 *inc_tag_flags.
get(x>>levm1, y>>levm1, levm1) = 1;
3105 if (*inc_tag.
get(x>>levm1, y>>levm1, levm1) > 0)
3113 for (
ui32 cur_lev = num_levels; cur_lev > 0; --cur_lev)
3115 ui32 levm1 = cur_lev - 1;
3117 if (*mmsb_tag_flags.
get(x>>levm1, y>>levm1, levm1) == 0)
3119 int num_zeros = *mmsb_tag.
get(x>>levm1, y>>levm1, levm1);
3120 num_zeros -= *mmsb_tag.
get(x>>cur_lev, y>>cur_lev, cur_lev);
3122 elastic, cur_coded_list, ph_bytes);
3123 *mmsb_tag_flags.
get(x>>levm1, y>>levm1, levm1) = 1;
3131 bb_put_bits(&bb, 12, 4, elastic, cur_coded_list, ph_bytes);
3134 bb_put_bits(&bb, 2, 2, elastic, cur_coded_list, ph_bytes);
3137 bb_put_bits(&bb, 0, 1, elastic, cur_coded_list, ph_bytes);
3150 int bits =
ojph_max(bits1, bits2 - extra_bit) - 3;
3153 elastic, cur_coded_list, ph_bytes);
3156 elastic, cur_coded_list, ph_bytes);
3159 elastic, cur_coded_list, ph_bytes);
3172 return coded ? cb_bytes + ph_bytes : 1;
3191 for (
int s = sst; s < send; ++s)
3196 for (
ui32 y = 0; y < height; ++y)
3200 for (
ui32 x = 0; x < width; ++x, ++cp)
3216 file->
write(&buf, 1);
3249 throw "error reading from file";
3280 assert(num_bits <= 32);
3290 num_bits -= tx_bits;
3291 bits |= (bbp->
tmp >> bbp->
avail_bits) & ((1 << tx_bits) - 1);
3308 if (num_bytes > bytes_read)
3310 0, num_bytes - bytes_read);
3312 return bytes_read == bytes;
3322 if (bbp->
file->
read(marker, 2) != 2)
3323 throw "error reading from file";
3325 if ((
int)marker[0] != (
EPH >> 8) || (
int)marker[1] != (
EPH & 0xFF))
3326 throw "should find EPH, but found something else";
3337 assert(bbp->
unstuff ==
false);
3352 if (bbp->
file->
read(marker, 2) != 2)
3353 throw "error reading from file";
3354 if ((
int)marker[0] == (
SOP >> 8) && (
int)marker[1] == (
SOP & 0xFF))
3360 if (bbp->
file->
read(&com_len, 2) != 2)
3361 throw "error reading from file";
3364 throw "something is wrong with SOP length";
3368 throw "error seeking file";
3372 throw "precinct truncated early";
3379 throw "error seeking file";
3393 assert(data_left > 0);
3395 bb_init(&bb, data_left, file);
3401 bool empty_packet =
true;
3402 for (
int s = sst; s < send; ++s)
3413 empty_packet =
false;
3416 ui32 num_levels = 1 +
3420 tag_tree inc_tag, inc_tag_flags, mmsb_tag, mmsb_tag_flags;
3422 *inc_tag.
get(0, 0, num_levels) = 0;
3423 inc_tag_flags.
init(
scratch + tag_tree_size, lev_idx, num_levels,
3425 *inc_tag_flags.
get(0, 0, num_levels) = 0;
3426 mmsb_tag.
init(
scratch + (tag_tree_size<<1), lev_idx, num_levels,
3428 *mmsb_tag.
get(0, 0, num_levels) = 0;
3429 mmsb_tag_flags.
init(
scratch + (tag_tree_size<<1) + tag_tree_size,
3430 lev_idx, num_levels,
cb_idxs[s].siz, 0);
3431 *mmsb_tag_flags.
get(0, 0, num_levels) = 0;
3437 for (
ui32 y = 0; y < height; ++y)
3441 for (
ui32 x = 0; x < width; ++x, ++cp)
3444 bool empty_cb =
false;
3445 for (
ui32 cl = num_levels; cl > 0; --cl)
3447 ui32 cur_lev = cl - 1;
3448 empty_cb = *inc_tag.
get(x>>cur_lev, y>>cur_lev, cur_lev) == 1;
3452 if (*inc_tag_flags.
get(x>>cur_lev, y>>cur_lev, cur_lev) == 0)
3456 { data_left = 0;
throw "error reading from file p1"; }
3457 empty_cb = (bit == 0);
3458 *inc_tag.
get(x>>cur_lev, y>>cur_lev, cur_lev) = (
ui8)(1 - bit);
3459 *inc_tag_flags.
get(x>>cur_lev, y>>cur_lev, cur_lev) = 1;
3470 for (
ui32 levp1 = num_levels; levp1 > 0; --levp1)
3472 ui32 cur_lev = levp1 - 1;
3473 mmsbs = *mmsb_tag.
get(x>>levp1, y>>levp1, levp1);
3475 if (*mmsb_tag_flags.
get(x>>cur_lev, y>>cur_lev, cur_lev) == 0)
3481 { data_left = 0;
throw "error reading from file p2"; }
3484 *mmsb_tag.
get(x>>cur_lev, y>>cur_lev, cur_lev) = (
ui8)mmsbs;
3485 *mmsb_tag_flags.
get(x>>cur_lev, y>>cur_lev, cur_lev) = 1;
3489 if (mmsbs > cp->
Kmax)
3490 throw "error in parsing a tile header; "
3491 "missing msbs are larger or equal to Kmax. The most likely "
3492 "cause is a corruption in the bitstream.";
3496 ui32 bit, num_passes = 1;
3498 { data_left = 0;
throw "error reading from file p3"; }
3503 { data_left = 0;
throw "error reading from file p4"; }
3507 { data_left = 0;
throw "error reading from file p5"; }
3508 num_passes = 3 + bit;
3512 { data_left = 0;
throw "error reading from file p6"; }
3513 num_passes = 6 + bit;
3517 { data_left = 0;
throw "error reading from file p7"; }
3518 num_passes = 37 + bit;
3533 { data_left = 0;
throw "error reading from file p8"; }
3538 { data_left = 0;
throw "error reading from file p9"; }
3542 if (
bb_read_bits(&bb, bits1 + extra_bit, bit) ==
false)
3543 { data_left = 0;
throw "error reading from file p10"; }
3551 for (
int s = sst; s < send; ++s)
3556 for (
ui32 y = 0; y < height; ++y)
3560 for (
ui32 x = 0; x < width; ++x, ++cp)
3575 assert(bytes_read == t || bb.
bytes_left == 0);
3650 const rect &band_rect,
3680 d /= (float)(1u << (31 - this->
K_max));
3712 cb_size.
h =
ojph_min(tby1, y_lower_bound + nominal.
h) - tby0;
3714 int line_offset = 0;
3718 ui32 cbx1 =
ojph_min(tbx1, x_lower_bound + (i + 1) * nominal.
w);
3719 cb_size.
w = cbx1 - cbx0;
3722 line_offset += cb_size.
w;
3748 ui32 pcx0, pcx1, pcy0, pcy1, shift = (
band_num != 0 ? 1 : 0);
3749 ui32 yb, xb, coly = 0, colx = 0;
3750 for (
ui32 y = 0; y < num_precincts.
h; ++y)
3754 pcy0 = (pcy0 - (
band_num >> 1) + (1<<shift) - 1) >> shift;
3755 pcy1 = (pcy1 - (
band_num >> 1) + (1<<shift) - 1) >> shift;
3757 precinct *p = precincts + y * num_precincts.
w;
3762 for (
ui32 x = 0; x < num_precincts.
w; ++x, ++p)
3766 pcx0 = (pcx0 - (
band_num & 1) + (1<<shift) - 1) >> shift;
3767 pcx1 = (pcx1 - (
band_num & 1) + (1<<shift) - 1) >> shift;
3827 cb_size.
h = cby1 -
ojph_max(tby0, cby0);
3832 ui32 cbx1 =
ojph_min(tbx1, x_lower_bound + (i + 1) * nominal.
w);
3833 cb_size.
w = cbx1 - cbx0;
3864 cb_size.
h = cby1 - cby0;
3869 ui32 cbx1 =
ojph_min(tbx1, x_lower_bound + (i + 1) * nominal.
w);
3870 cb_size.
w = cbx1 - cbx0;
3902 const size& nominal)
3913 const size& cb_size,
3915 ui32 K_max,
int line_offset)
3919 this->
stride = (nominal.
w + 7) & ~7U;
3930 this->K_max =
K_max;
3931 for (
int i = 0; i < 8; ++i)
3940#if !defined(OJPH_ENABLE_WASM_SIMD) || !defined(OJPH_EMSCRIPTEN)
3955#ifndef OJPH_DISABLE_INTEL_SIMD
4025 if (mv >= 1u<<(31 -
K_max))
4045 for (
int i = 0; i < 8; ++i)
4062 if (result ==
false)
4067 OJPH_ERROR(0x000300A1,
"Error decoding a codeblock\n");
4078 for (
size_t i = 0; i < count; i += 4, p += 1)
4084 float delta_inv,
ui32 count,
4092 for (
ui32 i = count; i > 0; --i)
4095 ui32 sign = v >= 0 ? 0 : 0x80000000;
4096 ui32 val = (
ui32)(v >= 0 ? v : -v);
4106 float delta_inv,
ui32 count,
4112 float *p = (
float*)sp;
4113 for (
ui32 i = count; i > 0; --i)
4117 ui32 sign = t >= 0 ? 0 : 0x80000000;
4118 ui32 val = (
ui32)(t >= 0 ? t : -t);
4127 float delta,
ui32 count)
4133 for (
ui32 i = count; i > 0; --i)
4136 si32 val = (v & 0x7FFFFFFF) >> shift;
4137 *p++ = (v & 0x80000000) ? -val : val;
4143 float delta,
ui32 count)
4147 float *p = (
float*)dp;
4148 for (
ui32 i = count; i > 0; --i)
4151 float val = (float)(v & 0x7FFFFFFF) *
delta;
4152 *p++ = (v & 0x80000000) ? -val : val;
OJPH_EXPORT param_siz access_siz()
OJPH_EXPORT param_cod access_cod()
OJPH_EXPORT void restrict_input_resolution(ui32 skipped_res_for_data, ui32 skipped_res_for_recon)
local::codestream * state
OJPH_EXPORT void set_planar(bool planar)
OJPH_EXPORT ~codestream()
OJPH_EXPORT void enable_resilience()
OJPH_EXPORT line_buf * exchange(line_buf *line, ui32 &next_component)
OJPH_EXPORT void set_profile(const char *s)
OJPH_EXPORT void write_headers(outfile_base *file)
OJPH_EXPORT param_qcd access_qcd()
OJPH_EXPORT void read_headers(infile_base *file)
OJPH_EXPORT void create()
OJPH_EXPORT bool is_planar() const
OJPH_EXPORT line_buf * pull(ui32 &comp_num)
virtual size_t read(void *ptr, size_t size)=0
bool(* cb_decoder_fun)(ui8 *coded_data, ui32 *decoded_data, ui32 missing_msbs, ui32 num_passes, ui32 lengths1, ui32 lengths2, ui32 width, ui32 height, ui32 stride, bool stripe_causal)
static void gen_mem_clear(void *addr, size_t count)
static void gen_rev_tx_from_cb(const ui32 *sp, void *dp, ui32 K_max, float delta, ui32 count)
static ui32 gen_find_max_val(ui32 *addr)
static void pre_alloc(codestream *codestream, const size &nominal)
coded_cb_header * coded_cb
find_max_val_fun find_max_val
static void gen_irv_tx_from_cb(const ui32 *sp, void *dp, ui32 K_max, float delta, ui32 count)
void push(line_buf *line)
static cb_decoder_fun decode_cb
tx_from_cb_fun tx_from_cb
void encode(mem_elastic_allocator *elastic)
void recreate(const size &cb_size, coded_cb_header *coded_cb)
static void gen_irv_tx_to_cb(const void *sp, ui32 *dp, ui32 K_max, float delta_inv, ui32 count, ui32 *max_val)
void finalize_alloc(codestream *codestream, subband *parent, const size &nominal, const size &cb_size, coded_cb_header *coded_cb, ui32 K_max, int tbx0)
static void gen_rev_tx_to_cb(const void *sp, ui32 *dp, ui32 K_max, float delta_inv, ui32 count, ui32 *max_val)
void pull_line(line_buf *line)
param_qcd * access_qcd(ui32 comp_num)
ui32 skipped_res_for_recon
ojph::param_siz access_siz()
mem_elastic_allocator * get_elastic_alloc()
ui32 get_skipped_res_for_read()
line_buf * exchange(line_buf *line, ui32 &next_component)
void set_planar(int planar)
const param_siz * get_siz()
void check_imf_validity()
mem_fixed_allocator * get_allocator()
void restrict_input_resolution(ui32 skipped_res_for_data, ui32 skipped_res_for_recon)
ui8 * get_precinct_scratch()
mem_elastic_allocator * elastic_alloc
ojph::param_cod access_cod()
const param_cod * get_cod()
mem_fixed_allocator * allocator
ui32 precinct_scratch_needed_bytes
void check_broadcast_validity()
void read_headers(infile_base *file)
void set_profile(const char *s)
bool employ_color_transform
void write_headers(outfile_base *file)
ui32 get_skipped_res_for_recon()
line_buf * pull(ui32 &comp_num)
ui32 skipped_res_for_read
bool get_top_left_precinct(point &top_left)
void parse_one_precinct(ui32 &data_left, infile_base *file)
bool skipped_res_for_recon
mem_elastic_allocator * elastic
void write_precincts(outfile_base *file)
bool skipped_res_for_read
resolution * next_resolution()
void finalize_alloc(codestream *codestream, const rect &res_rect, const rect &recon_res_rect, ui32 comp_num, ui32 res_num, point comp_downsamp, tile_comp *parent_tile_comp, resolution *parent_res)
void parse_all_precincts(ui32 &data_left, infile_base *file)
static void pre_alloc(codestream *codestream, const rect &res_rect, const rect &recon_res_rect, ui32 res_num)
void write_one_precinct(outfile_base *file)
void exchange_buf(line_buf *l)
coded_cb_header * coded_cbs
void get_cb_indices(const size &num_precincts, precinct *precincts)
mem_elastic_allocator * elastic
static void pre_alloc(codestream *codestream, const rect &band_rect, ui32 res_num)
void finalize_alloc(codestream *codestream, const rect &band_rect, resolution *res, ui32 res_num, ui32 subband_num)
static void pre_alloc(codestream *codestream, const rect &comp_rect, const rect &recon_comp_rect)
ui32 get_num_decompositions()
bool get_top_left_precinct(ui32 res_num, point &top_left)
void write_one_precinct(ui32 res_num, outfile_base *file)
void finalize_alloc(codestream *codestream, tile *parent, ui32 comp_num, const rect &comp_rect, const rect &recon_comp_rect)
void parse_one_precinct(ui32 res_num, ui32 &data_left, infile_base *file)
ojph::point comp_downsamp
void write_precincts(ui32 res_num, outfile_base *file)
void parse_precincts(ui32 res_num, ui32 &data_left, infile_base *file)
bool pull(line_buf *, ui32 comp_num)
void finalize_alloc(codestream *codestream, const rect &tile_rect, const rect &recon_tile_rect, ui32 tile_idx, ui32 offset)
void fill_tlm(param_tlm *tlm)
static void pre_alloc(codestream *codestream, const rect &tile_rect, const rect &recon_tile_rect)
void flush(outfile_base *file)
ui32 skipped_res_for_read
bool push(line_buf *line, ui32 comp_num)
bool employ_color_transform
void parse_tile_header(const param_sot &sot, infile_base *file, const ui64 &tile_start_location)
void get_buffer(ui32 needed_bytes, coded_lists *&p)
void pre_alloc_data(size_t num_ele, ui32 pre_size)
void pre_alloc_obj(size_t num_ele)
T * post_alloc_data(size_t num_ele, ui32 pre_size)
T * post_alloc_obj(size_t num_ele)
virtual size_t write(const void *ptr, size_t size)=0
OJPH_EXPORT int get_progression_order() const
OJPH_EXPORT ui32 get_num_decompositions() const
OJPH_EXPORT size get_log_block_dims() const
OJPH_EXPORT bool is_reversible() const
OJPH_EXPORT bool get_block_vertical_causality() const
OJPH_EXPORT size get_log_precinct_size(ui32 level_num) const
OJPH_EXPORT point get_image_extent() const
OJPH_EXPORT ui32 get_bit_depth(ui32 comp_num) const
OJPH_EXPORT point get_image_offset() const
OJPH_EXPORT size get_tile_size() const
OJPH_EXPORT point get_downsampling(ui32 comp_num) const
OJPH_EXPORT point get_tile_offset() const
OJPH_EXPORT bool is_signed(ui32 comp_num) const
OJPH_EXPORT ui32 get_num_components() const
static bool bb_read_chunk(bit_read_buf *bbp, ui32 num_bytes, coded_lists *&cur_coded_list, mem_elastic_allocator *elastic)
bool ojph_decode_codeblock_wasm(ui8 *coded_data, ui32 *decoded_data, ui32 missing_msbs, ui32 num_passes, ui32 lengths1, ui32 lengths2, ui32 width, ui32 height, ui32 stride, bool stripe_causal)
Decodes one codeblock, processing the cleanup, siginificance propagation, and magnitude refinement pa...
void(* cnvrt_float_to_si32)(const float *sp, si32 *dp, float mul, ui32 width)
ui32 avx2_find_max_val(ui32 *address)
void avx2_irv_tx_from_cb(const ui32 *sp, void *dp, ui32 K_max, float delta, ui32 count)
static int find_marker(infile_base *f, const ui16 *char_list, int list_len)
static bool bb_read_bit(bit_read_buf *bbp, ui32 &bit)
static int skip_marker(infile_base *file, const char *marker, const char *msg, int msg_level, bool resilient)
static void bb_terminate(bit_write_buf *bbp)
void(* irrev_horz_wvlt_fwd_tx)(line_buf *src, line_buf *ldst, line_buf *hdst, ui32 width, bool even)
static void bb_init(bit_write_buf *bbp, mem_elastic_allocator *elastic, coded_lists *&cur_coded_list)
bool ojph_decode_codeblock_ssse3(ui8 *coded_data, ui32 *decoded_data, ui32 missing_msbs, ui32 num_passes, ui32 lengths1, ui32 lengths2, ui32 width, ui32 height, ui32 stride, bool stripe_causal)
Decodes one codeblock, processing the cleanup, siginificance propagation, and magnitude refinement pa...
void(* cnvrt_si32_to_float_shftd)(const si32 *sp, float *dp, float mul, ui32 width)
void(* ict_forward)(const float *r, const float *g, const float *b, float *y, float *cb, float *cr, ui32 repeat)
void sse2_irv_tx_to_cb(const void *sp, ui32 *dp, ui32 K_max, float delta_inv, ui32 count, ui32 *max_val)
void(* rev_horz_wvlt_bwd_tx)(line_buf *dst, line_buf *lsrc, line_buf *hsrc, ui32 width, bool even)
void avx_mem_clear(void *addr, size_t count)
void(* cnvrt_si32_to_si32_shftd)(const si32 *sp, si32 *dp, int shift, ui32 width)
static bool bb_read_bits(bit_read_buf *bbp, int num_bits, ui32 &bits)
static bool bb_skip_sop(bit_read_buf *bbp)
void(* ict_backward)(const float *y, const float *cb, const float *cr, float *r, float *g, float *b, ui32 repeat)
static void rotate_buffers(line_buf *line1, line_buf *line2, line_buf *line3, line_buf *line4)
void(* rct_backward)(const si32 *y, const si32 *cb, const si32 *cr, si32 *r, si32 *g, si32 *b, ui32 repeat)
void wasm_irv_tx_from_cb(const ui32 *sp, void *dp, ui32 K_max, float delta, ui32 count)
void init_wavelet_transform_functions()
void avx2_rev_tx_to_cb(const void *sp, ui32 *dp, ui32 K_max, float delta_inv, ui32 count, ui32 *max_val)
void init_colour_transform_functions()
void(* rev_vert_wvlt_fwd_update)(const line_buf *src1, const line_buf *src2, line_buf *dst, ui32 repeat)
static bool bb_read(bit_read_buf *bbp)
void(* cnvrt_float_to_si32_shftd)(const float *sp, si32 *dp, float mul, ui32 width)
void wasm_irv_tx_to_cb(const void *sp, ui32 *dp, ui32 K_max, float delta_inv, ui32 count, ui32 *max_val)
void sse2_irv_tx_from_cb(const ui32 *sp, void *dp, ui32 K_max, float delta, ui32 count)
void sse_mem_clear(void *addr, size_t count)
static ui32 log2ceil(ui32 x)
void wasm_rev_tx_to_cb(const void *sp, ui32 *dp, ui32 K_max, float delta_inv, ui32 count, ui32 *max_val)
void sse2_rev_tx_from_cb(const ui32 *sp, void *dp, ui32 K_max, float delta, ui32 count)
void sse2_rev_tx_to_cb(const void *sp, ui32 *dp, ui32 K_max, float delta_inv, ui32 count, ui32 *max_val)
static void bb_put_bits(bit_write_buf *bbp, ui32 data, int num_bits, mem_elastic_allocator *elastic, coded_lists *&cur_coded_list, ui32 &ph_bytes)
void(* cnvrt_si32_to_float)(const si32 *sp, float *dp, float mul, ui32 width)
void(* rev_horz_wvlt_fwd_tx)(line_buf *src, line_buf *ldst, line_buf *hdst, ui32 width, bool even)
void(* irrev_vert_wvlt_step)(const line_buf *src1, const line_buf *src2, line_buf *dst, int step_num, ui32 repeat)
void(* rct_forward)(const si32 *r, const si32 *g, const si32 *b, si32 *y, si32 *cb, si32 *cr, ui32 repeat)
void wasm_mem_clear(void *addr, size_t count)
ui32 sse2_find_max_val(ui32 *address)
static ui16 swap_byte(ui16 t)
void(* rev_vert_wvlt_bwd_update)(const line_buf *src1, const line_buf *src2, line_buf *dst, ui32 repeat)
void wasm_rev_tx_from_cb(const ui32 *sp, void *dp, ui32 K_max, float delta, ui32 count)
void avx2_rev_tx_from_cb(const ui32 *sp, void *dp, ui32 K_max, float delta, ui32 count)
void(* rev_vert_wvlt_bwd_predict)(const line_buf *src1, const line_buf *src2, line_buf *dst, ui32 repeat)
bool ojph_decode_codeblock(ui8 *coded_data, ui32 *decoded_data, ui32 missing_msbs, ui32 num_passes, ui32 lengths1, ui32 lengths2, ui32 width, ui32 height, ui32 stride, bool stripe_causal)
Decodes one codeblock, processing the cleanup, siginificance propagation, and magnitude refinement pa...
void(* rev_vert_wvlt_fwd_predict)(const line_buf *src1, const line_buf *src2, line_buf *dst, ui32 repeat)
void(* irrev_horz_wvlt_bwd_tx)(line_buf *src, line_buf *ldst, line_buf *hdst, ui32 width, bool even)
void(* irrev_vert_wvlt_K)(const line_buf *src, line_buf *dst, bool L_analysis_or_H_synthesis, ui32 repeat)
static void bb_put_bit(bit_write_buf *bbp, ui32 bit, mem_elastic_allocator *elastic, coded_lists *&cur_coded_list, ui32 &ph_bytes)
static void bb_skip_eph(bit_read_buf *bbp)
void avx2_irv_tx_to_cb(const void *sp, ui32 *dp, ui32 K_max, float delta_inv, ui32 count, ui32 *max_val)
void ojph_encode_codeblock(ui32 *buf, ui32 missing_msbs, ui32 num_passes, ui32 width, ui32 height, ui32 stride, ui32 *lengths, ojph::mem_elastic_allocator *elastic, ojph::coded_lists *&coded)
static void bb_expand_buf(bit_write_buf *bbp, mem_elastic_allocator *elastic, coded_lists *&cur_coded_list)
ui32 wasm_find_max_val(ui32 *address)
const char OJPH_PN_STRING_BROADCAST[]
const char OJPH_PN_STRING_IMF[]
@ X86_CPU_EXT_LEVEL_SSSE3
static si32 ojph_trunc(float val)
static ui32 count_leading_zeros(ui32 val)
#define OJPH_INT_TO_STRING(I)
#define ojph_div_ceil(a, b)
#define OJPH_ERROR(t,...)
#define OPENJPH_VERSION_PATCH
#define OPENJPH_VERSION_MAJOR
#define OPENJPH_VERSION_MINOR
void wrap(T *buffer, size_t num_ele, ui32 pre_size)
void check_validity(const param_cod &cod, const param_qcd &qcd)
void read(infile_base *file)
bool write(outfile_base *file)
void check_validity(const param_siz &siz)
bool write(outfile_base *file)
size get_log_block_dims() const
bool is_employing_color_transform() const
void read(infile_base *file)
size get_log_precinct_size(ui32 res_num) const
bool packets_use_eph() const
ui8 get_num_decompositions() const
bool packets_may_use_sop() const
bool is_reversible() const
void read(infile_base *file, ui32 num_comps)
ui32 get_Kmax(ui32 resolution, ui32 subband) const
void check_validity(const param_siz &siz, const param_cod &cod)
bool write(outfile_base *file)
void read(infile_base *file)
float irrev_get_delta(ui32 resolution, ui32 subband) const
void set_skipped_resolutions(ui32 skipped_resolutions)
ui32 get_bit_depth(ui32 comp_num) const
ui32 get_recon_height(ui32 comp_num) const
bool is_signed(ui32 comp_num) const
bool write(outfile_base *file)
ui16 get_num_components() const
ui32 get_height(ui32 comp_num) const
point get_downsampling(ui32 comp_num) const
void read(infile_base *file)
ui32 get_width(ui32 comp_num) const
ui32 get_recon_width(ui32 comp_num) const
ui8 get_num_tile_parts() const
void init(ui32 payload_length=0, ui16 tile_idx=0, ui8 tile_part_index=0, ui8 num_tile_parts=0)
ui16 get_tile_index() const
bool read(infile_base *file, bool resilient)
ui8 get_tile_part_index() const
ui32 get_payload_length() const
bool write(outfile_base *file, ui32 payload_len)
void set_next_pair(ui16 Ttlm, ui32 Ptlm)
bool write(outfile_base *file)
void init(ui32 num_pairs, Ttlm_Ptlm_pair *store)
void write(outfile_base *file)
ui32 prepare_precinct(int tag_tree_size, ui32 *lev_idx, mem_elastic_allocator *elastic)
void parse(int tag_tree_size, ui32 *lev_idx, mem_elastic_allocator *elastic, ui32 &data_left, infile_base *file, bool skipped)
ui8 * get(ui32 x, ui32 y, ui32 lev)
void init(ui8 *buf, ui32 *lev_idx, ui32 num_levels, size s, int init_val)