Account Options

  1. Sign in
The old Google Groups will be going away soon.
Switch to the new Google Groups.
Google Groups Home
« Groups Home
opj_encode with tcp broken
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
RobinC  
View profile  
 More options Aug 14 2009, 5:14 pm
From: RobinC <robin.cornel...@gmail.com>
Date: Fri, 14 Aug 2009 14:14:57 -0700 (PDT)
Local: Fri, Aug 14 2009 5:14 pm
Subject: Re: [OpenJPEG] Re: opj_encode with tcp broken
Trying to continue this thread, http://groups.google.com/group/openjpeg/browse_thread/thread/4683bba9...

but google will not let me. so heres a new one

I spent some time looking at this today, and got the following results
(v1.3 this is on)

Windows 32 bit does not have this problem
Linux 32 bit compiled with -O3 does have this problem
Linux 32 bit compiled with -O0 does not have this problem
Linux 64 bit has this problem

So its very arch/compiler specific, looking at the resulting files
between linux 32 bit -O3 and Linux 64 bit (by converting a 4 channel
tga to j2k and back) the results for the j2k stage were identical for
both fail situations. SO i brute forced it looking for differences in
the code at run time and hit a bunch of issues that all stemmed back
to mct.c, and in particular the arrays of size [3] being accessed by
mct_getnorm_real() and mct_getnorm()

This in turn is accessed by t1_getwmsedec(), now t1_getwmsedec() knows
which component we are on, so for a 4 channel image its calling the
mct_getnorm() with ordinals of 0,1,2,3 so its an array overrun. Now i
guess that windows and linux 32bit no opt are working because that
array overrun hits a non-zero memory location, on linux 64 bit and
optimised that location appears to be 0 which then cascades back
through the code multipling things by 0 and screwing the encode up.

So i quickly did this to test

--- openjpeg-1.3+dfsg.orig/libopenjpeg/mct.c
+++ openjpeg-1.3+dfsg/libopenjpeg/mct.c
@@ -34,12 +34,12 @@
 /* <summary> */
 /* This table contains the norms of the basis function of the
reversible MCT. */
 /* </summary> */
-static const double mct_norms[3] = { 1.732, .8292, .8292 };
+static const double mct_norms[5] = { 1.732, .8292, .8292, .8292 , .
8292   };

 /* <summary> */
 /* This table contains the norms of the basis function of the
irreversible MCT. */
 /* </summary> */
-static const double mct_norms_real[3] = { 1.732, 1.805, 1.573 };
+static const double mct_norms_real[5] = { 1.732, 1.805, 1.573 ,
1.573, 1.573};

 /* <summary> */
 /* Foward reversible MCT. */

and it works, i can encode and decode 4 channel images with out ending
up with a 50% alpha applied to the whole image.

Now the questions are, what is the *correct* implementation of a
solution?

Should the norms be defined for channels >0,1,2 should mct_getnorm_real
() just limit to a maximum ordinal of 2, or should t1_getwmsedec() or
further up the call stack know better and not actually expose
t1_getwmsedec()  to this situation in the first place?

Regards

robin


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
RobinC  
View profile  
 More options Aug 15 2009, 7:23 pm
From: RobinC <robin.cornel...@gmail.com>
Date: Sat, 15 Aug 2009 16:23:04 -0700 (PDT)
Local: Sat, Aug 15 2009 7:23 pm
Subject: Re: opj_encode with tcp broken

Ok so to save me looking like a _complete_ fool i did some further
research, and now i understand what the MCT is doing...

Turns out the MCT transform is only valid for 3 component images.
Openjpeg 1.3 blindly ignores this, v2.0 in the codecs check the number
of channels and use this to disable the MCT (although looks like the
lib itself supports more complex things via custom tables). So the fix
for 1.3 is to check the number of components and if !=3 i believe all
you need to do is to return 1.0 for w1 in t1_getwmsedec()

Robin


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Antonin Descampe  
View profile  
 More options Nov 6 2009, 7:53 am
From: Antonin Descampe <antonin.desca...@uclouvain.be>
Date: Fri, 6 Nov 2009 13:53:50 +0100
Local: Fri, Nov 6 2009 7:53 am
Subject: Re: [OpenJPEG] Re: opj_encode with tcp broken

Hi Robin,

You're completely right. The MCT is only valid for 3 components  
images. And even more, the transformation has been designed for RGB  
components. There was a unstatisfying test in t1_getwmsedec as the  
number of components was only checked in order to know if it was  
greater than 1.

The mct_getnorm should actually be called only if the MCT has been  
applied. I changed this with a double check : (i) tcp->mct should be  
set to 1, (ii) the number of components should be exactly 3.

Could you check if it correctly solve the issue on your 4-components  
images ?

Cheers,

Antonin

Le 16 août 2009 à 01:23, RobinC a écrit :


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Galfar  
View profile  
 More options Dec 24 2009, 3:32 pm
From: Galfar <marekmau...@gmail.com>
Date: Thu, 24 Dec 2009 12:32:20 -0800 (PST)
Local: Thurs, Dec 24 2009 3:32 pm
Subject: Re: opj_encode with tcp broken
Hi,
I can confirm that 4-component images are working correctly
with the new check in 1_getwmsedec.

However, I was wondering if it would be possible to use MCT
(it's some sort of RGB -> YCC conversion right?)
on images with more than 3 components: for RGB components use MCT
and leave additional components alone?

Something like:
w1 = (mct && numcomps >=3 && compno < 3) ? mct_getnorm_real(compno) :
1.0;
Or is it more complicated?

Marek

On Nov 6, 1:53 pm, Antonin Descampe <antonin.desca...@uclouvain.be>
wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »