[FFmpeg-devel] [PATCH v2] avformat/pcm: decrease delay when reading PCM streams.

Michael Niedermayer michael at niedermayer.cc
Thu Feb 15 02:54:17 EET 2018


On Wed, Feb 14, 2018 at 03:11:54PM +0100, Philipp M. Scholl wrote:
> Hi there,
> 
>  thanks for the feedback. I made the following changes to the patch:
> 
>  - hard-code to 40ms delay. Wasn't really sure what a good value is. But given
>    that the is mainly for encoding low-rate sensor data in audio streams,
>    together with a video recording, 40ms should be fine in most cases.
> 
>  - fix issue when sample rate is smaller (<100, now 25).
> 
>  - use ff_log2 for calculating a power of two read size. A power of two to make
>    efficient use of I/O buffers.
> 
>  - remove the superfluous check for multiple input streams. PCM decoders are
>    always single-streams, right?!
> 
>  - remove cosmetic changes, and remove readsize hunk :)
> 
>  any comments?
> 
> cheers,
>  -phil
> 
>  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 at bawue.de>
> ---
>  libavformat/pcm.c               | 14 ++++++++---
>  tests/ref/seek/acodec-pcm-f32be | 54 ++++++++++++++++++++---------------------
>  tests/ref/seek/acodec-pcm-f64be | 54 ++++++++++++++++++++---------------------
>  tests/ref/seek/lavf-alaw        | 44 ++++++++++++++++-----------------
>  tests/ref/seek/lavf-au          | 30 +++++++++++------------
>  tests/ref/seek/lavf-mov         | 44 ++++++++++++++++-----------------
>  tests/ref/seek/lavf-mulaw       | 44 ++++++++++++++++-----------------
>  tests/ref/seek/lavf-voc         | 22 ++++++++---------
>  8 files changed, 157 insertions(+), 149 deletions(-)

breaks fate


[...]
> --- a/tests/ref/seek/lavf-alaw
> +++ b/tests/ref/seek/lavf-alaw
> @@ -1,53 +1,53 @@
> -ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:      0 size:  1024
> +ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:      0 size:   128
>  ret: 0         st:-1 flags:0  ts:-1.000000
> -ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:      0 size:  1024
> +ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:      0 size:   128
>  ret: 0         st:-1 flags:1  ts: 1.894167
> -ret: 0         st: 0 flags:1 dts: 1.894150 pts: 1.894150 pos:  41766 size:  1024
> +ret: 0         st: 0 flags:1 dts: 1.894150 pts: 1.894150 pos:  41766 size:   128
>  ret: 0         st: 0 flags:0  ts: 0.788345
> -ret: 0         st: 0 flags:1 dts: 0.788345 pts: 0.788345 pos:  17383 size:  1024
> +ret: 0         st: 0 flags:1 dts: 0.788345 pts: 0.788345 pos:  17383 size:   128
>  ret: 0         st: 0 flags:1  ts:-0.317506
> -ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:      0 size:  1024
> +ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:      0 size:   128
>  ret: 0         st:-1 flags:0  ts: 2.576668
>  ret:-EOF

--- ./tests/ref/seek/lavf-alaw  2018-02-15 01:43:47.387759133 +0100
+++ tests/data/fate/seek-lavf-alaw      2018-02-15 01:49:09.979762980 +0100
@@ -1,53 +1,53 @@
-ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:      0 size:   128
+ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:      0 size:   512
 ret: 0         st:-1 flags:0  ts:-1.000000
-ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:      0 size:   128
+ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:      0 size:   512
 ret: 0         st:-1 flags:1  ts: 1.894167
-ret: 0         st: 0 flags:1 dts: 1.894150 pts: 1.894150 pos:  41766 size:   128
+ret: 0         st: 0 flags:1 dts: 1.894150 pts: 1.894150 pos:  41766 size:   512
 ret: 0         st: 0 flags:0  ts: 0.788345
-ret: 0         st: 0 flags:1 dts: 0.788345 pts: 0.788345 pos:  17383 size:   128
+ret: 0         st: 0 flags:1 dts: 0.788345 pts: 0.788345 pos:  17383 size:   512
 ret: 0         st: 0 flags:1  ts:-0.317506
-ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:      0 size:   128
+ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:      0 size:   512
 ret: 0         st:-1 flags:0  ts: 2.576668
 ret:-EOF

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Opposition brings concord. Out of discord comes the fairest harmony.
-- Heraclitus
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20180215/3ec4998a/attachment.sig>


More information about the ffmpeg-devel mailing list