JP2 file signature

482 views
Skip to first unread message

Srividya

unread,
Feb 8, 2012, 10:45:28 PM2/8/12
to OpenJPEG
Hi,

The file signature of a JP2 file is described as
00 00 00 0C 6A 50 20 20 0D 0A 87 0A. There is a check in this regards
in jp2.c also.

But for a lot of jp2 files, I observed that the first 12 bytes are
00 00 00 0C 6A 50 20 20 0A 87 0A 00. There is a discrepancy in the 9th
byte. Because of this, while trying to decode a JP2 file, I get an
error "Error with JP Marker". Why is this so? Am I missing something?

Thanks in advance for your help.

Regards,
Srividya

szuk...@arcor.de

unread,
Feb 10, 2012, 6:42:32 AM2/10/12
to open...@googlegroups.com
---
ISO/IEC 15444-1:2002:

The type of the JPEG 2000 Signature box shall be
'jP\040\040' (0x6A50 2020).

The length of this box shall be 12 bytes.

The contents of this box shall be the 4-byte
character string '<CR><LF><0x87><LF>' (0x0D0A 870A).


For file verification purposes, this box can be
considered a fixed-length 12-byte string which
shall have the value:
0x0000 000C 6A50 2020 0D0A 870A.
---

Can you send such a file you have found?

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
>

Tim Mattox

unread,
Feb 10, 2012, 9:48:34 AM2/10/12
to open...@googlegroups.com
This looks like the jp2 file was passed through a dos2unix text converter,
and the <CR> was simply removed. My best guess is that the file is now
fully corrupted, especially if the binary data originally had <CR><LF> in it
anyplace else.
This JPEG2000 signature box was deliberately crafted this way to detect
such corruption by improper transmission/processing as a text file.

--
Tim Mattox, Ph.D. - http://homepage.mac.com/tmattox/ - tma...@gmail.com

Srividya Rajamani

unread,
Feb 12, 2012, 9:57:37 PM2/12/12
to open...@googlegroups.com
Hi,
 
Thanks for your response.
 
I am attaching a couple of jp2 files for which I face this issue.
 
Regards,
Srividya
test1.jp2
input.jp2

szuk...@arcor.de

unread,
Feb 12, 2012, 10:25:30 PM2/12/12
to open...@googlegroups.com
file input.jp2
input.jp2: JPEG 2000 image data

file test1.jp2
test1.jp2: JPEG 2000 image data

j2k_dump accepts both images

j2k_to_image accepts both images

winfried


----- Original Nachricht ----
From: Srividya Rajamani <srivi...@gmail.com>
To: open...@googlegroups.com
Date: 13.02.2012 03:57
Subject: Re: [OpenJPEG] JP2 file signature

Srividya Rajamani

unread,
Feb 12, 2012, 10:29:41 PM2/12/12
to open...@googlegroups.com
Hi,
 
Thanks for the quick response.
 
I notice this behavior on Windows when using vc++ compiler. Would this have to do with the issue?
Should something need to be done differently on windows?
 
Regards,
Srividya
 

Srividya Rajamani

unread,
Feb 12, 2012, 10:48:08 PM2/12/12
to open...@googlegroups.com
Hi,
 
I ask this because I notice the same issue on all jp2 files, even those that I downloaded from the openJPEG samples link. (Cevennes2.jp2).
 
So, this does not seem to be an issue with jp2 files itself but with the environment that I am using.
 
Regards,
Srividya

Srividya Rajamani

unread,
Feb 13, 2012, 1:40:33 AM2/13/12
to open...@googlegroups.com
Hi,
 
The problem was with the mode in which the file was opened. The code was written for Linux and hence the mode was omitted. (ios::binary).
 
std::ifstream is;
is.open( filename );
 
Since the mode was not specified, on windows, it was being opened as a text file and hence the problem.
 
Your replies helped me figure out the problem.
Thanks for your help.
 
Regards,
Srividya

Antonin Descampe

unread,
Feb 13, 2012, 5:35:45 AM2/13/12
to open...@googlegroups.com
Hi,

If you fixed sth in the code to open JP2 files on windows, could you
send a patch to fix it on the SVN ?

Many thanks,

Antonin

On 02/13/2012 07:40 AM, Srividya Rajamani wrote:
> Since the mode was not specified, on windows, it was being opened as a
> text file and hence the problem.

--
Antonin Descampe
www.openjpeg.org

Srividya Rajamani

unread,
Feb 13, 2012, 9:57:47 PM2/13/12
to open...@googlegroups.com
Hi,

The change needed was not in openJPEG code. It was in one of the gdcm application code.

Regards,
Srividya

--
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+unsubscribe@googlegroups.com
Reply all
Reply to author
Forward
0 new messages