ffmpeg/doc
Drew Dunne 76471fb143 vf_colorspace: Add an option to clamp trc LUT output
Add a new flag to the vf_colorspace filter which provides the user an
option to clamp the linear and delinear transfer characteristics LUT
values to the [0, 1] represented range. This helps constrain the
potential value range when converting between colorspaces.

Certain colors when going through the conversion can result in out of
gamut colors after the rotation. The colorspace filter allows that with
the extended range. The added clamping just keeps the colors within the
[0, 1) range rather than using that extended range. I'm not enough of a
color scientist to say which is correct, but there are certain
situations where we would prefer to keep the colors in gamut.

The example I have is:

A solid color image of 8-bit YUV: Y=157, U=164, V=98.

Specify the input as:

Input range: MPEG
In color matrix: BT470BG
In color primaries: BT470M
In color transfer characteristics: Gamma 28

Output as:
Out color range: JPEG
Out color matrix: BT.709
Out color primaries: BT.709
Out color transfer characteristics: BT.709

During the calculation you get:

Input YUV:                             y=157,      u=164,      v-98
Post-yuv2rgb BT.470BG:                 r=0.456055, g=0.684152, b=0.928606
Post-apply gamma28 linear LUT:         r=0.110979, g=0.345494, b=0.812709
Post-color rotation BT.470M to BT.709: r=-0.04161, g=0.384626, b=0.852400
Post-apply Rec.709 delinear LUT:       r=-0.16382, g=0.615932, b=0.923793
Post-rgb2yuv Rec.709 matrix:           y=120,      u=190,      v=25

Where with this change, the delinear LUT output would be clamped to 0,
so the result would be:
r=0.000000, g=0.612390, b=0.918807 and a final output of
y=129, u=185, v=46

As for the long and av_clip64, this was just because lrint returned a
long, so I left it as that and then used av_clip64 to the [0,1) range to
avoid overflow. But re-reading, it looks like av_clip_int16 would
downcast that long to int anyway so the possibility of overflow already
existed there. I've put it back to int just to match the existing
behavior.
2025-09-15 14:39:09 +00:00
..
doxy
examples doc/examples/vaapi_encode: fix invalid check on fwrite 2025-09-08 20:43:07 +00:00
.gitignore
APIchanges avutil/hwcontext_d3d12va: added resource and heap flags to DeviceContext 2025-09-08 15:44:47 +00:00
authors.texi Use https for repository links 2023-03-01 21:59:10 +01:00
bitstream_filters.texi lavc: add eia608_to_smpte436m bitstream filter 2025-08-08 03:04:42 -07:00
bootstrap.min.css doc/html: fix styling issue with Texinfo 7.0 2023-11-08 23:54:23 +01:00
build_system.txt all: fix whitespace/new-line issues 2025-08-03 13:48:47 +02:00
codecs.texi avcodec/avcodec: add AVCodecContext.alpha_mode 2025-09-02 17:06:24 +02:00
community.texi doc/community.texi: fix spelling error 2025-08-09 22:01:42 +00:00
decoders.texi all: fix typos found by codespell 2025-08-03 13:48:47 +02:00
default.css
demuxers.texi avformat/img2dec: remove deprecated glob_sequence pattern type 2025-08-26 14:41:44 +00:00
developer.texi Revert "doc/developer: Basic documentation for Source Plugins" 2025-08-11 19:53:28 +09:00
devices.texi
doxy-wrapper.sh doc: fix generating doxy with out-of-tree builds 2021-06-11 19:28:27 +02:00
Doxyfile all: fix typos found by codespell 2025-08-03 13:48:47 +02:00
encoders.texi avcodec/dvbsubenc: add a min_bpp option to work around some decoders 2025-08-04 19:45:45 +01:00
errno.txt
faq.texi doc/faq: use texi's @tie instead of 0xA0 for non-breaking space 2024-01-10 19:52:23 +01:00
fate.texi fate: Add a target for listing failed tests 2024-12-11 14:10:22 +02:00
fate_config.sh.template doc: replace http/git by https urls 2025-04-03 01:57:46 +02:00
ffmpeg-bitstream-filters.texi Remove the ffserver program 2018-01-06 18:31:37 +00:00
ffmpeg-codecs.texi Remove the ffserver program 2018-01-06 18:31:37 +00:00
ffmpeg-devices.texi Remove the ffserver program 2018-01-06 18:31:37 +00:00
ffmpeg-filters.texi Remove the ffserver program 2018-01-06 18:31:37 +00:00
ffmpeg-formats.texi Remove the ffserver program 2018-01-06 18:31:37 +00:00
ffmpeg-protocols.texi Remove the ffserver program 2018-01-06 18:31:37 +00:00
ffmpeg-resampler.texi Remove the ffserver program 2018-01-06 18:31:37 +00:00
ffmpeg-scaler.texi Remove the ffserver program 2018-01-06 18:31:37 +00:00
ffmpeg-utils.texi Remove the ffserver program 2018-01-06 18:31:37 +00:00
ffmpeg.texi all: fix typos found by codespell 2025-08-03 13:48:47 +02:00
ffmpeg.txt
ffplay.texi fftools/ffplay: add hwaccel decoding support 2023-11-15 01:20:11 +08:00
ffprobe.texi ffprobe: add -codec:<media_spec> option and -c:<media_spec> variant 2025-08-10 10:19:57 +02:00
ffprobe.xsd fftools/ffprobe: print lossless frame flag 2025-01-05 22:23:16 +01:00
fftools-common-opts.texi fftools/opt_common: add time and datetime log flags 2025-02-16 15:41:40 +01:00
filter_design.txt avfilter: factorize requesting an input frame from multi output filters 2025-07-03 21:41:53 +02:00
filters.texi vf_colorspace: Add an option to clamp trc LUT output 2025-09-15 14:39:09 +00:00
formats.texi avformat/demux: add duration_probesize AVOption 2024-04-02 19:53:40 +02:00
general.texi doc/general: move contents into a separate file. 2020-09-08 14:29:19 +02:00
general_contents.texi all: fix typos found by codespell 2025-08-03 13:48:47 +02:00
git-howto.texi doc: replace http/git by https urls 2025-04-03 01:57:46 +02:00
htmlxref.cnf doc: add htmlxref.cnf 2025-05-18 19:54:09 -03:00
indevs.texi all: fix typos found by codespell 2025-08-03 13:48:47 +02:00
infra.txt doc/infra: List at what companies the name servers are hosted and who provides the servers 2024-11-28 23:19:00 +01:00
issue_tracker.txt Remove the ffserver program 2018-01-06 18:31:37 +00:00
lexicon
libavcodec.texi Remove the ffserver program 2018-01-06 18:31:37 +00:00
libavdevice.texi Remove the ffserver program 2018-01-06 18:31:37 +00:00
libavfilter.texi Remove the ffserver program 2018-01-06 18:31:37 +00:00
libavformat.texi Remove the ffserver program 2018-01-06 18:31:37 +00:00
libavutil.texi Remove the ffserver program 2018-01-06 18:31:37 +00:00
libswresample.texi Remove the ffserver program 2018-01-06 18:31:37 +00:00
libswscale.texi Remove the ffserver program 2018-01-06 18:31:37 +00:00
mailing-list-faq.texi doc/mailing-list-faq: remove dead link 2024-08-14 18:25:37 +02:00
Makefile doc: use HOSTEXESUF when calling print_options 2024-04-24 00:09:38 +02:00
metadata.texi doc/muxers: add ffmetadata 2024-03-18 17:59:19 +01:00
mips.txt avcodec/iirfilter: Remove iirfilter, psy-preprocessing 2025-06-06 17:21:31 +02:00
multithreading.txt avcodec/codec_internal: Remove FF_CODEC_CAP_ALLOCATE_PROGRESS 2024-04-19 13:18:04 +02:00
muxers.texi lavf: add mcc muxer 2025-08-08 03:04:42 -07:00
nut.texi all: fix whitespace/new-line issues 2025-08-03 13:48:47 +02:00
optimization.txt configure: drop yasm support 2024-10-06 01:32:47 +02:00
outdevs.texi doc/{in,out}devs: Remove documentation for removed devices 2025-04-03 06:04:57 +02:00
patchwork
platform.texi configure: drop yasm support 2024-10-06 01:32:47 +02:00
print_options.c Merge commit '2025d37871' 2017-03-29 15:20:10 +02:00
protocols.texi avformat/tcp: add option for enabling TCP keepalive 2025-08-22 18:20:08 +00:00
rate_distortion.txt
resampler.texi swresample/swresample: add a used channel layout option using the new API 2023-02-19 18:28:45 -03:00
scaler.texi swscale: add SWS_UNSTABLE flag 2025-09-01 19:28:35 +02:00
snow.txt doc/snow: fix typos 2019-02-10 16:46:56 +01:00
style.min.css doc: add styles for good/bad code examples 2024-11-25 17:17:57 +01:00
swresample.txt
swscale-v2.txt all: fix typos found by codespell 2025-08-03 13:48:47 +02:00
swscale.txt
t2h.init
t2h.pm doc/t2h: Support texinfo 7.1 and 7.2 pretest 2025-02-06 18:00:34 -03:00
tablegen.txt
texi2pod.pl all: fix whitespace/new-line issues 2025-08-03 13:48:47 +02:00
texidep.pl all: fix whitespace/new-line issues 2025-08-03 13:48:47 +02:00
transforms.md x86/tx_float: add 15xN PFA FFT AVX SIMD 2022-09-23 12:35:27 +02:00
undefined.txt all: fix whitespace/new-line issues 2025-08-03 13:48:47 +02:00
utils.texi avutil/channel_layout: add a 9.1.6 layout 2024-12-13 16:35:47 -03:00
writing_filters.txt Update missed irc links 2021-06-18 18:58:25 +02:00