Opened 10 years ago

Closed 10 years ago

#1179 closed defect (fixed)

libopenjpeg: encoded as rgb48, decodes as yuv444p16le

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

Description

the output jp2 file decodes correctly with IrfanView, so the problem is probably in libopenjpeg's decoder

C:\>ffmpeg -i test.bmp -vcodec libopenjpeg -pix_fmt rgb48 out.jp2
ffmpeg version N-39267-g4082198 Copyright (c) 2000-2012 the FFmpeg developers
  built on Mar 25 2012 20:25:08 with gcc 4.6.2
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-ru
ntime-cpudetect --enable-avisynth --enable-bzlib --enable-frei0r --enable-libope
ncore-amrnb --enable-libopencore-amrwb --enable-libfreetype --enable-libgsm --en
able-libmp3lame --enable-libopenjpeg --enable-librtmp --enable-libschroedinger -
-enable-libspeex --enable-libtheora --enable-libvo-aacenc --enable-libvo-amrwben
c --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-
libxvid --enable-zlib
  libavutil      51. 44.100 / 51. 44.100
  libavcodec     54. 12.100 / 54. 12.100
  libavformat    54.  3.100 / 54.  3.100
  libavdevice    53.  4.100 / 53.  4.100
  libavfilter     2. 65.102 /  2. 65.102
  libswscale      2.  1.100 /  2.  1.100
  libswresample   0. 10.100 /  0. 10.100
  libpostproc    52.  0.100 / 52.  0.100
Input #0, image2, from 'test.bmp':
  Duration: 00:00:00.04, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: bmp, bgr24, 1024x768, 25 tbr, 25 tbn, 25 tbc
[buffer @ 02191D60] w:1024 h:768 pixfmt:bgr24 tb:1/1000000 sar:0/1 sws_param:
[buffersink @ 02191120] auto-inserting filter 'auto-inserted scale 0' between th
e filter 'src' and the filter 'out'
[scale @ 02191580] w:1024 h:768 fmt:bgr24 sar:0/1 -> w:1024 h:768 fmt:rgb48le sa
r:0/1 flags:0x4
Output #0, image2, to 'out.jp2':
  Metadata:
    encoder         : Lavf54.3.100
    Stream #0:0: Video: j2k, rgb48le, 1024x768, q=2-31, 200 kb/s, 90k tbn, 25 tb
c
Stream mapping:
  Stream #0:0 -> #0:0 (bmp -> libopenjpeg)
Press [q] to stop, [?] for help
frame=    1 fps=0.3 q=0.0 Lsize=       0kB time=00:00:00.04 bitrate=   0.0kbits/
s
video:3506kB audio:0kB global headers:0kB muxing overhead -100.000000%
C:\>ffmpeg -i out.jp2
ffmpeg version N-39267-g4082198 Copyright (c) 2000-2012 the FFmpeg developers
  built on Mar 25 2012 20:25:08 with gcc 4.6.2
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-ru
ntime-cpudetect --enable-avisynth --enable-bzlib --enable-frei0r --enable-libope
ncore-amrnb --enable-libopencore-amrwb --enable-libfreetype --enable-libgsm --en
able-libmp3lame --enable-libopenjpeg --enable-librtmp --enable-libschroedinger -
-enable-libspeex --enable-libtheora --enable-libvo-aacenc --enable-libvo-amrwben
c --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-
libxvid --enable-zlib
  libavutil      51. 44.100 / 51. 44.100
  libavcodec     54. 12.100 / 54. 12.100
  libavformat    54.  3.100 / 54.  3.100
  libavdevice    53.  4.100 / 53.  4.100
  libavfilter     2. 65.102 /  2. 65.102
  libswscale      2.  1.100 /  2.  1.100
  libswresample   0. 10.100 /  0. 10.100
  libpostproc    52.  0.100 / 52.  0.100
Input #0, image2, from 'out.jp2':
  Duration: 00:00:00.04, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: j2k, yuv444p16le, 1024x768, 25 tbr, 25 tbn, 25 tbc
At least one output file must be specified

Attachments (1)

Test.BMP (2.3 MB ) - added by ami_stuff 10 years ago.

Change History (7)

by ami_stuff, 10 years ago

Attachment: Test.BMP added

comment:1 by ami_stuff, 10 years ago

-pix_fmt yuv444p out.jp2 -> out.jp2 is identified as rgb24

comment:2 by Carl Eugen Hoyos, 10 years ago

Component: undeterminedavcodec
Keywords: libopenjpeg added
Version: unspecifiedgit-master

Does IrfanView show pictures encoded with -pix_fmt yuv444p16 correctly?
Or both rgb24 and yuv444p?
I suspect this ticket cannot be fixed / there will always be an incorrectly decoded image, see also http://thread.gmane.org/gmane.comp.video.ffmpeg.devel/137075/focus=137086

comment:3 by ami_stuff, 10 years ago

Does IrfanView show pictures encoded with -pix_fmt yuv444p16 correctly?

no, this one decodes incorrectly

Or both rgb24 and yuv444p?

these looks ok

in reply to:  3 comment:4 by Carl Eugen Hoyos, 10 years ago

Reproduced by developer: set
Status: newopen

Both outrgb.jp2 and outyuv.jp2 decode correctly with OSX Picture Viewer and jasper, outyuv.jp2 fails with FFmpeg and ImageMagick. Old j2k_to_image (libopenjpeg) failed for outyuv.jp2, current openjpeg svn works fine for both files.
$ ffmpeg -i tests/lena.pnm -pix_fmt rgb24 outrgb.jp2
$ ffmpeg -i tests/lena.pnm -pix_fmt yuv444p outyuv.jp2

comment:5 by mbradshaw, 10 years ago

This can be corrected in some cases, actually. Paul's patch from March (commit 67d5fcc989a0ee3cc3b3a89e643ee7f099ca6229) adds support for using the JP2 format (and makes this default). If frames are saved in the JP2 format, the color space will be saved as well. If frames are saved in the J2K format, the color space will not be saved and must be guessed. OpenJPEG's opj_image structure has a color_space member identifying it as either unknown/unspecified (which it will be for J2K frames), RGB, gray, or YUV (it should be one of the last three for JP2 frames).

comment:6 by Carl Eugen Hoyos, 10 years ago

Resolution: fixed
Status: openclosed

Fixed by Michael Bradshaw.

Note: See TracTickets for help on using tickets.