Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp M. Scholl <pscholl@bawue.de>2018-03-10 17:50:06 +0300
committerMichael Niedermayer <michael@niedermayer.cc>2018-03-13 03:34:42 +0300
commit040b28aeccce8bc3c2e109f8e0ea7f0ed4d3af08 (patch)
tree2f1ff70fb75f3f9f671e04fe04291048274d7051 /libavformat
parentaf7e953a595690caf4127957f42d639641035411 (diff)
avformat/pcm: decrease delay when reading PCM streams.
Thanks for the discussion. Here's the next version, now with /25 and removed ff_log2(). The blocksize of the PCM decoder is hard-coded. This creates unnecessary delay when reading low-rate (<100Hz) streams. This creates issues when multiplexing multiple streams, since other inputs are only opened/read after a low-rate input block was completely read. This patch decreases the blocksize for low-rate inputs, so approximately a block is read every 40ms. This decreases the startup delay when multiplexing inputs with different rates. Signed-off-by: Philipp M. Scholl <pscholl@bawue.de> Reviewed-by: Paul B Mahol <onemda@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavformat')
-rw-r--r--libavformat/pcm.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/libavformat/pcm.c b/libavformat/pcm.c
index 806f91b6b1..767bbd045a 100644
--- a/libavformat/pcm.c
+++ b/libavformat/pcm.c
@@ -28,13 +28,20 @@
int ff_pcm_read_packet(AVFormatContext *s, AVPacket *pkt)
{
+ AVCodecParameters *par = s->streams[0]->codecpar;
int ret, size;
- size= RAW_SAMPLES*s->streams[0]->codecpar->block_align;
- if (size <= 0)
+ if (par->block_align <= 0)
return AVERROR(EINVAL);
- ret= av_get_packet(s->pb, pkt, size);
+ /*
+ * Compute read size to complete a read every 62ms.
+ * Clamp to RAW_SAMPLES if larger.
+ */
+ size = FFMAX(par->sample_rate/25, 1);
+ size = FFMIN(size, RAW_SAMPLES) * par->block_align;
+
+ ret = av_get_packet(s->pb, pkt, size);
pkt->flags &= ~AV_PKT_FLAG_CORRUPT;
pkt->stream_index = 0;