diff mbox series

[FFmpeg-devel,6/8] avformat/rtpdec_rfc4175: add support for TCS

Message ID 1633515251-5156-6-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 | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

Comments

Andreas Rheinhardt Oct. 11, 2021, 3:01 p.m. UTC | #1
lance.lmwang@gmail.com:
> From: Limin Wang <lance.lmwang@gmail.com>
> 
> Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
> ---
>  libavformat/rtpdec_rfc4175.c | 19 +++++++++++++++++++
>  1 file changed, 19 insertions(+)
> 
> diff --git a/libavformat/rtpdec_rfc4175.c b/libavformat/rtpdec_rfc4175.c
> index 367567d..db6b9b8 100644
> --- a/libavformat/rtpdec_rfc4175.c
> +++ b/libavformat/rtpdec_rfc4175.c
> @@ -30,6 +30,7 @@
>  struct PayloadContext {
>      char *sampling;
>      char *framerate;
> +    char *TCS;
>      int depth;
>      int width;
>      int height;
> @@ -66,6 +67,21 @@ static int rfc4175_parse_format(AVStream *stream, PayloadContext *data)
>          return AVERROR_INVALIDDATA;
>      }
>  
> +    if (!data->TCS)
> +        stream->codecpar->color_trc = AVCOL_TRC_UNSPECIFIED;
> +    else if (!strncmp(data->TCS, "SDR", 3))
> +        stream->codecpar->color_trc = AVCOL_TRC_BT709;
> +    else if (!strncmp(data->TCS, "PQ", 2))
> +        stream->codecpar->color_trc = AVCOL_TRC_SMPTE2084;
> +    else if (!strncmp(data->TCS, "HLG", 3))
> +        stream->codecpar->color_trc = AVCOL_TRC_ARIB_STD_B67;
> +    else if (!strncmp(data->TCS, "LINEAR", 6))
> +        stream->codecpar->color_trc = AVCOL_TRC_LINEAR;
> +    else if (!strncmp(data->TCS, "ST428-1", 7))
> +        stream->codecpar->color_trc = AVCOL_TRC_SMPTEST428_1;
> +    else if (!strncmp(data->TCS, "UNSPECIFIED", 11))
> +        stream->codecpar->color_trc = AVCOL_TRC_UNSPECIFIED;
> +
>      desc = av_pix_fmt_desc_get(pixfmt);
>      stream->codecpar->format = pixfmt;
>      stream->codecpar->codec_tag = tag;
> @@ -97,6 +113,8 @@ static int rfc4175_parse_fmtp(AVFormatContext *s, AVStream *stream,
>          data->depth = atoi(value);
>      else if (!strncmp(attr, "exactframerate", 14))
>          data->framerate = av_strdup(value);
> +    else if (!strncmp(attr, "TCS", 3))
> +        data->TCS = av_strdup(value);
>  
>      return 0;
>  }
> @@ -126,6 +144,7 @@ static int rfc4175_parse_sdp_line(AVFormatContext *s, int st_index,
>          ret = rfc4175_parse_format(stream, data);
>          av_freep(&data->sampling);
>          av_freep(&data->framerate);
> +        av_freep(&data->TCS);
>  
>          return ret;
>      }
> 

Same here: Why an (unchecked) temporary value?

- Andreas
Limin Wang Oct. 11, 2021, 3:25 p.m. UTC | #2
On Mon, Oct 11, 2021 at 05:01:54PM +0200, Andreas Rheinhardt wrote:
> lance.lmwang@gmail.com:
> > From: Limin Wang <lance.lmwang@gmail.com>
> > 
> > Signed-off-by: Limin Wang <lance.lmwang@gmail.com>
> > ---
> >  libavformat/rtpdec_rfc4175.c | 19 +++++++++++++++++++
> >  1 file changed, 19 insertions(+)
> > 
> > diff --git a/libavformat/rtpdec_rfc4175.c b/libavformat/rtpdec_rfc4175.c
> > index 367567d..db6b9b8 100644
> > --- a/libavformat/rtpdec_rfc4175.c
> > +++ b/libavformat/rtpdec_rfc4175.c
> > @@ -30,6 +30,7 @@
> >  struct PayloadContext {
> >      char *sampling;
> >      char *framerate;
> > +    char *TCS;
> >      int depth;
> >      int width;
> >      int height;
> > @@ -66,6 +67,21 @@ static int rfc4175_parse_format(AVStream *stream, PayloadContext *data)
> >          return AVERROR_INVALIDDATA;
> >      }
> >  
> > +    if (!data->TCS)
> > +        stream->codecpar->color_trc = AVCOL_TRC_UNSPECIFIED;
> > +    else if (!strncmp(data->TCS, "SDR", 3))
> > +        stream->codecpar->color_trc = AVCOL_TRC_BT709;
> > +    else if (!strncmp(data->TCS, "PQ", 2))
> > +        stream->codecpar->color_trc = AVCOL_TRC_SMPTE2084;
> > +    else if (!strncmp(data->TCS, "HLG", 3))
> > +        stream->codecpar->color_trc = AVCOL_TRC_ARIB_STD_B67;
> > +    else if (!strncmp(data->TCS, "LINEAR", 6))
> > +        stream->codecpar->color_trc = AVCOL_TRC_LINEAR;
> > +    else if (!strncmp(data->TCS, "ST428-1", 7))
> > +        stream->codecpar->color_trc = AVCOL_TRC_SMPTEST428_1;
> > +    else if (!strncmp(data->TCS, "UNSPECIFIED", 11))
> > +        stream->codecpar->color_trc = AVCOL_TRC_UNSPECIFIED;
> > +
> >      desc = av_pix_fmt_desc_get(pixfmt);
> >      stream->codecpar->format = pixfmt;
> >      stream->codecpar->codec_tag = tag;
> > @@ -97,6 +113,8 @@ static int rfc4175_parse_fmtp(AVFormatContext *s, AVStream *stream,
> >          data->depth = atoi(value);
> >      else if (!strncmp(attr, "exactframerate", 14))
> >          data->framerate = av_strdup(value);
> > +    else if (!strncmp(attr, "TCS", 3))
> > +        data->TCS = av_strdup(value);
> >  
> >      return 0;
> >  }
> > @@ -126,6 +144,7 @@ static int rfc4175_parse_sdp_line(AVFormatContext *s, int st_index,
> >          ret = rfc4175_parse_format(stream, data);
> >          av_freep(&data->sampling);
> >          av_freep(&data->framerate);
> > +        av_freep(&data->TCS);
> >  
> >          return ret;
> >      }
> > 
> 
> Same here: Why an (unchecked) temporary value?

OK, will updated to remove the temporary value.

> 
> - Andreas
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
diff mbox series

Patch

diff --git a/libavformat/rtpdec_rfc4175.c b/libavformat/rtpdec_rfc4175.c
index 367567d..db6b9b8 100644
--- a/libavformat/rtpdec_rfc4175.c
+++ b/libavformat/rtpdec_rfc4175.c
@@ -30,6 +30,7 @@ 
 struct PayloadContext {
     char *sampling;
     char *framerate;
+    char *TCS;
     int depth;
     int width;
     int height;
@@ -66,6 +67,21 @@  static int rfc4175_parse_format(AVStream *stream, PayloadContext *data)
         return AVERROR_INVALIDDATA;
     }
 
+    if (!data->TCS)
+        stream->codecpar->color_trc = AVCOL_TRC_UNSPECIFIED;
+    else if (!strncmp(data->TCS, "SDR", 3))
+        stream->codecpar->color_trc = AVCOL_TRC_BT709;
+    else if (!strncmp(data->TCS, "PQ", 2))
+        stream->codecpar->color_trc = AVCOL_TRC_SMPTE2084;
+    else if (!strncmp(data->TCS, "HLG", 3))
+        stream->codecpar->color_trc = AVCOL_TRC_ARIB_STD_B67;
+    else if (!strncmp(data->TCS, "LINEAR", 6))
+        stream->codecpar->color_trc = AVCOL_TRC_LINEAR;
+    else if (!strncmp(data->TCS, "ST428-1", 7))
+        stream->codecpar->color_trc = AVCOL_TRC_SMPTEST428_1;
+    else if (!strncmp(data->TCS, "UNSPECIFIED", 11))
+        stream->codecpar->color_trc = AVCOL_TRC_UNSPECIFIED;
+
     desc = av_pix_fmt_desc_get(pixfmt);
     stream->codecpar->format = pixfmt;
     stream->codecpar->codec_tag = tag;
@@ -97,6 +113,8 @@  static int rfc4175_parse_fmtp(AVFormatContext *s, AVStream *stream,
         data->depth = atoi(value);
     else if (!strncmp(attr, "exactframerate", 14))
         data->framerate = av_strdup(value);
+    else if (!strncmp(attr, "TCS", 3))
+        data->TCS = av_strdup(value);
 
     return 0;
 }
@@ -126,6 +144,7 @@  static int rfc4175_parse_sdp_line(AVFormatContext *s, int st_index,
         ret = rfc4175_parse_format(stream, data);
         av_freep(&data->sampling);
         av_freep(&data->framerate);
+        av_freep(&data->TCS);
 
         return ret;
     }