[FFmpeg-devel] [PATCH] avcodec: use sRGB to stringify gbr/bt709/iec61966-2-1 instead

Leo Izen leo.izen at gmail.com
Sat Jun 17 21:07:54 EEST 2023


The sRGB color space uses RGB matrix (i.e. identity), BT.709 primaries,
and the ISO/IEC 61966-2-1 transfer function (unique to sRGB). This set
of tags is very common, so printing it as "sRGB" instead of the current
form "gbr/bt709/iec61966-2-1" is preferable.

Signed-off-by: <leo.izen at gmail.com>
---
 libavcodec/avcodec.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/libavcodec/avcodec.c b/libavcodec/avcodec.c
index db8226f9b3..8132c76aad 100644
--- a/libavcodec/avcodec.c
+++ b/libavcodec/avcodec.c
@@ -571,7 +571,11 @@ void avcodec_string(char *buf, int buf_size, AVCodecContext *enc, int encode)
                 const char *col = unknown_if_null(av_color_space_name(enc->colorspace));
                 const char *pri = unknown_if_null(av_color_primaries_name(enc->color_primaries));
                 const char *trc = unknown_if_null(av_color_transfer_name(enc->color_trc));
-                if (strcmp(col, pri) || strcmp(col, trc)) {
+                if (enc->colorspace == AVCOL_SPC_RGB &&
+                        enc->color_primaries == AVCOL_PRI_BT709 &&
+                        enc->color_trc == AVCOL_TRC_IEC61966_2_1) {
+                    av_bprintf(&bprint, "sRGB, ");
+                } else if (strcmp(col, pri) || strcmp(col, trc)) {
                     new_line = 1;
                     av_bprintf(&bprint, "%s/%s/%s, ", col, pri, trc);
                 } else
-- 
2.41.0



More information about the ffmpeg-devel mailing list