Broken (Re: [OpenJPEG] Error decoding JP2 files)

86 views
Skip to first unread message

Mathieu Malaterre

unread,
Apr 23, 2012, 10:28:54 AM4/23/12
to open...@googlegroups.com
Winfried,

Your patch make an old test fails:

http://my.cdash.org/viewTest.php?onlydelta&buildid=325015

Do you have time to check the error today ? I'll have to revert
r1642 otherwise

Thanks much !

On Sat, Mar 17, 2012 at 10:29 PM, <szuk...@arcor.de> wrote:
> Here is a second patch. Quiet, but expensive.
>
> winfried
>
> --
> You are subscribed to the mailing-list of the OpenJPEG project (www.openjpeg.org)
> To post: email to open...@googlegroups.com
> To unsubscribe: email to openjpeg+u...@googlegroups.com
> For more options: visit http://groups.google.com/group/openjpeg
> For more info about OpenJPEG main partners : visit  www.tele.ucl.ac.be (UCL) and www.intopix.com

--
Mathieu

szuk...@arcor.de

unread,
Apr 23, 2012, 3:52:28 PM4/23/12
to open...@googlegroups.com
TEST: 251 - NR-DEC-illegalcolortransform.j2k-14-decode (Failed)
FILE: data/input/nonregression/illegalcolortransform.j2k
LIB : openjpeg-branch15-r1648

Mathieu,

I suppose you mean the second part of the patch, here marked
with line 1885:

===========================
./j2k_to_image -i /tmp/illegalcolortransform.j2k -o illegalcolortransform-j2k.png

[WARNING] j2k.c:1885:001c4a80: expected a marker instead of d900
[INFO] tile 1 of 1
[INFO] - tiers-1 took 1.191819 s
[INFO] - dwt took 0.116982 s
[WARNING] Number of components (1) is inconsistent with a MCT. Skip the MCT step.
[INFO] - tile decoded in 1.338796 s
Successfully generated Outfile illegalcolortransform-j2k.png
===========================

Without the second part of the patch I get:

===========================
./j2k_to_image -i /tmp/illegalcolortransform.j2k -o illegalcolortransform-j2k.png

[ERROR] 001c4a80: unexpected marker d900
ERROR -> j2k_to_image: failed to decode image!
===========================

The first part of the patch is skipped:

===========================
./j2k_to_image -i /tmp/illegalcolortransform.j2k -o illegalcolortransform-j2k.png

j2k.c:1486: s(0x7effc609d080) + len(1853968) ==> e(0x7effc6261a90)
truncate(0)
e[-2]84 e[-1]ff

[WARNING] 001c4a80: expected a marker instead of d900
[INFO] tile 1 of 1
[INFO] - tiers-1 took 1.174821 s
[INFO] - dwt took 0.114982 s
[WARNING] Number of components (1) is inconsistent with a MCT. Skip the MCT step.
[INFO] - tile decoded in 1.319799 s

Successfully generated Outfile illegalcolortransform-j2k.png
===========================

By the way: the first part of the patch is clumsy. See below.

winfried

--- openjpeg-branch15-r1648/libopenjpeg/j2k.c.orig 2012-04-23 20:35:43.091158832 +0200
+++ openjpeg-branch15-r1648/libopenjpeg/j2k.c 2012-04-23 21:37:58.343244927 +0200
@@ -1477,23 +1477,21 @@
truncate = 1; /* Case of a truncate codestream */
}

- {
+ {/* chop padding bytes: */
unsigned char *s, *e;
- int skipped = 0;

s = cio_getbp(cio);
e = s + len;

- if((unsigned int)(e - s) > 8) s = e - 8;
+ if(len > 8) s = e - 8;

- if(e[-2] == 0x00 && e[-1] == 0x00)
+ if(e[-2] == 0x00 && e[-1] == 0x00) /* padding bytes */
{
while(e > s)
{
if(e[-2] == 0xff && e[-1] == 0xd9) break;
- --len; --e; ++skipped;
+ --len; --e; truncate = 1;
}
- if(skipped) truncate = 1;
}
}

szuk...@arcor.de

unread,
Apr 23, 2012, 4:59:28 PM4/23/12
to open...@googlegroups.com
Mathieu,

the test file 'data/input/nonregression/file409752.jp2'
has 5 padding bytes:

#define J2K_MS_EOC 0xffd9

ff, d9, 00, 00, 00, 00, 00

Using the patched j2k.c :

========================
./j2k_to_image -i /tmp/file409752.jp2 -o file409752-jp2.png

j2k.c:1486: s(0x13cb319) + len(7765) ==> e(0x13cd16e)
truncate(0)

FIRST:e[-2]00 e[-1]00
FINAL:e[-2]ff e[-1]d9

[INFO] tile 1 of 1

[INFO] - tiers-1 took 0.017997 s
[INFO] - dwt took 0.011998 s
[INFO] - tile decoded in 0.035995 s
Successfully generated Outfile file409752-jp2.png
========================

Without the patch, e.g. in r1563:

========================
./j2k_to_image -i /tmp/file409752.jp2 -o file409752-jp2.png

[ERROR] 00001f1e: expected a marker instead of 0
[ERROR] Failed to decode J2K image


ERROR -> j2k_to_image: failed to decode image!
========================

winfried

szuk...@arcor.de

unread,
Apr 23, 2012, 5:11:22 PM4/23/12
to open...@googlegroups.com
Mathieu,

test file 'data/input/nonregression/file409752.jp2'
has 5 padding bytes, as I showed. Here is the result
of EXPERIMENTAL:

Start 300: NR-DEC-file409752.jp2-31-decode
300/304 Test #300: NR-DEC-file409752.jp2-31-decode ...................................... Passed 0.02 sec
Start 301: NR-DEC-file409752.jp2-31-dump
301/304 Test #301: NR-DEC-file409752.jp2-31-dump ........................................ Passed 0.01 sec
Start 302: NR-DEC-file409752.jp2-31-compare_dump2base
302/304 Test #302: NR-DEC-file409752.jp2-31-compare_dump2base ........................... Passed 0.00 sec

winfried

Mathieu Malaterre

unread,
May 29, 2012, 12:22:15 PM5/29/12
to open...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages