ylb11 / openjpeg

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

OpenJPEG does not allow streaming neither in resolution nor in quality #376

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
As title says. OpenJPEG 2.1.0 currently does not allow one to read partially a 
JP2 file neither by resolution nor by quality.

Original issue reported on code.google.com by mathieu.malaterre on 15 Jul 2014 at 11:05

GoogleCodeExporter commented 9 years ago
Resolution access is typically:

$ kdu_compress -i data/input/nonregression/Bretagne2.ppm  Clayers=12 Clevels=5 
Corder=RPCL -o /tmp/bret.jp2
$./bin/opj_decompress -i /tmp/bret.jp2 -o /tmp/bret.jp2.tif -r 4 -l 1

Original comment by mathieu.malaterre on 15 Jul 2014 at 11:06

GoogleCodeExporter commented 9 years ago
Quality access is typically:

$ kdu_compress -i  svn/data/input/nonregression/Bretagne2.ppm Clayers=12 
Clevels=5 Corder=LRCP -o /tmp/bret.jp2 Creversible=yes

Which we checked with:

$ kdu_expand -layers 1 -i /tmp/bret.jp2 -o /tmp/bret.jp2.kdu.tif

Consumed 1 tile-part(s) from a total of 1 tile(s).
Consumed 192,143 codestream bytes (excluding any file format) = 0.305059
bits/pel.
Processed using the multi-threaded environment, with
    8 parallel threads of execution

But:

$ ./bin/opj_decompress -i  /tmp/bret.jp2 -o /tmp/bret.jp2.tif -l 1
fread: 1048576 1048576
[INFO] Start to read j2k main header (85).
[INFO] Main header has been correctly decoded.
[INFO] No decoded area parameters, set the decoded area to the whole image
fread: 4186164 4186164
[INFO] Header of tile 0 / 0 has been read.
fread: 1048576 2
[INFO] Tile 1/1 has been decoded.
[INFO] Image data has been updated with tile 1.

fread: 1048576 0
[INFO] Stream reached its end !
[INFO] Generated Outfile /tmp/bret.jp2.tif

where:

$ svn di ..
Index: ../src/lib/openjp2/openjpeg.c
===================================================================
--- ../src/lib/openjp2/openjpeg.c (revision 2874)
+++ ../src/lib/openjp2/openjpeg.c (working copy)
@@ -91,6 +91,7 @@
 static OPJ_SIZE_T opj_read_from_file (void * p_buffer, OPJ_SIZE_T
p_nb_bytes, FILE * p_file)
 {
  OPJ_SIZE_T l_nb_read = fread(p_buffer,1,p_nb_bytes,p_file);
+  printf( "fread: %d %d\n", p_nb_bytes, l_nb_read );
  return l_nb_read ? l_nb_read : (OPJ_SIZE_T)-1;
 }

Original comment by mathieu.malaterre on 15 Jul 2014 at 11:07

GoogleCodeExporter commented 9 years ago
Feel free to split the bug into two part (resolution & quality) if needed.

Original comment by mathieu.malaterre on 15 Jul 2014 at 11:08

GoogleCodeExporter commented 9 years ago

Original comment by antonin on 16 Jul 2014 at 9:07