Opened 10 years ago

Closed 10 years ago

#3751 closed defect (fixed)

Identity Hald CLUT Introduces Color Shift

Reported by: aguo Owned by:
Priority: normal Component: avfilter
Version: unspecified Keywords: haldclut
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Hi!

I'm having an issue with applying Hald CLUTs to a dpx image sequence.
I am trying to use ffmpeg to convert a sequence of dpx film scans in logarithmic colorspace into two quicktime files: one with h264 encoding and one with avid dnxhd encoding.

In investigating the problems I've been encountering I realized that using hald cluts with ffmpeg introduced color shifts that are external to the corrections specified by the LUT. Even applying an identity hald clut to an image changes the image despite the fact that the identity clut is meant to not change the input image at all.

Our command line/build is:

C:\Users\aguo>ffmpeg -i I:\studio\software\release\HaldCLUT\EA0570_bright\ea0570_bg_20140214_1.1659199.dpx -i I:\studio\software\release\HaldCLUT\Identity_level_8.HCLUT_neutral.tga -filter_complex 'haldclut' I:\studio\artists\aguo\neutralIdentityCLUTtest.jpg

ffmpeg version N-63548-g6b041cb Copyright (c) 2000-2014 the FFmpeg developers

built on May 28 2014 22:01:42 with gcc 4.8.2 (GCC)

configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-av

isynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enab

le-iconv --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetyp

e --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-

libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libope

njpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsox

r --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab -

-enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx

--enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-

libxavs --enable-libxvid --enable-decklink --enable-zlib

libavutil 52. 87.100 / 52. 87.100

libavcodec 55. 65.100 / 55. 65.100

libavformat 55. 42.100 / 55. 42.100

libavdevice 55. 13.101 / 55. 13.101

libavfilter 4. 5.100 / 4. 5.100

libswscale 2. 6.100 / 2. 6.100

libswresample 0. 19.100 / 0. 19.100

libpostproc 52. 3.100 / 52. 3.100

The same problem happens when we use a jpg as the input. This should not change the input at all but actually ends up introducing a color shift that makes the image significantly more blue.

My guess is that the issue is that ffmpeg is trying to guess/assign a colorspace to the Hald CLUT and the colorspace interpretation of the Hald CLUT is changing the CLUT.

As the guy who created CLUTs explains, "A HaldClut is not really an image
(its only stored in an image file format for convinience), its a lookup
table.

A lookuptables function is to input some values, in our case a 3
dimentional value (RGB), and then output some values, again 3 values in
our case. It doesnt really care where thouse values come from or what they
mean they just does a conversion. Depending on what you put in the table
you can make any kind of conversion.

its just a numbers to numbers conversion"

If that is the case, is there a way to disable ffmpeg from trying to assign the CLUT a colorspace?
Or if that isn't the issue, why would applying an identity CLUT through ffmpeg change in the input image?
We got the Identity CLUT straight from the developer's website here: http://www.quelsolaar.com/files/index.html

Any help would be greatly appreciated. Thanks!

Change History (5)

comment:1 by Clément Bœsch, 10 years ago

Be careful with the identity LUT of the Hald CLUT; if you got it from quelsolaar.com, it is broken: open it with a random image viewer, and look at the last pixel column on the right. You should see the shift.

You can generate a proper identity CLUT with FFmpeg itself. Try to use that instead.

comment:2 by Clément Bœsch, 10 years ago

Component: undeterminedavfilter
Keywords: haldclut added
Resolution: needs_more_info
Status: newclosed

comment:3 by Carl Eugen Hoyos, 10 years ago

If you want to report a problem with FFmpeg, please provide the command line that doesn't produce the expected output together with the complete, uncut console output.

comment:4 by JohnL, 10 years ago

Resolution: needs_more_info
Status: closedreopened

Regardless of the problems with the quelsolaar.com identity clut, a generated identity HALD CLUT also exhibits the color shift. The following examples shows it is actually swapping the red and blue color channels.

ffmpeg -y -v verbose -i rgb.png -filter_complex haldclutsrc=8[clut],[0][clut]haldclut=shortest=1 output%d.png
ffmpeg version 2.2.3 Copyright (c) 2000-2014 the FFmpeg developers
  built on Jun  3 2014 06:51:16 with Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/2.2.3 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-nonfree --enable-hardcoded-tables --enable-avresample --enable-vda --cc=clang --host-cflags= --host-ldflags= --enable-libx264 --enable-libfaac --enable-libmp3lame --enable-libxvid
  libavutil      52. 66.100 / 52. 66.100
  libavcodec     55. 52.102 / 55. 52.102
  libavformat    55. 33.100 / 55. 33.100
  libavdevice    55. 10.100 / 55. 10.100
  libavfilter     4.  2.100 /  4.  2.100
  libavresample   1.  2.  0 /  1.  2.  0
  libswscale      2.  5.102 /  2.  5.102
  libswresample   0. 18.100 /  0. 18.100
  libpostproc    52.  3.100 / 52.  3.100
Input #0, image2, from 'rgb.png':
  Duration: 00:00:00.04, start: 0.000000, bitrate: N/A
    Stream #0:0: Video: png, rgba, 271x271 [SAR 2834:2834 DAR 1:1], 25 tbr, 25 tbn, 25 tbc
[Parsed_haldclutsrc_0 @ 0x7ff05040c0e0] size:0x0 rate:25/1 duration:-1.000000 sar:1/1
[graph 0 input from stream 0:0 @ 0x7ff05040bba0] w:271 h:271 pixfmt:rgba tb:1/25 fr:25/1 sar:2834/2834 sws_param:flags=2
[Parsed_haldclut_1 @ 0x7ff05040c380] [framesync @ 0x106682040] Selected 1/25 time base
[Parsed_haldclut_1 @ 0x7ff05040c380] [framesync @ 0x106682040] Sync level 2
Output #0, image2, to 'output%d.png':
  Metadata:
    encoder         : Lavf55.33.100
    Stream #0:0: Video: png, rgba, 271x271 [SAR 2834:2834 DAR 1:1], q=2-31, 200 kb/s, 90k tbn, 25 tbc
Stream mapping:
  Stream #0:0 (png) -> haldclut:main
  haldclut -> Stream #0:0 (png)
Press [q] to stop, [?] for help
[Parsed_haldclut_1 @ 0x7ff05040c380] [framesync @ 0x106682040] Sync level 1
[Parsed_haldclut_1 @ 0x7ff05040c380] [framesync @ 0x106682040] Sync level 0
No more output streams to write to, finishing.
frame=    1 fps=0.0 q=0.0 Lsize=N/A time=00:00:00.04 bitrate=N/A    
video:6kB audio:0kB subtitle:0 data:0 global headers:0kB muxing overhead -100.338982%

rgb.png:
http://www.kirupa.com/images/rgb_image.png

output1.png:
http://i58.tinypic.com/rsal4k.png

comment:5 by Clément Bœsch, 10 years ago

Resolution: fixed
Status: reopenedclosed

Should be fixed in d5601cf6fc1c1606ec45466d5d72fd1e60a4ba3b. Please test git-master.

I'm sorry about that mistake, it seems I badly tested this part. Thank you for your report.

Note: most CLUT from quelsolaar.com seems to exhibit the right column bug so I couldn't test properly with these. Nevertheless, the code should be correct now. Please re-open if it's still problematic.

Note: See TracTickets for help on using tickets.