Changeset 13659

Show
Ignore:
Timestamp:
02/01/08 16:53:51 (3 months ago)
Author:
warmerdam
Message:

Modified so that the RGBA interface is not used for YCbCr mode JPEG
compressed data. Set JPEGCOLORMODE to RGB at the point a directory is read
to avoid error report if doing it later during writing. This fixes the GDAL
1.5.0 issues with writing YCbCr JPEG compressed data. Also includes a patch
in libtiff/tif_jpeg.c to avoid subsamplingfixup if no data written yet.(#2189)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1.5/gdal/frmts/gtiff/geotiff.cpp

    r13409 r13659  
    19001900    if( nLoadedBlock == nBlockId ) 
    19011901        return CE_None; 
    1902  
    1903 /* -------------------------------------------------------------------- */ 
    1904 /*      This is rather overkill, but relatively harmless so we do it    */ 
    1905 /*      here to be sure.                                                */ 
    1906 /* -------------------------------------------------------------------- */ 
    1907     if( nCompression == COMPRESSION_JPEG  
    1908         && nPhotometric == PHOTOMETRIC_YCBCR  
    1909         && CSLTestBoolean( CPLGetConfigOption("CONVERT_YCBCR_TO_RGB", 
    1910                                               "YES") ) ) 
    1911     { 
    1912         TIFFSetField(hTIFF, TIFFTAG_JPEGCOLORMODE, JPEGCOLORMODE_RGB); 
    1913     } 
    19141902 
    19151903/* -------------------------------------------------------------------- */ 
     
    31013089        nPhotometric == PHOTOMETRIC_LOGLUV || 
    31023090        ( nPhotometric == PHOTOMETRIC_YCBCR  
    3103           && CSLTestBoolean( CPLGetConfigOption("CONVERT_YCBCR_TO_RGB", 
    3104                                                 "YES") ))  ) 
     3091          && nCompression != COMPRESSION_JPEG ) ) 
    31053092    { 
    31063093        char    szMessage[1024]; 
     
    31173104    } 
    31183105         
     3106/* -------------------------------------------------------------------- */ 
     3107/*      YCbCr JPEG compressed images should be translated on the fly    */ 
     3108/*      to RGB by libtiff/libjpeg unless specifically requested         */ 
     3109/*      otherwise.                                                      */ 
     3110/* -------------------------------------------------------------------- */ 
     3111    if( nCompression == COMPRESSION_JPEG  
     3112        && nPhotometric == PHOTOMETRIC_YCBCR  
     3113        && CSLTestBoolean( CPLGetConfigOption("CONVERT_YCBCR_TO_RGB", 
     3114                                              "YES") ) ) 
     3115    { 
     3116        TIFFSetField(hTIFF, TIFFTAG_JPEGCOLORMODE, JPEGCOLORMODE_RGB); 
     3117    } 
     3118 
    31193119/* -------------------------------------------------------------------- */ 
    31203120/*      Should we treat this via the odd bits interface?                */ 
  • branches/1.5/gdal/frmts/gtiff/libtiff/tif_jpeg.c

    r13310 r13659  
    1 /* $Id: tif_jpeg.c,v 1.75 2007/12/10 19:58:41 fwarmerdam Exp $ */ 
     1/* $Id: tif_jpeg.c,v 1.76 2008/02/01 21:50:24 fwarmerdam Exp $ */ 
    22 
    33/* 
     
    682682        static const char module[] = "JPEGFixupTagsSubsampling"; 
    683683        struct JPEGFixupTagsSubsamplingData m; 
     684 
     685        if( tif->tif_dir.td_stripbytecount == NULL 
     686            || tif->tif_dir.td_stripbytecount[0] == 0 ) 
     687        { 
     688            /* Do not even try to check if the first strip/tile does not 
     689               yet exist, as occurs when GDAL has created a new NULL file 
     690               for instance. */ 
     691            return; 
     692        } 
     693 
    684694        m.tif=tif; 
    685695        m.buffersize=2048;