---
libavformat/yuv4mpeg.c | 33 ++++++++++++++++++++++++++++++++-
1 files changed, 32 insertions(+), 1 deletions(-)
diff --git a/libavformat/yuv4mpeg.c b/libavformat/yuv4mpeg.c
index 698ee68..3b9c93f 100644
--- a/libavformat/yuv4mpeg.c
+++ b/libavformat/yuv4mpeg.c
@@ -20,14 +20,18 @@
*/
#include "avformat.h"
#include "internal.h"
+#include "libavutil/opt.h"
+#include "libavutil/parseutils.h"
#define Y4M_MAGIC "YUV4MPEG2"
#define Y4M_FRAME_MAGIC "FRAME"
#define Y4M_LINE_MAX 256
struct frame_attributes {
+ AVClass *class;
int interlaced_frame;
int top_field_first;
+ char *framerate_override;
};
#if CONFIG_YUV4MPEGPIPE_MUXER
@@ -339,6 +343,18 @@ static int yuv4_read_header(AVFormatContext *s,
AVFormatParameters *ap)
rated = 1;
}
+ if (s1->framerate_override && s1->framerate_override[0] != 0) {
+ AVRational r;
+ int ret = av_parse_video_rate(&r, s1->framerate_override);
+ if (ret < 0) {
+ av_log(s, AV_LOG_ERROR, "Could not parse framerate: %s.\n",
+ s1->framerate_override);
+ return ret;
+ }
+ raten = r.num;
+ rated = r.den;
+ }
+
if (aspectn == 0 && aspectd == 0) {
// Pixel aspect unknown
aspectd = 1;
@@ -409,6 +425,20 @@ static int yuv4_probe(AVProbeData *pd)
}
#if CONFIG_YUV4MPEGPIPE_DEMUXER
+#define OFFSET(x) offsetof(struct frame_attributes, x)
+#define DEC AV_OPT_FLAG_DECODING_PARAM
+static const AVOption y4m_options[] = {
+ { "framerate", "", OFFSET(framerate_override), AV_OPT_TYPE_STRING, {.str =
""}, 0, 0, DEC },
+ { NULL },
+};
+
+static const AVClass y4m_demuxer_class = {
+ .class_name = "y4m demuxer",
+ .item_name = av_default_item_name,
+ .option = y4m_options,
+ .version = LIBAVUTIL_VERSION_INT,
+};
+
AVInputFormat ff_yuv4mpegpipe_demuxer = {
.name = "yuv4mpegpipe",
.long_name = NULL_IF_CONFIG_SMALL("YUV4MPEG pipe format"),
@@ -416,6 +446,7 @@ AVInputFormat ff_yuv4mpegpipe_demuxer = {
.read_probe = yuv4_probe,
.read_header = yuv4_read_header,
.read_packet = yuv4_read_packet,
- .extensions = "y4m"
+ .extensions = "y4m",
+ .priv_class = &y4m_demuxer_class,
};
#endif
--
1.7.3.1
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel