Opened 17 years ago
Closed 17 years ago
#1798 closed enhancement (fixed)
Improve jpeg dataset opening
Reported by: | Even Rouault | Owned by: | warmerdam |
---|---|---|---|
Priority: | normal | Milestone: | 1.5.0 |
Component: | GDAL_Raster | Version: | unspecified |
Severity: | normal | Keywords: | jpeg |
Cc: |
Description
To keep track on the "gdal fails on vrt (virtual raster) file" discussion on gdal dev list :
About the speed issue, in fact, jpeglib.h is very clear : /* Basic description of image --- filled in by jpeg_read_header(). */ /* Application may inspect these values to decide how to process image. */ JDIMENSION image_width; /* nominal image width (from SOF marker) */ JDIMENSION image_height; /* nominal image height */ int num_components; /* # of color components in JPEG image */ J_COLOR_SPACE jpeg_color_space; /* colorspace of JPEG image */ And we are lucky there, since these are just the values we need for JPGDataset::Open ! So, we can defer the call to jpeg_start_decompress to the first call to JPGDataset::LoadScanline. See the following patch : Index: frmts/jpeg/jpgdataset.cpp =================================================================== --- frmts/jpeg/jpgdataset.cpp (révision 12079) +++ frmts/jpeg/jpgdataset.cpp (copie de travail) @@ -87,6 +87,7 @@ int bSwabflag; int nTiffDirStart; int nTIFFHEADER; + int bHasDoneJpegStartDecompress; CPLErr LoadScanline(int); void Restart(); @@ -807,6 +808,7 @@ adfGeoTransform[3] = 0.0; adfGeoTransform[4] = 0.0; adfGeoTransform[5] = 1.0; + bHasDoneJpegStartDecompress = FALSE; poMaskBand = NULL; pabyBitMask = NULL; @@ -849,6 +851,12 @@ if( nLoadedScanline == iLine ) return CE_None; + if (!bHasDoneJpegStartDecompress) + { + jpeg_start_decompress( &sDInfo ); + bHasDoneJpegStartDecompress = TRUE; + } + if( pabyScanline == NULL ) pabyScanline = (GByte *) CPLMalloc(GetRasterCount() * GetRasterXSize() * 2); @@ -1391,8 +1399,6 @@ return NULL; } - jpeg_start_decompress( &(poDS->sDInfo) ); - /* -------------------------------------------------------------------- */ /* Capture some information from the file that is of interest. */ /* -------------------------------------------------------------------- */ It seems to work. gdalinfo is much faster on big jpeg files and openev still works.
Change History (2)
comment:1 by , 17 years ago
comment:2 by , 17 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
Commited in trunk in r12080