Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce encoder code block memory usage for non 64x64 code block sizes #444

Closed
gcode-importer opened this issue Nov 26, 2014 · 4 comments
Closed
Assignees

Comments

@gcode-importer
Copy link

Originally reported on Google Code with ID 444

Currently, all encoder code blocks allocate 8192*2 bytes, which is equivalent to 64
x 64 x sizeof(OPJ_UINT32)  bytes. i.e. it covers the worst case scenario (no compression)
on a 64x64 size code block.

For DCP encoding, for example, which mandates 32x32 code blocks, this uses 4 times
the worst-case memory needed.  

I have attached a simple fix: use the code block dimensions to decide
how much memory to allocate. 



Reported by boxerab on 2014-11-26 04:09:17


- _Attachment: [reduce_encode_codeblock_memory.diff](https://storage.googleapis.com/google-code-attachments/openjpeg/issue-444/comment-0/reduce_encode_codeblock_memory.diff)_
@gcode-importer
Copy link
Author

For this fix, it may be good to add some sanity checks on the code block dimensions.
I have not done so in this patch.

Reported by boxerab on 2014-11-30 01:40:53

@gcode-importer
Copy link
Author

Aaron,

I think that sanity checks shall be implemented. However, given that this is a coder
patch, they should probably be elsewhere (like parameter validation). This might (should)
already be the case.

Your patch does not take into account different sizes of block per tile/component &
I'll add that.

Reported by mayeut on 2014-12-12 20:43:48

  • Status changed: Started

@gcode-importer
Copy link
Author

On ElephantDream_4K.tif from the test suite encoded to j2k with -cinema4k option,

Before patch
Bytes Used  Count  Name
 696.65 MB  99.9%  main
 544.94 MB  78.2%    opj_j2k_encode
 542.39 MB  77.8%      opj_tcd_init_tile
 412.33 MB  59.1%        malloc
 128.32 MB  18.4%        calloc
   1.73 MB   0.2%        opj_tgt_create
   2.56 MB   0.3%      opj_j2k_post_write_tile
 101.33 MB  14.5%    tiftoimage
  49.36 MB   7.0%    opj_j2k_start_compress
   1.00 MB   0.1%    opj_stream_create_file_stream
   9.62 KB   0.0%    opj_setup_encoder
   1.62 KB   0.0%    opj_create_compress

After patch
Bytes Used  Count  Name
 387.31 MB  99.9%  main
 235.60 MB  60.8%    opj_j2k_encode
 233.05 MB  60.1%      opj_tcd_init_tile
 128.32 MB  33.1%        calloc
 102.99 MB  26.5%        malloc
   1.73 MB   0.4%        opj_tgt_create
   2.56 MB   0.6%      opj_j2k_post_write_tile
 101.33 MB  26.1%    tiftoimage
  49.36 MB  12.7%    opj_j2k_start_compress
   1.00 MB   0.2%    opj_stream_create_file_stream
   9.62 KB   0.0%    opj_setup_encoder
   1.62 KB   0.0%    opj_create_compress



Reported by mayeut on 2014-12-12 21:09:33

@gcode-importer
Copy link
Author

This issue was closed by revision r2955.

Reported by mayeut on 2014-12-12 21:54:25

  • Status changed: Fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant