conda-forge / libtiff-feedstock

A conda-smithy repository for libtiff.
BSD 3-Clause "New" or "Revised" License
1 stars 25 forks source link

WIP: attempt to enable 12 bit JPEG in Tiff #37

Closed gillins closed 5 years ago

gillins commented 5 years ago

Checklist

See discussion at https://github.com/conda-forge/gdal-feedstock/pull/255. Does anyone know a good reason not to enable this? Appears 12 bit was added in libjpeg 9a.

ping @hobu @kmuehlbauer

gillins commented 5 years ago

@conda-forge-admin, please rerender

conda-forge-linter commented 5 years ago

Hi! This is the friendly automated conda-forge-linting service.

I just wanted to let you know that I linted all conda-recipes in your PR (recipe) and found it was in an excellent condition.

kmuehlbauer commented 5 years ago

From the CMakeLists.txt:

# 8/12-bit jpeg mode
option(jpeg12 "enable libjpeg 8/12-bit dual mode (requires separate
12-bit libjpeg build)" ON)
set(JPEG12_INCLUDE_DIR JPEG12_INCLUDE_DIR-NOTFOUND CACHE PATH "Include directory for 12-bit libjpeg")
set(JPEG12_LIBRARY JPEG12_LIBRARY-NOTFOUND CACHE FILEPATH "12-bit libjpeg library")

What does requires separate 12-bit libjpeg build mean actually? Do we need 8bit libjpeg and 12bit libjpeg?

kmuehlbauer commented 5 years ago

AFAIU from reading issues and stuff we need to build libjpeg twice: normal libjpeg and libjpeg12. Any thoughts on this?

See here:

In 2009 ESRI and Surdex agreed to support work to support reading and writing 8/12 bit jpeg
compressed tiff files. Further work on the mk1-branch was considered as well as other fairly 
radical options. In the end it was decide to go with a more straight forward approach which 
is to link two copies of libjpeg into libtiff - one built for 8bit and one for 12bit. 
Renaming of the entire public API of the 12bit libjpeg is used to facilitate coexistance. 
This work was done by Frank Warmerdam. This page attempts to document the changes 
made, and explain how to build a dual model libtiff and GDAL. 
gillins commented 5 years ago

Really weird... Does anyone know how to build libjpeg in 12 bit mode?

kmuehlbauer commented 5 years ago

@rouault As written in the osgeo-link above, libjpeg needs to be build twice, as libjpeg and libjpeg12 to make it work with libtiff for 12bit.

Could you please summarize how to do this? Any pointers are very welcome. We really like to add this capability to conda but need some expert help here.

rouault commented 5 years ago

I'm not sure I've ever tried building an external libjpeg12, but the hints given in the wiki page seems to be a good start

 To build in 12bit mode it should only be necessary to define BITS_IN_JSAMPLE to 12, and NEED_12_BIT_NAMES in jmorecfg.h.

#define BITS_IN_JSAMPLE 12
#define NEED_12_BIT_NAMES
gillins commented 5 years ago

Thanks @rouault. Another question - how would you specify both the 8 and 12 bit JPEG libs to gdal?

@kmuehlbauer I won't be able to look at this for another week, if you want to have a go please do. Otherwise I'll try when I get back. A quick look at jpeg 9c suggests that NEED_12_BIT_NAMES isn't supported any more, and I couldn't see another mechanism for changing the exported function names, but I'm probably missing something.

rouault commented 5 years ago

how would you specify both the 8 and 12 bit JPEG libs to gdal?

The JPEG 8bit with --with-jpeg. But I do see there's no provision in the configure script for an external libjpeg12. Would require some hacking in it and in the makfiles. That's why I didn't remember having ever built an external libjpeg12... I somehow remember somone mentionning they would be interested in this, but nobody provided a patch.

kmuehlbauer commented 5 years ago

@gillins I'll try to free some time, but cannot promise.

gillins commented 5 years ago

I had a look at this and found that libjpeg doesn't actually compile in 12 bit mode anymore (see message below). Closing until this is tidied up upstream.

wrtarga.c:29:3: warning: data definition has no type or storage class
   Sorry, this code only copes with 8-bit JSAMPLEs. /* deliberate syntax err */
   ^~~~~
wrtarga.c:29:3: warning: type defaults to 'int' in declaration of 'Sorry' [-Wimplicit-int]
wrtarga.c:29:15: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'code'
   Sorry, this code only copes with 8-bit JSAMPLEs. /* deliberate syntax err */
               ^~~~
wrtarga.c:49:3: warning: data definition has no type or storage class
 } tga_dest_struct;
   ^~~~~~~~~~~~~~~
wrtarga.c:49:3: warning: type defaults to 'int' in declaration of 'tga_dest_struct' [-Wimplicit-int]
wrtarga.c:51:25: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token
 typedef tga_dest_struct * tga_dest_ptr;
mingwandroid commented 5 years ago

@gillins what do upstream say about this?

gillins commented 5 years ago

I can't find any information, or even which mailing list to direct questions to. Maybe we should try using jpeg-turbo?

mingwandroid commented 5 years ago

@hobu, your thoughts would be very welcome!