reehan79 / openjpeg

Automatically exported from code.google.com/p/openjpeg
0 stars 0 forks source link

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

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
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. 

Original issue reported on code.google.com by boxe...@gmail.com on 26 Nov 2014 at 4:09

Attachments:

GoogleCodeExporter commented 9 years ago
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.

Original comment by boxe...@gmail.com on 30 Nov 2014 at 1:40

GoogleCodeExporter commented 9 years ago
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.

Original comment by m.darb...@gmail.com on 12 Dec 2014 at 8:43

GoogleCodeExporter commented 9 years ago
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

Original comment by m.darb...@gmail.com on 12 Dec 2014 at 9:09

GoogleCodeExporter commented 9 years ago
This issue was closed by revision r2955.

Original comment by m.darb...@gmail.com on 12 Dec 2014 at 9:54