diff options
author | wm4 <wm4@nowhere> | 2013-08-04 23:25:54 +0200 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2013-08-04 23:25:54 +0200 |
commit | cccfac47a423cbaeda04f9864c4676ed1c9d5002 (patch) | |
tree | 5de89b6851bcc04655d700c63ebf0c3e05342862 /demux | |
parent | b53497a403d0b1453e35f02a157542f67e0c7374 (diff) | |
download | mpv-cccfac47a423cbaeda04f9864c4676ed1c9d5002.tar.bz2 mpv-cccfac47a423cbaeda04f9864c4676ed1c9d5002.tar.xz |
demux_lavf: make avio buffer configurable
Perhaps not very useful, but reserved for situations when a user reports
awful latency and experimentation/debugging might be required to find
out why or to fix it (happens often).
Diffstat (limited to 'demux')
-rw-r--r-- | demux/demux_lavf.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/demux/demux_lavf.c b/demux/demux_lavf.c index 11e17f949f..1654562bd9 100644 --- a/demux/demux_lavf.c +++ b/demux/demux_lavf.c @@ -51,10 +51,16 @@ #define OPT_BASE_STRUCT struct MPOpts +// Should correspond to IO_BUFFER_SIZE in libavformat/aviobuf.c (not public) +// libavformat (almost) always reads data in blocks of this size. +#define BIO_BUFFER_SIZE 32768 + const m_option_t lavfdopts_conf[] = { OPT_INTRANGE("probesize", lavfdopts.probesize, 0, 32, INT_MAX), OPT_STRING("format", lavfdopts.format, 0), OPT_FLOATRANGE("analyzeduration", lavfdopts.analyzeduration, 0, 0, 3600), + OPT_INTRANGE("buffersize", lavfdopts.buffersize, 0, 1, 10 * 1024 * 1024, + OPTDEF_INT(BIO_BUFFER_SIZE)), OPT_FLAG("allow-mimetype", lavfdopts.allow_mimetype, 0), OPT_INTRANGE("probescore", lavfdopts.probescore, 0, 0, 100), OPT_STRING("cryptokey", lavfdopts.cryptokey, 0), @@ -64,10 +70,6 @@ const m_option_t lavfdopts_conf[] = { {NULL, NULL, 0, 0, 0, 0, NULL} }; -// Should correspond to IO_BUFFER_SIZE in libavformat/aviobuf.c (not public) -// libavformat (almost) always reads data in blocks of this size. -#define BIO_BUFFER_SIZE 32768 - #define MAX_PKT_QUEUE 50 typedef struct lavf_priv { @@ -570,10 +572,10 @@ static int demux_open_lavf(demuxer_t *demuxer, enum demux_check check) if (!(priv->avif->flags & AVFMT_NOFILE) && demuxer->stream->type != STREAMTYPE_AVDEVICE) { - void *buffer = av_malloc(BIO_BUFFER_SIZE); + void *buffer = av_malloc(lavfdopts->buffersize); if (!buffer) return -1; - priv->pb = avio_alloc_context(buffer, BIO_BUFFER_SIZE, 0, + priv->pb = avio_alloc_context(buffer, lavfdopts->buffersize, 0, demuxer, mp_read, NULL, mp_seek); if (!priv->pb) { av_free(buffer); |