Message ID | 20230617180754.216755-1-leo.izen@gmail.com |
---|---|
State | New |
Headers | show |
Series | [FFmpeg-devel] avcodec: use sRGB to stringify gbr/bt709/iec61966-2-1 instead | expand |
Context | Check | Description |
---|---|---|
yinshiyou/make_loongarch64 | success | Make finished |
yinshiyou/make_fate_loongarch64 | success | Make fate finished |
andriy/make_x86 | success | Make finished |
andriy/make_fate_x86 | success | Make fate finished |
On 6/17/2023 7:07 PM, Leo Izen wrote: > - 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)) { I real dont think special casing a single colorspace like this is a good idea, nor do I think hiding the explicit values is. Same reason we do not special case e.g. HLG. - Derek
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
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@gmail.com> --- libavcodec/avcodec.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)