Skip to content

Commit 91b553a

Browse files
committed
Added TIFF codec version reporting in logfile and updated return signature for getCodecVersion() function.
Also code cleanups for OpenJPEGImage and KakaduImage classes.
1 parent cfad495 commit 91b553a

File tree

9 files changed

+43
-17
lines changed

9 files changed

+43
-17
lines changed

ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
24/09/2024:
2+
- Added TIFF codec version reporting in logfile and updated return signature for getCodecVersion() function.
3+
Also code cleanups for OpenJPEGImage and KakaduImage classes.
4+
5+
16
13/09/2024:
27
- Updated XYZ to sRGB conversion matrix to use that in the official IEC 61966-2-1 specification
38

src/IIPImage.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ class IIPImage {
468468

469469
/// Get codec version
470470
/** @return codec version */
471-
static const char* getCodecVersion(){ return "0.0.0"; };
471+
static std::string getCodecVersion(){ return "0.0.0"; };
472472

473473

474474
/// Comparison equality operator

src/JTL.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ void JTL::send( Session* session, int resolution, int tile ){
8383
#ifdef HAVE_WEBP
8484
else if( session->view->output_format == ImageEncoding::WEBP ) compressor = session->webp;
8585
#endif
86-
#ifdef HAVE_AVIF
86+
#ifdef HAVE_AVIF
8787
else if( session->view->output_format == ImageEncoding::AVIF ) compressor = session->avif;
8888
#endif
8989
else compressor = session->jpeg;

src/KakaduImage.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,9 +250,9 @@ void KakaduImage::loadImageInfo( int seq, int ang )
250250
logfile << "Kakadu :: Capture Resolution : " << dpi_x << "x" << dpi_y << " pixels/cm" << endl;
251251
#endif
252252

253-
// Loop through each resolution and calculate the image dimensions -
253+
// Loop through each resolution and calculate the image dimensions -
254254
// We calculate ourselves rather than relying on get_dims() to force a similar
255-
// behaviour to TIFF with resolutions at floor(x/2) rather than Kakadu's default ceil(x/2)
255+
// behaviour to TIFF with resolutions at floor(x/2) rather than Kakadu's default ceil(x/2)
256256
for( unsigned int c=1; c<numResolutions; c++ ){
257257
// codestream.apply_input_restrictions(0,0,c,1,NULL,KDU_WANT_OUTPUT_COMPONENTS);
258258
// kdu_dims layers;

src/KakaduImage.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
Culture of the Czech Republic.
1010
1111
12-
Copyright (C) 2009-2023 IIPImage.
12+
Copyright (C) 2009-2024 IIPImage.
1313
Author: Ruven Pillay
1414
1515
This program is free software; you can redistribute it and/or modify
@@ -139,7 +139,7 @@ class KakaduImage : public IIPImage {
139139

140140
/// Get codec version
141141
/** @return codec version */
142-
static const char* getCodecVersion(){ return kdu_get_core_version(); };
142+
static std::string getCodecVersion(){ return kdu_get_core_version(); };
143143

144144

145145
/// Overloaded function for opening a TIFF image

src/Main.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,7 @@ int main( int argc, char *argv[] )
424424
logfile << "Setting ICC profile embedding to " << (embed_icc? "true" : "false") << endl;
425425
logfile << "Setting codec passthrough to " << (IIPImage::codec_passthrough? "true" : "false") << endl;
426426
if( !copyright.empty() ) logfile << "Setting default rights/copyright statement to '" << copyright << "'" << endl;
427+
logfile << "Setting up TIFF support via " << TPTImage::getCodecVersion() << endl;
427428
#ifdef HAVE_KAKADU
428429
logfile << "Setting up JPEG2000 support via Kakadu SDK " << KakaduImage::getCodecVersion() << endl;
429430
logfile << "Setting Kakadu read-mode to " << ((kdu_readmode==2) ? "resilient" : (kdu_readmode==1) ? "fussy" : "fast") << endl;

src/OpenJPEGImage.cc

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -187,9 +187,9 @@ void OpenJPEGImage::loadImageInfo( int seq, int ang )
187187
logfile << "OpenJPEG :: Resolution : " << w << "x" << h << endl;
188188
#endif
189189

190-
// Loop through each resolution and calculate the image dimensions -
190+
// Loop through each resolution and calculate the image dimensions -
191191
// We force a similar behaviour to TIFF with resolutions at floor(x/2)
192-
// rather than OpenJPEG's default ceil(x/2)
192+
// rather than OpenJPEG's default ceil(x/2)
193193
for( unsigned int c=1; c<numResolutions; c++ ){
194194
w = floor( w/2.0 );
195195
h = floor( h/2.0 );
@@ -274,7 +274,7 @@ void OpenJPEGImage::loadImageInfo( int seq, int ang )
274274
if( bpc == 16 ) max.push_back( 65535.0 );
275275
else max.push_back( 255.0 );
276276
}
277-
277+
278278
// Indicate that our metadata has been read
279279
isSet = true;
280280

@@ -310,7 +310,7 @@ RawTile OpenJPEGImage::getTile( int seq, int ang, unsigned int res, int layers,
310310

311311
unsigned int tw = tile_widths[0];
312312
unsigned int th = tile_heights[0];
313-
313+
314314
// Get the width and height for last row and column tiles
315315
unsigned int rem_x = image_widths[vipsres] % tile_widths[0];
316316
unsigned int rem_y = image_heights[vipsres] % tile_heights[0];
@@ -339,7 +339,7 @@ RawTile OpenJPEGImage::getTile( int seq, int ang, unsigned int res, int layers,
339339
// Calculate the pixel offsets for this tile
340340
int xoffset = (tile % ntlx) * tile_widths[0];
341341
int yoffset = (unsigned int) floor((double)(tile/ntlx)) * tile_heights[0];
342-
342+
343343
#ifdef OPENJPEG_DEBUG
344344
logfile << "OpenJPEG :: Tile size: " << tw << "x" << th << " @" << channels << endl;
345345
#endif
@@ -372,7 +372,7 @@ RawTile OpenJPEGImage::getRegion( int ha, int va, unsigned int res, int layers,
372372
unsigned int obpc = bpc;
373373
if( bpc <= 16 && bpc > 8 ) obpc = 16;
374374
else if( bpc <= 8 ) obpc = 8;
375-
375+
376376
#ifdef OPENJPEG_DEBUG
377377
Timer timer;
378378
timer.start();
@@ -410,7 +410,7 @@ void OpenJPEGImage::process( unsigned int res, int layers, int xoffset, int yoff
410410
else if( bpc <= 8 ) obpc = 8;
411411

412412
unsigned int factor = 1; // Downsampling factor - set it to default value
413-
int vipsres = (numResolutions - 1) - res; // Reverse resolution number
413+
int vipsres = getNativeResolution( res ); // Reverse resolution number
414414

415415
// Calculate number of extra resolutions needed that have not been encoded in the image
416416
if( res < virtual_levels ){
@@ -488,10 +488,10 @@ void OpenJPEGImage::process( unsigned int res, int layers, int xoffset, int yoff
488488
// Copy our decoded data by looping over all pixels
489489
size_t n = 0;
490490

491-
for( unsigned int j=0; j < th; j += factor ){
492-
for( unsigned int i = 0; i < tw; i += factor ){
491+
for( unsigned int j=0; j<th; j+=factor ){
492+
for( unsigned int i=0; i<tw; i+=factor ){
493493
size_t index = tw*j + i;
494-
for( unsigned int k = 0; k < channels; k++ ){
494+
for( unsigned int k=0; k<channels; k++ ){
495495
// Handle 16 and 8 bit data:
496496
// OpenJPEG's output data is 32 bit unsigned int, so just mask of the bottom 2 bytes
497497
// for 16 bit output or bottom 1 byte for 8 bit

src/OpenJPEGImage.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ class OpenJPEGImage : public IIPImage {
135135

136136
/// Get codec version
137137
/** @return codec version */
138-
static const char* getCodecVersion(){ return opj_version(); };
138+
static std::string getCodecVersion(){ return opj_version(); };
139139

140140

141141
};

src/TPTImage.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,19 @@ class TPTImage : public IIPImage {
5656
/// Constructor
5757
TPTImage():IIPImage(), tiff( NULL ) {};
5858

59+
5960
/// Constructor
6061
/** @param path image path
6162
*/
6263
TPTImage( const std::string& path ): IIPImage(path), tiff(NULL), subifd_ifd(0) {};
6364

65+
6466
/// Copy Constructor
6567
/** @param image IIPImage object
6668
*/
6769
TPTImage( const TPTImage& image ): IIPImage(image), tiff(NULL), subifd_ifd(0) {};
6870

71+
6972
/// Assignment Operator
7073
/** @param image TPTImage object
7174
*/
@@ -78,29 +81,46 @@ class TPTImage : public IIPImage {
7881
return *this;
7982
}
8083

84+
8185
/// Construct from an IIPImage object
8286
/** @param image IIPImage object
8387
*/
8488
TPTImage( const IIPImage& image ): IIPImage(image), tiff(NULL), subifd_ifd(0) {};
8589

90+
8691
/// Destructor
8792
~TPTImage() { closeImage(); };
8893

94+
8995
/// Overloaded static function for seting up logging for codec library
9096
static void setupLogging();
9197

98+
99+
/// Get codec version
100+
/** @return codec version */
101+
static std::string getCodecVersion(){
102+
std::string version = std::string( TIFFGetVersion() );
103+
// Strip off everything after newline
104+
version = version.substr( 0, version.find_first_of("\n") );
105+
return version;
106+
}
107+
108+
92109
/// Overloaded function for opening a TIFF image
93110
void openImage();
94111

112+
95113
/// Overloaded function for loading TIFF image information
96114
/** @param x horizontal sequence angle
97115
@param y vertical sequence angle
98116
*/
99117
void loadImageInfo( int x, int y );
100118

119+
101120
/// Overloaded function for closing a TIFF image
102121
void closeImage();
103122

123+
104124
/// Overloaded function for getting a particular tile
105125
/** @param x horizontal sequence angle
106126
@param y vertical sequence angle

0 commit comments

Comments
 (0)