Opened 4 years ago

Last modified 3 years ago

#4653 open defect

jpeg2000: -M 1 mode is not lossless (compared to openjpeg)

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

Description

C:\>opj_compress.exe -i test.bmp -M 1 -o lossless_m4.jp2

[INFO] tile number 1 / 1
[INFO] Generated outfile lossless_m1.jp2
C:\>ffmpeg -i lossless_m1.jp2 out.bmp
ffmpeg version 2.6.git Copyright (c) 2000-2015 the FFmpeg developers
  built with gcc 4.6.2 (GCC)
  configuration: --disable-pthreads --enable-gpl --disable-ffprobe
  libavutil      54. 27.100 / 54. 27.100
  libavcodec     56. 41.100 / 56. 41.100
  libavformat    56. 37.100 / 56. 37.100
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 17.100 /  5. 17.100
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  2.100 /  1.  2.100
  libpostproc    53.  3.100 / 53.  3.100
[jpeg2000 @ 0229f700] Warning: not compiled with thread support, using thread em
ulation
[jpeg2000 @ 0229f700] extra cblk styles 1
[jpeg2000 @ 0229f700] Selective arithmetic coding bypass
[jpeg2000 @ 0229f700] End mismatch 1
    Last message repeated 27 times
[jpeg2000 @ 0229f700] End mismatch 2
[jpeg2000 @ 0229f700] End mismatch 1
    Last message repeated 21 times
[jpeg2000 @ 0229f700] End mismatch 2
[jpeg2000 @ 0229f700] End mismatch 1
[jpeg2000 @ 0229f700] End mismatch 2
    Last message repeated 1 times
[jpeg2000 @ 0229f700] End mismatch 1
[jpeg2000 @ 0229f700] End mismatch 2
[jpeg2000 @ 0229f700] End mismatch 9
[jpeg2000 @ 0229f700] End mismatch 2
[jpeg2000 @ 0229f700] End mismatch 5
[jpeg2000 @ 0229f700] End mismatch 6
[jpeg2000 @ 0229f700] End mismatch 19
[jpeg2000 @ 0229f700] End mismatch 1
[jpeg2000 @ 0229f700] End mismatch 20
[jpeg2000 @ 0229f700] End mismatch 7
[jpeg2000 @ 0229f700] End mismatch 3
[jpeg2000 @ 0229f700] End mismatch 1
[jpeg2000 @ 0229f700] End mismatch 6
[jpeg2000 @ 0229f700] End mismatch 10
[jpeg2000 @ 0229f700] End mismatch 5
[jpeg2000 @ 0229f700] End mismatch 1
[jpeg2000 @ 0229f700] End mismatch 4
[jpeg2000 @ 0229f700] End mismatch 12
[jpeg2000 @ 0229f700] End mismatch 10
[jpeg2000 @ 0229f700] End mismatch 1
[jpeg2000 @ 0229f700] End mismatch 2
[jpeg2000 @ 0229f700] End mismatch 29
[jpeg2000 @ 0229f700] End mismatch 12
[jpeg2000 @ 0229f700] End mismatch 2
[jpeg2000 @ 0229f700] End mismatch 24
[jpeg2000 @ 0229f700] End mismatch 13
[jpeg2000 @ 0229f700] End mismatch 1
[jpeg2000 @ 0229f700] End mismatch 8
[jpeg2000 @ 0229f700] End mismatch 2
    Last message repeated 1 times
[jpeg2000 @ 0229f700] End mismatch 3
[jpeg2000 @ 0229f700] End mismatch 2
[jpeg2000 @ 0229f700] End mismatch 3
[jpeg2000 @ 0229f700] End mismatch 1
    Last message repeated 3 times
[jpeg2000 @ 0229f700] End mismatch 3
[jpeg2000 @ 0229f700] End mismatch 1
[jpeg2000 @ 0229f700] End mismatch 16
[jpeg2000 @ 0229f700] End mismatch 1
    Last message repeated 2 times
[jpeg2000 @ 0229f700] End mismatch 4
[jpeg2000 @ 0229f700] End mismatch 9
[jpeg2000 @ 0229f700] End mismatch 1
[jpeg2000 @ 0229f700] End mismatch 2
[jpeg2000 @ 0229f700] End mismatch 5
[jpeg2000 @ 0229f700] End mismatch 1
[jpeg2000 @ 0229f700] End mismatch 3
[jpeg2000 @ 0229f700] End mismatch 1
[jpeg2000 @ 0229f700] End mismatch 8
[jpeg2000 @ 0229f700] End mismatch 2
[jpeg2000 @ 0229f700] End mismatch 4
    Last message repeated 1 times
[jpeg2000 @ 0229f700] End mismatch 2
[jpeg2000 @ 0229f700] End mismatch 1
[jpeg2000 @ 0229f700] End mismatch 5
[jpeg2000 @ 0229f700] End mismatch 26
[jpeg2000 @ 0229f700] End mismatch 31
[jpeg2000 @ 0229f700] End mismatch 2
    Last message repeated 1 times
[jpeg2000 @ 0229f700] End mismatch 10
[jpeg2000 @ 0229f700] End mismatch 2
[jpeg2000 @ 0229f700] End mismatch 1
    Last message repeated 1 times
[jpeg2000 @ 0229f700] End mismatch 2
[jpeg2000 @ 0229f700] End mismatch 1
    Last message repeated 1 times
[jpeg2000 @ 0229f700] End mismatch 2
[jpeg2000 @ 0229f700] End mismatch 26
[jpeg2000 @ 0229f700] End mismatch 32
[jpeg2000 @ 0229f700] End mismatch 49
[jpeg2000 @ 0229f700] End mismatch 38
[jpeg2000 @ 0229f700] End mismatch 20
[jpeg2000 @ 0229f700] End mismatch 8
[jpeg2000 @ 0229f700] End mismatch 5
[jpeg2000 @ 0229f700] End mismatch 18
[jpeg2000 @ 0229f700] End mismatch 78
[jpeg2000 @ 0229f700] End mismatch 9
[jpeg2000 @ 0229f700] End mismatch 16
[jpeg2000 @ 0229f700] End mismatch 1
    Last message repeated 6 times
[jpeg2000 @ 0229f700] End mismatch 2
[jpeg2000 @ 0229f700] End mismatch 1
    Last message repeated 1 times
[jpeg2000 @ 0229f700] End mismatch 2
    Last message repeated 1 times
[jpeg2000 @ 0229f700] End mismatch 1
[jpeg2000 @ 0229f700] End mismatch 2
[jpeg2000 @ 0229f700] End mismatch 1
[jpeg2000 @ 0229f700] End mismatch 18
[jpeg2000 @ 0229f700] End mismatch 5
[jpeg2000 @ 0229f700] End mismatch 18
[jpeg2000 @ 0229f700] End mismatch 8
[jpeg2000 @ 0229f700] End mismatch 9
[jpeg2000 @ 0229f700] End mismatch 6
[jpeg2000 @ 0229f700] End mismatch 29
[jpeg2000 @ 0229f700] End mismatch 9
[jpeg2000 @ 0229f700] End mismatch 5
[jpeg2000 @ 0229f700] End mismatch 3
    Last message repeated 1 times
[jpeg2000 @ 0229f700] End mismatch 10
[jpeg2000 @ 0229f700] End mismatch 4
[jpeg2000 @ 0229f700] End mismatch 10
[jpeg2000 @ 0229f700] End mismatch 2
[jpeg2000 @ 0229f700] End mismatch 15
[jpeg2000 @ 0229f700] End mismatch 20
[jpeg2000 @ 0229f700] End mismatch 6
[jpeg2000 @ 0229f700] End mismatch 16
    Last message repeated 1 times
[jpeg2000 @ 0229f700] End mismatch 2
[jpeg2000 @ 0229f700] End mismatch 4
[jpeg2000 @ 0229f700] End mismatch 8
[jpeg2000 @ 0229f700] End mismatch 50
[jpeg2000 @ 0229f700] End mismatch 20
[jpeg2000 @ 0229f700] End mismatch 41
[jpeg2000 @ 0229f700] End mismatch 1
    Last message repeated 3 times
[jpeg2000 @ 0229f700] End mismatch 4
[jpeg2000 @ 0229f700] End mismatch 1
[jpeg2000 @ 0229f700] End mismatch 3
[jpeg2000 @ 0229f700] End mismatch 1
[jpeg2000 @ 0229f700] End mismatch 2
[jpeg2000 @ 0229f700] End mismatch 4
[jpeg2000 @ 0229f700] End mismatch 2
[jpeg2000 @ 0229f700] End mismatch 24
[jpeg2000 @ 0229f700] End mismatch 31
[jpeg2000 @ 0229f700] End mismatch 38
[jpeg2000 @ 0229f700] End mismatch 20
[jpeg2000 @ 0229f700] End mismatch 23
[jpeg2000 @ 0229f700] End mismatch 38
[jpeg2000 @ 0229f700] End mismatch 21
[jpeg2000 @ 0229f700] End mismatch 47
[jpeg2000 @ 0229f700] End mismatch 68
[jpeg2000 @ 0229f700] End mismatch 17
[jpeg2000 @ 0229f700] End mismatch 12
[jpeg2000 @ 0229f700] End mismatch 14
[jpeg2000 @ 0229f700] End mismatch 19
    Last message repeated 1 times
[jpeg2000 @ 0229f700] End mismatch 9
[jpeg2000 @ 0229f700] End mismatch 11
[jpeg2000 @ 0229f700] End mismatch 31
[jpeg2000 @ 0229f700] End mismatch 22
[jpeg2000 @ 0229f700] End mismatch 17
[jpeg2000 @ 0229f700] End mismatch 49
[jpeg2000 @ 0229f700] End mismatch 25
[jpeg2000 @ 0229f700] End mismatch 18
[jpeg2000 @ 0229f700] End mismatch 7
    Last message repeated 1 times
[jpeg2000 @ 0229f700] End mismatch 22
    Last message repeated 1 times
[jpeg2000 @ 0229f700] End mismatch 35
[jpeg2000 @ 0229f700] End mismatch 72
[jpeg2000 @ 0229f700] End mismatch 15
[jpeg2000 @ 0229f700] End mismatch 58
[jpeg2000 @ 0229f700] End mismatch 92
[jpeg2000 @ 0229f700] End mismatch 85
[jpeg2000 @ 0229f700] End mismatch 17
[jpeg2000 @ 0229f700] End mismatch 19
[jpeg2000 @ 0229f700] End mismatch 22
[jpeg2000 @ 0229f700] End mismatch 57
[jpeg2000 @ 0229f700] End mismatch 20
Input #0, j2k_pipe, from 'lossless_m1.jp2':
  Duration: N/A, bitrate: N/A
    Stream #0:0: Video: jpeg2000 (JPEG 2000 codestream restriction 0), rgb24, 99
9x749, 25 tbr, 25 tbn, 25 tbc
[bmp @ 02294bc0] Warning: not compiled with thread support, using thread emulati
on
[jpeg2000 @ 02333a20] Warning: not compiled with thread support, using thread em
ulation
Output #0, image2, to 'out.bmp':
  Metadata:
    encoder         : Lavf56.37.100
    Stream #0:0: Video: bmp, bgr24, 999x749, q=2-31, 200 kb/s, 25 fps, 25 tbn, 2
5 tbc
    Metadata:
      encoder         : Lavc56.41.100 bmp
Stream mapping:
  Stream #0:0 -> #0:0 (jpeg2000 (native) -> bmp (native))
Press [q] to stop, [?] for help
[jpeg2000 @ 02333a20] extra cblk styles 1
[jpeg2000 @ 02333a20] Selective arithmetic coding bypass
[jpeg2000 @ 02333a20] End mismatch 1
    Last message repeated 27 times
[jpeg2000 @ 02333a20] End mismatch 2
[jpeg2000 @ 02333a20] End mismatch 1
    Last message repeated 21 times
[jpeg2000 @ 02333a20] End mismatch 2
[jpeg2000 @ 02333a20] End mismatch 1
[jpeg2000 @ 02333a20] End mismatch 2
    Last message repeated 1 times
[jpeg2000 @ 02333a20] End mismatch 1
[jpeg2000 @ 02333a20] End mismatch 2
[jpeg2000 @ 02333a20] End mismatch 9
[jpeg2000 @ 02333a20] End mismatch 2
[jpeg2000 @ 02333a20] End mismatch 5
[jpeg2000 @ 02333a20] End mismatch 6
[jpeg2000 @ 02333a20] End mismatch 19
[jpeg2000 @ 02333a20] End mismatch 1
[jpeg2000 @ 02333a20] End mismatch 20
[jpeg2000 @ 02333a20] End mismatch 7
[jpeg2000 @ 02333a20] End mismatch 3
[jpeg2000 @ 02333a20] End mismatch 1
[jpeg2000 @ 02333a20] End mismatch 6
[jpeg2000 @ 02333a20] End mismatch 10
[jpeg2000 @ 02333a20] End mismatch 5
[jpeg2000 @ 02333a20] End mismatch 1
[jpeg2000 @ 02333a20] End mismatch 4
[jpeg2000 @ 02333a20] End mismatch 12
[jpeg2000 @ 02333a20] End mismatch 10
[jpeg2000 @ 02333a20] End mismatch 1
[jpeg2000 @ 02333a20] End mismatch 2
[jpeg2000 @ 02333a20] End mismatch 29
[jpeg2000 @ 02333a20] End mismatch 12
[jpeg2000 @ 02333a20] End mismatch 2
[jpeg2000 @ 02333a20] End mismatch 24
[jpeg2000 @ 02333a20] End mismatch 13
[jpeg2000 @ 02333a20] End mismatch 1
[jpeg2000 @ 02333a20] End mismatch 8
[jpeg2000 @ 02333a20] End mismatch 2
    Last message repeated 1 times
[jpeg2000 @ 02333a20] End mismatch 3
[jpeg2000 @ 02333a20] End mismatch 2
[jpeg2000 @ 02333a20] End mismatch 3
[jpeg2000 @ 02333a20] End mismatch 1
    Last message repeated 3 times
[jpeg2000 @ 02333a20] End mismatch 3
[jpeg2000 @ 02333a20] End mismatch 1
[jpeg2000 @ 02333a20] End mismatch 16
[jpeg2000 @ 02333a20] End mismatch 1
    Last message repeated 2 times
[jpeg2000 @ 02333a20] End mismatch 4
[jpeg2000 @ 02333a20] End mismatch 9
[jpeg2000 @ 02333a20] End mismatch 1
[jpeg2000 @ 02333a20] End mismatch 2
[jpeg2000 @ 02333a20] End mismatch 5
[jpeg2000 @ 02333a20] End mismatch 1
[jpeg2000 @ 02333a20] End mismatch 3
[jpeg2000 @ 02333a20] End mismatch 1
[jpeg2000 @ 02333a20] End mismatch 8
[jpeg2000 @ 02333a20] End mismatch 2
[jpeg2000 @ 02333a20] End mismatch 4
    Last message repeated 1 times
[jpeg2000 @ 02333a20] End mismatch 2
[jpeg2000 @ 02333a20] End mismatch 1
[jpeg2000 @ 02333a20] End mismatch 5
[jpeg2000 @ 02333a20] End mismatch 26
[jpeg2000 @ 02333a20] End mismatch 31
[jpeg2000 @ 02333a20] End mismatch 2
    Last message repeated 1 times
[jpeg2000 @ 02333a20] End mismatch 10
[jpeg2000 @ 02333a20] End mismatch 2
[jpeg2000 @ 02333a20] End mismatch 1
    Last message repeated 1 times
[jpeg2000 @ 02333a20] End mismatch 2
[jpeg2000 @ 02333a20] End mismatch 1
    Last message repeated 1 times
[jpeg2000 @ 02333a20] End mismatch 2
[jpeg2000 @ 02333a20] End mismatch 26
[jpeg2000 @ 02333a20] End mismatch 32
[jpeg2000 @ 02333a20] End mismatch 49
[jpeg2000 @ 02333a20] End mismatch 38
[jpeg2000 @ 02333a20] End mismatch 20
[jpeg2000 @ 02333a20] End mismatch 8
[jpeg2000 @ 02333a20] End mismatch 5
[jpeg2000 @ 02333a20] End mismatch 18
[jpeg2000 @ 02333a20] End mismatch 78
[jpeg2000 @ 02333a20] End mismatch 9
[jpeg2000 @ 02333a20] End mismatch 16
[jpeg2000 @ 02333a20] End mismatch 1
    Last message repeated 6 times
[jpeg2000 @ 02333a20] End mismatch 2
[jpeg2000 @ 02333a20] End mismatch 1
    Last message repeated 1 times
[jpeg2000 @ 02333a20] End mismatch 2
    Last message repeated 1 times
[jpeg2000 @ 02333a20] End mismatch 1
[jpeg2000 @ 02333a20] End mismatch 2
[jpeg2000 @ 02333a20] End mismatch 1
[jpeg2000 @ 02333a20] End mismatch 18
[jpeg2000 @ 02333a20] End mismatch 5
[jpeg2000 @ 02333a20] End mismatch 18
[jpeg2000 @ 02333a20] End mismatch 8
[jpeg2000 @ 02333a20] End mismatch 9
[jpeg2000 @ 02333a20] End mismatch 6
[jpeg2000 @ 02333a20] End mismatch 29
[jpeg2000 @ 02333a20] End mismatch 9
[jpeg2000 @ 02333a20] End mismatch 5
[jpeg2000 @ 02333a20] End mismatch 3
    Last message repeated 1 times
[jpeg2000 @ 02333a20] End mismatch 10
[jpeg2000 @ 02333a20] End mismatch 4
[jpeg2000 @ 02333a20] End mismatch 10
[jpeg2000 @ 02333a20] End mismatch 2
[jpeg2000 @ 02333a20] End mismatch 15
[jpeg2000 @ 02333a20] End mismatch 20
[jpeg2000 @ 02333a20] End mismatch 6
[jpeg2000 @ 02333a20] End mismatch 16
    Last message repeated 1 times
[jpeg2000 @ 02333a20] End mismatch 2
[jpeg2000 @ 02333a20] End mismatch 4
[jpeg2000 @ 02333a20] End mismatch 8
[jpeg2000 @ 02333a20] End mismatch 50
[jpeg2000 @ 02333a20] End mismatch 20
[jpeg2000 @ 02333a20] End mismatch 41
[jpeg2000 @ 02333a20] End mismatch 1
    Last message repeated 3 times
[jpeg2000 @ 02333a20] End mismatch 4
[jpeg2000 @ 02333a20] End mismatch 1
[jpeg2000 @ 02333a20] End mismatch 3
[jpeg2000 @ 02333a20] End mismatch 1
[jpeg2000 @ 02333a20] End mismatch 2
[jpeg2000 @ 02333a20] End mismatch 4
[jpeg2000 @ 02333a20] End mismatch 2
[jpeg2000 @ 02333a20] End mismatch 24
[jpeg2000 @ 02333a20] End mismatch 31
[jpeg2000 @ 02333a20] End mismatch 38
[jpeg2000 @ 02333a20] End mismatch 20
[jpeg2000 @ 02333a20] End mismatch 23
[jpeg2000 @ 02333a20] End mismatch 38
[jpeg2000 @ 02333a20] End mismatch 21
[jpeg2000 @ 02333a20] End mismatch 47
[jpeg2000 @ 02333a20] End mismatch 68
[jpeg2000 @ 02333a20] End mismatch 17
[jpeg2000 @ 02333a20] End mismatch 12
[jpeg2000 @ 02333a20] End mismatch 14
[jpeg2000 @ 02333a20] End mismatch 19
    Last message repeated 1 times
[jpeg2000 @ 02333a20] End mismatch 9
[jpeg2000 @ 02333a20] End mismatch 11
[jpeg2000 @ 02333a20] End mismatch 31
[jpeg2000 @ 02333a20] End mismatch 22
[jpeg2000 @ 02333a20] End mismatch 17
[jpeg2000 @ 02333a20] End mismatch 49
[jpeg2000 @ 02333a20] End mismatch 25
[jpeg2000 @ 02333a20] End mismatch 18
[jpeg2000 @ 02333a20] End mismatch 7
    Last message repeated 1 times
[jpeg2000 @ 02333a20] End mismatch 22
    Last message repeated 1 times
[jpeg2000 @ 02333a20] End mismatch 35
[jpeg2000 @ 02333a20] End mismatch 72
[jpeg2000 @ 02333a20] End mismatch 15
[jpeg2000 @ 02333a20] End mismatch 58
[jpeg2000 @ 02333a20] End mismatch 92
[jpeg2000 @ 02333a20] End mismatch 85
[jpeg2000 @ 02333a20] End mismatch 17
[jpeg2000 @ 02333a20] End mismatch 19
[jpeg2000 @ 02333a20] End mismatch 22
[jpeg2000 @ 02333a20] End mismatch 57
[jpeg2000 @ 02333a20] End mismatch 20
frame=    1 fps=0.0 q=0.0 Lsize=N/A time=00:00:00.04 bitrate=N/A
video:2194kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing
overhead: unknown

Attachments (2)

lossless_m1.jp2 (720.2 KB) - added by ami_stuff 4 years ago.
test.png (1.7 MB) - added by ami_stuff 4 years ago.

Change History (9)

Changed 4 years ago by ami_stuff

comment:1 Changed 4 years ago by cehoyos

  • Component changed from undetermined to avcodec
  • Keywords j2k added
  • Reproduced by developer set
  • Status changed from new to open
  • Version changed from unspecified to git-master

Output differs between jasper and libopenjpeg.

comment:2 Changed 4 years ago by cehoyos

What is the expected output? Can you convert test.bmp to png and attach it?

comment:3 Changed 4 years ago by ami_stuff

After re-testing it looks like output of -M 2/8/16/32-encoded files decoded by openjpeg is identical to input bmp image (and to the output from ffmpeg's decoder), while output of -M 1/4-encoded files is not the same, so maybe there is no bug?

What I notice is that output of "lossless_m1.jp2​" looks better from openjpeg's decoder than from ffmpeg's decoder.

Changed 4 years ago by ami_stuff

comment:4 Changed 4 years ago by cehoyos

There is a visual difference between the output with FFmpeg and the output with libopenjpeg and jasper (more - or different - artefacts with FFmpeg).

comment:5 Changed 4 years ago by ami_stuff

This is what I get from different decoders:

http://www.datafilehost.com/d/c593f18a

It looks like ffmpeg's output is a bit different (visually) compared to apollo/kakadu/lurawave/lead's output, so some algo doesn't match them.

Last edited 4 years ago by ami_stuff (previous) (diff)

comment:6 Changed 3 years ago by boxerab

I have been looking into this very problem on the OpenJPEG side of things.

This is a bug in OpenJPEG - lossless encoding with M==1 (i.e. BYPASS mode) or M ==4 (RESTART mode) gives a lossy image.

This has been broken for years and years.

I have opened an issue on OpenJPEG github tracker:

https://github.com/uclouvain/openjpeg/issues/674

I would recommend closing this bug as invalid.

Last edited 3 years ago by boxerab (previous) (diff)

comment:7 Changed 3 years ago by cehoyos

  • Priority changed from normal to minor
Note: See TracTickets for help on using tickets.