Commit fea5ff255e for ffmpeg
commit fea5ff255e0566012cd2c677c5868d71b61ca715
Author: Ramiro Polla <ramiro.polla@gmail.com>
Date: Thu Oct 29 19:43:15 2026 +0100
avutil/pixfmt: document color range for floating point formats
The narrow and full range definitions only exist for integer
representations: H.273 (VideoFullRangeFlag), BT.709, BT.2020 and BT.2100
all specify them as equations on n-bit integer code values, and none of
them define range for floating point. Floating point samples hold the
normalized signal E directly, and may lie outside of its nominal range
(e.g. HDR highlights above 1.0, out-of-gamut colors below 0.0).
This matches other implementations: zimg applies pixel_range to integer
formats only, and VapourSynth uses fixed float bounds regardless of
_Range (Y in [0, 1], chroma centered on 0).
Since AVFrame and AVCodecContext still carry a range for these formats,
document that the field is ignored for them. libavfilter tags them as
AVCOL_RANGE_UNSPECIFIED, while some decoders tag them as AVCOL_RANGE_JPEG.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Ramiro Polla <ramiro.polla@gmail.com>
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index bb654ec5a6..d9ec6df9fa 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -678,6 +678,9 @@ typedef struct AVCodecContext {
* output format.
* - decoding: Set by libavcodec, can be set by the user to propagate the
* color range to components reading from the decoder context.
+ *
+ * @note This field is ignored for floating point pixel formats, which
+ * are always full range. See AVColorRange.
*/
enum AVColorRange color_range;
diff --git a/libavutil/frame.h b/libavutil/frame.h
index 1fd296aa83..ec4e0c7ac7 100644
--- a/libavutil/frame.h
+++ b/libavutil/frame.h
@@ -726,6 +726,9 @@ typedef struct AVFrame {
* MPEG vs JPEG YUV range.
* - encoding: Set by user
* - decoding: Set by libavcodec
+ *
+ * @note This field is ignored for floating point pixel formats, which
+ * are always full range. See AVColorRange.
*/
enum AVColorRange color_range;
diff --git a/libavutil/pixfmt.h b/libavutil/pixfmt.h
index 750e05b644..b0bf9524c9 100644
--- a/libavutil/pixfmt.h
+++ b/libavutil/pixfmt.h
@@ -749,6 +749,10 @@ enum AVColorSpace {
* - 'n' is the output bit depth.
* - For additional definitions such as rounding and clipping to valid n
* bit unsigned integer range, please refer to BT.2100 (Table 9).
+ *
+ * These definitions only apply to integer representations. Floating point
+ * representations hold 'E' directly, without any scaling or offset, and are
+ * not limited to its nominal range.
*/
enum AVColorRange {
AVCOL_RANGE_UNSPECIFIED = 0,