summaryrefslogtreecommitdiff
path: root/libavformat/tty.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2011-05-27 23:47:05 +0200
committerMichael Niedermayer <michaelni@gmx.at>2011-05-27 23:48:22 +0200
commit8381ab143779d25611a1bb05d674bc39fe940f77 (patch)
tree74773be2c947475433dcc47898aec49a0c4b198b /libavformat/tty.c
parentb8773e44d56667edea2d68d067d0c156522ca304 (diff)
parent79aeade6f6f8fbd7ce1da619fdd475e5db88ae24 (diff)
downloadffmpeg-8381ab143779d25611a1bb05d674bc39fe940f77.tar.gz
Merge remote-tracking branch 'qatar/master'
* qatar/master: (29 commits) ARM: disable ff_vector_fmul_vfp on VFPv3 systems ARM: check for VFPv3 swscale: Remove unused variables in x86 code. doc: Drop DJGPP section, Libav now compiles out-of-the-box on FreeDOS. x86: Add appropriate ifdefs around certain AVX functions. cmdutils: use sws_freeContext() instead of av_freep(). swscale: delay allocation of formatConvBuffer(). swscale: fix build with --disable-swscale-alpha. movenc: Deprecate the global RTP hinting flag, use a private AVOption instead movenc: Add an AVClass for setting muxer specific options swscale: fix non-bitexact yuv2yuv[X2]() MMX/MMX2 functions. configure: report yasm/nasm presence properly tcp: make connect() timeout properly rawdec: factor video demuxer definitions into a macro. rtspdec: add initial_pause private option. lavf: deprecate AVFormatParameters.width/height. tty: add video_size private option. rawdec: add video_size private option. x11grab: add video_size private option. x11grab: factorize returning error codes. ... Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavformat/tty.c')
-rw-r--r--libavformat/tty.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/libavformat/tty.c b/libavformat/tty.c
index 171099d3cb..8340218bd2 100644
--- a/libavformat/tty.c
+++ b/libavformat/tty.c
@@ -28,6 +28,7 @@
#include "libavutil/avstring.h"
#include "libavutil/log.h"
#include "libavutil/opt.h"
+#include "libavutil/parseutils.h"
#include "avformat.h"
#include "sauce.h"
@@ -35,6 +36,7 @@ typedef struct {
AVClass *class;
int chars_per_frame;
uint64_t fsize; /**< file size less metadata buffer */
+ char *video_size;/**< A string describing video size, set by a private option. */
} TtyDemuxContext;
/**
@@ -71,14 +73,30 @@ static int read_header(AVFormatContext *avctx,
AVFormatParameters *ap)
{
TtyDemuxContext *s = avctx->priv_data;
+ int width = 0, height = 0, ret;
AVStream *st = av_new_stream(avctx, 0);
if (!st)
return AVERROR(ENOMEM);
st->codec->codec_tag = 0;
st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
st->codec->codec_id = CODEC_ID_ANSI;
- if (ap->width) st->codec->width = ap->width;
- if (ap->height) st->codec->height = ap->height;
+
+ if (s->video_size) {
+ ret = av_parse_video_size(&width, &height, s->video_size);
+ av_freep(&s->video_size);
+ if (ret < 0) {
+ av_log (avctx, 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;
if (!ap->time_base.num) {
av_set_pts_info(st, 60, 1, 25);
@@ -129,8 +147,11 @@ static int read_packet(AVFormatContext *avctx, AVPacket *pkt)
return 0;
}
+#define OFFSET(x) offsetof(TtyDemuxContext, x)
+#define DEC AV_OPT_FLAG_DECODING_PARAM
static const AVOption options[] = {
{ "chars_per_frame", "", offsetof(TtyDemuxContext, chars_per_frame), FF_OPT_TYPE_INT, {.dbl = 6000}, 1, INT_MAX, AV_OPT_FLAG_DECODING_PARAM},
+ { "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 },
};