From 324d0241f7fe082ca4a6d2bd9deeebbe7654e6fd Mon Sep 17 00:00:00 2001 From: Even Rouault Date: Wed, 23 Oct 2019 15:22:40 +0200 Subject: [PATCH] JPEG: fix further calls to RasterIO after reading full image at full resolution (fixes #1947) --- autotest/gdrivers/jpeg.py | 8 ++++++++ gdal/frmts/jpeg/jpgdataset.cpp | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/autotest/gdrivers/jpeg.py b/autotest/gdrivers/jpeg.py index dbcb4b845230..d749d8a3cc2c 100755 --- a/autotest/gdrivers/jpeg.py +++ b/autotest/gdrivers/jpeg.py @@ -796,8 +796,15 @@ def test_jpeg_23(): assert cs == got_cs # Pixel interleaved + ds = gdal.Open('data/albania.jpg') data = ds.ReadRaster(0, 0, ds.RasterXSize, ds.RasterYSize, buf_pixel_space=3, buf_band_space=1) + y = int(ds.RasterYSize/2) + data_bottom = ds.ReadRaster(0, y, ds.RasterXSize, ds.RasterYSize - y, + buf_pixel_space=3, buf_band_space=1) + data_top = ds.ReadRaster(0, 0, ds.RasterXSize, y, + buf_pixel_space=3, buf_band_space=1) + assert data == data_top + data_bottom tmp_ds = gdal.GetDriverByName('Mem').Create( '', ds.RasterXSize, ds.RasterYSize, 3) tmp_ds.WriteRaster(0, 0, ds.RasterXSize, ds.RasterYSize, data, @@ -806,6 +813,7 @@ def test_jpeg_23(): assert cs == got_cs # Pixel interleaved with padding + ds = gdal.Open('data/albania.jpg') data = ds.ReadRaster(0, 0, ds.RasterXSize, ds.RasterYSize, buf_pixel_space=4, buf_band_space=1) tmp_ds = gdal.GetDriverByName('Mem').Create( diff --git a/gdal/frmts/jpeg/jpgdataset.cpp b/gdal/frmts/jpeg/jpgdataset.cpp index 0db43d794e34..735fc29d8bbd 100644 --- a/gdal/frmts/jpeg/jpgdataset.cpp +++ b/gdal/frmts/jpeg/jpgdataset.cpp @@ -1869,7 +1869,7 @@ CPLErr JPGDatasetCommon::IRasterIO( GDALRWFlag eRWFlag, } } } - nLoadedScanline = -1; + nLoadedScanline = nRasterYSize; } else {