Opened 2 years ago
Last modified 20 months ago
#10058 open defect
jpeg2000: support paletted images
Reported by: | ami_stuff | Owned by: | |
---|---|---|---|
Priority: | important | Component: | avcodec |
Version: | git-master | Keywords: | j2k regression |
Cc: | Blocked By: | ||
Blocking: | Reproduced by developer: | yes | |
Analyzed by developer: | no |
Description
https://github.com/openpreserve/jpylyzer-test-files/raw/master/palettedImage.jp2
openjpeg decodes it with palette
there are also some other unsupported jpeg2000 files marked as valid here:
https://github.com/openpreserve/jpylyzer-test-files
./ffmpeg -i palettedImage.jp2 -y out.bmp ffmpeg version N-109101-g822da7a317 Copyright (c) 2000-2022 the FFmpeg developers built with gcc 9 (Ubuntu 9.4.0-1ubuntu1~20.04.1) configuration: libavutil 57. 42.100 / 57. 42.100 libavcodec 59. 52.102 / 59. 52.102 libavformat 59. 34.101 / 59. 34.101 libavdevice 59. 8.101 / 59. 8.101 libavfilter 8. 50.100 / 8. 50.100 libswscale 6. 8.112 / 6. 8.112 libswresample 4. 9.100 / 4. 9.100 [jpeg2000 @ 0x5647e8d3cd40] SOC marker not present Input #0, j2k_pipe, from 'palettedImage.jp2': Duration: N/A, bitrate: N/A Stream #0:0: Video: jpeg2000, pal8, 1024x1024, 25 fps, 25 tbr, 25 tbn Stream mapping: Stream #0:0 -> #0:0 (jpeg2000 (native) -> bmp (native)) Press [q] to stop, [?] for help [jpeg2000 @ 0x5647e8d4f640] SOC marker not present Error while decoding stream #0:0: Invalid data found when processing input [jpeg2000 @ 0x5647e8d50bc0] Progression order RPCL Output #0, image2, to 'out.bmp': Metadata: encoder : Lavf59.34.101 Stream #0:0: Video: bmp, gray(progressive), 1024x1024, q=2-31, 200 kb/s, 25 fps, 25 tbn Metadata: encoder : Lavc59.52.102 bmp frame= 0 fps=0.0 q=-0.0 size= 0kB time=00:00:00.04 bitrate= 0.0kbits/[image2 @ 0x5647e8d3e0c0] The specified filename 'out.bmp' does not contain an image sequence pattern or a pattern is invalid. [image2 @ 0x5647e8d3e0c0] Use a pattern such as %03d for an image sequence or use the -update option (with -frames:v 1 if needed) to write a single image. frame= 1 fps=0.0 q=-0.0 Lsize=N/A time=00:00:00.04 bitrate=N/A speed=0.322x video:1025kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
Change History (13)
follow-ups: 2 3 comment:1 by , 2 years ago
follow-up: 5 comment:2 by , 2 years ago
Replying to Balling:
openjpeg decodes it with palette
No, it does not.
ffplay -i palettedImage.jp2 -vcodec libopenjpeg
while
ffplay -i palettedImage.jp2 -vcodec jpeg2000
works.
something really strange happens here
with the ffmpeg from my system I get color output:
ffmpeg -vcodec jpeg2000 -i 'palettedImage.jp2' -pix_fmt bgr24 -y out.bmp ffmpeg version 4.2.7-0ubuntu0.1 Copyright (c) 2000-2022 the FFmpeg developers built with gcc 9 (Ubuntu 9.4.0-1ubuntu1~20.04.1) configuration: --prefix=/usr --extra-version=0ubuntu0.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-nvenc --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared WARNING: library configuration mismatch avcodec configuration: --prefix=/usr --extra-version=0ubuntu0.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-nvenc --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared --enable-version3 --disable-doc --disable-programs --enable-libaribb24 --enable-liblensfun --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libtesseract --enable-libvo_amrwbenc libavutil 56. 31.100 / 56. 31.100 libavcodec 58. 54.100 / 58. 54.100 libavformat 58. 29.100 / 58. 29.100 libavdevice 58. 8.100 / 58. 8.100 libavfilter 7. 57.100 / 7. 57.100 libavresample 4. 0. 0 / 4. 0. 0 libswscale 5. 5.100 / 5. 5.100 libswresample 3. 5.100 / 3. 5.100 libpostproc 55. 5.100 / 55. 5.100 [jpeg2000 @ 0x5623cbbd2700] Progression order RPCL Input #0, j2k_pipe, from 'palettedImage.jp2': Duration: N/A, bitrate: N/A Stream #0:0: Video: jpeg2000, pal8, 1024x1024, 25 tbr, 25 tbn, 25 tbc Stream mapping: Stream #0:0 -> #0:0 (jpeg2000 (native) -> bmp (native)) Press [q] to stop, [?] for help [jpeg2000 @ 0x5623cbc1c640] Progression order RPCL Output #0, image2, to 'out.bmp': Metadata: encoder : Lavf58.29.100 Stream #0:0: Video: bmp, bgr24, 1024x1024, q=2-31, 200 kb/s, 25 fps, 25 tbn, 25 tbc Metadata: encoder : Lavc58.54.100 bmp frame= 1 fps=0.0 q=-0.0 Lsize=N/A time=00:00:00.04 bitrate=N/A speed=0.317x video:3072kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
VFS..D jpeg2000 JPEG 2000 VF...D libopenjpeg OpenJPEG JPEG 2000 (codec jpeg2000)
but with my own build I get only grayscale output:
./ffmpeg -vcodec jpeg2000 -i palettedImage.jp2 -pix_fmt bgr24 -y out.bmp ffmpeg version N-109101-g822da7a317 Copyright (c) 2000-2022 the FFmpeg developers built with gcc 9 (Ubuntu 9.4.0-1ubuntu1~20.04.1) configuration: libavutil 57. 42.100 / 57. 42.100 libavcodec 59. 52.102 / 59. 52.102 libavformat 59. 34.101 / 59. 34.101 libavdevice 59. 8.101 / 59. 8.101 libavfilter 8. 50.100 / 8. 50.100 libswscale 6. 8.112 / 6. 8.112 libswresample 4. 9.100 / 4. 9.100 [jpeg2000 @ 0x55770e74bdc0] SOC marker not present Input #0, j2k_pipe, from 'palettedImage.jp2': Duration: N/A, bitrate: N/A Stream #0:0: Video: jpeg2000, pal8, 1024x1024, 25 fps, 25 tbr, 25 tbn Stream mapping: Stream #0:0 -> #0:0 (jpeg2000 (native) -> bmp (native)) Press [q] to stop, [?] for help [jpeg2000 @ 0x55770e75e940] SOC marker not present Error while decoding stream #0:0: Invalid data found when processing input [jpeg2000 @ 0x55770e75fec0] Progression order RPCL Output #0, image2, to 'out.bmp': Metadata: encoder : Lavf59.34.101 Stream #0:0: Video: bmp, bgr24(pc, gbr/unknown/unknown, progressive), 1024x1024, q=2-31, 200 kb/s, 25 fps, 25 tbn Metadata: encoder : Lavc59.52.102 bmp frame= 0 fps=0.0 q=-0.0 size= 0kB time=00:00:00.04 bitrate= 0.0kbits/[image2 @ 0x55770e74d340] The specified filename 'out.bmp' does not contain an image sequence pattern or a pattern is invalid. [image2 @ 0x55770e74d340] Use a pattern such as %03d for an image sequence or use the -update option (with -frames:v 1 if needed) to write a single image. frame= 1 fps=0.0 q=-0.0 Lsize=N/A time=00:00:00.04 bitrate=N/A speed=0.306x video:3072kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
My own build has no openjpeg support.
And if that's not enough, the ffmpeg from my system crashes when I force usage of libopenjpeg:
ffmpeg -vcodec libopenjpeg -i 'palettedImage.jp2' -pix_fmt bgr24 -y out.bmp ffmpeg version 4.2.7-0ubuntu0.1 Copyright (c) 2000-2022 the FFmpeg developers built with gcc 9 (Ubuntu 9.4.0-1ubuntu1~20.04.1) configuration: --prefix=/usr --extra-version=0ubuntu0.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-nvenc --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared WARNING: library configuration mismatch avcodec configuration: --prefix=/usr --extra-version=0ubuntu0.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-nvenc --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared --enable-version3 --disable-doc --disable-programs --enable-libaribb24 --enable-liblensfun --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libtesseract --enable-libvo_amrwbenc libavutil 56. 31.100 / 56. 31.100 libavcodec 58. 54.100 / 58. 54.100 libavformat 58. 29.100 / 58. 29.100 libavdevice 58. 8.100 / 58. 8.100 libavfilter 7. 57.100 / 7. 57.100 libavresample 4. 0. 0 / 4. 0. 0 libswscale 5. 5.100 / 5. 5.100 libswresample 3. 5.100 / 3. 5.100 libpostproc 55. 5.100 / 55. 5.100 Input #0, j2k_pipe, from 'palettedImage.jp2': Duration: N/A, bitrate: N/A Stream #0:0: Video: jpeg2000, gray, 1024x1024, 25 tbr, 25 tbn, 25 tbc Stream mapping: Stream #0:0 -> #0:0 (jpeg2000 (libopenjpeg) -> bmp (native)) Press [q] to stop, [?] for help free(): invalid pointer
==20017== Invalid write of size 1 ==20017== at 0x53912C8: ??? (in /usr/lib/x86_64-linux-gnu/libavcodec.so.58.54.100) ==20017== by 0x50F12BF: ??? (in /usr/lib/x86_64-linux-gnu/libavcodec.so.58.54.100) ==20017== by 0x50F1FC7: avcodec_send_packet (in /usr/lib/x86_64-linux-gnu/libavcodec.so.58.54.100) ==20017== by 0x4DC9F22: ??? (in /usr/lib/x86_64-linux-gnu/libavformat.so.58.29.100) ==20017== by 0x4DD2BEF: avformat_find_stream_info (in /usr/lib/x86_64-linux-gnu/libavformat.so.58.29.100) ==20017== by 0x11D3E3: ??? (in /usr/bin/ffmpeg) ==20017== by 0x11EFC3: ??? (in /usr/bin/ffmpeg) ==20017== by 0x115DD7: main (in /usr/bin/ffmpeg) ==20017== Address 0x11d1b28f is 0 bytes after a block of size 1,048,655 alloc'd ==20017== at 0x483E0F0: memalign (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so) ==20017== by 0x483E212: posix_memalign (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so) ==20017== by 0x6598FFC: av_malloc (in /usr/lib/x86_64-linux-gnu/libavutil.so.56.31.100) ==20017== by 0x65773AC: av_buffer_alloc (in /usr/lib/x86_64-linux-gnu/libavutil.so.56.31.100) ==20017== by 0x6577431: av_buffer_allocz (in /usr/lib/x86_64-linux-gnu/libavutil.so.56.31.100) ==20017== by 0x6577BBC: av_buffer_pool_get (in /usr/lib/x86_64-linux-gnu/libavutil.so.56.31.100) ==20017== by 0x50F36BB: avcodec_default_get_buffer2 (in /usr/lib/x86_64-linux-gnu/libavcodec.so.58.54.100) ==20017== by 0x50F3F5A: ??? (in /usr/lib/x86_64-linux-gnu/libavcodec.so.58.54.100) ==20017== by 0x54BB197: ??? (in /usr/lib/x86_64-linux-gnu/libavcodec.so.58.54.100) ==20017== by 0x5390D80: ??? (in /usr/lib/x86_64-linux-gnu/libavcodec.so.58.54.100) ==20017== by 0x50F12BF: ??? (in /usr/lib/x86_64-linux-gnu/libavcodec.so.58.54.100) ==20017== by 0x50F1FC7: avcodec_send_packet (in /usr/lib/x86_64-linux-gnu/libavcodec.so.58.54.100) ==20017== ==20017== Invalid read of size 4 ==20017== at 0x6577505: av_buffer_unref (in /usr/lib/x86_64-linux-gnu/libavutil.so.56.31.100) ==20017== by 0x6583A1B: av_frame_unref (in /usr/lib/x86_64-linux-gnu/libavutil.so.56.31.100) ==20017== by 0x6583BAD: av_frame_free (in /usr/lib/x86_64-linux-gnu/libavutil.so.56.31.100) ==20017== by 0x4DC9EE5: ??? (in /usr/lib/x86_64-linux-gnu/libavformat.so.58.29.100) ==20017== by 0x4DD2BEF: avformat_find_stream_info (in /usr/lib/x86_64-linux-gnu/libavformat.so.58.29.100) ==20017== by 0x11D3E3: ??? (in /usr/bin/ffmpeg) ==20017== by 0x11EFC3: ??? (in /usr/bin/ffmpeg) ==20017== by 0x115DD7: main (in /usr/bin/ffmpeg) ==20017== Address 0x121a000f15000b1b is not stack'd, malloc'd or (recently) free'd ==20017== ==20017== ==20017== Process terminating with default action of signal 11 (SIGSEGV)
comment:3 by , 2 years ago
Replying to Balling:
openjpeg decodes it with palette
No, it does not.
ffplay -i palettedImage.jp2 -vcodec libopenjpeg
while
ffplay -i palettedImage.jp2 -vcodec jpeg2000
works.
Do you get color output with this build:
https://github.com/BtbN/FFmpeg-Builds/releases
?
It looks like regression for me, I get grayscale output with -vcodec libopenjpeg and -vcodec jpeg2000.
comment:4 by , 2 years ago
Status: | new → open |
---|
Do you get color output with this build:
No. Yes, with openjpeg: opj_decompress.exe -i palettedImage.jp2 -o dfadf.png
the picture is yellow.
follow-up: 6 comment:5 by , 2 years ago
the crash is reproducible with this build:
https://www.johnvansickle.com/ffmpeg/old-releases/ffmpeg-4.2.2-arm64-static.tar.xz
so there are at least three bugs here:
- regression in native jpeg2000 decoder for paletted images
- crash in ffmpeg 4.2.7 with forced libopenjpeg
- ffmpeg's libopenjpeg decoder should support decoding of paletted images
follow-up: 7 comment:6 by , 2 years ago
Replying to ami_stuff:
the crash is reproducible with this build:
https://www.johnvansickle.com/ffmpeg/old-releases/ffmpeg-4.2.2-arm64-static.tar.xz
so there are at least three bugs here:
- regression in native jpeg2000 decoder for paletted images
Which FFmpeg version works correctly with the native decoder?
- crash in ffmpeg 4.2.7 with forced libopenjpeg
But not with current FFmpeg git head?
- ffmpeg's libopenjpeg decoder should support decoding of paletted images
That was not supported by libopenjpeg when I looked last time.
follow-up: 10 comment:7 by , 2 years ago
Replying to Carl Eugen Hoyos:
Replying to ami_stuff:
the crash is reproducible with this build:
https://www.johnvansickle.com/ffmpeg/old-releases/ffmpeg-4.2.2-arm64-static.tar.xz
so there are at least three bugs here:
- regression in native jpeg2000 decoder for paletted images
Which FFmpeg version works correctly with the native decoder?
4.2.7 and 4.2.2, more I didn't test.
- crash in ffmpeg 4.2.7 with forced libopenjpeg
But not with current FFmpeg git head?
That's correct, can't reproduce it with git head. But some distros are giving their users outdated ffmpeg versions, so it would be nice to fix it.
- ffmpeg's libopenjpeg decoder should support decoding of paletted images
That was not supported by libopenjpeg when I looked last time.
comment:8 by , 2 years ago
Component: | undetermined → avcodec |
---|---|
Keywords: | j2k regression added |
Priority: | normal → important |
Reproduced by developer: | set |
Version: | unspecified → git-master |
Regression since d09c35677defb383f69395cef84a5e20c41da6d2, work-around is to force the image2 demuxer.
comment:10 by , 2 years ago
Replying to ami_stuff:
Replying to Carl Eugen Hoyos:
Replying to ami_stuff:
the crash is reproducible with this build:
https://www.johnvansickle.com/ffmpeg/old-releases/ffmpeg-4.2.2-arm64-static.tar.xz
- crash in ffmpeg 4.2.7 with forced libopenjpeg
But not with current FFmpeg git head?
That's correct, can't reproduce it with git head.
I was wrong, see ticket #10061.
comment:11 by , 2 years ago
ffmpeg -c:v jpeg2000 -f image2 -i palettedImage.jp2 out2123.bmp
produces some off-by-two differences with opj_decompress.exe. Strange, it is lossless, right?
E.g. 28, 20, 0 (opj_decompress.exe) vs 30, 21, 0 (jpeg2000).
comment:12 by , 21 months ago
comment:13 by , 20 months ago
Genius Michael Niedermayer removed libopenjpeg decoder whatsover. WTF. Encoder is still there, but... 60ccb3fe787be3bb10fc4545b3593cd1e0b769ed
No, it does not.
ffplay -i palettedImage.jp2 -vcodec libopenjpeg
while
ffplay -i palettedImage.jp2 -vcodec jpeg2000
works.