[Gdal-dev] strange problem with ECW ( performance and quality) when getting the scanlines from SizeY-1 to 0 instead of from 0 to SizeY-1

Frank Warmerdam warmerdam at pobox.com
Wed Oct 20 14:45:11 EDT 2004


Stephane Routelous wrote:
> Hi,
> 
> I faced a real strange problem with ecw.
> You can reproduce it with gdal_translate modifying the code of
> gdaldriver.cpp
> I'm using GDAL 1.2.3.0, released 2004/08/25
> 
> First, get the testdata image from ERMapper (Greyscale.ecw)
> 
> 1/ run gdal_translate.exe GreyScale.ecw output1.bmp -of BMP
> 
> 2/ modify the code in gdaldriver.cpp line 333 (in the CreateCopy method)
> from 	for( int iLine = 0; iLine < nYSize; iLine++ )
> to	for( int iLine = nYSize-1; iLine >=0 ; iLine-- )
> 
> 3/ recompile gdal
> 
> 4/ run gdal_translate.exe GreyScale.ecw output2.bmp -of BMP
> 
> the second version is *a lot* slower, and the result is quite strange.

Stephane,

I don't know why the results are visually different.  I would guess this is a
problem the low level ECW SDK but we are calling it in a very peculiar way in
the 2nd case.

The reason things are much slower is that the ECW driver tries to guess
what you are going to want to read.  Within the GDAL ECW code, it needs to set
a "view window" on the ECW file.  This is a fairly expensive operation, so if
the application is asking for data one scanline at a time it is important that
we not set a one scanline view window each time.  So the code guesses that if
you are accessing one scanline that it should setup a view window that starts
at the requested scanline and continues down the image to the bottom at the
same resolution.  If your next request is for the next scanline it can just
get it from the ECW SDK.  If it is very different it will need to set a new
view window.

In the case of your altered code, each scanline requested results in a new
view being set (starting one line sooner), so it is very slow.

But this still doesn't explain the streakiness unless it is the nature of the
ECW decoder to experience mild artifacts at view window boundaries.

Best regards,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | Geospatial Programmer for Rent




More information about the Gdal-dev mailing list