[FFmpeg-cvslog] rawdec: add video_size private option.
Anton Khirnov
git at videolan.org
Fri May 27 23:57:12 CEST 2011
ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Tue May 24 07:43:01 2011 +0200| [973f686a6c4f7c3b9120a1e22cb7c0159ea9aee2] | committer: Anton Khirnov
rawdec: add video_size private option.
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=973f686a6c4f7c3b9120a1e22cb7c0159ea9aee2
---
libavformat/rawdec.c | 40 +++++++++++++++++++++++++++++++++++++---
libavformat/rawdec.h | 6 ++++++
libavformat/rawvideodec.c | 3 ++-
3 files changed, 45 insertions(+), 4 deletions(-)
diff --git a/libavformat/rawdec.c b/libavformat/rawdec.c
index b545dbd..265822b 100644
--- a/libavformat/rawdec.c
+++ b/libavformat/rawdec.c
@@ -24,6 +24,7 @@
#include "avio_internal.h"
#include "rawdec.h"
#include "libavutil/opt.h"
+#include "libavutil/parseutils.h"
/* raw input */
int ff_raw_read_header(AVFormatContext *s, AVFormatParameters *ap)
@@ -66,17 +67,34 @@ int ff_raw_read_header(AVFormatContext *s, AVFormatParameters *ap)
av_set_pts_info(st, 64, 1, st->codec->sample_rate);
break;
}
- case AVMEDIA_TYPE_VIDEO:
+ case AVMEDIA_TYPE_VIDEO: {
+ FFRawVideoDemuxerContext *s1 = s->priv_data;
+ int width = 0, height = 0, ret;
if(ap->time_base.num)
av_set_pts_info(st, 64, ap->time_base.num, ap->time_base.den);
else
av_set_pts_info(st, 64, 1, 25);
- st->codec->width = ap->width;
- st->codec->height = ap->height;
+ if (s1->video_size) {
+ ret = av_parse_video_size(&width, &height, s1->video_size);
+ av_freep(&s1->video_size);
+ if (ret < 0) {
+ av_log(s, AV_LOG_ERROR, "Couldn't parse video size.\n");
+ return ret;
+ }
+ }
+#if FF_API_FORMAT_PARAMETERS
+ if (ap->width > 0)
+ width = ap->width;
+ if (ap->height > 0)
+ height = ap->height;
+#endif
+ st->codec->width = width;
+ st->codec->height = height;
st->codec->pix_fmt = ap->pix_fmt;
if(st->codec->pix_fmt == PIX_FMT_NONE)
st->codec->pix_fmt= PIX_FMT_YUV420P;
break;
+ }
default:
return -1;
}
@@ -165,6 +183,22 @@ const AVClass ff_rawaudio_demuxer_class = {
.version = LIBAVUTIL_VERSION_INT,
};
+#define OFFSET(x) offsetof(FFRawVideoDemuxerContext, x)
+#define DEC AV_OPT_FLAG_DECODING_PARAM
+static const AVOption video_options[] = {
+ { "video_size", "A string describing frame size, such as 640x480 or hd720.", OFFSET(video_size), FF_OPT_TYPE_STRING, {.str = NULL}, 0, 0, DEC },
+ { NULL },
+};
+#undef OFFSET
+#undef DEC
+
+const AVClass ff_rawvideo_demuxer_class = {
+ .class_name = "rawvideo demuxer",
+ .item_name = av_default_item_name,
+ .option = video_options,
+ .version = LIBAVUTIL_VERSION_INT,
+};
+
#if CONFIG_G722_DEMUXER
AVInputFormat ff_g722_demuxer = {
"g722",
diff --git a/libavformat/rawdec.h b/libavformat/rawdec.h
index e473eb2..517efd4 100644
--- a/libavformat/rawdec.h
+++ b/libavformat/rawdec.h
@@ -31,7 +31,13 @@ typedef struct RawAudioDemuxerContext {
int channels;
} RawAudioDemuxerContext;
+typedef struct FFRawVideoDemuxerContext {
+ const AVClass *class; /**< Class for private options. */
+ char *video_size; /**< String describing video size, set by a private option. */
+} FFRawVideoDemuxerContext;
+
extern const AVClass ff_rawaudio_demuxer_class;
+extern const AVClass ff_rawvideo_demuxer_class;
int ff_raw_read_header(AVFormatContext *s, AVFormatParameters *ap);
diff --git a/libavformat/rawvideodec.c b/libavformat/rawvideodec.c
index a29f7da..f8d9b65 100644
--- a/libavformat/rawvideodec.c
+++ b/libavformat/rawvideodec.c
@@ -47,11 +47,12 @@ static int rawvideo_read_packet(AVFormatContext *s, AVPacket *pkt)
AVInputFormat ff_rawvideo_demuxer = {
"rawvideo",
NULL_IF_CONFIG_SMALL("raw video format"),
- 0,
+ sizeof(FFRawVideoDemuxerContext),
NULL,
ff_raw_read_header,
rawvideo_read_packet,
.flags= AVFMT_GENERIC_INDEX,
.extensions = "yuv,cif,qcif,rgb",
.value = CODEC_ID_RAWVIDEO,
+ .priv_class = &ff_rawvideo_demuxer_class,
};
More information about the ffmpeg-cvslog
mailing list