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

Submitted by Philipp M. Scholl on Feb. 13, 2018, 2:11 p.m.

Details

Message ID 20180213141049.GA14366@pluto.informatik.privat
State New
Headers show

Commit Message

Philipp M. Scholl Feb. 13, 2018, 2:11 p.m.
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 10ms. This decreases the startup
delay when multiplexing inputs with different rates.

Signed-off-by: Philipp M. Scholl <pscholl@bawue.de>
---
 libavformat/pcm.c               | 41 +++++++++++++++++++++++++++----
 tests/Makefile                  |  1 +
 tests/ref/lavf/ast              |  4 +--
 tests/ref/lavf/mov              | 24 +++++++++---------
 tests/ref/lavf/smjpeg           |  6 ++---
 tests/ref/lavf/voc              |  4 +--
 tests/ref/lavf/voc_s16          |  4 +--
 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 ++++++++---------
 14 files changed, 204 insertions(+), 172 deletions(-)

Comments

Hendrik Leppkes Feb. 13, 2018, 3:09 p.m.
On Tue, Feb 13, 2018 at 3:11 PM, Philipp M. Scholl <pscholl@bawue.de> wrote:
>  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 10ms. This decreases the startup
> delay when multiplexing inputs with different rates.
>
> Signed-off-by: Philipp M. Scholl <pscholl@bawue.de>
> ---
>  libavformat/pcm.c               | 41 +++++++++++++++++++++++++++----
>  tests/Makefile                  |  1 +
>  tests/ref/lavf/ast              |  4 +--
>  tests/ref/lavf/mov              | 24 +++++++++---------
>  tests/ref/lavf/smjpeg           |  6 ++---
>  tests/ref/lavf/voc              |  4 +--
>  tests/ref/lavf/voc_s16          |  4 +--
>  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 ++++++++---------
>  14 files changed, 204 insertions(+), 172 deletions(-)
>
> diff --git a/libavformat/pcm.c b/libavformat/pcm.c
> index 806f91b6b1..f0ea029633 100644
> --- a/libavformat/pcm.c
> +++ b/libavformat/pcm.c
> @@ -24,17 +24,48 @@
>  #include "internal.h"
>  #include "pcm.h"
>
> -#define RAW_SAMPLES     1024
> +#define RAW_SAMPLES 1024
> +
> +/*
> + * copied from https://stackoverflow.com/questions/2679815/previous-power-of-2
> + * computes the previous power of two.
> + */
> +static uint32_t flp2 (uint32_t x)
> +{
> +    x = x | (x >> 1);
> +    x = x | (x >> 2);
> +    x = x | (x >> 4);
> +    x = x | (x >> 8);
> +    x = x | (x >> 16);
> +    x = x - (x >> 1);
> +    return x + (x == 0); /* if x is zero, return 1 */
> +}

I can't comment on the usefulness of the change as a whole, but we
have ff_clz for this.

>
>  int ff_pcm_read_packet(AVFormatContext *s, AVPacket *pkt)
>  {
> -    int ret, size;
> +    int i, ret, strmsize, readsize = INT_MAX;
> +    AVCodecParameters *codec;
> +
> +     /*
> +      * recompute read size based on sample rate of the inputs, make sure
> +      * to complete a read every 10ms by selecting the smallest sample rate
> +      */
> +    for (i=0; i < s->nb_streams; i++) {
> +      codec = s->streams[i]->codecpar;
> +      strmsize = codec->sample_rate / 100 * codec->block_align;
> +      readsize = FFMIN(readsize, strmsize);
> +    }
> +
> +    /*
> +     * clamp to RAW_SAMPLES if larger, and to previous power of two.
> +     */
> +    readsize = flp2(FFMIN(readsize,
> +               RAW_SAMPLES * s->streams[0]->codecpar->block_align));
>
> -    size= RAW_SAMPLES*s->streams[0]->codecpar->block_align;
> -    if (size <= 0)
> +    if (readsize <= 0)
>          return AVERROR(EINVAL);
>
> -    ret= av_get_packet(s->pb, pkt, size);
> +    ret = av_get_packet(s->pb, pkt, readsize);
>
>      pkt->flags &= ~AV_PKT_FLAG_CORRUPT;
>      pkt->stream_index = 0;
> diff --git a/tests/Makefile b/tests/Makefile
> index 327e3f4420..9df0d7eff9 100644
> --- a/tests/Makefile
> +++ b/tests/Makefile
> @@ -1,3 +1,4 @@
> +PROGSSUF = _g
>  THREADS = 1
>  VREF = tests/vsynth1/00.pgm
>  AREF = tests/data/asynth1.sw
> diff --git a/tests/ref/lavf/ast b/tests/ref/lavf/ast
> index 513c612e76..f01786720d 100644
> --- a/tests/ref/lavf/ast
> +++ b/tests/ref/lavf/ast
> @@ -1,3 +1,3 @@
> -07f5d23aa8bade984034f7005bd72947 *./tests/data/lavf/lavf.ast
> -177872 ./tests/data/lavf/lavf.ast
> +7b3e74233bb7399593316b9fced596fd *./tests/data/lavf/lavf.ast
> +182000 ./tests/data/lavf/lavf.ast
>  ./tests/data/lavf/lavf.ast CRC=0xe61e3bd0
> diff --git a/tests/ref/lavf/mov b/tests/ref/lavf/mov
> index 2e1f24dfc6..57324f73f7 100644
> --- a/tests/ref/lavf/mov
> +++ b/tests/ref/lavf/mov
> @@ -1,15 +1,15 @@
> -a10d50f2679df92264e1fc21cb8be630 *./tests/data/lavf/lavf.mov
> -366449 ./tests/data/lavf/lavf.mov
> -./tests/data/lavf/lavf.mov CRC=0xbb2b949b
> -6258f70f974e3c802e01d02ac33c7bbd *./tests/data/lavf/lavf.mov
> -357539 ./tests/data/lavf/lavf.mov
> -./tests/data/lavf/lavf.mov CRC=0xbb2b949b
> -ba3b8b49e420510a0d417400dbedfc2d *./tests/data/lavf/lavf.mov
> -366621 ./tests/data/lavf/lavf.mov
> -./tests/data/lavf/lavf.mov CRC=0xa9793231
> -fd0e4de8e7f6d0c8c0681d7020f00f50 *./tests/data/lavf/lavf.mov
> -356921 ./tests/data/lavf/lavf.mov
> -./tests/data/lavf/lavf.mov CRC=0xbb2b949b
> +fc5707661e4fbfec0613202feacdc005 *./tests/data/lavf/lavf.mov
> +371609 ./tests/data/lavf/lavf.mov
> +./tests/data/lavf/lavf.mov CRC=0x1e04949b
> +f901c132467eaaa3d0b0620418b8ce54 *./tests/data/lavf/lavf.mov
> +357443 ./tests/data/lavf/lavf.mov
> +./tests/data/lavf/lavf.mov CRC=0x1e04949b
> +0cb4720f248243fa7180a83b9aaa96d7 *./tests/data/lavf/lavf.mov
> +366489 ./tests/data/lavf/lavf.mov
> +./tests/data/lavf/lavf.mov CRC=0x10a43231
> +8cd0311e2e080675db3913a312fce2ce *./tests/data/lavf/lavf.mov
> +356825 ./tests/data/lavf/lavf.mov
> +./tests/data/lavf/lavf.mov CRC=0x1e04949b
>  ebca72c186a4f3ba9bb17d9cb5b74fef *./tests/data/lavf/lavf.mp4
>  312457 ./tests/data/lavf/lavf.mp4
>  ./tests/data/lavf/lavf.mp4 CRC=0x9d9a638a
> diff --git a/tests/ref/lavf/smjpeg b/tests/ref/lavf/smjpeg
> index fb8c6542fa..3ae3ffff65 100644
> --- a/tests/ref/lavf/smjpeg
> +++ b/tests/ref/lavf/smjpeg
> @@ -1,3 +1,3 @@
> -3fe90213ac4f5275eb85ad0a4e4bdb44 *./tests/data/lavf/lavf.smjpeg
> -728642 ./tests/data/lavf/lavf.smjpeg
> -./tests/data/lavf/lavf.smjpeg CRC=0x54bf6147
> +5df56884e1bd4aad5a26941c3ddc8196 *./tests/data/lavf/lavf.smjpeg
> +730190 ./tests/data/lavf/lavf.smjpeg
> +./tests/data/lavf/lavf.smjpeg CRC=0xde196147
> diff --git a/tests/ref/lavf/voc b/tests/ref/lavf/voc
> index ded8af7227..b543a051fe 100644
> --- a/tests/ref/lavf/voc
> +++ b/tests/ref/lavf/voc
> @@ -1,3 +1,3 @@
> -bb5ad96a5e1b35683d50bf18115db821 *./tests/data/lavf/lavf.voc
> -44305 ./tests/data/lavf/lavf.voc
> +6a101a05377ddd79aff95c3606810818 *./tests/data/lavf/lavf.voc
> +44821 ./tests/data/lavf/lavf.voc
>  ./tests/data/lavf/lavf.voc CRC=0x298fd284
> diff --git a/tests/ref/lavf/voc_s16 b/tests/ref/lavf/voc_s16
> index d026090aff..ccdb6366b1 100644
> --- a/tests/ref/lavf/voc_s16
> +++ b/tests/ref/lavf/voc_s16
> @@ -1,3 +1,3 @@
> -db9fa22ff71992bd8b6cc80047223c92 *./tests/data/lavf/lavf.s16.voc
> -176615 ./tests/data/lavf/lavf.s16.voc
> +ed4a2fdb86c34ad7f6d9772fd8cdfab1 *./tests/data/lavf/lavf.s16.voc
> +177131 ./tests/data/lavf/lavf.s16.voc
>  ./tests/data/lavf/lavf.s16.voc CRC=0xe61e3bd0
> diff --git a/tests/ref/seek/acodec-pcm-f32be b/tests/ref/seek/acodec-pcm-f32be
> index b838262b58..89c8e9d7a9 100644
> --- a/tests/ref/seek/acodec-pcm-f32be
> +++ b/tests/ref/seek/acodec-pcm-f32be
> @@ -1,53 +1,53 @@
> -ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size:  8192
> +ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size:  2048
>  ret: 0         st:-1 flags:0  ts:-1.000000
> -ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size:  8192
> +ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size:  2048
>  ret: 0         st:-1 flags:1  ts: 1.894167
> -ret: 0         st: 0 flags:1 dts: 1.894172 pts: 1.894172 pos: 668296 size:  8192
> +ret: 0         st: 0 flags:1 dts: 1.894172 pts: 1.894172 pos: 668296 size:  2048
>  ret: 0         st: 0 flags:0  ts: 0.788345
> -ret: 0         st: 0 flags:1 dts: 0.788345 pts: 0.788345 pos: 278160 size:  8192
> +ret: 0         st: 0 flags:1 dts: 0.788345 pts: 0.788345 pos: 278160 size:  2048
>  ret: 0         st: 0 flags:1  ts:-0.317506
> -ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size:  8192
> +ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size:  2048
>  ret: 0         st:-1 flags:0  ts: 2.576668
> -ret: 0         st: 0 flags:1 dts: 2.576667 pts: 2.576667 pos: 909080 size:  8192
> +ret: 0         st: 0 flags:1 dts: 2.576667 pts: 2.576667 pos: 909080 size:  2048
>  ret: 0         st:-1 flags:1  ts: 1.470835
> -ret: 0         st: 0 flags:1 dts: 1.470839 pts: 1.470839 pos: 518944 size:  8192
> +ret: 0         st: 0 flags:1 dts: 1.470839 pts: 1.470839 pos: 518944 size:  2048
>  ret: 0         st: 0 flags:0  ts: 0.365011
> -ret: 0         st: 0 flags:1 dts: 0.365011 pts: 0.365011 pos: 128808 size:  8192
> +ret: 0         st: 0 flags:1 dts: 0.365011 pts: 0.365011 pos: 128808 size:  2048
>  ret: 0         st: 0 flags:1  ts:-0.740839
> -ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size:  8192
> +ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size:  2048
>  ret: 0         st:-1 flags:0  ts: 2.153336
> -ret: 0         st: 0 flags:1 dts: 2.153333 pts: 2.153333 pos: 759728 size:  8192
> +ret: 0         st: 0 flags:1 dts: 2.153333 pts: 2.153333 pos: 759728 size:  2048
>  ret: 0         st:-1 flags:1  ts: 1.047503
> -ret: 0         st: 0 flags:1 dts: 1.047506 pts: 1.047506 pos: 369592 size:  8192
> +ret: 0         st: 0 flags:1 dts: 1.047506 pts: 1.047506 pos: 369592 size:  2048
>  ret: 0         st: 0 flags:0  ts:-0.058322
> -ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size:  8192
> +ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size:  2048
>  ret: 0         st: 0 flags:1  ts: 2.835828
> -ret: 0         st: 0 flags:1 dts: 2.835828 pts: 2.835828 pos:1000512 size:  8192
> +ret: 0         st: 0 flags:1 dts: 2.835828 pts: 2.835828 pos:1000512 size:  2048
>  ret: 0         st:-1 flags:0  ts: 1.730004
> -ret: 0         st: 0 flags:1 dts: 1.730000 pts: 1.730000 pos: 610376 size:  8192
> +ret: 0         st: 0 flags:1 dts: 1.730000 pts: 1.730000 pos: 610376 size:  2048
>  ret: 0         st:-1 flags:1  ts: 0.624171
> -ret: 0         st: 0 flags:1 dts: 0.624172 pts: 0.624172 pos: 220240 size:  8192
> +ret: 0         st: 0 flags:1 dts: 0.624172 pts: 0.624172 pos: 220240 size:  2048
>  ret: 0         st: 0 flags:0  ts:-0.481655
> -ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size:  8192
> +ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size:  2048
>  ret: 0         st: 0 flags:1  ts: 2.412494
> -ret: 0         st: 0 flags:1 dts: 2.412494 pts: 2.412494 pos: 851160 size:  8192
> +ret: 0         st: 0 flags:1 dts: 2.412494 pts: 2.412494 pos: 851160 size:  2048
>  ret: 0         st:-1 flags:0  ts: 1.306672
> -ret: 0         st: 0 flags:1 dts: 1.306667 pts: 1.306667 pos: 461024 size:  8192
> +ret: 0         st: 0 flags:1 dts: 1.306667 pts: 1.306667 pos: 461024 size:  2048
>  ret: 0         st:-1 flags:1  ts: 0.200839
> -ret: 0         st: 0 flags:1 dts: 0.200839 pts: 0.200839 pos:  70888 size:  8192
> +ret: 0         st: 0 flags:1 dts: 0.200839 pts: 0.200839 pos:  70888 size:  2048
>  ret: 0         st: 0 flags:0  ts:-0.904989
> -ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size:  8192
> +ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size:  2048
>  ret: 0         st: 0 flags:1  ts: 1.989184
> -ret: 0         st: 0 flags:1 dts: 1.989184 pts: 1.989184 pos: 701816 size:  8192
> +ret: 0         st: 0 flags:1 dts: 1.989184 pts: 1.989184 pos: 701816 size:  2048
>  ret: 0         st:-1 flags:0  ts: 0.883340
> -ret: 0         st: 0 flags:1 dts: 0.883333 pts: 0.883333 pos: 311672 size:  8192
> +ret: 0         st: 0 flags:1 dts: 0.883333 pts: 0.883333 pos: 311672 size:  2048
>  ret: 0         st:-1 flags:1  ts:-0.222493
> -ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size:  8192
> +ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size:  2048
>  ret: 0         st: 0 flags:0  ts: 2.671678
> -ret: 0         st: 0 flags:1 dts: 2.671678 pts: 2.671678 pos: 942600 size:  8192
> +ret: 0         st: 0 flags:1 dts: 2.671678 pts: 2.671678 pos: 942600 size:  2048
>  ret: 0         st: 0 flags:1  ts: 1.565850
> -ret: 0         st: 0 flags:1 dts: 1.565850 pts: 1.565850 pos: 552464 size:  8192
> +ret: 0         st: 0 flags:1 dts: 1.565850 pts: 1.565850 pos: 552464 size:  2048
>  ret: 0         st:-1 flags:0  ts: 0.460008
> -ret: 0         st: 0 flags:1 dts: 0.460000 pts: 0.460000 pos: 162320 size:  8192
> +ret: 0         st: 0 flags:1 dts: 0.460000 pts: 0.460000 pos: 162320 size:  2048
>  ret: 0         st:-1 flags:1  ts:-0.645825
> -ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size:  8192
> +ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size:  2048
> diff --git a/tests/ref/seek/acodec-pcm-f64be b/tests/ref/seek/acodec-pcm-f64be
> index 82223517d5..8b050e9914 100644
> --- a/tests/ref/seek/acodec-pcm-f64be
> +++ b/tests/ref/seek/acodec-pcm-f64be
> @@ -1,53 +1,53 @@
> -ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size: 16384
> +ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size:  4096
>  ret: 0         st:-1 flags:0  ts:-1.000000
> -ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size: 16384
> +ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size:  4096
>  ret: 0         st:-1 flags:1  ts: 1.894167
> -ret: 0         st: 0 flags:1 dts: 1.894172 pts: 1.894172 pos:1336560 size: 16384
> +ret: 0         st: 0 flags:1 dts: 1.894172 pts: 1.894172 pos:1336560 size:  4096
>  ret: 0         st: 0 flags:0  ts: 0.788345
> -ret: 0         st: 0 flags:1 dts: 0.788345 pts: 0.788345 pos: 556288 size: 16384
> +ret: 0         st: 0 flags:1 dts: 0.788345 pts: 0.788345 pos: 556288 size:  4096
>  ret: 0         st: 0 flags:1  ts:-0.317506
> -ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size: 16384
> +ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size:  4096
>  ret: 0         st:-1 flags:0  ts: 2.576668
> -ret: 0         st: 0 flags:1 dts: 2.576667 pts: 2.576667 pos:1818128 size: 16384
> +ret: 0         st: 0 flags:1 dts: 2.576667 pts: 2.576667 pos:1818128 size:  4096
>  ret: 0         st:-1 flags:1  ts: 1.470835
> -ret: 0         st: 0 flags:1 dts: 1.470839 pts: 1.470839 pos:1037856 size: 16384
> +ret: 0         st: 0 flags:1 dts: 1.470839 pts: 1.470839 pos:1037856 size:  4096
>  ret: 0         st: 0 flags:0  ts: 0.365011
> -ret: 0         st: 0 flags:1 dts: 0.365011 pts: 0.365011 pos: 257584 size: 16384
> +ret: 0         st: 0 flags:1 dts: 0.365011 pts: 0.365011 pos: 257584 size:  4096
>  ret: 0         st: 0 flags:1  ts:-0.740839
> -ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size: 16384
> +ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size:  4096
>  ret: 0         st:-1 flags:0  ts: 2.153336
> -ret: 0         st: 0 flags:1 dts: 2.153333 pts: 2.153333 pos:1519424 size: 16384
> +ret: 0         st: 0 flags:1 dts: 2.153333 pts: 2.153333 pos:1519424 size:  4096
>  ret: 0         st:-1 flags:1  ts: 1.047503
> -ret: 0         st: 0 flags:1 dts: 1.047506 pts: 1.047506 pos: 739152 size: 16384
> +ret: 0         st: 0 flags:1 dts: 1.047506 pts: 1.047506 pos: 739152 size:  4096
>  ret: 0         st: 0 flags:0  ts:-0.058322
> -ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size: 16384
> +ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size:  4096
>  ret: 0         st: 0 flags:1  ts: 2.835828
> -ret: 0         st: 0 flags:1 dts: 2.835828 pts: 2.835828 pos:2000992 size: 16384
> +ret: 0         st: 0 flags:1 dts: 2.835828 pts: 2.835828 pos:2000992 size:  4096
>  ret: 0         st:-1 flags:0  ts: 1.730004
> -ret: 0         st: 0 flags:1 dts: 1.730000 pts: 1.730000 pos:1220720 size: 16384
> +ret: 0         st: 0 flags:1 dts: 1.730000 pts: 1.730000 pos:1220720 size:  4096
>  ret: 0         st:-1 flags:1  ts: 0.624171
> -ret: 0         st: 0 flags:1 dts: 0.624172 pts: 0.624172 pos: 440448 size: 16384
> +ret: 0         st: 0 flags:1 dts: 0.624172 pts: 0.624172 pos: 440448 size:  4096
>  ret: 0         st: 0 flags:0  ts:-0.481655
> -ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size: 16384
> +ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size:  4096
>  ret: 0         st: 0 flags:1  ts: 2.412494
> -ret: 0         st: 0 flags:1 dts: 2.412494 pts: 2.412494 pos:1702288 size: 16384
> +ret: 0         st: 0 flags:1 dts: 2.412494 pts: 2.412494 pos:1702288 size:  4096
>  ret: 0         st:-1 flags:0  ts: 1.306672
> -ret: 0         st: 0 flags:1 dts: 1.306667 pts: 1.306667 pos: 922016 size: 16384
> +ret: 0         st: 0 flags:1 dts: 1.306667 pts: 1.306667 pos: 922016 size:  4096
>  ret: 0         st:-1 flags:1  ts: 0.200839
> -ret: 0         st: 0 flags:1 dts: 0.200839 pts: 0.200839 pos: 141744 size: 16384
> +ret: 0         st: 0 flags:1 dts: 0.200839 pts: 0.200839 pos: 141744 size:  4096
>  ret: 0         st: 0 flags:0  ts:-0.904989
> -ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size: 16384
> +ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size:  4096
>  ret: 0         st: 0 flags:1  ts: 1.989184
> -ret: 0         st: 0 flags:1 dts: 1.989184 pts: 1.989184 pos:1403600 size: 16384
> +ret: 0         st: 0 flags:1 dts: 1.989184 pts: 1.989184 pos:1403600 size:  4096
>  ret: 0         st:-1 flags:0  ts: 0.883340
> -ret: 0         st: 0 flags:1 dts: 0.883333 pts: 0.883333 pos: 623312 size: 16384
> +ret: 0         st: 0 flags:1 dts: 0.883333 pts: 0.883333 pos: 623312 size:  4096
>  ret: 0         st:-1 flags:1  ts:-0.222493
> -ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size: 16384
> +ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size:  4096
>  ret: 0         st: 0 flags:0  ts: 2.671678
> -ret: 0         st: 0 flags:1 dts: 2.671678 pts: 2.671678 pos:1885168 size: 16384
> +ret: 0         st: 0 flags:1 dts: 2.671678 pts: 2.671678 pos:1885168 size:  4096
>  ret: 0         st: 0 flags:1  ts: 1.565850
> -ret: 0         st: 0 flags:1 dts: 1.565850 pts: 1.565850 pos:1104896 size: 16384
> +ret: 0         st: 0 flags:1 dts: 1.565850 pts: 1.565850 pos:1104896 size:  4096
>  ret: 0         st:-1 flags:0  ts: 0.460008
> -ret: 0         st: 0 flags:1 dts: 0.460000 pts: 0.460000 pos: 324608 size: 16384
> +ret: 0         st: 0 flags:1 dts: 0.460000 pts: 0.460000 pos: 324608 size:  4096
>  ret: 0         st:-1 flags:1  ts:-0.645825
> -ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size: 16384
> +ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size:  4096
> diff --git a/tests/ref/seek/lavf-alaw b/tests/ref/seek/lavf-alaw
> index 4b1f8fbc02..e46de928a2 100644
> --- 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
>  ret: 0         st:-1 flags:1  ts: 1.470835
> -ret: 0         st: 0 flags:1 dts: 1.470839 pts: 1.470839 pos:  32432 size:  1024
> +ret: 0         st: 0 flags:1 dts: 1.470839 pts: 1.470839 pos:  32432 size:   128
>  ret: 0         st: 0 flags:0  ts: 0.364989
> -ret: 0         st: 0 flags:1 dts: 0.364989 pts: 0.364989 pos:   8048 size:  1024
> +ret: 0         st: 0 flags:1 dts: 0.364989 pts: 0.364989 pos:   8048 size:   128
>  ret: 0         st: 0 flags:1  ts:-0.740816
> -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.153336
>  ret:-EOF
>  ret: 0         st:-1 flags:1  ts: 1.047503
> -ret: 0         st: 0 flags:1 dts: 1.047483 pts: 1.047483 pos:  23097 size:  1024
> +ret: 0         st: 0 flags:1 dts: 1.047483 pts: 1.047483 pos:  23097 size:   128
>  ret: 0         st: 0 flags:0  ts:-0.058322
> -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: 0 flags:1  ts: 2.835828
>  ret:-EOF
>  ret: 0         st:-1 flags:0  ts: 1.730004
> -ret: 0         st: 0 flags:1 dts: 1.730023 pts: 1.730023 pos:  38147 size:  1024
> +ret: 0         st: 0 flags:1 dts: 1.730023 pts: 1.730023 pos:  38147 size:   128
>  ret: 0         st:-1 flags:1  ts: 0.624171
> -ret: 0         st: 0 flags:1 dts: 0.624172 pts: 0.624172 pos:  13763 size:  1024
> +ret: 0         st: 0 flags:1 dts: 0.624172 pts: 0.624172 pos:  13763 size:   128
>  ret: 0         st: 0 flags:0  ts:-0.481678
> -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: 0 flags:1  ts: 2.412517
>  ret:-EOF
>  ret: 0         st:-1 flags:0  ts: 1.306672
> -ret: 0         st: 0 flags:1 dts: 1.306667 pts: 1.306667 pos:  28812 size:  1024
> +ret: 0         st: 0 flags:1 dts: 1.306667 pts: 1.306667 pos:  28812 size:   128
>  ret: 0         st:-1 flags:1  ts: 0.200839
> -ret: 0         st: 0 flags:1 dts: 0.200816 pts: 0.200816 pos:   4428 size:  1024
> +ret: 0         st: 0 flags:1 dts: 0.200816 pts: 0.200816 pos:   4428 size:   128
>  ret: 0         st: 0 flags:0  ts:-0.904989
> -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: 0 flags:1  ts: 1.989161
> -ret: 0         st: 0 flags:1 dts: 1.989161 pts: 1.989161 pos:  43861 size:   239
> +ret: 0         st: 0 flags:1 dts: 1.989161 pts: 1.989161 pos:  43861 size:   128
>  ret: 0         st:-1 flags:0  ts: 0.883340
> -ret: 0         st: 0 flags:1 dts: 0.883356 pts: 0.883356 pos:  19478 size:  1024
> +ret: 0         st: 0 flags:1 dts: 0.883356 pts: 0.883356 pos:  19478 size:   128
>  ret: 0         st:-1 flags:1  ts:-0.222493
> -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: 0 flags:0  ts: 2.671655
>  ret:-EOF
>  ret: 0         st: 0 flags:1  ts: 1.565850
> -ret: 0         st: 0 flags:1 dts: 1.565850 pts: 1.565850 pos:  34527 size:  1024
> +ret: 0         st: 0 flags:1 dts: 1.565850 pts: 1.565850 pos:  34527 size:   128
>  ret: 0         st:-1 flags:0  ts: 0.460008
> -ret: 0         st: 0 flags:1 dts: 0.460000 pts: 0.460000 pos:  10143 size:  1024
> +ret: 0         st: 0 flags:1 dts: 0.460000 pts: 0.460000 pos:  10143 size:   128
>  ret: 0         st:-1 flags:1  ts:-0.645825
> -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
> diff --git a/tests/ref/seek/lavf-au b/tests/ref/seek/lavf-au
> index 8edce58f65..6ac6192738 100644
> --- a/tests/ref/seek/lavf-au
> +++ b/tests/ref/seek/lavf-au
> @@ -1,53 +1,53 @@
> -ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     40 size:  2048
> +ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     40 size:   512
>  ret: 0         st:-1 flags:0  ts:-1.000000
> -ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     40 size:  2048
> +ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     40 size:   512
>  ret: 0         st:-1 flags:1  ts: 1.894167
>  ret:-EOF
>  ret: 0         st: 0 flags:0  ts: 0.788345
> -ret: 0         st: 0 flags:1 dts: 0.788345 pts: 0.788345 pos:  69572 size:  2048
> +ret: 0         st: 0 flags:1 dts: 0.788345 pts: 0.788345 pos:  69572 size:   512
>  ret: 0         st: 0 flags:1  ts:-0.317506
> -ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     40 size:  2048
> +ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     40 size:   512
>  ret: 0         st:-1 flags:0  ts: 2.576668
>  ret:-EOF
>  ret: 0         st:-1 flags:1  ts: 1.470835
>  ret:-EOF
>  ret: 0         st: 0 flags:0  ts: 0.365011
> -ret: 0         st: 0 flags:1 dts: 0.365011 pts: 0.365011 pos:  32234 size:  2048
> +ret: 0         st: 0 flags:1 dts: 0.365011 pts: 0.365011 pos:  32234 size:   512
>  ret: 0         st: 0 flags:1  ts:-0.740839
> -ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     40 size:  2048
> +ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     40 size:   512
>  ret: 0         st:-1 flags:0  ts: 2.153336
>  ret:-EOF
>  ret: 0         st:-1 flags:1  ts: 1.047503
>  ret:-EOF
>  ret: 0         st: 0 flags:0  ts:-0.058322
> -ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     40 size:  2048
> +ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     40 size:   512
>  ret: 0         st: 0 flags:1  ts: 2.835828
>  ret:-EOF
>  ret: 0         st:-1 flags:0  ts: 1.730004
>  ret:-EOF
>  ret: 0         st:-1 flags:1  ts: 0.624171
> -ret: 0         st: 0 flags:1 dts: 0.624172 pts: 0.624172 pos:  55092 size:  2048
> +ret: 0         st: 0 flags:1 dts: 0.624172 pts: 0.624172 pos:  55092 size:   512
>  ret: 0         st: 0 flags:0  ts:-0.481655
> -ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     40 size:  2048
> +ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     40 size:   512
>  ret: 0         st: 0 flags:1  ts: 2.412494
>  ret:-EOF
>  ret: 0         st:-1 flags:0  ts: 1.306672
>  ret:-EOF
>  ret: 0         st:-1 flags:1  ts: 0.200839
> -ret: 0         st: 0 flags:1 dts: 0.200839 pts: 0.200839 pos:  17754 size:  2048
> +ret: 0         st: 0 flags:1 dts: 0.200839 pts: 0.200839 pos:  17754 size:   512
>  ret: 0         st: 0 flags:0  ts:-0.904989
> -ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     40 size:  2048
> +ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     40 size:   512
>  ret: 0         st: 0 flags:1  ts: 1.989184
>  ret:-EOF
>  ret: 0         st:-1 flags:0  ts: 0.883340
> -ret: 0         st: 0 flags:1 dts: 0.883333 pts: 0.883333 pos:  77950 size:  2048
> +ret: 0         st: 0 flags:1 dts: 0.883333 pts: 0.883333 pos:  77950 size:   512
>  ret: 0         st:-1 flags:1  ts:-0.222493
> -ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     40 size:  2048
> +ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     40 size:   512
>  ret: 0         st: 0 flags:0  ts: 2.671678
>  ret:-EOF
>  ret: 0         st: 0 flags:1  ts: 1.565850
>  ret:-EOF
>  ret: 0         st:-1 flags:0  ts: 0.460008
> -ret: 0         st: 0 flags:1 dts: 0.460000 pts: 0.460000 pos:  40612 size:  2048
> +ret: 0         st: 0 flags:1 dts: 0.460000 pts: 0.460000 pos:  40612 size:   512
>  ret: 0         st:-1 flags:1  ts:-0.645825
> -ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     40 size:  2048
> +ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     40 size:   512
> diff --git a/tests/ref/seek/lavf-mov b/tests/ref/seek/lavf-mov
> index 27ea7c7730..88fba97cf3 100644
> --- a/tests/ref/seek/lavf-mov
> +++ b/tests/ref/seek/lavf-mov
> @@ -1,48 +1,48 @@
> -ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:   1767 size: 27837
> +ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:   1671 size: 27837
>  ret: 0         st:-1 flags:0  ts:-1.000000
> -ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:   1767 size: 27837
> +ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:   1671 size: 27837
>  ret: 0         st:-1 flags:1  ts: 1.894167
> -ret: 0         st: 1 flags:1 dts: 0.952018 pts: 0.952018 pos: 326971 size:  1024
> +ret: 0         st: 1 flags:1 dts: 0.946213 pts: 0.946213 pos: 326619 size:   768
>  ret: 0         st: 0 flags:0  ts: 0.788359
> -ret: 0         st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 327995 size: 27834
> +ret: 0         st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 327387 size: 27834
>  ret: 0         st: 0 flags:1  ts:-0.317500
> -ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:   1767 size: 27837
> +ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:   1671 size: 27837
>  ret:-1         st: 1 flags:0  ts: 2.576667
>  ret: 0         st: 1 flags:1  ts: 1.470839
> -ret: 0         st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 327995 size: 27834
> +ret: 0         st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 327387 size: 27834
>  ret: 0         st:-1 flags:0  ts: 0.365002
> -ret: 0         st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 165249 size: 27925
> +ret: 0         st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 164897 size: 27925
>  ret: 0         st:-1 flags:1  ts:-0.740831
> -ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:   1767 size: 27837
> +ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:   1671 size: 27837
>  ret:-1         st: 0 flags:0  ts: 2.153359
>  ret: 0         st: 0 flags:1  ts: 1.047500
> -ret: 0         st: 1 flags:1 dts: 0.952018 pts: 0.952018 pos: 326971 size:  1024
> +ret: 0         st: 1 flags:1 dts: 0.946213 pts: 0.946213 pos: 326619 size:   768
>  ret: 0         st: 1 flags:0  ts:-0.058322
> -ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:   1767 size: 27837
> +ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:   1671 size: 27837
>  ret: 0         st: 1 flags:1  ts: 2.835828
> -ret: 0         st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 327995 size: 27834
> +ret: 0         st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 327387 size: 27834
>  ret:-1         st:-1 flags:0  ts: 1.730004
>  ret: 0         st:-1 flags:1  ts: 0.624171
> -ret: 0         st: 1 flags:1 dts: 0.464399 pts: 0.464399 pos: 164225 size:  1024
> +ret: 0         st: 1 flags:1 dts: 0.464399 pts: 0.464399 pos: 164129 size:   768
>  ret: 0         st: 0 flags:0  ts:-0.481641
> -ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:   1767 size: 27837
> +ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:   1671 size: 27837
>  ret: 0         st: 0 flags:1  ts: 2.412500
> -ret: 0         st: 1 flags:1 dts: 0.952018 pts: 0.952018 pos: 326971 size:  1024
> +ret: 0         st: 1 flags:1 dts: 0.946213 pts: 0.946213 pos: 326619 size:   768
>  ret:-1         st: 1 flags:0  ts: 1.306667
>  ret: 0         st: 1 flags:1  ts: 0.200839
> -ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:   1767 size: 27837
> +ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:   1671 size: 27837
>  ret: 0         st:-1 flags:0  ts:-0.904994
> -ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:   1767 size: 27837
> +ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:   1671 size: 27837
>  ret: 0         st:-1 flags:1  ts: 1.989173
> -ret: 0         st: 1 flags:1 dts: 0.952018 pts: 0.952018 pos: 326971 size:  1024
> +ret: 0         st: 1 flags:1 dts: 0.946213 pts: 0.946213 pos: 326619 size:   768
>  ret: 0         st: 0 flags:0  ts: 0.883359
> -ret: 0         st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 327995 size: 27834
> +ret: 0         st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 327387 size: 27834
>  ret: 0         st: 0 flags:1  ts:-0.222500
> -ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:   1767 size: 27837
> +ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:   1671 size: 27837
>  ret:-1         st: 1 flags:0  ts: 2.671678
>  ret: 0         st: 1 flags:1  ts: 1.565850
> -ret: 0         st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 327995 size: 27834
> +ret: 0         st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 327387 size: 27834
>  ret: 0         st:-1 flags:0  ts: 0.460008
> -ret: 0         st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 165249 size: 27925
> +ret: 0         st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 164897 size: 27925
>  ret: 0         st:-1 flags:1  ts:-0.645825
> -ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:   1767 size: 27837
> +ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:   1671 size: 27837
> diff --git a/tests/ref/seek/lavf-mulaw b/tests/ref/seek/lavf-mulaw
> index 4b1f8fbc02..e46de928a2 100644
> --- a/tests/ref/seek/lavf-mulaw
> +++ b/tests/ref/seek/lavf-mulaw
> @@ -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
>  ret: 0         st:-1 flags:1  ts: 1.470835
> -ret: 0         st: 0 flags:1 dts: 1.470839 pts: 1.470839 pos:  32432 size:  1024
> +ret: 0         st: 0 flags:1 dts: 1.470839 pts: 1.470839 pos:  32432 size:   128
>  ret: 0         st: 0 flags:0  ts: 0.364989
> -ret: 0         st: 0 flags:1 dts: 0.364989 pts: 0.364989 pos:   8048 size:  1024
> +ret: 0         st: 0 flags:1 dts: 0.364989 pts: 0.364989 pos:   8048 size:   128
>  ret: 0         st: 0 flags:1  ts:-0.740816
> -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.153336
>  ret:-EOF
>  ret: 0         st:-1 flags:1  ts: 1.047503
> -ret: 0         st: 0 flags:1 dts: 1.047483 pts: 1.047483 pos:  23097 size:  1024
> +ret: 0         st: 0 flags:1 dts: 1.047483 pts: 1.047483 pos:  23097 size:   128
>  ret: 0         st: 0 flags:0  ts:-0.058322
> -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: 0 flags:1  ts: 2.835828
>  ret:-EOF
>  ret: 0         st:-1 flags:0  ts: 1.730004
> -ret: 0         st: 0 flags:1 dts: 1.730023 pts: 1.730023 pos:  38147 size:  1024
> +ret: 0         st: 0 flags:1 dts: 1.730023 pts: 1.730023 pos:  38147 size:   128
>  ret: 0         st:-1 flags:1  ts: 0.624171
> -ret: 0         st: 0 flags:1 dts: 0.624172 pts: 0.624172 pos:  13763 size:  1024
> +ret: 0         st: 0 flags:1 dts: 0.624172 pts: 0.624172 pos:  13763 size:   128
>  ret: 0         st: 0 flags:0  ts:-0.481678
> -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: 0 flags:1  ts: 2.412517
>  ret:-EOF
>  ret: 0         st:-1 flags:0  ts: 1.306672
> -ret: 0         st: 0 flags:1 dts: 1.306667 pts: 1.306667 pos:  28812 size:  1024
> +ret: 0         st: 0 flags:1 dts: 1.306667 pts: 1.306667 pos:  28812 size:   128
>  ret: 0         st:-1 flags:1  ts: 0.200839
> -ret: 0         st: 0 flags:1 dts: 0.200816 pts: 0.200816 pos:   4428 size:  1024
> +ret: 0         st: 0 flags:1 dts: 0.200816 pts: 0.200816 pos:   4428 size:   128
>  ret: 0         st: 0 flags:0  ts:-0.904989
> -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: 0 flags:1  ts: 1.989161
> -ret: 0         st: 0 flags:1 dts: 1.989161 pts: 1.989161 pos:  43861 size:   239
> +ret: 0         st: 0 flags:1 dts: 1.989161 pts: 1.989161 pos:  43861 size:   128
>  ret: 0         st:-1 flags:0  ts: 0.883340
> -ret: 0         st: 0 flags:1 dts: 0.883356 pts: 0.883356 pos:  19478 size:  1024
> +ret: 0         st: 0 flags:1 dts: 0.883356 pts: 0.883356 pos:  19478 size:   128
>  ret: 0         st:-1 flags:1  ts:-0.222493
> -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: 0 flags:0  ts: 2.671655
>  ret:-EOF
>  ret: 0         st: 0 flags:1  ts: 1.565850
> -ret: 0         st: 0 flags:1 dts: 1.565850 pts: 1.565850 pos:  34527 size:  1024
> +ret: 0         st: 0 flags:1 dts: 1.565850 pts: 1.565850 pos:  34527 size:   128
>  ret: 0         st:-1 flags:0  ts: 0.460008
> -ret: 0         st: 0 flags:1 dts: 0.460000 pts: 0.460000 pos:  10143 size:  1024
> +ret: 0         st: 0 flags:1 dts: 0.460000 pts: 0.460000 pos:  10143 size:   128
>  ret: 0         st:-1 flags:1  ts:-0.645825
> -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
> diff --git a/tests/ref/seek/lavf-voc b/tests/ref/seek/lavf-voc
> index 014c251129..47d683230a 100644
> --- a/tests/ref/seek/lavf-voc
> +++ b/tests/ref/seek/lavf-voc
> @@ -1,44 +1,44 @@
> -ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size:  1024
> +ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size:   256
>  ret: 0         st:-1 flags:0  ts:-1.000000
> -ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size:  1024
> +ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size:   256
>  ret: 0         st:-1 flags:1  ts: 1.894167
>  ret:-EOF
>  ret: 0         st: 0 flags:0  ts: 0.788330
> -ret: 0         st: 0 flags:1 dts: 0.800773 pts: 0.800773 pos:  34984 size:  1024
> +ret: 0         st: 0 flags:1 dts: 0.788997 pts: 0.788997 pos:  34872 size:   256
>  ret:-1         st: 0 flags:1  ts:-0.317494
>  ret:-1         st:-1 flags:0  ts: 2.576668
>  ret: 0         st:-1 flags:1  ts: 1.470835
>  ret:-EOF
>  ret: 0         st: 0 flags:0  ts: 0.365012
> -ret: 0         st: 0 flags:1 dts: 0.376834 pts: 0.376834 pos:  16480 size:  1024
> +ret: 0         st: 0 flags:1 dts: 0.365058 pts: 0.365058 pos:  16152 size:   256
>  ret:-1         st: 0 flags:1  ts:-0.740834
>  ret:-1         st:-1 flags:0  ts: 2.153336
>  ret: 0         st:-1 flags:1  ts: 1.047503
>  ret:-EOF
>  ret: 0         st: 0 flags:0  ts:-0.058328
> -ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size:  1024
> +ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size:   256
>  ret: 0         st: 0 flags:1  ts: 2.835848
>  ret:-EOF
>  ret:-1         st:-1 flags:0  ts: 1.730004
>  ret: 0         st:-1 flags:1  ts: 0.624171
> -ret: 0         st: 0 flags:1 dts: 0.612356 pts: 0.612356 pos:  26760 size:  1024
> +ret: 0         st: 0 flags:1 dts: 0.624132 pts: 0.624132 pos:  27592 size:   256
>  ret: 0         st: 0 flags:0  ts:-0.481669
> -ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size:  1024
> +ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size:   256
>  ret: 0         st: 0 flags:1  ts: 2.412507
>  ret:-EOF
>  ret:-1         st:-1 flags:0  ts: 1.306672
>  ret: 0         st:-1 flags:1  ts: 0.200839
> -ret: 0         st: 0 flags:1 dts: 0.188417 pts: 0.188417 pos:   8256 size:  1024
> +ret: 0         st: 0 flags:1 dts: 0.200193 pts: 0.200193 pos:   8872 size:   256
>  ret: 0         st: 0 flags:0  ts:-0.904986
> -ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size:  1024
> +ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size:   256
>  ret: 0         st: 0 flags:1  ts: 1.989167
>  ret:-EOF
>  ret: 0         st:-1 flags:0  ts: 0.883340
> -ret: 0         st: 0 flags:1 dts: 0.894981 pts: 0.894981 pos:  39096 size:  1024
> +ret: 0         st: 0 flags:1 dts: 0.889093 pts: 0.889093 pos:  39292 size:   256
>  ret:-1         st:-1 flags:1  ts:-0.222493
>  ret:-1         st: 0 flags:0  ts: 2.671673
>  ret: 0         st: 0 flags:1  ts: 1.565849
>  ret:-EOF
>  ret: 0         st:-1 flags:0  ts: 0.460008
> -ret: 0         st: 0 flags:1 dts: 0.471043 pts: 0.471043 pos:  20592 size:  1024
> +ret: 0         st: 0 flags:1 dts: 0.465155 pts: 0.465155 pos:  20572 size:   256
>  ret:-1         st:-1 flags:1  ts:-0.645825
> --
> 2.16.1
>
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
Tomas Härdin Feb. 13, 2018, 3:11 p.m.
tis 2018-02-13 klockan 15:11 +0100 skrev Philipp M. Scholl:
>  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 10ms. This decreases the startup
> delay when multiplexing inputs with different rates.
> 
> > Signed-off-by: Philipp M. Scholl <pscholl@bawue.de>
> ---
> diff --git a/libavformat/pcm.c b/libavformat/pcm.c
> index 806f91b6b1..f0ea029633 100644
> --- a/libavformat/pcm.c
> +++ b/libavformat/pcm.c
> @@ -24,17 +24,48 @@
>  #include "internal.h"
>  #include "pcm.h"
>  
> -#define RAW_SAMPLES     1024
> +#define RAW_SAMPLES 1024

Please avoid mixing cosmetic and functional changes

> +
> +/*
> + * copied from https://stackoverflow.com/questions/2679815/previous-power-of-2
> + * computes the previous power of two.
> + */

Got any idea what kind of license Hacker's Delight uses?

> +static uint32_t flp2 (uint32_t x)
> +{
> +    x = x | (x >> 1);
> +    x = x | (x >> 2);
> +    x = x | (x >> 4);
> +    x = x | (x >> 8);
> +    x = x | (x >> 16);
> +    x = x - (x >> 1);
> +    return x + (x == 0); /* if x is zero, return 1 */
> +}

What's wrong with 1<<ff_log2(x)?

>  
>  int ff_pcm_read_packet(AVFormatContext *s, AVPacket *pkt)
>  {
> -    int ret, size;
> +    int i, ret, strmsize, readsize = INT_MAX;
> +    AVCodecParameters *codec;
> +
> +     /*
> +      * recompute read size based on sample rate of the inputs, make sure
> +      * to complete a read every 10ms by selecting the smallest sample rate
> +      */
> +    for (i=0; i < s->nb_streams; i++) {
> +      codec = s->streams[i]->codecpar;
> +      strmsize = codec->sample_rate / 100 * codec->block_align;

What if sample_rate < 100 Hz?

> +      readsize = FFMIN(readsize, strmsize);
> +    }
> +
> +    /*
> +     * clamp to RAW_SAMPLES if larger, and to previous power of two.
> +     */
> +    readsize = flp2(FFMIN(readsize,
> +               RAW_SAMPLES * s->streams[0]->codecpar->block_align));

Any particular reason for previous power of two?

>  
> -    size= RAW_SAMPLES*s->streams[0]->codecpar->block_align;
> -    if (size <= 0)
> +    if (readsize <= 0)
>          return AVERROR(EINVAL);

Might want to separate this into a check for block_align>0, then
FFMAX(readsize, block_align) so we always get something. That would
take care of the < 100 Hz issue

>  
> -    ret= av_get_packet(s->pb, pkt, size);
> +    ret = av_get_packet(s->pb, pkt, readsize);

Keeping the name as "size" removes the need for this hunk :)

/Tomas
Marton Balint Feb. 13, 2018, 7:09 p.m.
On Tue, 13 Feb 2018, Philipp M. Scholl wrote:

> 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 10ms. This decreases the startup
> delay when multiplexing inputs with different rates.

Maybe it's just me, but I'd shoot for at least 40 ms instead of 10 ms, too 
small audio frames are ineffective, and some areas of the code limit the 
number of frames in buffers (e.g.: avfilter), or the number of packets in 
queues (e.g.: muxing queue), so having bigger audio frames by default 
makes it less probable for the user to reach these limits and get strange 
errors.

If you really need smaller frames than 40 ms, then I suggest add a tunable 
parameter for the demuxer.

Regards,
Marton

Patch hide | download patch | download mbox

diff --git a/libavformat/pcm.c b/libavformat/pcm.c
index 806f91b6b1..f0ea029633 100644
--- a/libavformat/pcm.c
+++ b/libavformat/pcm.c
@@ -24,17 +24,48 @@ 
 #include "internal.h"
 #include "pcm.h"
 
-#define RAW_SAMPLES     1024
+#define RAW_SAMPLES 1024
+
+/*
+ * copied from https://stackoverflow.com/questions/2679815/previous-power-of-2
+ * computes the previous power of two.
+ */
+static uint32_t flp2 (uint32_t x)
+{
+    x = x | (x >> 1);
+    x = x | (x >> 2);
+    x = x | (x >> 4);
+    x = x | (x >> 8);
+    x = x | (x >> 16);
+    x = x - (x >> 1);
+    return x + (x == 0); /* if x is zero, return 1 */
+}
 
 int ff_pcm_read_packet(AVFormatContext *s, AVPacket *pkt)
 {
-    int ret, size;
+    int i, ret, strmsize, readsize = INT_MAX;
+    AVCodecParameters *codec;
+
+     /*
+      * recompute read size based on sample rate of the inputs, make sure
+      * to complete a read every 10ms by selecting the smallest sample rate
+      */
+    for (i=0; i < s->nb_streams; i++) {
+      codec = s->streams[i]->codecpar;
+      strmsize = codec->sample_rate / 100 * codec->block_align;
+      readsize = FFMIN(readsize, strmsize);
+    }
+
+    /*
+     * clamp to RAW_SAMPLES if larger, and to previous power of two.
+     */
+    readsize = flp2(FFMIN(readsize,
+               RAW_SAMPLES * s->streams[0]->codecpar->block_align));
 
-    size= RAW_SAMPLES*s->streams[0]->codecpar->block_align;
-    if (size <= 0)
+    if (readsize <= 0)
         return AVERROR(EINVAL);
 
-    ret= av_get_packet(s->pb, pkt, size);
+    ret = av_get_packet(s->pb, pkt, readsize);
 
     pkt->flags &= ~AV_PKT_FLAG_CORRUPT;
     pkt->stream_index = 0;
diff --git a/tests/Makefile b/tests/Makefile
index 327e3f4420..9df0d7eff9 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -1,3 +1,4 @@ 
+PROGSSUF = _g
 THREADS = 1
 VREF = tests/vsynth1/00.pgm
 AREF = tests/data/asynth1.sw
diff --git a/tests/ref/lavf/ast b/tests/ref/lavf/ast
index 513c612e76..f01786720d 100644
--- a/tests/ref/lavf/ast
+++ b/tests/ref/lavf/ast
@@ -1,3 +1,3 @@ 
-07f5d23aa8bade984034f7005bd72947 *./tests/data/lavf/lavf.ast
-177872 ./tests/data/lavf/lavf.ast
+7b3e74233bb7399593316b9fced596fd *./tests/data/lavf/lavf.ast
+182000 ./tests/data/lavf/lavf.ast
 ./tests/data/lavf/lavf.ast CRC=0xe61e3bd0
diff --git a/tests/ref/lavf/mov b/tests/ref/lavf/mov
index 2e1f24dfc6..57324f73f7 100644
--- a/tests/ref/lavf/mov
+++ b/tests/ref/lavf/mov
@@ -1,15 +1,15 @@ 
-a10d50f2679df92264e1fc21cb8be630 *./tests/data/lavf/lavf.mov
-366449 ./tests/data/lavf/lavf.mov
-./tests/data/lavf/lavf.mov CRC=0xbb2b949b
-6258f70f974e3c802e01d02ac33c7bbd *./tests/data/lavf/lavf.mov
-357539 ./tests/data/lavf/lavf.mov
-./tests/data/lavf/lavf.mov CRC=0xbb2b949b
-ba3b8b49e420510a0d417400dbedfc2d *./tests/data/lavf/lavf.mov
-366621 ./tests/data/lavf/lavf.mov
-./tests/data/lavf/lavf.mov CRC=0xa9793231
-fd0e4de8e7f6d0c8c0681d7020f00f50 *./tests/data/lavf/lavf.mov
-356921 ./tests/data/lavf/lavf.mov
-./tests/data/lavf/lavf.mov CRC=0xbb2b949b
+fc5707661e4fbfec0613202feacdc005 *./tests/data/lavf/lavf.mov
+371609 ./tests/data/lavf/lavf.mov
+./tests/data/lavf/lavf.mov CRC=0x1e04949b
+f901c132467eaaa3d0b0620418b8ce54 *./tests/data/lavf/lavf.mov
+357443 ./tests/data/lavf/lavf.mov
+./tests/data/lavf/lavf.mov CRC=0x1e04949b
+0cb4720f248243fa7180a83b9aaa96d7 *./tests/data/lavf/lavf.mov
+366489 ./tests/data/lavf/lavf.mov
+./tests/data/lavf/lavf.mov CRC=0x10a43231
+8cd0311e2e080675db3913a312fce2ce *./tests/data/lavf/lavf.mov
+356825 ./tests/data/lavf/lavf.mov
+./tests/data/lavf/lavf.mov CRC=0x1e04949b
 ebca72c186a4f3ba9bb17d9cb5b74fef *./tests/data/lavf/lavf.mp4
 312457 ./tests/data/lavf/lavf.mp4
 ./tests/data/lavf/lavf.mp4 CRC=0x9d9a638a
diff --git a/tests/ref/lavf/smjpeg b/tests/ref/lavf/smjpeg
index fb8c6542fa..3ae3ffff65 100644
--- a/tests/ref/lavf/smjpeg
+++ b/tests/ref/lavf/smjpeg
@@ -1,3 +1,3 @@ 
-3fe90213ac4f5275eb85ad0a4e4bdb44 *./tests/data/lavf/lavf.smjpeg
-728642 ./tests/data/lavf/lavf.smjpeg
-./tests/data/lavf/lavf.smjpeg CRC=0x54bf6147
+5df56884e1bd4aad5a26941c3ddc8196 *./tests/data/lavf/lavf.smjpeg
+730190 ./tests/data/lavf/lavf.smjpeg
+./tests/data/lavf/lavf.smjpeg CRC=0xde196147
diff --git a/tests/ref/lavf/voc b/tests/ref/lavf/voc
index ded8af7227..b543a051fe 100644
--- a/tests/ref/lavf/voc
+++ b/tests/ref/lavf/voc
@@ -1,3 +1,3 @@ 
-bb5ad96a5e1b35683d50bf18115db821 *./tests/data/lavf/lavf.voc
-44305 ./tests/data/lavf/lavf.voc
+6a101a05377ddd79aff95c3606810818 *./tests/data/lavf/lavf.voc
+44821 ./tests/data/lavf/lavf.voc
 ./tests/data/lavf/lavf.voc CRC=0x298fd284
diff --git a/tests/ref/lavf/voc_s16 b/tests/ref/lavf/voc_s16
index d026090aff..ccdb6366b1 100644
--- a/tests/ref/lavf/voc_s16
+++ b/tests/ref/lavf/voc_s16
@@ -1,3 +1,3 @@ 
-db9fa22ff71992bd8b6cc80047223c92 *./tests/data/lavf/lavf.s16.voc
-176615 ./tests/data/lavf/lavf.s16.voc
+ed4a2fdb86c34ad7f6d9772fd8cdfab1 *./tests/data/lavf/lavf.s16.voc
+177131 ./tests/data/lavf/lavf.s16.voc
 ./tests/data/lavf/lavf.s16.voc CRC=0xe61e3bd0
diff --git a/tests/ref/seek/acodec-pcm-f32be b/tests/ref/seek/acodec-pcm-f32be
index b838262b58..89c8e9d7a9 100644
--- a/tests/ref/seek/acodec-pcm-f32be
+++ b/tests/ref/seek/acodec-pcm-f32be
@@ -1,53 +1,53 @@ 
-ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size:  8192
+ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size:  2048
 ret: 0         st:-1 flags:0  ts:-1.000000
-ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size:  8192
+ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size:  2048
 ret: 0         st:-1 flags:1  ts: 1.894167
-ret: 0         st: 0 flags:1 dts: 1.894172 pts: 1.894172 pos: 668296 size:  8192
+ret: 0         st: 0 flags:1 dts: 1.894172 pts: 1.894172 pos: 668296 size:  2048
 ret: 0         st: 0 flags:0  ts: 0.788345
-ret: 0         st: 0 flags:1 dts: 0.788345 pts: 0.788345 pos: 278160 size:  8192
+ret: 0         st: 0 flags:1 dts: 0.788345 pts: 0.788345 pos: 278160 size:  2048
 ret: 0         st: 0 flags:1  ts:-0.317506
-ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size:  8192
+ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size:  2048
 ret: 0         st:-1 flags:0  ts: 2.576668
-ret: 0         st: 0 flags:1 dts: 2.576667 pts: 2.576667 pos: 909080 size:  8192
+ret: 0         st: 0 flags:1 dts: 2.576667 pts: 2.576667 pos: 909080 size:  2048
 ret: 0         st:-1 flags:1  ts: 1.470835
-ret: 0         st: 0 flags:1 dts: 1.470839 pts: 1.470839 pos: 518944 size:  8192
+ret: 0         st: 0 flags:1 dts: 1.470839 pts: 1.470839 pos: 518944 size:  2048
 ret: 0         st: 0 flags:0  ts: 0.365011
-ret: 0         st: 0 flags:1 dts: 0.365011 pts: 0.365011 pos: 128808 size:  8192
+ret: 0         st: 0 flags:1 dts: 0.365011 pts: 0.365011 pos: 128808 size:  2048
 ret: 0         st: 0 flags:1  ts:-0.740839
-ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size:  8192
+ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size:  2048
 ret: 0         st:-1 flags:0  ts: 2.153336
-ret: 0         st: 0 flags:1 dts: 2.153333 pts: 2.153333 pos: 759728 size:  8192
+ret: 0         st: 0 flags:1 dts: 2.153333 pts: 2.153333 pos: 759728 size:  2048
 ret: 0         st:-1 flags:1  ts: 1.047503
-ret: 0         st: 0 flags:1 dts: 1.047506 pts: 1.047506 pos: 369592 size:  8192
+ret: 0         st: 0 flags:1 dts: 1.047506 pts: 1.047506 pos: 369592 size:  2048
 ret: 0         st: 0 flags:0  ts:-0.058322
-ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size:  8192
+ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size:  2048
 ret: 0         st: 0 flags:1  ts: 2.835828
-ret: 0         st: 0 flags:1 dts: 2.835828 pts: 2.835828 pos:1000512 size:  8192
+ret: 0         st: 0 flags:1 dts: 2.835828 pts: 2.835828 pos:1000512 size:  2048
 ret: 0         st:-1 flags:0  ts: 1.730004
-ret: 0         st: 0 flags:1 dts: 1.730000 pts: 1.730000 pos: 610376 size:  8192
+ret: 0         st: 0 flags:1 dts: 1.730000 pts: 1.730000 pos: 610376 size:  2048
 ret: 0         st:-1 flags:1  ts: 0.624171
-ret: 0         st: 0 flags:1 dts: 0.624172 pts: 0.624172 pos: 220240 size:  8192
+ret: 0         st: 0 flags:1 dts: 0.624172 pts: 0.624172 pos: 220240 size:  2048
 ret: 0         st: 0 flags:0  ts:-0.481655
-ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size:  8192
+ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size:  2048
 ret: 0         st: 0 flags:1  ts: 2.412494
-ret: 0         st: 0 flags:1 dts: 2.412494 pts: 2.412494 pos: 851160 size:  8192
+ret: 0         st: 0 flags:1 dts: 2.412494 pts: 2.412494 pos: 851160 size:  2048
 ret: 0         st:-1 flags:0  ts: 1.306672
-ret: 0         st: 0 flags:1 dts: 1.306667 pts: 1.306667 pos: 461024 size:  8192
+ret: 0         st: 0 flags:1 dts: 1.306667 pts: 1.306667 pos: 461024 size:  2048
 ret: 0         st:-1 flags:1  ts: 0.200839
-ret: 0         st: 0 flags:1 dts: 0.200839 pts: 0.200839 pos:  70888 size:  8192
+ret: 0         st: 0 flags:1 dts: 0.200839 pts: 0.200839 pos:  70888 size:  2048
 ret: 0         st: 0 flags:0  ts:-0.904989
-ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size:  8192
+ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size:  2048
 ret: 0         st: 0 flags:1  ts: 1.989184
-ret: 0         st: 0 flags:1 dts: 1.989184 pts: 1.989184 pos: 701816 size:  8192
+ret: 0         st: 0 flags:1 dts: 1.989184 pts: 1.989184 pos: 701816 size:  2048
 ret: 0         st:-1 flags:0  ts: 0.883340
-ret: 0         st: 0 flags:1 dts: 0.883333 pts: 0.883333 pos: 311672 size:  8192
+ret: 0         st: 0 flags:1 dts: 0.883333 pts: 0.883333 pos: 311672 size:  2048
 ret: 0         st:-1 flags:1  ts:-0.222493
-ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size:  8192
+ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size:  2048
 ret: 0         st: 0 flags:0  ts: 2.671678
-ret: 0         st: 0 flags:1 dts: 2.671678 pts: 2.671678 pos: 942600 size:  8192
+ret: 0         st: 0 flags:1 dts: 2.671678 pts: 2.671678 pos: 942600 size:  2048
 ret: 0         st: 0 flags:1  ts: 1.565850
-ret: 0         st: 0 flags:1 dts: 1.565850 pts: 1.565850 pos: 552464 size:  8192
+ret: 0         st: 0 flags:1 dts: 1.565850 pts: 1.565850 pos: 552464 size:  2048
 ret: 0         st:-1 flags:0  ts: 0.460008
-ret: 0         st: 0 flags:1 dts: 0.460000 pts: 0.460000 pos: 162320 size:  8192
+ret: 0         st: 0 flags:1 dts: 0.460000 pts: 0.460000 pos: 162320 size:  2048
 ret: 0         st:-1 flags:1  ts:-0.645825
-ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size:  8192
+ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size:  2048
diff --git a/tests/ref/seek/acodec-pcm-f64be b/tests/ref/seek/acodec-pcm-f64be
index 82223517d5..8b050e9914 100644
--- a/tests/ref/seek/acodec-pcm-f64be
+++ b/tests/ref/seek/acodec-pcm-f64be
@@ -1,53 +1,53 @@ 
-ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size: 16384
+ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size:  4096
 ret: 0         st:-1 flags:0  ts:-1.000000
-ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size: 16384
+ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size:  4096
 ret: 0         st:-1 flags:1  ts: 1.894167
-ret: 0         st: 0 flags:1 dts: 1.894172 pts: 1.894172 pos:1336560 size: 16384
+ret: 0         st: 0 flags:1 dts: 1.894172 pts: 1.894172 pos:1336560 size:  4096
 ret: 0         st: 0 flags:0  ts: 0.788345
-ret: 0         st: 0 flags:1 dts: 0.788345 pts: 0.788345 pos: 556288 size: 16384
+ret: 0         st: 0 flags:1 dts: 0.788345 pts: 0.788345 pos: 556288 size:  4096
 ret: 0         st: 0 flags:1  ts:-0.317506
-ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size: 16384
+ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size:  4096
 ret: 0         st:-1 flags:0  ts: 2.576668
-ret: 0         st: 0 flags:1 dts: 2.576667 pts: 2.576667 pos:1818128 size: 16384
+ret: 0         st: 0 flags:1 dts: 2.576667 pts: 2.576667 pos:1818128 size:  4096
 ret: 0         st:-1 flags:1  ts: 1.470835
-ret: 0         st: 0 flags:1 dts: 1.470839 pts: 1.470839 pos:1037856 size: 16384
+ret: 0         st: 0 flags:1 dts: 1.470839 pts: 1.470839 pos:1037856 size:  4096
 ret: 0         st: 0 flags:0  ts: 0.365011
-ret: 0         st: 0 flags:1 dts: 0.365011 pts: 0.365011 pos: 257584 size: 16384
+ret: 0         st: 0 flags:1 dts: 0.365011 pts: 0.365011 pos: 257584 size:  4096
 ret: 0         st: 0 flags:1  ts:-0.740839
-ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size: 16384
+ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size:  4096
 ret: 0         st:-1 flags:0  ts: 2.153336
-ret: 0         st: 0 flags:1 dts: 2.153333 pts: 2.153333 pos:1519424 size: 16384
+ret: 0         st: 0 flags:1 dts: 2.153333 pts: 2.153333 pos:1519424 size:  4096
 ret: 0         st:-1 flags:1  ts: 1.047503
-ret: 0         st: 0 flags:1 dts: 1.047506 pts: 1.047506 pos: 739152 size: 16384
+ret: 0         st: 0 flags:1 dts: 1.047506 pts: 1.047506 pos: 739152 size:  4096
 ret: 0         st: 0 flags:0  ts:-0.058322
-ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size: 16384
+ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size:  4096
 ret: 0         st: 0 flags:1  ts: 2.835828
-ret: 0         st: 0 flags:1 dts: 2.835828 pts: 2.835828 pos:2000992 size: 16384
+ret: 0         st: 0 flags:1 dts: 2.835828 pts: 2.835828 pos:2000992 size:  4096
 ret: 0         st:-1 flags:0  ts: 1.730004
-ret: 0         st: 0 flags:1 dts: 1.730000 pts: 1.730000 pos:1220720 size: 16384
+ret: 0         st: 0 flags:1 dts: 1.730000 pts: 1.730000 pos:1220720 size:  4096
 ret: 0         st:-1 flags:1  ts: 0.624171
-ret: 0         st: 0 flags:1 dts: 0.624172 pts: 0.624172 pos: 440448 size: 16384
+ret: 0         st: 0 flags:1 dts: 0.624172 pts: 0.624172 pos: 440448 size:  4096
 ret: 0         st: 0 flags:0  ts:-0.481655
-ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size: 16384
+ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size:  4096
 ret: 0         st: 0 flags:1  ts: 2.412494
-ret: 0         st: 0 flags:1 dts: 2.412494 pts: 2.412494 pos:1702288 size: 16384
+ret: 0         st: 0 flags:1 dts: 2.412494 pts: 2.412494 pos:1702288 size:  4096
 ret: 0         st:-1 flags:0  ts: 1.306672
-ret: 0         st: 0 flags:1 dts: 1.306667 pts: 1.306667 pos: 922016 size: 16384
+ret: 0         st: 0 flags:1 dts: 1.306667 pts: 1.306667 pos: 922016 size:  4096
 ret: 0         st:-1 flags:1  ts: 0.200839
-ret: 0         st: 0 flags:1 dts: 0.200839 pts: 0.200839 pos: 141744 size: 16384
+ret: 0         st: 0 flags:1 dts: 0.200839 pts: 0.200839 pos: 141744 size:  4096
 ret: 0         st: 0 flags:0  ts:-0.904989
-ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size: 16384
+ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size:  4096
 ret: 0         st: 0 flags:1  ts: 1.989184
-ret: 0         st: 0 flags:1 dts: 1.989184 pts: 1.989184 pos:1403600 size: 16384
+ret: 0         st: 0 flags:1 dts: 1.989184 pts: 1.989184 pos:1403600 size:  4096
 ret: 0         st:-1 flags:0  ts: 0.883340
-ret: 0         st: 0 flags:1 dts: 0.883333 pts: 0.883333 pos: 623312 size: 16384
+ret: 0         st: 0 flags:1 dts: 0.883333 pts: 0.883333 pos: 623312 size:  4096
 ret: 0         st:-1 flags:1  ts:-0.222493
-ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size: 16384
+ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size:  4096
 ret: 0         st: 0 flags:0  ts: 2.671678
-ret: 0         st: 0 flags:1 dts: 2.671678 pts: 2.671678 pos:1885168 size: 16384
+ret: 0         st: 0 flags:1 dts: 2.671678 pts: 2.671678 pos:1885168 size:  4096
 ret: 0         st: 0 flags:1  ts: 1.565850
-ret: 0         st: 0 flags:1 dts: 1.565850 pts: 1.565850 pos:1104896 size: 16384
+ret: 0         st: 0 flags:1 dts: 1.565850 pts: 1.565850 pos:1104896 size:  4096
 ret: 0         st:-1 flags:0  ts: 0.460008
-ret: 0         st: 0 flags:1 dts: 0.460000 pts: 0.460000 pos: 324608 size: 16384
+ret: 0         st: 0 flags:1 dts: 0.460000 pts: 0.460000 pos: 324608 size:  4096
 ret: 0         st:-1 flags:1  ts:-0.645825
-ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size: 16384
+ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size:  4096
diff --git a/tests/ref/seek/lavf-alaw b/tests/ref/seek/lavf-alaw
index 4b1f8fbc02..e46de928a2 100644
--- 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
 ret: 0         st:-1 flags:1  ts: 1.470835
-ret: 0         st: 0 flags:1 dts: 1.470839 pts: 1.470839 pos:  32432 size:  1024
+ret: 0         st: 0 flags:1 dts: 1.470839 pts: 1.470839 pos:  32432 size:   128
 ret: 0         st: 0 flags:0  ts: 0.364989
-ret: 0         st: 0 flags:1 dts: 0.364989 pts: 0.364989 pos:   8048 size:  1024
+ret: 0         st: 0 flags:1 dts: 0.364989 pts: 0.364989 pos:   8048 size:   128
 ret: 0         st: 0 flags:1  ts:-0.740816
-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.153336
 ret:-EOF
 ret: 0         st:-1 flags:1  ts: 1.047503
-ret: 0         st: 0 flags:1 dts: 1.047483 pts: 1.047483 pos:  23097 size:  1024
+ret: 0         st: 0 flags:1 dts: 1.047483 pts: 1.047483 pos:  23097 size:   128
 ret: 0         st: 0 flags:0  ts:-0.058322
-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: 0 flags:1  ts: 2.835828
 ret:-EOF
 ret: 0         st:-1 flags:0  ts: 1.730004
-ret: 0         st: 0 flags:1 dts: 1.730023 pts: 1.730023 pos:  38147 size:  1024
+ret: 0         st: 0 flags:1 dts: 1.730023 pts: 1.730023 pos:  38147 size:   128
 ret: 0         st:-1 flags:1  ts: 0.624171
-ret: 0         st: 0 flags:1 dts: 0.624172 pts: 0.624172 pos:  13763 size:  1024
+ret: 0         st: 0 flags:1 dts: 0.624172 pts: 0.624172 pos:  13763 size:   128
 ret: 0         st: 0 flags:0  ts:-0.481678
-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: 0 flags:1  ts: 2.412517
 ret:-EOF
 ret: 0         st:-1 flags:0  ts: 1.306672
-ret: 0         st: 0 flags:1 dts: 1.306667 pts: 1.306667 pos:  28812 size:  1024
+ret: 0         st: 0 flags:1 dts: 1.306667 pts: 1.306667 pos:  28812 size:   128
 ret: 0         st:-1 flags:1  ts: 0.200839
-ret: 0         st: 0 flags:1 dts: 0.200816 pts: 0.200816 pos:   4428 size:  1024
+ret: 0         st: 0 flags:1 dts: 0.200816 pts: 0.200816 pos:   4428 size:   128
 ret: 0         st: 0 flags:0  ts:-0.904989
-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: 0 flags:1  ts: 1.989161
-ret: 0         st: 0 flags:1 dts: 1.989161 pts: 1.989161 pos:  43861 size:   239
+ret: 0         st: 0 flags:1 dts: 1.989161 pts: 1.989161 pos:  43861 size:   128
 ret: 0         st:-1 flags:0  ts: 0.883340
-ret: 0         st: 0 flags:1 dts: 0.883356 pts: 0.883356 pos:  19478 size:  1024
+ret: 0         st: 0 flags:1 dts: 0.883356 pts: 0.883356 pos:  19478 size:   128
 ret: 0         st:-1 flags:1  ts:-0.222493
-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: 0 flags:0  ts: 2.671655
 ret:-EOF
 ret: 0         st: 0 flags:1  ts: 1.565850
-ret: 0         st: 0 flags:1 dts: 1.565850 pts: 1.565850 pos:  34527 size:  1024
+ret: 0         st: 0 flags:1 dts: 1.565850 pts: 1.565850 pos:  34527 size:   128
 ret: 0         st:-1 flags:0  ts: 0.460008
-ret: 0         st: 0 flags:1 dts: 0.460000 pts: 0.460000 pos:  10143 size:  1024
+ret: 0         st: 0 flags:1 dts: 0.460000 pts: 0.460000 pos:  10143 size:   128
 ret: 0         st:-1 flags:1  ts:-0.645825
-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
diff --git a/tests/ref/seek/lavf-au b/tests/ref/seek/lavf-au
index 8edce58f65..6ac6192738 100644
--- a/tests/ref/seek/lavf-au
+++ b/tests/ref/seek/lavf-au
@@ -1,53 +1,53 @@ 
-ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     40 size:  2048
+ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     40 size:   512
 ret: 0         st:-1 flags:0  ts:-1.000000
-ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     40 size:  2048
+ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     40 size:   512
 ret: 0         st:-1 flags:1  ts: 1.894167
 ret:-EOF
 ret: 0         st: 0 flags:0  ts: 0.788345
-ret: 0         st: 0 flags:1 dts: 0.788345 pts: 0.788345 pos:  69572 size:  2048
+ret: 0         st: 0 flags:1 dts: 0.788345 pts: 0.788345 pos:  69572 size:   512
 ret: 0         st: 0 flags:1  ts:-0.317506
-ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     40 size:  2048
+ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     40 size:   512
 ret: 0         st:-1 flags:0  ts: 2.576668
 ret:-EOF
 ret: 0         st:-1 flags:1  ts: 1.470835
 ret:-EOF
 ret: 0         st: 0 flags:0  ts: 0.365011
-ret: 0         st: 0 flags:1 dts: 0.365011 pts: 0.365011 pos:  32234 size:  2048
+ret: 0         st: 0 flags:1 dts: 0.365011 pts: 0.365011 pos:  32234 size:   512
 ret: 0         st: 0 flags:1  ts:-0.740839
-ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     40 size:  2048
+ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     40 size:   512
 ret: 0         st:-1 flags:0  ts: 2.153336
 ret:-EOF
 ret: 0         st:-1 flags:1  ts: 1.047503
 ret:-EOF
 ret: 0         st: 0 flags:0  ts:-0.058322
-ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     40 size:  2048
+ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     40 size:   512
 ret: 0         st: 0 flags:1  ts: 2.835828
 ret:-EOF
 ret: 0         st:-1 flags:0  ts: 1.730004
 ret:-EOF
 ret: 0         st:-1 flags:1  ts: 0.624171
-ret: 0         st: 0 flags:1 dts: 0.624172 pts: 0.624172 pos:  55092 size:  2048
+ret: 0         st: 0 flags:1 dts: 0.624172 pts: 0.624172 pos:  55092 size:   512
 ret: 0         st: 0 flags:0  ts:-0.481655
-ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     40 size:  2048
+ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     40 size:   512
 ret: 0         st: 0 flags:1  ts: 2.412494
 ret:-EOF
 ret: 0         st:-1 flags:0  ts: 1.306672
 ret:-EOF
 ret: 0         st:-1 flags:1  ts: 0.200839
-ret: 0         st: 0 flags:1 dts: 0.200839 pts: 0.200839 pos:  17754 size:  2048
+ret: 0         st: 0 flags:1 dts: 0.200839 pts: 0.200839 pos:  17754 size:   512
 ret: 0         st: 0 flags:0  ts:-0.904989
-ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     40 size:  2048
+ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     40 size:   512
 ret: 0         st: 0 flags:1  ts: 1.989184
 ret:-EOF
 ret: 0         st:-1 flags:0  ts: 0.883340
-ret: 0         st: 0 flags:1 dts: 0.883333 pts: 0.883333 pos:  77950 size:  2048
+ret: 0         st: 0 flags:1 dts: 0.883333 pts: 0.883333 pos:  77950 size:   512
 ret: 0         st:-1 flags:1  ts:-0.222493
-ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     40 size:  2048
+ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     40 size:   512
 ret: 0         st: 0 flags:0  ts: 2.671678
 ret:-EOF
 ret: 0         st: 0 flags:1  ts: 1.565850
 ret:-EOF
 ret: 0         st:-1 flags:0  ts: 0.460008
-ret: 0         st: 0 flags:1 dts: 0.460000 pts: 0.460000 pos:  40612 size:  2048
+ret: 0         st: 0 flags:1 dts: 0.460000 pts: 0.460000 pos:  40612 size:   512
 ret: 0         st:-1 flags:1  ts:-0.645825
-ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     40 size:  2048
+ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     40 size:   512
diff --git a/tests/ref/seek/lavf-mov b/tests/ref/seek/lavf-mov
index 27ea7c7730..88fba97cf3 100644
--- a/tests/ref/seek/lavf-mov
+++ b/tests/ref/seek/lavf-mov
@@ -1,48 +1,48 @@ 
-ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:   1767 size: 27837
+ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:   1671 size: 27837
 ret: 0         st:-1 flags:0  ts:-1.000000
-ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:   1767 size: 27837
+ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:   1671 size: 27837
 ret: 0         st:-1 flags:1  ts: 1.894167
-ret: 0         st: 1 flags:1 dts: 0.952018 pts: 0.952018 pos: 326971 size:  1024
+ret: 0         st: 1 flags:1 dts: 0.946213 pts: 0.946213 pos: 326619 size:   768
 ret: 0         st: 0 flags:0  ts: 0.788359
-ret: 0         st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 327995 size: 27834
+ret: 0         st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 327387 size: 27834
 ret: 0         st: 0 flags:1  ts:-0.317500
-ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:   1767 size: 27837
+ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:   1671 size: 27837
 ret:-1         st: 1 flags:0  ts: 2.576667
 ret: 0         st: 1 flags:1  ts: 1.470839
-ret: 0         st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 327995 size: 27834
+ret: 0         st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 327387 size: 27834
 ret: 0         st:-1 flags:0  ts: 0.365002
-ret: 0         st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 165249 size: 27925
+ret: 0         st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 164897 size: 27925
 ret: 0         st:-1 flags:1  ts:-0.740831
-ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:   1767 size: 27837
+ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:   1671 size: 27837
 ret:-1         st: 0 flags:0  ts: 2.153359
 ret: 0         st: 0 flags:1  ts: 1.047500
-ret: 0         st: 1 flags:1 dts: 0.952018 pts: 0.952018 pos: 326971 size:  1024
+ret: 0         st: 1 flags:1 dts: 0.946213 pts: 0.946213 pos: 326619 size:   768
 ret: 0         st: 1 flags:0  ts:-0.058322
-ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:   1767 size: 27837
+ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:   1671 size: 27837
 ret: 0         st: 1 flags:1  ts: 2.835828
-ret: 0         st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 327995 size: 27834
+ret: 0         st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 327387 size: 27834
 ret:-1         st:-1 flags:0  ts: 1.730004
 ret: 0         st:-1 flags:1  ts: 0.624171
-ret: 0         st: 1 flags:1 dts: 0.464399 pts: 0.464399 pos: 164225 size:  1024
+ret: 0         st: 1 flags:1 dts: 0.464399 pts: 0.464399 pos: 164129 size:   768
 ret: 0         st: 0 flags:0  ts:-0.481641
-ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:   1767 size: 27837
+ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:   1671 size: 27837
 ret: 0         st: 0 flags:1  ts: 2.412500
-ret: 0         st: 1 flags:1 dts: 0.952018 pts: 0.952018 pos: 326971 size:  1024
+ret: 0         st: 1 flags:1 dts: 0.946213 pts: 0.946213 pos: 326619 size:   768
 ret:-1         st: 1 flags:0  ts: 1.306667
 ret: 0         st: 1 flags:1  ts: 0.200839
-ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:   1767 size: 27837
+ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:   1671 size: 27837
 ret: 0         st:-1 flags:0  ts:-0.904994
-ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:   1767 size: 27837
+ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:   1671 size: 27837
 ret: 0         st:-1 flags:1  ts: 1.989173
-ret: 0         st: 1 flags:1 dts: 0.952018 pts: 0.952018 pos: 326971 size:  1024
+ret: 0         st: 1 flags:1 dts: 0.946213 pts: 0.946213 pos: 326619 size:   768
 ret: 0         st: 0 flags:0  ts: 0.883359
-ret: 0         st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 327995 size: 27834
+ret: 0         st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 327387 size: 27834
 ret: 0         st: 0 flags:1  ts:-0.222500
-ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:   1767 size: 27837
+ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:   1671 size: 27837
 ret:-1         st: 1 flags:0  ts: 2.671678
 ret: 0         st: 1 flags:1  ts: 1.565850
-ret: 0         st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 327995 size: 27834
+ret: 0         st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos: 327387 size: 27834
 ret: 0         st:-1 flags:0  ts: 0.460008
-ret: 0         st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 165249 size: 27925
+ret: 0         st: 0 flags:1 dts: 0.480000 pts: 0.480000 pos: 164897 size: 27925
 ret: 0         st:-1 flags:1  ts:-0.645825
-ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:   1767 size: 27837
+ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:   1671 size: 27837
diff --git a/tests/ref/seek/lavf-mulaw b/tests/ref/seek/lavf-mulaw
index 4b1f8fbc02..e46de928a2 100644
--- a/tests/ref/seek/lavf-mulaw
+++ b/tests/ref/seek/lavf-mulaw
@@ -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
 ret: 0         st:-1 flags:1  ts: 1.470835
-ret: 0         st: 0 flags:1 dts: 1.470839 pts: 1.470839 pos:  32432 size:  1024
+ret: 0         st: 0 flags:1 dts: 1.470839 pts: 1.470839 pos:  32432 size:   128
 ret: 0         st: 0 flags:0  ts: 0.364989
-ret: 0         st: 0 flags:1 dts: 0.364989 pts: 0.364989 pos:   8048 size:  1024
+ret: 0         st: 0 flags:1 dts: 0.364989 pts: 0.364989 pos:   8048 size:   128
 ret: 0         st: 0 flags:1  ts:-0.740816
-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.153336
 ret:-EOF
 ret: 0         st:-1 flags:1  ts: 1.047503
-ret: 0         st: 0 flags:1 dts: 1.047483 pts: 1.047483 pos:  23097 size:  1024
+ret: 0         st: 0 flags:1 dts: 1.047483 pts: 1.047483 pos:  23097 size:   128
 ret: 0         st: 0 flags:0  ts:-0.058322
-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: 0 flags:1  ts: 2.835828
 ret:-EOF
 ret: 0         st:-1 flags:0  ts: 1.730004
-ret: 0         st: 0 flags:1 dts: 1.730023 pts: 1.730023 pos:  38147 size:  1024
+ret: 0         st: 0 flags:1 dts: 1.730023 pts: 1.730023 pos:  38147 size:   128
 ret: 0         st:-1 flags:1  ts: 0.624171
-ret: 0         st: 0 flags:1 dts: 0.624172 pts: 0.624172 pos:  13763 size:  1024
+ret: 0         st: 0 flags:1 dts: 0.624172 pts: 0.624172 pos:  13763 size:   128
 ret: 0         st: 0 flags:0  ts:-0.481678
-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: 0 flags:1  ts: 2.412517
 ret:-EOF
 ret: 0         st:-1 flags:0  ts: 1.306672
-ret: 0         st: 0 flags:1 dts: 1.306667 pts: 1.306667 pos:  28812 size:  1024
+ret: 0         st: 0 flags:1 dts: 1.306667 pts: 1.306667 pos:  28812 size:   128
 ret: 0         st:-1 flags:1  ts: 0.200839
-ret: 0         st: 0 flags:1 dts: 0.200816 pts: 0.200816 pos:   4428 size:  1024
+ret: 0         st: 0 flags:1 dts: 0.200816 pts: 0.200816 pos:   4428 size:   128
 ret: 0         st: 0 flags:0  ts:-0.904989
-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: 0 flags:1  ts: 1.989161
-ret: 0         st: 0 flags:1 dts: 1.989161 pts: 1.989161 pos:  43861 size:   239
+ret: 0         st: 0 flags:1 dts: 1.989161 pts: 1.989161 pos:  43861 size:   128
 ret: 0         st:-1 flags:0  ts: 0.883340
-ret: 0         st: 0 flags:1 dts: 0.883356 pts: 0.883356 pos:  19478 size:  1024
+ret: 0         st: 0 flags:1 dts: 0.883356 pts: 0.883356 pos:  19478 size:   128
 ret: 0         st:-1 flags:1  ts:-0.222493
-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: 0 flags:0  ts: 2.671655
 ret:-EOF
 ret: 0         st: 0 flags:1  ts: 1.565850
-ret: 0         st: 0 flags:1 dts: 1.565850 pts: 1.565850 pos:  34527 size:  1024
+ret: 0         st: 0 flags:1 dts: 1.565850 pts: 1.565850 pos:  34527 size:   128
 ret: 0         st:-1 flags:0  ts: 0.460008
-ret: 0         st: 0 flags:1 dts: 0.460000 pts: 0.460000 pos:  10143 size:  1024
+ret: 0         st: 0 flags:1 dts: 0.460000 pts: 0.460000 pos:  10143 size:   128
 ret: 0         st:-1 flags:1  ts:-0.645825
-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
diff --git a/tests/ref/seek/lavf-voc b/tests/ref/seek/lavf-voc
index 014c251129..47d683230a 100644
--- a/tests/ref/seek/lavf-voc
+++ b/tests/ref/seek/lavf-voc
@@ -1,44 +1,44 @@ 
-ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size:  1024
+ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size:   256
 ret: 0         st:-1 flags:0  ts:-1.000000
-ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size:  1024
+ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size:   256
 ret: 0         st:-1 flags:1  ts: 1.894167
 ret:-EOF
 ret: 0         st: 0 flags:0  ts: 0.788330
-ret: 0         st: 0 flags:1 dts: 0.800773 pts: 0.800773 pos:  34984 size:  1024
+ret: 0         st: 0 flags:1 dts: 0.788997 pts: 0.788997 pos:  34872 size:   256
 ret:-1         st: 0 flags:1  ts:-0.317494
 ret:-1         st:-1 flags:0  ts: 2.576668
 ret: 0         st:-1 flags:1  ts: 1.470835
 ret:-EOF
 ret: 0         st: 0 flags:0  ts: 0.365012
-ret: 0         st: 0 flags:1 dts: 0.376834 pts: 0.376834 pos:  16480 size:  1024
+ret: 0         st: 0 flags:1 dts: 0.365058 pts: 0.365058 pos:  16152 size:   256
 ret:-1         st: 0 flags:1  ts:-0.740834
 ret:-1         st:-1 flags:0  ts: 2.153336
 ret: 0         st:-1 flags:1  ts: 1.047503
 ret:-EOF
 ret: 0         st: 0 flags:0  ts:-0.058328
-ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size:  1024
+ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size:   256
 ret: 0         st: 0 flags:1  ts: 2.835848
 ret:-EOF
 ret:-1         st:-1 flags:0  ts: 1.730004
 ret: 0         st:-1 flags:1  ts: 0.624171
-ret: 0         st: 0 flags:1 dts: 0.612356 pts: 0.612356 pos:  26760 size:  1024
+ret: 0         st: 0 flags:1 dts: 0.624132 pts: 0.624132 pos:  27592 size:   256
 ret: 0         st: 0 flags:0  ts:-0.481669
-ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size:  1024
+ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size:   256
 ret: 0         st: 0 flags:1  ts: 2.412507
 ret:-EOF
 ret:-1         st:-1 flags:0  ts: 1.306672
 ret: 0         st:-1 flags:1  ts: 0.200839
-ret: 0         st: 0 flags:1 dts: 0.188417 pts: 0.188417 pos:   8256 size:  1024
+ret: 0         st: 0 flags:1 dts: 0.200193 pts: 0.200193 pos:   8872 size:   256
 ret: 0         st: 0 flags:0  ts:-0.904986
-ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size:  1024
+ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:     32 size:   256
 ret: 0         st: 0 flags:1  ts: 1.989167
 ret:-EOF
 ret: 0         st:-1 flags:0  ts: 0.883340
-ret: 0         st: 0 flags:1 dts: 0.894981 pts: 0.894981 pos:  39096 size:  1024
+ret: 0         st: 0 flags:1 dts: 0.889093 pts: 0.889093 pos:  39292 size:   256
 ret:-1         st:-1 flags:1  ts:-0.222493
 ret:-1         st: 0 flags:0  ts: 2.671673
 ret: 0         st: 0 flags:1  ts: 1.565849
 ret:-EOF
 ret: 0         st:-1 flags:0  ts: 0.460008
-ret: 0         st: 0 flags:1 dts: 0.471043 pts: 0.471043 pos:  20592 size:  1024
+ret: 0         st: 0 flags:1 dts: 0.465155 pts: 0.465155 pos:  20572 size:   256
 ret:-1         st:-1 flags:1  ts:-0.645825