Opened 7 months ago

Last modified 7 months ago

#9468 reopened defect

J2K is decoding rgb24 as bgr24 in native decoder

Reported by: Balling Owned by:
Priority: normal Component: avcodec
Version: git-master Keywords: j2k
Cc: Blocked By:
Blocking: Reproduced by developer: yes
Analyzed by developer: no

Description (last modified by Balling)

Summary of the bug:

JPEG2000 file from ePassport is tagged as EnumCS 16 (sRGB) and has thus rgb24 data inside https://github.com/uclouvain/openjpeg/issues/1382, yet native decoder (ffplay -vcodec jpeg2000) decodes it incorrectly while ffplay -vcodec libopenjpeg decodes it correctly (says it is rgb24). Same happens in ffmpeg, "the application", of course, -c:v libopenjpeg is good. I will also point out that ffmpeg.exe -pixel_format bgr24 -c:v jpeg2000 is bit perfect with libopenjpeg, so SHOULD be very simple fix.
How to reproduce (my ffmpeg defaults to jpeg2000):

ffmpeg.exe -i dg2img-3f096fe9d00296bc3734ac4f01b5bf60.j2k outfile.png
ffmpeg version N-104341-g933765aa0e-20211013 Copyright (c) 2000-2021 the FFmpeg developers
  built with gcc 10-win32 (GCC) 20210408
  configuration: --prefix=/ffbuild/prefix --pkg-config-flags=--static --pkg-config=pkg-config --cross-prefix=x86_64-w64-mingw32- --arch=x86_64 --target-os=mingw32 --enable-gpl --enable-version3 --disable-debug --enable-shared --disable-static --disable-w32threads --enable-pthreads --enable-iconv --enable-libxml2 --enable-zlib --enable-libfreetype --enable-libfribidi --enable-gmp --enable-lzma --enable-fontconfig --enable-libvorbis --enable-opencl --enable-libvmaf --enable-vulkan --disable-libxcb --disable-xlib --enable-amf --enable-libaom --enable-avisynth --enable-libdav1d --enable-libdavs2 --disable-libfdk-aac --enable-ffnvcodec --enable-cuda-llvm --enable-frei0r --enable-libglslang --enable-libgme --enable-libass --enable-libbluray --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvpx --enable-libwebp --enable-lv2 --enable-libmfx --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librav1e --enable-librubberband --enable-schannel --enable-sdl2 --enable-libsoxr --enable-libsrt --enable-libsvtav1 --enable-libtwolame --enable-libuavs3d --disable-libdrm --disable-vaapi --enable-libvidstab --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libzimg --enable-libzvbi --extra-cflags=-DLIBTWOLAME_STATIC --extra-cxxflags= --extra-ldflags=-pthread --extra-ldexeflags= --extra-libs=-lgomp --extra-version=20211013
  libavutil      57.  7.100 / 57.  7.100
  libavcodec     59. 12.100 / 59. 12.100
  libavformat    59.  6.100 / 59.  6.100
  libavdevice    59.  0.101 / 59.  0.101
  libavfilter     8. 14.100 /  8. 14.100
  libswscale      6.  1.100 /  6.  1.100
  libswresample   4.  0.100 /  4.  0.100
  libpostproc    56.  0.100 / 56.  0.100
[jpeg2000 @ 0000021e61c1e840] End mismatch 1
[jpeg2000 @ 0000021e61c1e840] End mismatch 15
[jpeg2000 @ 0000021e61c1e840] End mismatch 24
[jpeg2000 @ 0000021e61c1e840] End mismatch 34
[jpeg2000 @ 0000021e61c1e840] End mismatch 16
[jpeg2000 @ 0000021e61c1e840] End mismatch 18
[jpeg2000 @ 0000021e61c1e840] End mismatch 10
[jpeg2000 @ 0000021e61c1e840] End mismatch 1
[jpeg2000 @ 0000021e61c1e840] End mismatch 7
[jpeg2000 @ 0000021e61c1e840] End mismatch 5
[jpeg2000 @ 0000021e61c1e840] End mismatch 10
    Last message repeated 1 times
[jpeg2000 @ 0000021e61c1e840] End mismatch 2
[jpeg2000 @ 0000021e61c1e840] End mismatch 1
[jpeg2000 @ 0000021e61c1e840] End mismatch 5
[jpeg2000 @ 0000021e61c1e840] End mismatch 2
[jpeg2000 @ 0000021e61c1e840] End mismatch 1
Input #0, j2k_pipe, from 'dg2img-3f096fe9d00296bc3734ac4f01b5bf60.j2k':
  Duration: N/A, bitrate: N/A
  Stream #0:0: Video: jpeg2000, rgb24, 413x531, lossless, 25 fps, 25 tbr, 25 tbn
Stream mapping:
  Stream #0:0 -> #0:0 (jpeg2000 (native) -> png (native))
Press [q] to stop, [?] for help
[jpeg2000 @ 0000021e61ee52c0] End mismatch 1
[jpeg2000 @ 0000021e61ee52c0] End mismatch 15
[jpeg2000 @ 0000021e61ee52c0] End mismatch 24
[jpeg2000 @ 0000021e61ee52c0] End mismatch 34
[jpeg2000 @ 0000021e61ee52c0] End mismatch 16
[jpeg2000 @ 0000021e61ee52c0] End mismatch 18
[jpeg2000 @ 0000021e61ee52c0] End mismatch 10
[jpeg2000 @ 0000021e61ee52c0] End mismatch 1
[jpeg2000 @ 0000021e61ee52c0] End mismatch 7
[jpeg2000 @ 0000021e61ee52c0] End mismatch 5
[jpeg2000 @ 0000021e61ee52c0] End mismatch 10
    Last message repeated 1 times
[jpeg2000 @ 0000021e61ee52c0] End mismatch 2
[jpeg2000 @ 0000021e61ee52c0] End mismatch 1
[jpeg2000 @ 0000021e61ee52c0] End mismatch 5
[jpeg2000 @ 0000021e61ee52c0] End mismatch 2
[jpeg2000 @ 0000021e61ee52c0] End mismatch 1
Output #0, image2, to 'outfile.png':
  Metadata:
    encoder         : Lavf59.6.100
  Stream #0:0: Video: png, rgb24(progressive), 413x531, q=2-31, 200 kb/s, 25 fps, 25 tbn
    Metadata:
      encoder         : Lavc59.12.100 png
frame=    1 fps=0.0 q=-0.0 Lsize=N/A time=00:00:00.04 bitrate=N/A speed=0.934x
video:324kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown

Patches should be submitted to the ffmpeg-devel mailing list and not this bug tracker.

Attachments (1)

dg2img-3f096fe9d00296bc3734ac4f01b5bf60.j2k (14.1 KB ) - added by Balling 7 months ago.

Download all attachments as: .zip

Change History (3)

comment:1 by Elon Musk, 7 months ago

Resolution: invalid
Status: newclosed

NO samples, closing.

comment:2 by Balling, 7 months ago

Description: modified (diff)
Resolution: invalid
Status: closedreopened

Sample attached.

Note: See TracTickets for help on using tickets.