diff mbox series

[FFmpeg-devel,7/8] avformat/rtpdec_rfc4175: add support for colorimetry

Message ID 1633515251-5156-7-git-send-email-lance.lmwang@gmail.com
State New
Headers show
Series [FFmpeg-devel,1/8] avcodec/bitpacked: check av_buffer_ref result
Related show

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_ppc success Make finished
andriy/make_fate_ppc success Make fate finished

Commit Message

Limin Wang Oct. 6, 2021, 10:14 a.m. UTC
From: Limin Wang <lance.lmwang@gmail.com>

Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
---
 libavformat/rtpdec_rfc4175.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
diff mbox series

Patch

diff --git a/libavformat/rtpdec_rfc4175.c b/libavformat/rtpdec_rfc4175.c
index db6b9b8..23a3f4f 100644
--- a/libavformat/rtpdec_rfc4175.c
+++ b/libavformat/rtpdec_rfc4175.c
@@ -31,6 +31,7 @@  struct PayloadContext {
     char *sampling;
     char *framerate;
     char *TCS;
+    char *colorimetry;
     int depth;
     int width;
     int height;
@@ -82,6 +83,20 @@  static int rfc4175_parse_format(AVStream *stream, PayloadContext *data)
     else if (!strncmp(data->TCS, "UNSPECIFIED", 11))
         stream->codecpar->color_trc = AVCOL_TRC_UNSPECIFIED;
 
+    if (!data->colorimetry) {
+        stream->codecpar->color_primaries = AVCOL_PRI_UNSPECIFIED;
+        stream->codecpar->color_space     = AVCOL_SPC_UNSPECIFIED;
+    } else if (!strncmp(data->colorimetry, "BT601", 5)) {
+        stream->codecpar->color_primaries = AVCOL_PRI_BT470BG;
+        stream->codecpar->color_space     = AVCOL_SPC_BT470BG;
+    } else if (!strncmp(data->colorimetry, "BT709", 5)) {
+        stream->codecpar->color_primaries = AVCOL_PRI_BT709;
+        stream->codecpar->color_space     = AVCOL_SPC_BT709;
+    } else if (!strncmp(data->colorimetry, "BT2020", 6)) {
+        stream->codecpar->color_primaries = AVCOL_PRI_BT2020;
+        stream->codecpar->color_space     = AVCOL_SPC_BT2020_NCL;
+    }
+
     desc = av_pix_fmt_desc_get(pixfmt);
     stream->codecpar->format = pixfmt;
     stream->codecpar->codec_tag = tag;
@@ -115,6 +130,8 @@  static int rfc4175_parse_fmtp(AVFormatContext *s, AVStream *stream,
         data->framerate = av_strdup(value);
     else if (!strncmp(attr, "TCS", 3))
         data->TCS = av_strdup(value);
+    else if (!strncmp(attr, "colorimetry", 11))
+        data->colorimetry = av_strdup(value);
 
     return 0;
 }
@@ -145,6 +162,7 @@  static int rfc4175_parse_sdp_line(AVFormatContext *s, int st_index,
         av_freep(&data->sampling);
         av_freep(&data->framerate);
         av_freep(&data->TCS);
+        av_freep(&data->colorimetry);
 
         return ret;
     }