GithubHelp home page GithubHelp logo

thorfdbg / libjpeg Goto Github PK

View Code? Open in Web Editor NEW
299.0 20.0 76.0 3.18 MB

A complete implementation of 10918-1 (JPEG) coming from jpeg.org (the ISO group) with extensions for HDR, lossless and alpha channel coding standardized as ISO/IEC 18477 (JPEG XT).

Perl 0.01% C++ 98.01% C 0.42% Shell 0.12% Python 0.05% Makefile 1.40%

libjpeg's Introduction

libjpeg

A complete implementation of 10918-1 (JPEG) coming from jpeg.org (the ISO group) with extensions for HDR standardized as 18477 (JPEG XT)

This release also includes the "JPEG on Steroids" improvements implemented for the ICIP 2016 Grand Challenge on Image Compression. For ideal visual performance, run jpeg as follows:

jpeg -q -oz -v -qt 3 -h -s 1x1,2x2,2x2 input.ppm output.jpg

libjpeg's People

Contributors

attritionorg avatar grimmer0125 avatar malaterre avatar thorfdbg avatar ziemek99 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

libjpeg's Issues

undefined reference to "some function"

I have been trying to compile the library but with no luck.
First there was an issue with the headers that i managed to fix -i think- then after that this error popped out:

/tmp/ccygeadE.o: In function main': main.cpp:(.text+0x1bdb): undefined reference to SplitQualityC(int, bool, int&, int&)'
main.cpp:(.text+0x1c0a): undefined reference to SplitQualityC(int, bool, int&, int&)' main.cpp:(.text+0x1cc8): undefined reference to Reconstruct(char const
, char const
, int, char const*, bool)'
main.cpp:(.text+0x212b): undefined reference to `EncodeC(char const*, char const*, char const*, char const*, int, int, int, int, int, int, bool, bool, bool, bool, bool, bool, bool, bool, bool, unsigned char, bool, bool, unsigned short, double, int, bool, bool, bool, bool, bool, bool, bool, bool, bool, int, int, int, bool, bool, bool, int, bool, char const*, char const*, char const*, int, int, int, int, bool, int, int, int, int, int, int, int, bool, bool, bool, bool, bool, bool)'
collect2: error: ld returned 1 exit status**

however i try to fix it i just mess it up even more.

any help to compile this library is appreciated.

Usage of dll?

I successfully built the DLL. It didn't export any functions at first, until I added BUILD_LIB to the preprocessor stuff. But all it seems to export now is some Tag-related stuff, not sure what it means.

Is it possible to have a dll that can be used to encode lossless JPEG? If so, what must I do and how would I use it? I'd probably like to use it via interop in C#, but I'd be happy with a normal explanation of how to use it in a normal C/C++ program.

Apologies in advance, I'm a beginner in C++, so some of my questions might seem trivial.

Segmentation fault in linebuffer.cpp:322

System info

Ubuntu X64, gcc (Ubuntu 5.5.0-12ubuntu1), jpeg (latest master e52406)

Command line

./jpeg -oz -h -s 1x1,2x2,2x2 @@ /dev/null

Output

*** Warning -1038 in Frame::StartParseHiddenScan, line 869, file frame.cpp
*** Reason is: Start of Scan SOS marker missing

*** Warning -1038 in Frame::ParseTrailer, line 1083, file frame.cpp
*** Reason is: missing an EOI marker at the end of the stream

*** Warning -1038 in Image::ParseTrailer, line 1464, file image.cpp
*** Reason is: expecting an EOI marker at the end of the stream

Segmentation fault

Address Sanitizer

ASAN:SIGSEGV
=================================================================
==9062==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x0000008583d3 bp 0x7ffc9436de80 sp 0x7ffc9436de60 T0)
    #0 0x8583d2 in LineBuffer::FetchRegion(int, Line const*, int*) /home/seviezhou/libjpeg/control/linebuffer.cpp:322
    #1 0x87ef78 in LineBitmapRequester::ReconstructRegion(RectAngle<int> const&, RectangleRequest const*) /home/seviezhou/libjpeg/control/linebitmaprequester.cpp:513
    #2 0x486b6c in Image::ReconstructRegion(BitMapHook*, RectangleRequest const*) /home/seviezhou/libjpeg/codestream/image.cpp:1111
    #3 0x45f10a in JPEG::InternalDisplayRectangle(JPG_TagItem*) /home/seviezhou/libjpeg/interface/jpeg.cpp:721
    #4 0x45f452 in JPEG::DisplayRectangle(JPG_TagItem*) /home/seviezhou/libjpeg/interface/jpeg.cpp:699
    #5 0x42c573 in Reconstruct(char const*, char const*, int, char const*, bool) /home/seviezhou/libjpeg/cmd/reconstruct.cpp:320
    #6 0x4055f0 in main /home/seviezhou/libjpeg/cmd/main.cpp:718
    #7 0x7fdc5ae9183f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2083f)
    #8 0x409da8 in _start (/home/seviezhou/libjpeg/jpeg+0x409da8)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV /home/seviezhou/libjpeg/control/linebuffer.cpp:322 LineBuffer::FetchRegion(int, Line const*, int*)
==9062==ABORTING

POC

SEGV-FetchRegion-linebuffer-322.zip

Assert fail in upsampler.cpp:90

System info

Ubuntu x86_64, gcc (Ubuntu 5.5.0-12ubuntu1), jpeg (latest master e52406)

Command line

./jpeg -oz -h -s 1x1,2x2,2x2 @@ /dev/null

Output

jpeg: upsampler.cpp:90: void Upsampler<sx, xy>::UpsampleRegion(const RectAngle<int>&, LONG*) const [with int sx = 2; int xy = 2; LONG = int]: Assertion `y >= m_lY && y < m_lY + m_lHeight' failed.
Aborted

POC

assert-fail-UpsampleRegion-upsampler-90.zip

Assertion fail in bitstream.hpp:172

System info

Ubuntu X64, gcc (Ubuntu 5.5.0-12ubuntu1), jpeg (latest master e52406)

Command line

./jpeg -oz -h -s 1x1,2x2,2x2 @@ /dev/null

Output

jpeg: ../io/bitstream.hpp:172: ULONG BitStream<false>::Get(UBYTE) [bitstuffing = false]: Assertion `bits > 0 && bits <= 24' failed.
Aborted

POC

assert-bitstream-172.zip

JPEG XT profile c encoding - inverted base image

images.zip
Dear Dr.Ritcher,
I did JPEG XT profile c encoding using reference software. But it seems output base image is inverted and mirrored one of original HDR image. I have attached images.zip file which contain original image which is beach_probe.pfm and profile c encoded image is beach_probe_c.jpg. can you please help to get correct base image?

Regards,
K.Kamalavasan

Assertion fail in environment.cpp:408

System info

Ubuntu X64, gcc (Ubuntu 5.5.0-12ubuntu1), jpeg (latest master e52406)

Command line

./jpeg -oz -h -s 1x1,2x2,2x2 @@ /dev/null

Output

512 bytes memory not yet released.

8709 bytes maximal required.

53 allocations performed.
jpeg: environment.cpp:408: Environ::~Environ(): Assertion `totalmem == 0' failed.
Aborted

POC

assert-environment-408.zip

Assertion fail in frame.cpp:1088

System info

Ubuntu X64, gcc (Ubuntu 5.5.0-12ubuntu1), jpeg (latest master e52406)

Command line

./jpeg -oz -h -s 1x1,2x2,2x2 ./assert-fail-ParseTrailer-frame-1088 /dev/null

Output

*** Warning -1038 in Frame::ParseTrailer, line 1088, file frame.cpp
*** Reason is: expecting a marker or marker segment - stream is out of sync

Segmentation fault

POC

assert-fail-ParseTrailer-frame-1088.zip

Typo

comming -> coming
image

Decoding - PFM PPM File format interchanging

Dear Sir

I have the following doubts in the JPEG XT Decoder
1) Why are some decoded images saved in PPM Fileformat, when requested to save in PFM Fileformat?
2) For a given PFM file, how do I convert the floating point raw pixel value to fixed point value (How to know the bit depth of a pixel from the PFM file)?

Regards,
Natheesan

jls to any format

When you convert images from jls format to any other amount received on the 18-bit larger than the original , which I think is not correct. Why? How to fix it?

Segmentation fault in sampleinterleavedlsscan.cpp:133

System info

Ubuntu X64, gcc (Ubuntu 5.5.0-12ubuntu1), jpeg (latest master e52406)

Command line

./jpeg -oz -h -s 1x1,2x2,2x2 @@ /dev/null

Output

Segmentation fault

AddressSanitizer output

ASAN:SIGSEGV
=================================================================
==81357==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x0000005200b8 bp 0x7ffdd2f954b0 sp 0x7ffdd2f95110 T0)
    #0 0x5200b7 in SampleInterleavedLSScan::ParseMCU() /home/seviezhou/libjpeg/codestream/sampleinterleavedlsscan.cpp:133
    #1 0x45c4b4 in JPEG::ReadInternal(JPG_TagItem*) /home/seviezhou/libjpeg/interface/jpeg.cpp:345
    #2 0x45d5be in JPEG::Read(JPG_TagItem*) /home/seviezhou/libjpeg/interface/jpeg.cpp:210
    #3 0x42adbf in Reconstruct(char const*, char const*, int, char const*, bool) /home/seviezhou/libjpeg/cmd/reconstruct.cpp:121
    #4 0x4055f0 in main /home/seviezhou/libjpeg/cmd/main.cpp:718
    #5 0x7ff8b3e8083f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2083f)
    #6 0x409da8 in _start (/home/seviezhou/libjpeg/jpeg+0x409da8)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV /home/seviezhou/libjpeg/codestream/sampleinterleavedlsscan.cpp:133 SampleInterleavedLSScan::ParseMCU()
==81357==ABORTING

POC

SEGV-ParseMCU-sampleinterleavedlsscan-133.zip

Usage in external project

Hellow ! It is possible to use libjpeg library in external project ? If it is possible, what files i must append to my project ? (headers)

Lossless Jpeg

Hello, Dr. Richter
I have two images Lossless Jpeg: 8 and 12 bits. I am doing 8-bit decoding in any other format, and all is well. The question is, how do I make the decoding of 12 bit? What specify flags?

Assertion fail in bytestream.hpp:236

System info

Ubuntu X64, gcc (Ubuntu 5.5.0-12ubuntu1), jpeg (latest master e52406)

Command line

./jpeg -oz -h -s 1x1,2x2,2x2 ./assert-fail-bytestream-236 /dev/null

Output

jpeg: ./bytestream.hpp:236: UBYTE ByteStream::LastUnDo(): Assertion `m_pucBufPtr == NULL || m_pucBufPtr > m_pucBuffer' failed.
Aborted

POC

assert-fail-bytestream-236.zip

libjpeg FTBFS inside sbuild

libjpeg fails to build from source in unstable when building it under
sbuild, because sbuild does not have a writeable $HOME directory:

| dh_auto_install
| make -j1 install DESTDIR=/<>/libjpeg-0.0~git20180720.99764820d250/debian/libjpeg-tools AM_UPDATE_INFO_DIR=no
| make[1]: Entering directory '/<>'
| mkdir: cannot create directory ‘/sbuild-nonexistent’: Permission denied
| make[1]: *** [Makefile:383: install] Error 1
| make[1]: Leaving directory '/<>'
| dh_auto_install: make -j1 install DESTDIR=/<>/libjpeg-0.0~git20180720.99764820d250/debian/libjpeg-tools AM_UPDATE_INFO_DIR=no returned exit code 2
| make: *** [debian/rules:5: binary] Error 255
| dpkg-buildpackage: error: fakeroot debian/rules binary subprocess returned exit status 2

Problem with create jpeg 12bit

jpegXT.exe -q 90 -a -qt 3 -c -r12 -g 1.0 -s 1x1,1x1,1x1 image_21447.ppm image_21447_12xt.jpg

Image
Format                                   : JPEG
Width                                    : 1 563 pixels
Height                                   : 1 558 pixels
Color space                              : YUV
Chroma subsampling                       : 4:4:4
Bit depth                                : 8 bits
Compression mode                         : Lossy
Stream size                              : 8.75 MiB (100%)

8bit -> (12bit) in conteiner JPEG 8bit?

Image
Format                                   : JPEG
Width                                    : 1 563 pixels
Height                                   : 1 558 pixels
Color space                              : RGB
Bit depth                                : 12 bits
Compression mode                         : Lossy
Stream size                              : 8.29 MiB (100%)

JPEGXT in program ImageConverter Plus

libjpeg fails to cross build from source

libjpeg fails to cross build from source, because it configures for the
build architecture. Unconventionally, ./configure is invoked by the
Makefile during dh_auto_build. This happens, because the Makefile also
performs autoconf and thus debhelper uses the makefile buildsystem due
to the absence of configure. Enabling autoreconf makes debhelper select
the autoconf buildsystem and run ./configure with --host. However,
configuration fails due to frequent use of AC_TRY_RUN. The attached
patch adds autoreconf and fixes a lot of AC_TRY_RUN, but not all. It is
an incremental improvement and does not make libjpeg cross buildable.
Please consider applying it anyway and close this bug when doing so.

ref:

Patch is at:

Assertion failure at coding/blockrow.hpp:93

Hi, for the following input,
93.txt

jpeg throws an assertion failure

jpeg: ../coding/blockrow.hpp:93: BlockRow<T>::Block* BlockRow<T>::BlockAt(ULONG) const [with T = int; ULONG = unsigned int]: Assertion `pos < m_ulWidth' failed.
Aborted

OS: Ubuntu 16.04
Commit: cf4cc9c

Guidance for building on Windows

Hi @thorfdbg,

I am attempting to support decoding of 1993 lossless JPEG natively on Windows and I cannot seem to find a compiled executable anywhere.

I have successfully compiled this library within Windows Services for Linux by doing the following:

git clone https://github.com/thorfdbg/libjpeg.git
cd libjpeg
./configure --prefix=/path/to/build-dir
make -j4
make install

This then allows me to successfully use the jpeg executable installed within ~/bin/wavelet/jpeg.

Nevertheless, I would like to distribute this functionality to other PCs through my Medical Physics Python library, PyMedPhys and requesting they set up Windows Services for Linux is unfortunately not viable. I have been attempting to compile this library within MSYS2. I have done this by downloading msys2 from http://www.msys2.org/ and then using pacman to install a range of tools that appear necessary.

Nevertheless, after all of that running:

./configure --prefix=/path/to/build-dir
make -j4

presents me with the following error:

Linking...
C:/Users/sbiggs/AppData/Local/msys2/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lc
collect2.exe: error: ld returned 1 exit status
make[1]: *** [Makefile:143: link] Error 1
make: *** [Makefile:200: debug] Error 2

Any direction or nudge in the right direction would be massively appreciated.

I have also attempted using VS2013 with the provided vs12.0/jpeg/jpeg.sln file on a Windows 10 machine. When doing that I get the following errors:

Error	5	error LNK2019: unresolved external symbol "public: __thiscall CositedUpsampler<1,1>::CositedUpsampler<1,1>(class Environ *,unsigned long,unsigned long)" (??0?$CositedUpsampler@$00$00@@QAE@PAVEnviron@@KK@Z) referenced in function "public: static class UpsamplerBase * __cdecl UpsamplerBase::CreateUpsampler(class Environ *,int,int,unsigned long,unsigned long,bool)" (?CreateUpsampler@UpsamplerBase@@SAPAV1@PAVEnviron@@HHKK_N@Z)	C:\Users\sbiggs\git\libjpeg\vs12.0\jpeg\jpeg\jpeglib.lib(upsamplerbase.obj)	jpeg

Error	23	error LNK2019: unresolved external symbol "public: __thiscall InterDownsampler<3,1>::InterDownsampler<3,1>(class Environ *,unsigned long,unsigned long)" (??0?$InterDownsampler@$02$00@@QAE@PAVEnviron@@KK@Z) referenced in function "public: static class DownsamplerBase * __cdecl DownsamplerBase::CreateDownsampler(class Environ *,int,int,unsigned long,unsigned long,bool)" (?CreateDownsampler@DownsamplerBase@@SAPAV1@PAVEnviron@@HHKK_N@Z)	C:\Users\sbiggs\git\libjpeg\vs12.0\jpeg\jpeg\jpeglib.lib(downsamplerbase.obj)	jpeg

Error	37	error LNK1120: 32 unresolved externals	C:\Users\sbiggs\git\libjpeg\vs12.0\jpeg\Debug\jpeg.exe	jpeg

Cheers,
Simon


For reference I have pasted the full output of the ./configure command below.

sbiggs@RCCC-Physics3 MINGW64 /c/Users/sbiggs/git/libjpeg
$ ./configure --prefix=/c/Users/sbiggs/git/libjpeg-build
configure: loading site script /mingw64/etc/config.site
checking for g++-4.9... no
checking for g++-4.7... no
checking for g++-4.4... no
checking for g++-4.3... no
checking for g++-4.2... no
checking for g++-4.1... no
checking for g++-4.0... no
checking for g++-3.4... no
checking for g++-3.3... no
checking for g++-3.2... no
checking for g++... g++
checking whether the C++ compiler works... yes
checking for C++ compiler default output file name... a.exe
checking for suffix of executables... .exe
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C++ compiler... yes
checking whether g++ accepts -g... yes
checking for gcc-4.9... no
checking for gcc-4.7... no
checking for gcc-4.4... no
checking for gcc-4.3... no
checking for gcc-4.2... no
checking for gcc-4.1... no
checking for gcc-4.0... no
checking for gcc-3.4... no
checking for gcc-3.3... no
checking for gcc-3.2... no
checking for gcc... gcc
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for gcc option to accept ISO C99... none needed
checking for gcc option to accept ISO Standard C... (cached) none needed
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking whether byte ordering is bigendian... no
checking for long long... yes
checking for unsigned long long... yes
checking for __int64... yes
checking size of char... 1
checking size of short... 2
checking size of int... 4
checking size of long... 4
checking size of long long... 8
checking size of __int64... 8
checking size of void *... 8
checking for ANSI C header files... (cached) yes
checking for an ANSI C-conforming const... yes
checking for inline... inline
checking for size_t... yes
checking whether time.h and sys/time.h may both be included... yes
checking whether stat file-mode macros are broken... no
checking fcntl.h usability... yes
checking fcntl.h presence... yes
checking for fcntl.h... yes
checking for stdlib.h... (cached) yes
checking for string.h... (cached) yes
checking for strings.h... (cached) yes
checking signal.h usability... yes
checking signal.h presence... yes
checking for signal.h... yes
checking for unistd.h... (cached) yes
checking stdarg.h usability... yes
checking stdarg.h presence... yes
checking for stdarg.h... yes
checking errno.h usability... yes
checking errno.h presence... yes
checking for errno.h... yes
checking stdio.h usability... yes
checking stdio.h presence... yes
checking for stdio.h... yes
checking bstring.h usability... no
checking bstring.h presence... no
checking for bstring.h... no
checking bstrings.h usability... no
checking bstrings.h presence... no
checking for bstrings.h... no
checking ctype.h usability... yes
checking ctype.h presence... yes
checking for ctype.h... yes
checking setjmp.h usability... yes
checking setjmp.h presence... yes
checking for setjmp.h... yes
checking stddef.h usability... yes
checking stddef.h presence... yes
checking for stddef.h... yes
checking time.h usability... yes
checking time.h presence... yes
checking for time.h... yes
checking sys/time.h usability... yes
checking sys/time.h presence... yes
checking for sys/time.h... yes
checking sys/times.h usability... no
checking sys/times.h presence... no
checking for sys/times.h... no
checking sys/param.h usability... yes
checking sys/param.h presence... yes
checking for sys/param.h... yes
checking assert.h usability... yes
checking assert.h presence... yes
checking for assert.h... yes
checking math.h usability... yes
checking math.h presence... yes
checking for math.h... yes
checking netinet/in.h usability... no
checking netinet/in.h presence... no
checking for netinet/in.h... no
checking for stdint.h... (cached) yes
checking for int8_t... yes
checking for int16_t... yes
checking for int32_t... yes
checking for int64_t... yes
checking for uint8_t... yes
checking for uint16_t... yes
checking for uint32_t... yes
checking for uint64_t... yes
checking for error_at_line... no
checking whether gcc needs -traditional... no
checking for working memcmp... yes
checking return type of signal handlers... void
checking for vprintf... yes
checking for _doprnt... no
checking for gettimeofday... yes
checking for memchr... yes
checking for memmove... yes
checking for memset... yes
checking for strchr... yes
checking for strerror... yes
checking for strrchr... yes
checking for strtol... yes
checking for strtod... yes
checking for time... yes
checking for snprintf... yes
checking for vsnprintf... yes
checking for clock... yes
checking for gettimeofday... (cached) yes
checking for isspace... yes
checking for longjmp... yes
checking for malloc... yes
checking for free... yes
checking for open... yes
checking for close... yes
checking for read... yes
checking for write... yes
checking for lseek... yes
checking for rename... yes
checking for signal... yes
checking for sleep... yes
checking for fopen64... yes
checking for __builtin_memset... yes
checking for __builtin_memcpy... yes
checking for __builtin_memmove... yes
checking for __builtin_expect... yes
checking for llseek... no
checking for lseek64... yes
checking for htonl... no
checking for htons... no
checking for ntohl... no
checking for ntohs... no
checking for signal... (cached) yes
checking for sigaction... no
checking for sigemptyset... no
checking for pipe... no
checking for dup... yes
checking for dup2... yes
checking for execve... yes
checking for fork... no
checking for fstat... yes
checking for system... yes
checking for kill... no
checking for sleep... (cached) yes
checking for struct timeval... no
checking for ptrdiff_t... yes
checking for sysconf... no
checking for times... no
checking for struct tms... no
checking whether _SC_CLK_TCK is declared... no
checking whether CLK_TCK is declared... yes
checking whether HZ is declared... no
checking whether STDIN_FILENO is declared... yes
checking whether STDOUT_FILENO is declared... yes
checking whether STDERR_FILENO is declared... yes
checking for library containing exp... none required
checking for __muldc3 in -lgcc_s... yes
checking whether argument type for signal handlers is "int"... yes
checking whether argument type for signal handlers is "..."... no
checking whether the GNU __attribute__ extension is available... yes
checking for the __null keyword... yes
checking whether integer constants are valid template arguments... yes
checking for SIGSEGV and SIGILL signals... yes
checking for atomic arithmetic functions __sync_add_and_fetch and __sync_fetch_and_sub... yes
checking for atomic __sync_val_compare_and_swap... yes
checking for worst-case structural alignment... 4
checking whether private subclasses have access to private members... yes
checking whether templates are in local namespace... yes
checking whether initializers of static const integral members work... yes
checking whether casting works in template arguments... yes
checking whether the noreturn attribute is available... yes
checking whether the always_inline attribute is available... no
checking whether __attribute__((visibility("hidden"))) is available for types... no
checking whether __attribute__((visibility("internal"))) is available for types... yes
checking whether __attribute__((visibility("default"))) is available for types... yes
checking whether __attribute__((may_alias)) is available for types... yes
checking whether __attribute__((aligned)) is available for types... yes
checking for working const_cast<> capability... yes
checking for working reinterpret_cast<> capability... yes
checking for uniqueness of static members thru various derivation paths... yes
checking whether __restrict__ pointers are available... yes
checking for the -mfpmath=387 compiler switch... yes
checking for the -fvisibility=internal compiler switch... yes
checking for the -fPIC compiler switch... yes
configure: creating ./config.status
config.status: creating automakefile
config.status: creating autoconfig.h

Segmentation fault in blockbitmaprequester.cpp:1182

System info

Ubuntu X64, gcc (Ubuntu 5.5.0-12ubuntu1), jpeg (latest master e52406)

Command line

./jpeg -oz -h -s 1x1,2x2,2x2 @@ /dev/null

Output

*** Warning -1038 in Frame::ParseTrailer, line 1088, file frame.cpp
*** Reason is: expecting a marker or marker segment - stream is out of sync

Segmentation fault

AddressSanitizer output

ASAN:SIGSEGV
=================================================================
==26800==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x000000873314 bp 0x7ffe658218c0 sp 0x7ffe65821780 T0)
    #0 0x873313 in BlockBitmapRequester::PushReconstructedData(RectangleRequest const*, RectAngle<int> const&, unsigned int, ColorTrafo*) /home/seviezhou/libjpeg/control/blockbitmaprequester.cpp:1182
    #1 0x486b6c in Image::ReconstructRegion(BitMapHook*, RectangleRequest const*) /home/seviezhou/libjpeg/codestream/image.cpp:1111
    #2 0x45f10a in JPEG::InternalDisplayRectangle(JPG_TagItem*) /home/seviezhou/libjpeg/interface/jpeg.cpp:721
    #3 0x45f452 in JPEG::DisplayRectangle(JPG_TagItem*) /home/seviezhou/libjpeg/interface/jpeg.cpp:699
    #4 0x42c573 in Reconstruct(char const*, char const*, int, char const*, bool) /home/seviezhou/libjpeg/cmd/reconstruct.cpp:320
    #5 0x4055f0 in main /home/seviezhou/libjpeg/cmd/main.cpp:718
    #6 0x7fdecbdba83f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2083f)
    #7 0x409da8 in _start (/home/seviezhou/libjpeg/jpeg+0x409da8)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV /home/seviezhou/libjpeg/control/blockbitmaprequester.cpp:1182 BlockBitmapRequester::PushReconstructedData(RectangleRequest const*, RectAngle<int> const&, unsigned int, ColorTrafo*)
==26800==ABORTING

POC

SEGV-PushReconstructedData-blockbitmaprequester-1182.zip

libjpeg FTCBFS: fails to compute reasonable compiler identification from cross tools

libjpeg fails to cross build from source, because it attempts to include
a file e.g. Makefile_Settings.arm. The "arm" part here comes from an
attempt at extracting a compiler identification from the compiler
variable. The $ac_tool_prefix confuses the parsing code. It needs to be
stripped of. Please consider applying the attached patch to make libjpeg
cross buildable.

Patch:

Segmentation fault in blockbitmaprequester.cpp:1047

System info

Ubuntu X64, gcc (Ubuntu 5.5.0-12ubuntu1), jpeg (latest master e52406)

Command line

./jpeg -oz -h -s 1x1,2x2,2x2 @@ /dev/null

Output

*** Warning -1038 in Tables::ParseTables, line 1384, file tables.cpp
*** Reason is: found invalid marker, probably a marker size is out of range

*** Warning -1038 in Frame::StartParseHiddenScan, line 869, file frame.cpp
*** Reason is: Start of Scan SOS marker missing

*** Warning -1038 in Frame::ParseTrailer, line 1083, file frame.cpp
*** Reason is: missing an EOI marker at the end of the stream

*** Warning -1038 in Image::ParseTrailer, line 1464, file image.cpp
*** Reason is: expecting an EOI marker at the end of the stream

Segmentation fault

AddressSanitizer output

ASAN:SIGSEGV
=================================================================
==56860==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x00000086f67b bp 0x7ffcf2756d80 sp 0x7ffcf2756c20 T0)
    #0 0x86f67a in BlockBitmapRequester::ReconstructUnsampled(RectangleRequest const*, RectAngle<int> const&, unsigned int, ColorTrafo*) /home/seviezhou/libjpeg/control/blockbitmaprequester.cpp:1047
    #1 0x486b6c in Image::ReconstructRegion(BitMapHook*, RectangleRequest const*) /home/seviezhou/libjpeg/codestream/image.cpp:1111
    #2 0x45f10a in JPEG::InternalDisplayRectangle(JPG_TagItem*) /home/seviezhou/libjpeg/interface/jpeg.cpp:721
    #3 0x45f452 in JPEG::DisplayRectangle(JPG_TagItem*) /home/seviezhou/libjpeg/interface/jpeg.cpp:699
    #4 0x42c573 in Reconstruct(char const*, char const*, int, char const*, bool) /home/seviezhou/libjpeg/cmd/reconstruct.cpp:320
    #5 0x4055f0 in main /home/seviezhou/libjpeg/cmd/main.cpp:718
    #6 0x7fe0a1fc283f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2083f)
    #7 0x409da8 in _start (/home/seviezhou/libjpeg/jpeg+0x409da8)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV /home/seviezhou/libjpeg/control/blockbitmaprequester.cpp:1047 BlockBitmapRequester::ReconstructUnsampled(RectangleRequest const*, RectAngle<int> const&, unsigned int, ColorTrafo*)
==56860==ABORTING

POC

SEGV-ReconstructUnsampled-blockbitmaprequester-1047.zip

Allow creation of default Baseline JPEG image: JPGFLAG_BASELINE

jpeg command line tool does not allow creation of default baseline JPEG, it always default to sequential extended:

int frametype = JPGFLAG_SEQUENTIAL;

There is no way then to reset back frametype to JPGFLAG_BASELINE.

Typical setup (create an 8x8 RGB black image):

$ convert -depth 8 -size 8x8 xc:black black.ppm
$ jpeg -h -s 1x1,2x2,2x2 -q 100 black.ppm black_jpeg.jpg

compare to the ijg/turbo-jpeg:

$ cjpeg -optimize -quality 100 -outfile black_cjpeg.jpg black.ppm

libjpeg it creating:

  • SOF1 Huffman Extended Sequential DCT

while ijg/turbo-jpeg creates:

  • SOF0 Huffman Baseline DCT

(as a side note it would also be nice to be able to remove the APPB marker completely).

Floating point exception in tables.cpp:1384

System info

Ubuntu X64, gcc (Ubuntu 5.5.0-12ubuntu1), jpeg (latest master e52406)

Command line

./jpeg -oz -h -s 1x1,2x2,2x2 ./floating-point-exception-ParseTables-tables-1384 /dev/null

Output

*** Warning -1038 in Tables::ParseTables, line 1384, file tables.cpp
*** Reason is: found invalid marker, probably a marker size is out of range

Floating point exception

POC

segment-fault-tables-1384.zip

Segmentation fault in blockbitmaprequester.cpp:1100

System info

Ubuntu X64, gcc (Ubuntu 5.5.0-12ubuntu1), jpeg (latest master e52406)

Command line

./jpeg -oz -h -s 1x1,2x2,2x2 @@ /dev/null

Output

For license conditions, see README.license for details.

*** Warning -1038 in Tables::ParseTables, line 1384, file tables.cpp
*** Reason is: found invalid marker, probably a marker size is out of range

*** Warning -1038 in Frame::StartParseHiddenScan, line 869, file frame.cpp
*** Reason is: Start of Scan SOS marker missing

*** Warning -1038 in Frame::ParseTrailer, line 1083, file frame.cpp
*** Reason is: missing an EOI marker at the end of the stream

*** Warning -1038 in Image::ParseTrailer, line 1464, file image.cpp
*** Reason is: expecting an EOI marker at the end of the stream

Segmentation fault

AddressSanitizer output

=================================================================
==15013==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x00000087109c bp 0x7fff76b3e9c0 sp 0x7fff76b3e760 T0)
    #0 0x87109b in BlockBitmapRequester::PullQData(RectangleRequest const*, RectAngle<int> const&) /home/seviezhou/libjpeg/control/blockbitmaprequester.cpp:1100
    #1 0x8742e9 in BlockBitmapRequester::ReconstructRegion(RectAngle<int> const&, RectangleRequest const*) /home/seviezhou/libjpeg/control/blockbitmaprequester.cpp:1249
    #2 0x486b6c in Image::ReconstructRegion(BitMapHook*, RectangleRequest const*) /home/seviezhou/libjpeg/codestream/image.cpp:1111
    #3 0x45f10a in JPEG::InternalDisplayRectangle(JPG_TagItem*) /home/seviezhou/libjpeg/interface/jpeg.cpp:721
    #4 0x45f452 in JPEG::DisplayRectangle(JPG_TagItem*) /home/seviezhou/libjpeg/interface/jpeg.cpp:699
    #5 0x42c573 in Reconstruct(char const*, char const*, int, char const*, bool) /home/seviezhou/libjpeg/cmd/reconstruct.cpp:320
    #6 0x4055f0 in main /home/seviezhou/libjpeg/cmd/main.cpp:718
    #7 0x7f727943883f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2083f)
    #8 0x409da8 in _start (/home/seviezhou/libjpeg/jpeg+0x409da8)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV /home/seviezhou/libjpeg/control/blockbitmaprequester.cpp:1100 BlockBitmapRequester::PullQData(RectangleRequest const*, RectAngle<int> const&)
==15013==ABORTING

POC

SEGV-PullQData-blockbitmaprequester-1100.zip

Question about the Thresholds::InstallDefaults and MAXVAL range in JPEG-LS LSE marker

Hi Thomas Richter,

I have a question about the Thresholds::InstallDefaults(...) method of your library and the text of the JPEG-LS ISO/IEC 14495-1 standard:
Section C.2.4.1.1, Table C.1 of the JPEG-LS standard defines that parameter MAXVAL can be 0 (default) or in the range [1, 2^P>, where P = is the number of bits per image sample.

I would thus assume that MAXVAL can be set to 50 for example when P = 8. Making it possible to create 8 bit images (for compatibility reasons), but use a custom LSE marker to indicate that only values up to 50 are used in the image.

However the method Thresholds::InstallDefaults has as its first parameter bpp, which is internally used to compute bpp and doesn’t allow this flexibility.

What is your opinion about this? Is this range incorrect and is MAXVAL always equal with 2^P -1?

Thanks, Victor

A heap overflow in linebuffer.cpp:322 causes segment fault

System info

Ubuntu X64, gcc (Ubuntu 5.5.0-12ubuntu1), jpeg (latest master e52406)

Command line

./jpeg -oz -h -s 1x1,2x2,2x2 @@ /dev/null

Output

*** Warning -1038 in Tables::ParseTables, line 1384, file tables.cpp
*** Reason is: found invalid marker, probably a marker size is out of range

*** Warning -1038 in Frame::ParseTrailer, line 1083, file frame.cpp
*** Reason is: missing an EOI marker at the end of the stream

*** Warning -1038 in Image::ParseTrailer, line 1464, file image.cpp
*** Reason is: expecting an EOI marker at the end of the stream

Segmentation fault

AddressSanitizer output

=================================================================
==35214==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x611000009fd0 at pc 0x7f06d39ea935 bp 0x7fff3a80bdc0 sp 0x7fff3a80b568
READ of size 32 at 0x611000009fd0 thread T0
    #0 0x7f06d39ea934 in __asan_memcpy (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x8c934)
    #1 0x8583e2 in LineBuffer::FetchRegion(int, Line const*, int*) /home/seviezhou/libjpeg/control/linebuffer.cpp:322
    #2 0x87ef78 in LineBitmapRequester::ReconstructRegion(RectAngle<int> const&, RectangleRequest const*) /home/seviezhou/libjpeg/control/linebitmaprequester.cpp:513
    #3 0x486b6c in Image::ReconstructRegion(BitMapHook*, RectangleRequest const*) /home/seviezhou/libjpeg/codestream/image.cpp:1111
    #4 0x45f10a in JPEG::InternalDisplayRectangle(JPG_TagItem*) /home/seviezhou/libjpeg/interface/jpeg.cpp:721
    #5 0x45f452 in JPEG::DisplayRectangle(JPG_TagItem*) /home/seviezhou/libjpeg/interface/jpeg.cpp:699
    #6 0x42c573 in Reconstruct(char const*, char const*, int, char const*, bool) /home/seviezhou/libjpeg/cmd/reconstruct.cpp:320
    #7 0x4055f0 in main /home/seviezhou/libjpeg/cmd/main.cpp:718
    #8 0x7f06d2ec883f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2083f)
    #9 0x409da8 in _start (/home/seviezhou/libjpeg/jpeg+0x409da8)

0x611000009fd0 is located 0 bytes to the right of 208-byte region [0x611000009f00,0x611000009fd0)
allocated by thread T0 here:
    #0 0x7f06d39f6602 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x98602)
    #1 0x44cadf in Environ::CoreAllocMem(unsigned int, unsigned int) /home/seviezhou/libjpeg/tools/environment.cpp:664
    #2 0x856107 in LineBuffer::StartMCUQuantizerRow(Scan*) /home/seviezhou/libjpeg/control/linebuffer.cpp:227
    #3 0x45c94d in JPEG::ReadInternal(JPG_TagItem*) /home/seviezhou/libjpeg/interface/jpeg.cpp:324
    #4 0x45d5be in JPEG::Read(JPG_TagItem*) /home/seviezhou/libjpeg/interface/jpeg.cpp:210
    #5 0x42adbf in Reconstruct(char const*, char const*, int, char const*, bool) /home/seviezhou/libjpeg/cmd/reconstruct.cpp:121
    #6 0x4055f0 in main /home/seviezhou/libjpeg/cmd/main.cpp:718
    #7 0x7f06d2ec883f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2083f)

SUMMARY: AddressSanitizer: heap-buffer-overflow ??:0 __asan_memcpy
Shadow bytes around the buggy address:
  0x0c227fff93a0: 00 00 00 00 00 00 00 00 00 00 fa fa fa fa fa fa
  0x0c227fff93b0: fa fa fa fa fa fa fa fa 00 00 00 00 00 00 00 00
  0x0c227fff93c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c227fff93d0: 00 00 fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c227fff93e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x0c227fff93f0: 00 00 00 00 00 00 00 00 00 00[fa]fa fa fa fa fa
  0x0c227fff9400: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c227fff9410: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c227fff9420: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c227fff9430: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c227fff9440: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07
  Heap left redzone:       fa
  Heap right redzone:      fb
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack partial redzone:   f4
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
==35214==ABORTING

POC

heap-overflow-FetchRegion-linebuffer-322.zip

A heap overflow in aclosslessscan.cpp:349 causes segment fault

System info

Ubuntu X64, gcc (Ubuntu 5.5.0-12ubuntu1), jpeg (latest master e52406)

Command line

./jpeg -oz -h -s 1x1,2x2,2x2 @@ /dev/null

Output

*** Warning -1038 in Frame::ParseTrailer, line 1083, file frame.cpp
*** Reason is: missing an EOI marker at the end of the stream

*** Warning -1038 in Image::ParseTrailer, line 1464, file image.cpp
*** Reason is: expecting an EOI marker at the end of the stream

Segmentation fault

AddressSanitizer output

=================================================================
==74952==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x61a00001f774 at pc 0x0000004f2c69 bp 0x7ffcf95a51b0 sp 0x7ffcf95a51a0
READ of size 4 at 0x61a00001f774 thread T0
    #0 0x4f2c68 in ACLosslessScan::ParseMCU(Line**, Line**) /home/seviezhou/libjpeg/codestream/aclosslessscan.cpp:349
    #1 0x4f3385 in ACLosslessScan::ParseMCU() /home/seviezhou/libjpeg/codestream/aclosslessscan.cpp:471
    #2 0x45c4b4 in JPEG::ReadInternal(JPG_TagItem*) /home/seviezhou/libjpeg/interface/jpeg.cpp:345
    #3 0x45d5be in JPEG::Read(JPG_TagItem*) /home/seviezhou/libjpeg/interface/jpeg.cpp:210
    #4 0x42adbf in Reconstruct(char const*, char const*, int, char const*, bool) /home/seviezhou/libjpeg/cmd/reconstruct.cpp:121
    #5 0x4055f0 in main /home/seviezhou/libjpeg/cmd/main.cpp:718
    #6 0x7f2ee6e9783f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2083f)
    #7 0x409da8 in _start (/home/seviezhou/libjpeg/jpeg+0x409da8)

0x61a00001f774 is located 0 bytes to the right of 1268-byte region [0x61a00001f280,0x61a00001f774)
allocated by thread T0 here:
    #0 0x7f2ee79c5602 in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.2+0x98602)
    #1 0x44cadf in Environ::CoreAllocMem(unsigned int, unsigned int) /home/seviezhou/libjpeg/tools/environment.cpp:664
    #2 0x4ef428 in ACLosslessScan::FindComponentDimensions() /home/seviezhou/libjpeg/codestream/aclosslessscan.cpp:130
    #3 0x4ef63c in ACLosslessScan::StartParseScan(ByteStream*, Checksum*, BufferCtrl*) /home/seviezhou/libjpeg/codestream/aclosslessscan.cpp:143
    #4 0x533499 in Frame::StartParseScan(ByteStream*, Checksum*) /home/seviezhou/libjpeg/marker/frame.cpp:847
    #5 0x45bec4 in JPEG::ReadInternal(JPG_TagItem*) /home/seviezhou/libjpeg/interface/jpeg.cpp:296
    #6 0x45d5be in JPEG::Read(JPG_TagItem*) /home/seviezhou/libjpeg/interface/jpeg.cpp:210
    #7 0x42adbf in Reconstruct(char const*, char const*, int, char const*, bool) /home/seviezhou/libjpeg/cmd/reconstruct.cpp:121
    #8 0x4055f0 in main /home/seviezhou/libjpeg/cmd/main.cpp:718
    #9 0x7f2ee6e9783f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2083f)

SUMMARY: AddressSanitizer: heap-buffer-overflow /home/seviezhou/libjpeg/codestream/aclosslessscan.cpp:349 ACLosslessScan::ParseMCU(Line**, Line**)
Shadow bytes around the buggy address:
  0x0c347fffbe90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c347fffbea0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c347fffbeb0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c347fffbec0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c347fffbed0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x0c347fffbee0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00[04]fa
  0x0c347fffbef0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c347fffbf00: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c347fffbf10: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c347fffbf20: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c347fffbf30: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07
  Heap left redzone:       fa
  Heap right redzone:      fb
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack partial redzone:   f4
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
==74952==ABORTING

POC

heap-overflow-ParseMCU-aclosslessscan-349.zip

qtable?

Maybe add?:

-qtables FILE Use quantization tables given in FILE.

COPYING file

It might be useful to have a COPYING file at the root of the repository, with the GPL 3 license text.
I had to go hunting into the source code to see how it was licensed.

Possibly invalid decompression for lossless JPEG

Dear Thomas,

I am observing a slightly different behavior in between a well known JPEG-lossless implementation and yours. If you decompress the attached lossless JPEG you'll see a tiny white area (around row 504, col 300). Would you please double check that the decompression as done with libjpeg 1.50 is correct for this input. Thanks.

UnsupportedMarkerType2b

RestartIntervalMarker::ParseMarker cannot handle JPEG-LS DRI segments with 5 or 6 bytes

Current implementation of ParseMarker will throw if len != 4. DRI marker segments are extended for JPEG-LS encoded images:

ISO/IEC 14495-1, C.2.5 Restart interval definition syntax
The restart interval marker segment is specified in Figure B.9 of CCITT Rec. T.81 | ISO/IEC 10918-1. Table B.7 of
CCITT Rec. T.81 | ISO/IEC 10918-1 is modified in this Recommendation | International Standard to allow the segment
length to vary from 4 to 6 bytes. This permits the restart interval to vary from two to four bytes to accommodate the
largest possible number of columns and lines. If the restart interval is a 24- or 32-bit parameter, the convention still
applies that the Most Significant Bit (MSB) shall come first and the Least Significant Bit (LSB) shall come last.

Problem about compress HDR images

I first use the following code:

jpeg -r -q 40 -Q 50 -h -profile c -rR 4 input.pfm outfile.jpg

And here I get the corresponding compressed and tone-mapped LDR image.

I would like to know how to get the corresponding HDR images (in radiance RGBE (.hdr) or OpenEXR (.exr) format)? I try to change the format of the output file,

jpeg -r -q 40 -Q 50 -h -profile c -rR 4 input.pfm outfile.pfm

and convert the output.pfm to hdr image, is it right? Thanks a lot for your help!

install on macOSx

Hi there.
How to install this lib in macOS Sierra 10.12.2?
Thank you.

About Decoding

Dr. Richter
It seems that the libjpeg provide only encoding function,but no decoding reference. Is that true?
If so, where can I find some implementation? I am developing an application of JPEG-XT. Be grateful for your notify.

Assertion fail in blockrow.hpp:93

System info

Ubuntu x86_64, gcc (Ubuntu 5.5.0-12ubuntu1), jpeg (latest master e52406)

Command line

./jpeg -oz -h -s 1x1,2x2,2x2 @@ /dev/null

Output

jpeg: ../coding/blockrow.hpp:93: BlockRow<T>::Block* BlockRow<T>::BlockAt(ULONG) const [with T = int; ULONG = unsigned int]: Assertion `pos < m_ulWidth' failed.
Aborted

POC

assert-fail-BlockA-blockrow-93.zip

SEGV-FetchRegion-LineBuffer322

System info

Ubuntu 16.04 xenial, gcc (Ubuntu 5.5.0-12ubuntu1), jpeg (latest master ea585f)

Command line

./jpeg -oz -h -s 1x1,2x2,2x2 @@ /dev/null

Output

*** Warning -1038 in Tables::ParseTables, line 1384, file tables.cpp
*** Reason is: found invalid marker, probably a marker size is out of range
*** Warning -1038 in Tables::ParseTables, line 1384, file tables.cpp
*** Reason is: found invalid marker, probably a marker size is out of range
*** Warning -1038 in Tables::ParseTables, line 1384, file tables.cpp
*** Reason is: found invalid marker, probably a marker size is out of range
*** Warning -1038 in Tables::ParseTables, line 1384, file tables.cpp
*** Reason is: found invalid marker, probably a marker size is out of range
*** Warning -1038 in Tables::ParseTables, line 1384, file tables.cpp
*** Reason is: found invalid marker, probably a marker size is out of range
*** Warning -1038 in Frame::StartParseHiddenScan, line 869, file frame.cpp
*** Reason is: Start of Scan SOS marker missing
*** Warning -1038 in Frame::ParseTrailer, line 1085, file frame.cpp
*** Reason is: missing an EOI marker at the end of the stream
*** Warning -1038 in Image::ParseTrailer, line 1464, file image.cpp
*** Reason is: expecting an EOI marker at the end of the stream

[1]    4496 segmentation fault  ./jpeg -oz -h -s 1x1,2x2,2x2  /dev/null

AddressSanitizer output

Program received signal SIGSEGV, Segmentation fault.
0x0000000000548f67 in LineBuffer::FetchRegion (this=0x7d1510, x=0, line=0x0, buffer=0x7fffffffd2d0) at linebuffer.cpp:322
322         memcpy(buffer,line->m_pData + (x << 3),8 * sizeof(LONG));
(gdb) bt
#0  0x0000000000548f67 in LineBuffer::FetchRegion (this=0x7d1510, x=0, line=0x0, buffer=0x7fffffffd2d0) at linebuffer.cpp:322
#1  0x000000000055050a in LineBitmapRequester::ReconstructRegion (this=0x7d1510, orgregion=..., rr=0x7fffffffd480) at linebitmaprequester.cpp:476
#2  0x0000000000421892 in Image::ReconstructRegion (this=0x7d1160, bmh=0x7fffffffd4a0, rr=0x7fffffffd480) at image.cpp:1111
#3  0x0000000000416c7f in JPEG::InternalDisplayRectangle (this=0x7cf278, tags=0x7fffffffdb20) at jpeg.cpp:721
#4  0x0000000000416b72 in JPEG::DisplayRectangle (this=0x7cf278, tags=0x7fffffffdb20) at jpeg.cpp:699
#5  0x000000000040c689 in Reconstruct (infile=0x7fffffffe43d "SEGV-FetchRegion-LineBuffer322", outfile=0x7fffffffe4b5 "/dev/null", colortrafo=1, alpha=0x0,
upsample=true) at reconstruct.cpp:320
#6  0x000000000040308c in main (argc=3, argv=0x7fffffffe168) at main.cpp:718

POC

SEGV-FetchRegion-LineBuffer322.zip

Segmentation fault in refinementscan.cpp:644

System info

Ubuntu x86_64, gcc (Ubuntu 5.5.0-12ubuntu1), jpeg (latest master e52406)

Command line

./jpeg -oz -h -s 1x1,2x2,2x2 @@ /dev/null

AddressSanitizer output

ASAN:SIGSEGV
=================================================================
==12664==ERROR: AddressSanitizer: SEGV on unknown address 0x0000000001d2 (pc 0x0000004a33fc bp 0x7ffed315df90 sp 0x7ffed315df70 T0)
    #0 0x4a33fb in HuffmanDecoder::Get(BitStream<false>*) ../coding/huffmandecoder.hpp:112
    #1 0x4fdeaa in RefinementScan::DecodeBlock(int*, HuffmanDecoder*, unsigned short&) /home/seviezhou/libjpeg/codestream/refinementscan.cpp:644
    #2 0x4ff7fc in RefinementScan::ParseMCU() /home/seviezhou/libjpeg/codestream/refinementscan.cpp:314
    #3 0x45c4b4 in JPEG::ReadInternal(JPG_TagItem*) /home/seviezhou/libjpeg/interface/jpeg.cpp:345
    #4 0x45d5be in JPEG::Read(JPG_TagItem*) /home/seviezhou/libjpeg/interface/jpeg.cpp:210
    #5 0x42adbf in Reconstruct(char const*, char const*, int, char const*, bool) /home/seviezhou/libjpeg/cmd/reconstruct.cpp:121
    #6 0x4055f0 in main /home/seviezhou/libjpeg/cmd/main.cpp:718
    #7 0x7fd6ee82983f in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2083f)
    #8 0x409da8 in _start (/home/seviezhou/libjpeg/jpeg+0x409da8)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV ../coding/huffmandecoder.hpp:112 HuffmanDecoder::Get(BitStream<false>*)
==12664==ABORTING

POC

SEGV-DecodeBlock-refinementscan-644.zip

Add cmake build tool

Migrating to CMake could help to build and install libjpeg on MSVC 15.x as simple as on gcc and you could remove any MSVS solution files (and autotools also)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.