[FFmpeg-devel] [PATCH 5/8] avformat/rtpdec_rfc4175: add support for exactframerate

lance.lmwang at gmail.com lance.lmwang at gmail.com
Wed Oct 6 13:14:08 EEST 2021


From: Limin Wang <lance.lmwang at gmail.com>

Signed-off-by: Limin Wang <lance.lmwang at gmail.com>
---
 libavformat/rtpdec_rfc4175.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/libavformat/rtpdec_rfc4175.c b/libavformat/rtpdec_rfc4175.c
index 46d30ed..367567d 100644
--- a/libavformat/rtpdec_rfc4175.c
+++ b/libavformat/rtpdec_rfc4175.c
@@ -25,9 +25,11 @@
 #include "rtpdec_formats.h"
 #include "libavutil/avstring.h"
 #include "libavutil/pixdesc.h"
+#include "libavutil/parseutils.h"
 
 struct PayloadContext {
     char *sampling;
+    char *framerate;
     int depth;
     int width;
     int height;
@@ -45,6 +47,7 @@ static int rfc4175_parse_format(AVStream *stream, PayloadContext *data)
     enum AVPixelFormat pixfmt;
     int tag;
     const AVPixFmtDescriptor *desc;
+    AVRational framerate;
 
     if (!strncmp(data->sampling, "YCbCr-4:2:2", 11)) {
         tag = MKTAG('U', 'Y', 'V', 'Y');
@@ -69,6 +72,14 @@ static int rfc4175_parse_format(AVStream *stream, PayloadContext *data)
     stream->codecpar->bits_per_coded_sample = av_get_bits_per_pixel(desc);
     data->frame_size = data->width * data->height * data->pgroup / data->xinc;
 
+    if (data->framerate) {
+        if (av_parse_video_rate(&framerate, data->framerate) < 0)
+            return AVERROR(EINVAL);
+        stream->avg_frame_rate = framerate;
+        if (framerate.den)
+            stream->codecpar->bit_rate = data->frame_size * av_q2d(framerate) * 8;
+    }
+
     return 0;
 }
 
@@ -84,6 +95,8 @@ static int rfc4175_parse_fmtp(AVFormatContext *s, AVStream *stream,
         data->sampling = av_strdup(value);
     else if (!strncmp(attr, "depth", 5))
         data->depth = atoi(value);
+    else if (!strncmp(attr, "exactframerate", 14))
+        data->framerate = av_strdup(value);
 
     return 0;
 }
@@ -112,6 +125,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);
 
         return ret;
     }
-- 
1.8.3.1



More information about the ffmpeg-devel mailing list