Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#8544 closed defect (invalid)

LUTRGB inaccurate, affects other colors

Reported by: chris319 Owned by:
Priority: normal Component: undetermined
Version: unspecified Keywords:
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the bug:
LUTRGB inaccurate, affects other colors.

When used on a white raster of R=255,G=255,B=255, LUTRGB=r=clip(val,47,194) returns:R=188,G=249,B=255.
LUTRGB is not clipping to specified value of 194 and is affecting the green channel which is not specified in the command. Pixel format is RGB24 — no subsampling.
Above command should return R=194,G=255,B=255, leaving green and blue unchanged.

How to reproduce:

ffmpeg -y  -i "White.mp4"  -c:v libx265  -crf 0  -vf scale=in_range=limited:in_color_matrix=bt709,format=rgb24,lutrgb='r=clip(val,47,194)',scale=out_color_matrix=bt709:out_range=full,format=rgb24  -r 59.94  -an  clipped.mp4

Console output:

ffmpeg -y  -i "White.mp4"  -c:v libx265  -crf 0  -vf scale=in_range=full:in_color_matrix=bt709,format=rgb24,lutrgb='r=clip(val,47,194)',scale=out_color_matrix=bt709:out_range=full,format=rgb24  -r 59.94    -an  clipped.mp4
ffmpeg version git-2019-12-02-968c4cb Copyright (c) 2000-2019 the FFmpeg developers
  built with gcc 9.2.1 (GCC) 20191125
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt --enable-amf
  libavutil      56. 36.101 / 56. 36.101
  libavcodec     58. 64.101 / 58. 64.101
  libavformat    58. 35.100 / 58. 35.100
  libavdevice    58.  9.101 / 58.  9.101
  libavfilter     7. 67.100 /  7. 67.100
  libswscale      5.  6.100 /  5.  6.100
  libswresample   3.  6.100 /  3.  6.100
  libpostproc    55.  6.100 / 55.  6.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'White.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.29.100
  Duration: 00:00:04.00, start: 0.000000, bitrate: 20 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709/unknown/bt709), 1920x1080 [SAR 1:1 DAR 16:9], 16 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
    Metadata:
      handler_name    : VideoHandler
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> hevc (libx265))
Press [q] to stop, [?] for help
x265 [info]: HEVC encoder version 3.2+15-04db2bfee5d6
x265 [info]: build info [Windows][GCC 9.2.1][64 bit] 8bit+10bit
x265 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
x265 [warning]: halving the quality when psy-rd is enabled for 444 input. Setting cbQpOffset = 6 and crQpOffset = 6
x265 [info]: Main 4:4:4 profile, Level-4.1 (Main tier)
x265 [info]: Thread pool created using 8 threads
x265 [info]: Slices                              : 1
x265 [info]: frame threads / pool features       : 3 / wpp(17 rows)
x265 [info]: Coding QT: max CU size, min CU size : 64 / 8
x265 [info]: Residual QT: max TU size, max depth : 32 / 1 inter / 1 intra
x265 [info]: ME / range / subpel / merge         : hex / 57 / 2 / 3
x265 [info]: Keyframe min / max / scenecut / bias: 25 / 250 / 40 / 5.00
x265 [info]: Cb/Cr QP Offset                     : 6 / 6
x265 [info]: Lookahead / bframes / badapt        : 20 / 4 / 2
x265 [info]: b-pyramid / weightp / weightb       : 1 / 1 / 0
x265 [info]: References / ref-limit  cu / depth  : 3 / off / on
x265 [info]: AQ: mode / str / qg-size / cu-tree  : 2 / 1.0 / 32 / 1
x265 [info]: Rate Control / qCompress            : CRF-0.0 / 0.60
x265 [info]: tools: rd=3 psy-rd=2.00 early-skip rskip signhide tmvp b-intra
x265 [info]: tools: strong-intra-smoothing lslices=6 deblock sao
Output #0, mp4, to 'clipped.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.35.100
    Stream #0:0(und): Video: hevc (libx265) (hev1 / 0x31766568), gbrp, 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 59.94 fps, 11988 tbn, 59.94 tbc (default)
    Metadata:
      handler_name    : VideoHandler
      encoder         : Lavc58.64.101 libx265
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
frame=  239 fps= 28 q=-0.0 Lsize=      36kB time=00:00:03.93 bitrate=  75.5kbits/s dup=139 drop=0 speed=0.454x
video:31kB audio:0kB subtitle:0kB other streams:0kB global headers:2kB muxing overhead: 18.843916%
x265 [info]: frame I:      1, Avg QP:7.53  kb/s: 721.68
x265 [info]: frame P:     76, Avg QP:8.00  kb/s: 62.57
x265 [info]: frame B:    162, Avg QP:10.72  kb/s: 55.94
x265 [info]: Weighted P-Frames: Y:0.0% UV:0.0%
x265 [info]: consecutive B-frames: 28.6% 11.7% 19.5% 1.3% 39.0%

encoded 239 frames in 8.64s (27.67 fps), 60.84 kb/s, Avg QP:9.84

ffmpeg version
built on ...

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

Attachments (1)

YUV255,128,128_unflagged.mp4 (13.8 KB ) - added by pdr0 5 years ago.
YUV(255,128,128) test file

Download all attachments as: .zip

Change History (4)

comment:1 by pdr0, 5 years ago

What is "White.mp4" ? What are the YUV values ?

You're converting to YUV inbetween, possibly incorrectly, that's not lutrgb's fault

You should be measuring the direct RGB output of lutrgb filter (eg. with a bmp), against direct input of a known RGB values e.g. 255,255,255.

lutrgb , the filter itself, works correctly

ffmpeg -i 255,255,255.bmp -vf lutrgb='r=clip(val,47,194)' out.bmp

Result
RGB 194,255,255

by pdr0, 5 years ago

YUV(255,128,128) test file

comment:2 by pdr0, 5 years ago

Resolution: invalid
Status: newclosed
ffmpeg -i YUV255,128,128_unflagged.mp4 -vf scale=in_range=full:in_color_matrix=bt709,format=rgb24,lutrgb='r=clip (val,47,194)',scale=out_color_matrix=bt709:out_range=full,format=rgb24 -frames:v 1 out2.bmp

Attached a full "white" YUV 255,128,128 test file

full range 709 conversion to RGB, lutrgb clip [47,194] , output a bmp

result
RGB 194,255,255

full range YUV=>RGB conversion works correctly, and -vf lutrgb works correctly

comment:3 by Carl Eugen Hoyos, 5 years ago

Component: ffmpegundetermined
Priority: importantnormal
Note: See TracTickets for help on using tickets.