[FFmpeg-devel] [PATCH 5/8] avformat/rtpdec_rfc4175: add support for exactframerate
lance.lmwang at gmail.com
lance.lmwang at gmail.com
Mon Oct 11 18:12:43 EEST 2021
On Mon, Oct 11, 2021 at 05:00:29PM +0200, Andreas Rheinhardt wrote:
> lance.lmwang at gmail.com:
> > 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;
> > }
> >
>
> Why the (unchecked!) allocation of a temporary string if you only want
> the number anyway?
I'm just following the same style for sampling, but I can change to parse the frame rate when
parsing fmtp string to save the temporary string allocation if you prefer to.
>
> - Andreas
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".
--
Thanks,
Limin Wang
More information about the ffmpeg-devel
mailing list