39 #include <emscripten.h>
67 catch (
const std::exception& e)
69 const char *p = e.what();
70 if (strncmp(p,
"ojph error", 10) != 0)
82 catch (
const std::exception& e)
84 const char *p = e.what();
85 if (strncmp(p,
"ojph error", 10) != 0)
107 catch (
const std::exception& e)
109 const char *p = e.what();
110 if (strncmp(p,
"ojph error", 10) != 0)
118 int skipped_res_for_read,
119 int skipped_res_for_recon)
122 skipped_res_for_recon);
220 int skipped_res_for_read,
221 int skipped_res_for_recon)
224 skipped_res_for_recon);
251 int main(
int argc,
const char* argv[])
253 const char filename[] =
"test.j2c";
254 FILE *f = fopen(filename,
"rb");
255 fseek(f, 0, SEEK_END);
256 long int size = ftell(f);
258 fseek(f, 0, SEEK_SET);
259 fread(compressed_data, 1, size, f);
267 printf(
"width = %d, height = %d\n", width, height);
271 decode_j2c_data(j2c);
273 for (
int y = 0; y < height; ++y)
275 for (
int c = 0; c < num_components; ++c)
278 ojph::ui8* dp = buf + c + y * width * num_components;
279 for (
int x = 0; x < width; ++x, dp+=num_components)
282 val = val >= 0 ? val : 0;
283 val = val <= max_val ? val : max_val;
290 f = fopen(
"test_out.ppm",
"wb");
291 if (num_components == 1)
292 fprintf(f,
"P5 %d %d %d\n", width, height, max_val);
294 fprintf(f,
"P6 %d %d %d\n", width, height, max_val);
295 fwrite(buf, width * height * num_components, 1, f);
int main(int argc, char *argv[])
OJPH_EXPORT param_siz access_siz()
OJPH_EXPORT void restrict_input_resolution(ui32 skipped_res_for_data, ui32 skipped_res_for_recon)
OJPH_EXPORT void set_planar(bool planar)
OJPH_EXPORT void enable_resilience()
OJPH_EXPORT void read_headers(infile_base *file)
OJPH_EXPORT void create()
OJPH_EXPORT line_buf * pull(ui32 &comp_num)
OJPH_EXPORT void open(const ui8 *data, size_t size)
OJPH_EXPORT ui32 get_bit_depth(ui32 comp_num) const
OJPH_EXPORT ui32 get_recon_height(ui32 comp_num) const
OJPH_EXPORT point get_downsampling(ui32 comp_num) const
OJPH_EXPORT ui32 get_recon_width(ui32 comp_num) const
OJPH_EXPORT bool is_signed(ui32 comp_num) const
OJPH_EXPORT ui32 get_num_components() const
j2k_struct * cpp_create_j2c_data(void)
EMSCRIPTEN_KEEPALIVE int get_j2c_num_components(j2k_struct *j2c)
EMSCRIPTEN_KEEPALIVE int get_j2c_downsampling_y(j2k_struct *j2c, int comp_num)
EMSCRIPTEN_KEEPALIVE void parse_j2c_data(j2k_struct *j2c)
EMSCRIPTEN_KEEPALIVE void enable_resilience(j2k_struct *j2c)
EMSCRIPTEN_KEEPALIVE signed int * pull_j2c_line(j2k_struct *j2c)
EMSCRIPTEN_KEEPALIVE void release_j2c_data(j2k_struct *j2c)
EMSCRIPTEN_KEEPALIVE int get_j2c_height(j2k_struct *j2c, int comp_num)
signed int * cpp_pull_j2c_line(j2k_struct *j2c)
EMSCRIPTEN_KEEPALIVE void init_j2c_data(j2k_struct *j2c, const uint8_t *data, size_t size)
void cpp_parse_j2c_data(j2k_struct *j2c)
void cpp_init_j2c_data(j2k_struct *j2c, const uint8_t *data, size_t size)
void cpp_restrict_input_resolution(j2k_struct *j2c, int skipped_res_for_read, int skipped_res_for_recon)
EMSCRIPTEN_KEEPALIVE j2k_struct * create_j2c_data(void)
EMSCRIPTEN_KEEPALIVE int get_j2c_is_signed(j2k_struct *j2c, int comp_num)
EMSCRIPTEN_KEEPALIVE int get_j2c_downsampling_x(j2k_struct *j2c, int comp_num)
EMSCRIPTEN_KEEPALIVE int get_j2c_bit_depth(j2k_struct *j2c, int comp_num)
EMSCRIPTEN_KEEPALIVE int get_j2c_width(j2k_struct *j2c, int comp_num)
EMSCRIPTEN_KEEPALIVE void restrict_input_resolution(j2k_struct *j2c, int skipped_res_for_read, int skipped_res_for_recon)
void cpp_release_j2c_data(j2k_struct *j2c)
ojph::mem_infile mem_file
ojph::codestream codestream