[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: FW: JJ2000 bug fix in entropy decoder



Richard,

Thanks for the heads up for the JJ2000 fix. I know you included test data but can you tell me which Grib2 files I can use as a test case so i can include it in my grib2 testsuite.

Thanks again,
Robb...





On Thu, 4 Sep 2008, Peter, Richard J CTR USAF AFWA AFWA/WDAC wrote:

Hi Robb,



  I received your contact from Steve Naples.  Below is a fix for
JJ2000's entropy decoder that is required for Grib2 decoding.  The
standard JJ2000 implementation has errors on single bit depth images
that for the case of landSea mask drop a portion of Canada into the
ocean.  All single bit-depth Grib2 records have problems when decoded.
I have tried to feed the change back to the community, but thought you
might appreciate the info so it could incorporated in a more timely
manner to your converter.





Richard Peter

Sr. Software Engineer

Raytheon - WDAC Project

DSN: 271-9843

Comm: (402) 294-9843



-----Original Message-----
From: Peter, Richard J CTR USAF AFWA AFWA/WDAC
Sent: Thursday, September 04, 2008 11:36 AM
To: 'address@hidden'
Subject: JJ2000 bug fix in entropy decoder



I'm trying to feed back a bug fix for JJ2000.  If I have the wrong
contact please let me know.  I have a JPEG2000 Codestream that was not
being properly decoded.  I found the error in the
jj2000.j2k.entropy.decoder.StdEntropyDecoder.java.







I have attached the codestream in question.  It is a simple land/sea bit
mask.  Using JJ2000 and an image viewer that can shift the image levels
so that 0 is black and 1 is white, a good portion of Canada is dropped
into the ocean.  The below change fixes the problem.











Details of fix:



jj2000.j2k.entropy.decoder.StdEntropyDecoder.java



line 1990: setmask = (3<<bp)>>1;







Needs to be



int one = (1<<bp);



int half = (one>>1);



setmask = one | half;







Must be changed for the case of bp = 30.



bp=30 causes the 3 to be shifted into the msb and when shifted back
becomes



0xE000 when it should be 0x6000











Using unsigned bitshift would also fix case of bp=30, but not sure if
that would be the correct behavior



for bp = 31



setmask = (3<<bp)>>>1;















Richard Peter



Sr. Software Engineer



Raytheon - WDAC Project



DSN: 271-9843



Comm: (402) 294-9843









===============================================================================
Robb Kambic                                Unidata Program Center
Software Engineer III                      Univ. Corp for Atmospheric Research
address@hidden             WWW: http://www.unidata.ucar.edu/
===============================================================================