diff mbox series

[FFmpeg-devel] avfilter/alimiter: Remove the delay introduced by lookahead buffer

Message ID 20220330210314.2055201-1-wangcao@google.com
State New
Headers show
Series [FFmpeg-devel] avfilter/alimiter: Remove the delay introduced by lookahead buffer | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_aarch64_jetson success Make finished
andriy/make_fate_aarch64_jetson success Make fate finished
andriy/make_armv7_RPi4 success Make finished
andriy/make_fate_armv7_RPi4 success Make fate finished

Commit Message

Wang Cao March 30, 2022, 9:03 p.m. UTC
The change essentially removes the delay introduces by lookahead buffer.
The valid audio data in the internal buffer is also flushed to ensure
the integrity of output.

Signed-off-by: Wang Cao <wangcao@google.com>
---
 doc/filters.texi               |   2 -
 libavfilter/af_alimiter.c      |  97 +++++-
 tests/ref/fate/filter-alimiter | 518 ++++++++++++++++-----------------
 3 files changed, 344 insertions(+), 273 deletions(-)

Thanks a lot for your time to review my patch. I have made "zero_delay"
option to default. Now the output samples will only be written after the
lookahead buffer is full. We also uses "request_frame" to flush the
internal buffers so that all valid input audio samples are written.

Comments

Paul B Mahol April 4, 2022, 3:46 p.m. UTC | #1
On Wed, Mar 30, 2022 at 11:05 PM Wang Cao <wangcao-at-google.com@ffmpeg.org>
wrote:

> The change essentially removes the delay introduces by lookahead buffer.
> The valid audio data in the internal buffer is also flushed to ensure
> the integrity of output.
>
>
This adds extra delay,  and complicates current code a lot.



> Signed-off-by: Wang Cao <wangcao@google.com>
> ---
>  doc/filters.texi               |   2 -
>  libavfilter/af_alimiter.c      |  97 +++++-
>  tests/ref/fate/filter-alimiter | 518 ++++++++++++++++-----------------
>  3 files changed, 344 insertions(+), 273 deletions(-)
>
> Thanks a lot for your time to review my patch. I have made "zero_delay"
> option to default. Now the output samples will only be written after the
> lookahead buffer is full. We also uses "request_frame" to flush the
> internal buffers so that all valid input audio samples are written.
>
> diff --git a/doc/filters.texi b/doc/filters.texi
> index d70ac3e237..5d1adf88e1 100644
> --- a/doc/filters.texi
> +++ b/doc/filters.texi
> @@ -1943,8 +1943,6 @@ aiir=z=1.3057 0 0 0:p=1.3057 2.3892 2.1860 1:f=sf:r=d
>
>  The limiter prevents an input signal from rising over a desired threshold.
>  This limiter uses lookahead technology to prevent your signal from
> distorting.
> -It means that there is a small delay after the signal is processed. Keep
> in mind
> -that the delay it produces is the attack time you set.
>
>  The filter accepts the following options:
>
> diff --git a/libavfilter/af_alimiter.c b/libavfilter/af_alimiter.c
> index 133f98f165..e1fcf98574 100644
> --- a/libavfilter/af_alimiter.c
> +++ b/libavfilter/af_alimiter.c
> @@ -30,6 +30,7 @@
>
>  #include "audio.h"
>  #include "avfilter.h"
> +#include "bufferqueue.h"
>  #include "formats.h"
>  #include "internal.h"
>
> @@ -55,6 +56,13 @@ typedef struct AudioLimiterContext {
>      int *nextpos;
>      double *nextdelta;
>
> +    int total_samples_to_flush;
> +    int lookahead_buffer_full;
> +
> +    struct FFBufQueue output_frame_queue;
> +    int output_sample_pos;
> +    int output_frame_pos;
> +
>      double delta;
>      int nextiter;
>      int nextlen;
> @@ -129,6 +137,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame
> *in)
>      AVFrame *out;
>      double *buf;
>      int n, c, i;
> +    int can_free_input_frame = 0;
> +    double peak = 0;
>
>      if (av_frame_is_writable(in)) {
>          out = in;
> @@ -138,12 +148,23 @@ static int filter_frame(AVFilterLink *inlink,
> AVFrame *in)
>              av_frame_free(&in);
>              return AVERROR(ENOMEM);
>          }
> +        can_free_input_frame = 1;
>          av_frame_copy_props(out, in);
>      }
> -    dst = (double *)out->data[0];
> +
> +    if (ff_bufqueue_is_full(&s->output_frame_queue)) {
> +        // In the runtime, the total number of frames in the queue is
> bounded by
> +        // attack_time, sample rate and frame size.
> +        return AVERROR_BUG;
> +    }
> +
> +    ff_bufqueue_add(ctx, &s->output_frame_queue, out);
>
>      for (n = 0; n < in->nb_samples; n++) {
> -        double peak = 0;
> +        out = ff_bufqueue_peek(&s->output_frame_queue,
> s->output_frame_pos);
> +        dst = (double *)out->data[0];
> +        dst += s->output_sample_pos * channels;
> +        peak = 0;
>
>          for (c = 0; c < channels; c++) {
>              double sample = src[c] * level_in;
> @@ -213,8 +234,21 @@ static int filter_frame(AVFilterLink *inlink, AVFrame
> *in)
>
>          s->att += s->delta;
>
> -        for (c = 0; c < channels; c++)
> -            dst[c] = buf[c] * s->att;
> +        // Checks lookahead buffer (s->buffer) has been filled
> +        if (!s->lookahead_buffer_full && (s->pos + channels) %
> buffer_size == 0) {
> +            s->lookahead_buffer_full = 1;
> +        }
> +        if (s->lookahead_buffer_full) {
> +            for (c = 0; c < channels; c++) {
> +                dst[c] = buf[c] * s->att;
> +                dst[c] = av_clipd(dst[c], -limit, limit) * level *
> level_out;
> +            }
> +            s->output_sample_pos++;
> +            if (s->output_sample_pos == out->nb_samples) {
> +                s->output_frame_pos++;
> +                s->output_sample_pos = 0;
> +            }
> +        }
>
>          if ((s->pos + channels) % buffer_size == nextpos[s->nextiter]) {
>              if (s->auto_release) {
> @@ -261,18 +295,55 @@ static int filter_frame(AVFilterLink *inlink,
> AVFrame *in)
>          if (s->delta != 0. && fabs(s->delta) < 0.00000000000001)
>              s->delta = 0.;
>
> -        for (c = 0; c < channels; c++)
> -            dst[c] = av_clipd(dst[c], -limit, limit) * level * level_out;
> -
>          s->pos = (s->pos + channels) % buffer_size;
>          src += channels;
> -        dst += channels;
>      }
> -
> -    if (in != out)
> +    if (can_free_input_frame) {
>          av_frame_free(&in);
> +    }
>
> -    return ff_filter_frame(outlink, out);
> +    if (s->output_frame_pos > 0) {
> +        s->output_frame_pos--;
> +        out = ff_bufqueue_get(&s->output_frame_queue);
> +        return ff_filter_frame(outlink, out);
> +    }
> +    return 0;
> +}
> +
> +static int request_frame(AVFilterLink* outlink)
> +{
> +    AVFilterContext *ctx = outlink->src;
> +    AudioLimiterContext *s = (AudioLimiterContext*)ctx->priv;
> +    int ret;
> +    AVFilterLink *inlink;
> +    AVFrame *out;
> +    AVFrame *silence_frame;
> +
> +    ret = ff_request_frame(ctx->inputs[0]);
> +
> +    if (ret != AVERROR_EOF || s->total_samples_to_flush == 0) {
> +      // Not necessarily an error, just not EOF.
> +      return ret;
> +    }
> +
> +    // Flush the frames in the internal buffer
> +    if (s->output_frame_pos > 0) {
> +        out = ff_bufqueue_get(&s->output_frame_queue);
> +        s->output_frame_pos--;
> +        return ff_filter_frame(outlink, out);
> +    }
> +
> +    // We reach here when input filters have finished producing data
> (i.e. EOF),
> +    // but because of the attack param, s->buffer still has meaningful
> +    // audio content that needs flushing.
> +    inlink = ctx->inputs[0];
> +    // Pushes silence frame to flush valid audio in the s->buffer
> +    silence_frame = ff_get_audio_buffer(inlink,
> s->total_samples_to_flush);
> +    ret = filter_frame(inlink, silence_frame);
> +    if (ret < 0) {
> +      return ret;
> +    }
> +    return AVERROR_EOF;
>  }
>
>  static int config_input(AVFilterLink *inlink)
> @@ -292,7 +363,8 @@ static int config_input(AVFilterLink *inlink)
>          return AVERROR(ENOMEM);
>
>      memset(s->nextpos, -1, obuffer_size * sizeof(*s->nextpos));
> -    s->buffer_size = inlink->sample_rate * s->attack *
> inlink->ch_layout.nb_channels;
> +    s->total_samples_to_flush = inlink->sample_rate * s->attack;
> +    s->buffer_size = s->total_samples_to_flush *
> inlink->ch_layout.nb_channels;
>      s->buffer_size -= s->buffer_size % inlink->ch_layout.nb_channels;
>
>      if (s->buffer_size <= 0) {
> @@ -325,6 +397,7 @@ static const AVFilterPad alimiter_outputs[] = {
>      {
>          .name = "default",
>          .type = AVMEDIA_TYPE_AUDIO,
> +        .request_frame = request_frame,
>      },
>  };
>
> diff --git a/tests/ref/fate/filter-alimiter
> b/tests/ref/fate/filter-alimiter
> index 56cfb614da..93daba92c6 100644
> --- a/tests/ref/fate/filter-alimiter
> +++ b/tests/ref/fate/filter-alimiter
> @@ -3,262 +3,262 @@
>  #codec_id 0: pcm_s16le
>  #sample_rate 0: 44100
>  #channel_layout_name 0: stereo
> -0,          0,          0,     1024,     4096, 0xd4194af4
> -0,       1024,       1024,     1024,     4096, 0x686af4ab
> -0,       2048,       2048,     1024,     4096, 0xe80cee61
> -0,       3072,       3072,     1024,     4096, 0xa686fbad
> -0,       4096,       4096,     1024,     4096, 0x191e062c
> -0,       5120,       5120,     1024,     4096, 0x1a13edb1
> -0,       6144,       6144,     1024,     4096, 0xab21f8ef
> -0,       7168,       7168,     1024,     4096, 0xaa30e757
> -0,       8192,       8192,     1024,     4096, 0x5afdf69f
> -0,       9216,       9216,     1024,     4096, 0x765e05ec
> -0,      10240,      10240,     1024,     4096, 0x6484f551
> -0,      11264,      11264,     1024,     4096, 0x61b9e9f7
> -0,      12288,      12288,     1024,     4096, 0xa735feb3
> -0,      13312,      13312,     1024,     4096, 0xb47203aa
> -0,      14336,      14336,     1024,     4096, 0xb6b5fbf5
> -0,      15360,      15360,     1024,     4096, 0xbc66f14f
> -0,      16384,      16384,     1024,     4096, 0x2003ff5b
> -0,      17408,      17408,     1024,     4096, 0x1160f17d
> -0,      18432,      18432,     1024,     4096, 0x308001a4
> -0,      19456,      19456,     1024,     4096, 0x9df9f429
> -0,      20480,      20480,     1024,     4096, 0x3e6eec0f
> -0,      21504,      21504,     1024,     4096, 0xca3301f2
> -0,      22528,      22528,     1024,     4096, 0x9eb1f961
> -0,      23552,      23552,     1024,     4096, 0xd0a50c8c
> -0,      24576,      24576,     1024,     4096, 0x071ee96b
> -0,      25600,      25600,     1024,     4096, 0x7a46f05b
> -0,      26624,      26624,     1024,     4096, 0x2cb2f475
> -0,      27648,      27648,     1024,     4096, 0x5bda0a52
> -0,      28672,      28672,     1024,     4096, 0x33c0f727
> -0,      29696,      29696,     1024,     4096, 0x53cfee59
> -0,      30720,      30720,     1024,     4096, 0x1588f221
> -0,      31744,      31744,     1024,     4096, 0x95d400d6
> -0,      32768,      32768,     1024,     4096, 0x0078009a
> -0,      33792,      33792,     1024,     4096, 0x686af4ab
> -0,      34816,      34816,     1024,     4096, 0xe80cee61
> -0,      35840,      35840,     1024,     4096, 0xa686fbad
> -0,      36864,      36864,     1024,     4096, 0x191e062c
> -0,      37888,      37888,     1024,     4096, 0x1a13edb1
> -0,      38912,      38912,     1024,     4096, 0xab21f8ef
> -0,      39936,      39936,     1024,     4096, 0xaa30e757
> -0,      40960,      40960,     1024,     4096, 0x5afdf69f
> -0,      41984,      41984,     1024,     4096, 0x765e05ec
> -0,      43008,      43008,     1024,     4096, 0x6484f551
> -0,      44032,      44032,     1024,     4096, 0x755e0600
> -0,      45056,      45056,     1024,     4096, 0x5056ecb9
> -0,      46080,      46080,     1024,     4096, 0xdcb609a8
> -0,      47104,      47104,     1024,     4096, 0xc87bf4a1
> -0,      48128,      48128,     1024,     4096, 0xecdfef95
> -0,      49152,      49152,     1024,     4096, 0x905ff13f
> -0,      50176,      50176,     1024,     4096, 0x4e69eeb3
> -0,      51200,      51200,     1024,     4096, 0x16e1082c
> -0,      52224,      52224,     1024,     4096, 0x606c0a22
> -0,      53248,      53248,     1024,     4096, 0x9f94f351
> -0,      54272,      54272,     1024,     4096, 0x2c47f63f
> -0,      55296,      55296,     1024,     4096, 0x9e14ebf9
> -0,      56320,      56320,     1024,     4096, 0x7804fbcb
> -0,      57344,      57344,     1024,     4096, 0xc7c6ffb7
> -0,      58368,      58368,     1024,     4096, 0xa547f68d
> -0,      59392,      59392,     1024,     4096, 0x0c87fed7
> -0,      60416,      60416,     1024,     4096, 0x88b5fef1
> -0,      61440,      61440,     1024,     4096, 0x325af00d
> -0,      62464,      62464,     1024,     4096, 0xd826edd9
> -0,      63488,      63488,     1024,     4096, 0x1fbe1138
> -0,      64512,      64512,     1024,     4096, 0xdf85da7b
> -0,      65536,      65536,     1024,     4096, 0xf987f9b3
> -0,      66560,      66560,     1024,     4096, 0x5df5e12f
> -0,      67584,      67584,     1024,     4096, 0x259cf8ef
> -0,      68608,      68608,     1024,     4096, 0xa191eb4f
> -0,      69632,      69632,     1024,     4096, 0xfe5bf1fd
> -0,      70656,      70656,     1024,     4096, 0x7675e2cb
> -0,      71680,      71680,     1024,     4096, 0x796a2f90
> -0,      72704,      72704,     1024,     4096, 0xaa52e7a5
> -0,      73728,      73728,     1024,     4096, 0x2b56fd81
> -0,      74752,      74752,     1024,     4096, 0xbf7c02ee
> -0,      75776,      75776,     1024,     4096, 0xfe4cebb1
> -0,      76800,      76800,     1024,     4096, 0xe5b7fdf7
> -0,      77824,      77824,     1024,     4096, 0xd271ece7
> -0,      78848,      78848,     1024,     4096, 0x96e0f69f
> -0,      79872,      79872,     1024,     4096, 0x6e5eef33
> -0,      80896,      80896,     1024,     4096, 0x78b70b6e
> -0,      81920,      81920,     1024,     4096, 0x61f2f075
> -0,      82944,      82944,     1024,     4096, 0xf1dc47dc
> -0,      83968,      83968,     1024,     4096, 0xf4b406d2
> -0,      84992,      84992,     1024,     4096, 0xe33806fe
> -0,      86016,      86016,     1024,     4096, 0x5b5ef087
> -0,      87040,      87040,     1024,     4096, 0x3fa207da
> -0,      88064,      88064,     1024,     4096, 0x4719f201
> -0,      89088,      89088,     1024,     4096, 0x641feaad
> -0,      90112,      90112,     1024,     4096, 0x905402ec
> -0,      91136,      91136,     1024,     4096, 0xf529e11f
> -0,      92160,      92160,     1024,     4096, 0x65a41838
> -0,      93184,      93184,     1024,     4096, 0x651efb6f
> -0,      94208,      94208,     1024,     4096, 0x251b1390
> -0,      95232,      95232,     1024,     4096, 0x45ea05a8
> -0,      96256,      96256,     1024,     4096, 0xe65be141
> -0,      97280,      97280,     1024,     4096, 0xd452d3dd
> -0,      98304,      98304,     1024,     4096, 0x3bdff821
> -0,      99328,      99328,     1024,     4096, 0x74da00e6
> -0,     100352,     100352,     1024,     4096, 0x4474fa19
> -0,     101376,     101376,     1024,     4096, 0x11ddedef
> -0,     102400,     102400,     1024,     4096, 0xf027d72b
> -0,     103424,     103424,     1024,     4096, 0xaa0a1ce6
> -0,     104448,     104448,     1024,     4096, 0x7168145e
> -0,     105472,     105472,     1024,     4096, 0x94a710a4
> -0,     106496,     106496,     1024,     4096, 0x6f55ecf1
> -0,     107520,     107520,     1024,     4096, 0xc12de6d7
> -0,     108544,     108544,     1024,     4096, 0x8ff7db15
> -0,     109568,     109568,     1024,     4096, 0x366d0cc6
> -0,     110592,     110592,     1024,     4096, 0xb04afa4f
> -0,     111616,     111616,     1024,     4096, 0xf6abbee7
> -0,     112640,     112640,     1024,     4096, 0xbe9910dc
> -0,     113664,     113664,     1024,     4096, 0x96c3047e
> -0,     114688,     114688,     1024,     4096, 0x9dc1e8e1
> -0,     115712,     115712,     1024,     4096, 0x4b2c1092
> -0,     116736,     116736,     1024,     4096, 0x592d212c
> -0,     117760,     117760,     1024,     4096, 0x5c3bda15
> -0,     118784,     118784,     1024,     4096, 0x43c8e90f
> -0,     119808,     119808,     1024,     4096, 0x3bfa074e
> -0,     120832,     120832,     1024,     4096, 0xa2d7d443
> -0,     121856,     121856,     1024,     4096, 0xd4b02844
> -0,     122880,     122880,     1024,     4096, 0x9f5d2a92
> -0,     123904,     123904,     1024,     4096, 0xc19bf69d
> -0,     124928,     124928,     1024,     4096, 0x47b8fe75
> -0,     125952,     125952,     1024,     4096, 0x337334b0
> -0,     126976,     126976,     1024,     4096, 0x96ed14f0
> -0,     128000,     128000,     1024,     4096, 0x9af0f67b
> -0,     129024,     129024,     1024,     4096, 0xdf541a60
> -0,     130048,     130048,     1024,     4096, 0x684f0c06
> -0,     131072,     131072,     1024,     4096, 0xe3d0015e
> -0,     132096,     132096,     1024,     4096, 0xf648d73c
> -0,     133120,     133120,     1024,     4096, 0x4041f3ee
> -0,     134144,     134144,     1024,     4096, 0x1421025f
> -0,     135168,     135168,     1024,     4096, 0x4eb5fc97
> -0,     136192,     136192,     1024,     4096, 0x510f02fe
> -0,     137216,     137216,     1024,     4096, 0x85e9e95e
> -0,     138240,     138240,     1024,     4096, 0xb1d0fe10
> -0,     139264,     139264,     1024,     4096, 0xda66f5f8
> -0,     140288,     140288,     1024,     4096, 0x3826eaa8
> -0,     141312,     141312,     1024,     4096, 0xa7cc0176
> -0,     142336,     142336,     1024,     4096, 0x71e8fe5a
> -0,     143360,     143360,     1024,     4096, 0x0149fcfa
> -0,     144384,     144384,     1024,     4096, 0xbd36fd8e
> -0,     145408,     145408,     1024,     4096, 0xec1afcc6
> -0,     146432,     146432,     1024,     4096, 0xea80ec5e
> -0,     147456,     147456,     1024,     4096, 0x8da1f0ac
> -0,     148480,     148480,     1024,     4096, 0x63c3e61c
> -0,     149504,     149504,     1024,     4096, 0x188cf09b
> -0,     150528,     150528,     1024,     4096, 0x7eebea85
> -0,     151552,     151552,     1024,     4096, 0x7ef6f718
> -0,     152576,     152576,     1024,     4096, 0xcd9fecfb
> -0,     153600,     153600,     1024,     4096, 0x1aa7f624
> -0,     154624,     154624,     1024,     4096, 0xcab5f1e3
> -0,     155648,     155648,     1024,     4096, 0x36e9f795
> -0,     156672,     156672,     1024,     4096, 0x952cf54d
> -0,     157696,     157696,     1024,     4096, 0x54a4ed3b
> -0,     158720,     158720,     1024,     4096, 0x1e24f992
> -0,     159744,     159744,     1024,     4096, 0xab6bfa09
> -0,     160768,     160768,     1024,     4096, 0xa021020b
> -0,     161792,     161792,     1024,     4096, 0xaa0600f5
> -0,     162816,     162816,     1024,     4096, 0xadf7ec92
> -0,     163840,     163840,     1024,     4096, 0x5dd5f63f
> -0,     164864,     164864,     1024,     4096, 0xc01bff89
> -0,     165888,     165888,     1024,     4096, 0x05dbf1e7
> -0,     166912,     166912,     1024,     4096, 0x44f00038
> -0,     167936,     167936,     1024,     4096, 0x6dc5f886
> -0,     168960,     168960,     1024,     4096, 0xeb88e729
> -0,     169984,     169984,     1024,     4096, 0xfe5cf53e
> -0,     171008,     171008,     1024,     4096, 0x2692f7a0
> -0,     172032,     172032,     1024,     4096, 0xe984f24b
> -0,     173056,     173056,     1024,     4096, 0x1a4ef732
> -0,     174080,     174080,     1024,     4096, 0x3b60010b
> -0,     175104,     175104,     1024,     4096, 0x6dd0eaf2
> -0,     176128,     176128,     1024,     4096, 0x313de851
> -0,     177152,     177152,     1024,     4096, 0x239ef043
> -0,     178176,     178176,     1024,     4096, 0x2366fe43
> -0,     179200,     179200,     1024,     4096, 0xbfd6f3b9
> -0,     180224,     180224,     1024,     4096, 0xb34bf67b
> -0,     181248,     181248,     1024,     4096, 0x00def7c1
> -0,     182272,     182272,     1024,     4096, 0xa6d0f466
> -0,     183296,     183296,     1024,     4096, 0xd1a1f1c2
> -0,     184320,     184320,     1024,     4096, 0x32f8923c
> -0,     185344,     185344,     1024,     4096, 0x137001d2
> -0,     186368,     186368,     1024,     4096, 0xb881f6cd
> -0,     187392,     187392,     1024,     4096, 0xf44e034a
> -0,     188416,     188416,     1024,     4096, 0xb43fecf7
> -0,     189440,     189440,     1024,     4096, 0xe62ced50
> -0,     190464,     190464,     1024,     4096, 0x221dfd0d
> -0,     191488,     191488,     1024,     4096, 0x85400147
> -0,     192512,     192512,     1024,     4096, 0x8bf8d054
> -0,     193536,     193536,     1024,     4096, 0x08370170
> -0,     194560,     194560,     1024,     4096, 0xec62effa
> -0,     195584,     195584,     1024,     4096, 0xd58cf67c
> -0,     196608,     196608,     1024,     4096, 0xf597f9a1
> -0,     197632,     197632,     1024,     4096, 0x63fcf0b0
> -0,     198656,     198656,     1024,     4096, 0x8cc8fd32
> -0,     199680,     199680,     1024,     4096, 0xf8c2072c
> -0,     200704,     200704,     1024,     4096, 0x0c7e93a5
> -0,     201728,     201728,     1024,     4096, 0x1cc3f612
> -0,     202752,     202752,     1024,     4096, 0x83adf8ee
> -0,     203776,     203776,     1024,     4096, 0x680e0195
> -0,     204800,     204800,     1024,     4096, 0x9d34fd2e
> -0,     205824,     205824,     1024,     4096, 0x44cdfb34
> -0,     206848,     206848,     1024,     4096, 0x193df790
> -0,     207872,     207872,     1024,     4096, 0xb337ef64
> -0,     208896,     208896,     1024,     4096, 0x0074ee38
> -0,     209920,     209920,     1024,     4096, 0x239ef043
> -0,     210944,     210944,     1024,     4096, 0x2366fe43
> -0,     211968,     211968,     1024,     4096, 0xbfd6f3b9
> -0,     212992,     212992,     1024,     4096, 0xb34bf67b
> -0,     214016,     214016,     1024,     4096, 0x00def7c1
> -0,     215040,     215040,     1024,     4096, 0xa6d0f466
> -0,     216064,     216064,     1024,     4096, 0xd1a1f1c2
> -0,     217088,     217088,     1024,     4096, 0x32f8923c
> -0,     218112,     218112,     1024,     4096, 0x137001d2
> -0,     219136,     219136,     1024,     4096, 0xb881f6cd
> -0,     220160,     220160,     1024,     4096, 0xf44e034a
> -0,     221184,     221184,     1024,     4096, 0xb43fecf7
> -0,     222208,     222208,     1024,     4096, 0xe62ced50
> -0,     223232,     223232,     1024,     4096, 0x221dfd0d
> -0,     224256,     224256,     1024,     4096, 0x85400147
> -0,     225280,     225280,     1024,     4096, 0x8bf8d054
> -0,     226304,     226304,     1024,     4096, 0x08370170
> -0,     227328,     227328,     1024,     4096, 0xec62effa
> -0,     228352,     228352,     1024,     4096, 0xd58cf67c
> -0,     229376,     229376,     1024,     4096, 0xf597f9a1
> -0,     230400,     230400,     1024,     4096, 0x63fcf0b0
> -0,     231424,     231424,     1024,     4096, 0x8cc8fd32
> -0,     232448,     232448,     1024,     4096, 0xf8c2072c
> -0,     233472,     233472,     1024,     4096, 0x0c7e93a5
> -0,     234496,     234496,     1024,     4096, 0x1cc3f612
> -0,     235520,     235520,     1024,     4096, 0x83adf8ee
> -0,     236544,     236544,     1024,     4096, 0x680e0195
> -0,     237568,     237568,     1024,     4096, 0x9d34fd2e
> -0,     238592,     238592,     1024,     4096, 0x44cdfb34
> -0,     239616,     239616,     1024,     4096, 0x193df790
> -0,     240640,     240640,     1024,     4096, 0xb337ef64
> -0,     241664,     241664,     1024,     4096, 0x0074ee38
> -0,     242688,     242688,     1024,     4096, 0x239ef043
> -0,     243712,     243712,     1024,     4096, 0x2366fe43
> -0,     244736,     244736,     1024,     4096, 0xbfd6f3b9
> -0,     245760,     245760,     1024,     4096, 0xb34bf67b
> -0,     246784,     246784,     1024,     4096, 0x00def7c1
> -0,     247808,     247808,     1024,     4096, 0xa6d0f466
> -0,     248832,     248832,     1024,     4096, 0xd1a1f1c2
> -0,     249856,     249856,     1024,     4096, 0x32f8923c
> -0,     250880,     250880,     1024,     4096, 0x137001d2
> -0,     251904,     251904,     1024,     4096, 0xb881f6cd
> -0,     252928,     252928,     1024,     4096, 0xf44e034a
> -0,     253952,     253952,     1024,     4096, 0xb43fecf7
> -0,     254976,     254976,     1024,     4096, 0xe62ced50
> -0,     256000,     256000,     1024,     4096, 0x221dfd0d
> -0,     257024,     257024,     1024,     4096, 0x85400147
> -0,     258048,     258048,     1024,     4096, 0x8bf8d054
> -0,     259072,     259072,     1024,     4096, 0x08370170
> -0,     260096,     260096,     1024,     4096, 0xec62effa
> -0,     261120,     261120,     1024,     4096, 0xd58cf67c
> -0,     262144,     262144,     1024,     4096, 0xf597f9a1
> -0,     263168,     263168,     1024,     4096, 0x63fcf0b0
> -0,     264192,     264192,      408,     1632, 0xedfa314a
> +0,          0,          0,     1024,     4096, 0xd0b20048
> +0,       1024,       1024,     1024,     4096, 0x8abaf0ab
> +0,       2048,       2048,     1024,     4096, 0x5a00f489
> +0,       3072,       3072,     1024,     4096, 0x6d87f3d3
> +0,       4096,       4096,     1024,     4096, 0x27fc04bc
> +0,       5120,       5120,     1024,     4096, 0x6d18f2e1
> +0,       6144,       6144,     1024,     4096, 0x6a11f0c9
> +0,       7168,       7168,     1024,     4096, 0xadf8ec27
> +0,       8192,       8192,     1024,     4096, 0xf0e2fcf9
> +0,       9216,       9216,     1024,     4096, 0x55280372
> +0,      10240,      10240,     1024,     4096, 0x898ffad3
> +0,      11264,      11264,     1024,     4096, 0x06a5eb6b
> +0,      12288,      12288,     1024,     4096, 0x9fadfe07
> +0,      13312,      13312,     1024,     4096, 0x6f32fd99
> +0,      14336,      14336,     1024,     4096, 0x7856f871
> +0,      15360,      15360,     1024,     4096, 0xf742f893
> +0,      16384,      16384,     1024,     4096, 0x7955f7e7
> +0,      17408,      17408,     1024,     4096, 0xbb32f521
> +0,      18432,      18432,     1024,     4096, 0x8302fda9
> +0,      19456,      19456,     1024,     4096, 0x0d3cfdeb
> +0,      20480,      20480,     1024,     4096, 0xd034ed5f
> +0,      21504,      21504,     1024,     4096, 0xd3c1fb11
> +0,      22528,      22528,     1024,     4096, 0x80bc0734
> +0,      23552,      23552,     1024,     4096, 0x82a60000
> +0,      24576,      24576,     1024,     4096, 0xaf6ceb09
> +0,      25600,      25600,     1024,     4096, 0x0c0dec9f
> +0,      26624,      26624,     1024,     4096, 0x8ca8f335
> +0,      27648,      27648,     1024,     4096, 0xc75604bc
> +0,      28672,      28672,     1024,     4096, 0x0a22f7b9
> +0,      29696,      29696,     1024,     4096, 0x237cf4a5
> +0,      30720,      30720,     1024,     4096, 0x5276f36f
> +0,      31744,      31744,     1024,     4096, 0x148a0194
> +0,      32768,      32768,     1024,     4096, 0xd0b20048
> +0,      33792,      33792,     1024,     4096, 0x8abaf0ab
> +0,      34816,      34816,     1024,     4096, 0x5a00f489
> +0,      35840,      35840,     1024,     4096, 0x6d87f3d3
> +0,      36864,      36864,     1024,     4096, 0x27fc04bc
> +0,      37888,      37888,     1024,     4096, 0x6d18f2e1
> +0,      38912,      38912,     1024,     4096, 0x6a11f0c9
> +0,      39936,      39936,     1024,     4096, 0xadf8ec27
> +0,      40960,      40960,     1024,     4096, 0xf0e2fcf9
> +0,      41984,      41984,     1024,     4096, 0x55280372
> +0,      43008,      43008,     1024,     4096, 0x8ac5fad5
> +0,      44032,      44032,     1024,     4096, 0x934007ba
> +0,      45056,      45056,     1024,     4096, 0x84acf4a3
> +0,      46080,      46080,     1024,     4096, 0x7c8ff49b
> +0,      47104,      47104,     1024,     4096, 0x79030244
> +0,      48128,      48128,     1024,     4096, 0x28d0e5f5
> +0,      49152,      49152,     1024,     4096, 0xf12df059
> +0,      50176,      50176,     1024,     4096, 0xd0eef7a7
> +0,      51200,      51200,     1024,     4096, 0x2e2e02e4
> +0,      52224,      52224,     1024,     4096, 0x7c421656
> +0,      53248,      53248,     1024,     4096, 0x79fcea35
> +0,      54272,      54272,     1024,     4096, 0xb566e88b
> +0,      55296,      55296,     1024,     4096, 0xad66f8e9
> +0,      56320,      56320,     1024,     4096, 0xe0d001dc
> +0,      57344,      57344,     1024,     4096, 0xfc5df6cd
> +0,      58368,      58368,     1024,     4096, 0x9dcefad5
> +0,      59392,      59392,     1024,     4096, 0xbde90702
> +0,      60416,      60416,     1024,     4096, 0x4feef329
> +0,      61440,      61440,     1024,     4096, 0xbb30ef39
> +0,      62464,      62464,     1024,     4096, 0x131ff1e3
> +0,      63488,      63488,     1024,     4096, 0x994c0184
> +0,      64512,      64512,     1024,     4096, 0xc981e10b
> +0,      65536,      65536,     1024,     4096, 0xceff022a
> +0,      66560,      66560,     1024,     4096, 0x07d1e1d3
> +0,      67584,      67584,     1024,     4096, 0x7ea5f31d
> +0,      68608,      68608,     1024,     4096, 0x16e1e885
> +0,      69632,      69632,     1024,     4096, 0x2a92fb45
> +0,      70656,      70656,     1024,     4096, 0x9f90ef6b
> +0,      71680,      71680,     1024,     4096, 0xed961010
> +0,      72704,      72704,     1024,     4096, 0x6169f659
> +0,      73728,      73728,     1024,     4096, 0xbe830c50
> +0,      74752,      74752,     1024,     4096, 0x1744ea89
> +0,      75776,      75776,     1024,     4096, 0x00bcf34f
> +0,      76800,      76800,     1024,     4096, 0x91f7f7f3
> +0,      77824,      77824,     1024,     4096, 0xa4e1f1fb
> +0,      78848,      78848,     1024,     4096, 0xf3e5f73b
> +0,      79872,      79872,     1024,     4096, 0x64d0eb95
> +0,      80896,      80896,     1024,     4096, 0xe0c90d40
> +0,      81920,      81920,     1024,     4096, 0xe9701e32
> +0,      82944,      82944,     1024,     4096, 0x760d26b0
> +0,      83968,      83968,     1024,     4096, 0x3f4303e4
> +0,      84992,      84992,     1024,     4096, 0x1cc502bc
> +0,      86016,      86016,     1024,     4096, 0x6d7bf089
> +0,      87040,      87040,     1024,     4096, 0xe03807fc
> +0,      88064,      88064,     1024,     4096, 0xf12fe897
> +0,      89088,      89088,     1024,     4096, 0x0123e87d
> +0,      90112,      90112,     1024,     4096, 0x869808d4
> +0,      91136,      91136,     1024,     4096, 0x9538def3
> +0,      92160,      92160,     1024,     4096, 0x92ed2ab0
> +0,      93184,      93184,     1024,     4096, 0xc80bfe9d
> +0,      94208,      94208,     1024,     4096, 0x56130220
> +0,      95232,      95232,     1024,     4096, 0xd3a7f0f3
> +0,      96256,      96256,     1024,     4096, 0xfca0eeaf
> +0,      97280,      97280,     1024,     4096, 0xd409d82b
> +0,      98304,      98304,     1024,     4096, 0x29ba0424
> +0,      99328,      99328,     1024,     4096, 0x4e9cdf19
> +0,     100352,     100352,     1024,     4096, 0xb0511cc0
> +0,     101376,     101376,     1024,     4096, 0xd499e541
> +0,     102400,     102400,     1024,     4096, 0x0910f25f
> +0,     103424,     103424,     1024,     4096, 0x6e5d1c08
> +0,     104448,     104448,     1024,     4096, 0xa07511a8
> +0,     105472,     105472,     1024,     4096, 0xddd1ee73
> +0,     106496,     106496,     1024,     4096, 0x5b46fb17
> +0,     107520,     107520,     1024,     4096, 0xc558e301
> +0,     108544,     108544,     1024,     4096, 0x9041e627
> +0,     109568,     109568,     1024,     4096, 0xeadae195
> +0,     110592,     110592,     1024,     4096, 0x663d0c5a
> +0,     111616,     111616,     1024,     4096, 0x1c57d55b
> +0,     112640,     112640,     1024,     4096, 0x7ce90702
> +0,     113664,     113664,     1024,     4096, 0xf56c15d0
> +0,     114688,     114688,     1024,     4096, 0xa2edd14d
> +0,     115712,     115712,     1024,     4096, 0x93f1171c
> +0,     116736,     116736,     1024,     4096, 0xe02e152a
> +0,     117760,     117760,     1024,     4096, 0x55aaeba7
> +0,     118784,     118784,     1024,     4096, 0xacabd7a7
> +0,     119808,     119808,     1024,     4096, 0xaa18150a
> +0,     120832,     120832,     1024,     4096, 0x065ed6a1
> +0,     121856,     121856,     1024,     4096, 0x9df9268e
> +0,     122880,     122880,     1024,     4096, 0x8e0a23e6
> +0,     123904,     123904,     1024,     4096, 0x872d019e
> +0,     124928,     124928,     1024,     4096, 0x3aff116c
> +0,     125952,     125952,     1024,     4096, 0x4a1717f8
> +0,     126976,     126976,     1024,     4096, 0xa3812998
> +0,     128000,     128000,     1024,     4096, 0x8f12ee4f
> +0,     129024,     129024,     1024,     4096, 0x1add13c4
> +0,     130048,     130048,     1024,     4096, 0x4f3825da
> +0,     131072,     131072,     1024,     4096, 0xf732d42b
> +0,     132096,     132096,     1024,     4096, 0xa2b3e578
> +0,     133120,     133120,     1024,     4096, 0xdc18ff83
> +0,     134144,     134144,     1024,     4096, 0xd13df8c5
> +0,     135168,     135168,     1024,     4096, 0x24c506ff
> +0,     136192,     136192,     1024,     4096, 0xb58cf9d4
> +0,     137216,     137216,     1024,     4096, 0x734cecba
> +0,     138240,     138240,     1024,     4096, 0x9af5fb4e
> +0,     139264,     139264,     1024,     4096, 0x8510f05f
> +0,     140288,     140288,     1024,     4096, 0x81e0f2c3
> +0,     141312,     141312,     1024,     4096, 0x5c060641
> +0,     142336,     142336,     1024,     4096, 0xb15bfc84
> +0,     143360,     143360,     1024,     4096, 0xe7dafcaa
> +0,     144384,     144384,     1024,     4096, 0x5419faaa
> +0,     145408,     145408,     1024,     4096, 0x6f97fa6f
> +0,     146432,     146432,     1024,     4096, 0x5e69e975
> +0,     147456,     147456,     1024,     4096, 0xd614f89e
> +0,     148480,     148480,     1024,     4096, 0x2532e193
> +0,     149504,     149504,     1024,     4096, 0x0ce9f04c
> +0,     150528,     150528,     1024,     4096, 0x0935ec67
> +0,     151552,     151552,     1024,     4096, 0x92d6f5d9
> +0,     152576,     152576,     1024,     4096, 0xccffea44
> +0,     153600,     153600,     1024,     4096, 0x81e3eea0
> +0,     154624,     154624,     1024,     4096, 0xc5c2fe66
> +0,     155648,     155648,     1024,     4096, 0x75dbf93c
> +0,     156672,     156672,     1024,     4096, 0x6294f023
> +0,     157696,     157696,     1024,     4096, 0xf39eef54
> +0,     158720,     158720,     1024,     4096, 0x03b1fa13
> +0,     159744,     159744,     1024,     4096, 0xacc0faf2
> +0,     160768,     160768,     1024,     4096, 0xcd9ffc79
> +0,     161792,     161792,     1024,     4096, 0x4ffc023f
> +0,     162816,     162816,     1024,     4096, 0x3126ed15
> +0,     163840,     163840,     1024,     4096, 0x611ff8d6
> +0,     164864,     164864,     1024,     4096, 0x6a9bfa1a
> +0,     165888,     165888,     1024,     4096, 0xb06cfb10
> +0,     166912,     166912,     1024,     4096, 0x1c9f00bb
> +0,     167936,     167936,     1024,     4096, 0xc0bbeebf
> +0,     168960,     168960,     1024,     4096, 0x383eea91
> +0,     169984,     169984,     1024,     4096, 0xf927f893
> +0,     171008,     171008,     1024,     4096, 0xbfc3f9b4
> +0,     172032,     172032,     1024,     4096, 0x9faaef83
> +0,     173056,     173056,     1024,     4096, 0x4dc6f411
> +0,     174080,     174080,     1024,     4096, 0x9432ff0f
> +0,     175104,     175104,     1024,     4096, 0x62d5e7d6
> +0,     176128,     176128,     1024,     4096, 0x1af9ea59
> +0,     177152,     177152,     1024,     4096, 0x3dcbf8d0
> +0,     178176,     178176,     1024,     4096, 0x80fbf978
> +0,     179200,     179200,     1024,     4096, 0xbe60f05b
> +0,     180224,     180224,     1024,     4096, 0xf12ffb83
> +0,     181248,     181248,     1024,     4096, 0xfed0f81a
> +0,     182272,     182272,     1024,     4096, 0x892eede2
> +0,     183296,     183296,     1024,     4096, 0x4101f200
> +0,     184320,     184320,     1024,     4096, 0x08759c99
> +0,     185344,     185344,     1024,     4096, 0xea80fab7
> +0,     186368,     186368,     1024,     4096, 0x2b47fcf4
> +0,     187392,     187392,     1024,     4096, 0x2933f949
> +0,     188416,     188416,     1024,     4096, 0x10c3eaed
> +0,     189440,     189440,     1024,     4096, 0x38bb0089
> +0,     190464,     190464,     1024,     4096, 0x4fa4f4b6
> +0,     191488,     191488,     1024,     4096, 0x47c9fd4c
> +0,     192512,     192512,     1024,     4096, 0x6e95d5d1
> +0,     193536,     193536,     1024,     4096, 0x6deaf758
> +0,     194560,     194560,     1024,     4096, 0x96a2f230
> +0,     195584,     195584,     1024,     4096, 0x6515fa5b
> +0,     196608,     196608,     1024,     4096, 0xbdf6f5a6
> +0,     197632,     197632,     1024,     4096, 0x74d4f365
> +0,     198656,     198656,     1024,     4096, 0x932903e3
> +0,     199680,     199680,     1024,     4096, 0x7468085e
> +0,     200704,     200704,     1024,     4096, 0x0d908b65
> +0,     201728,     201728,     1024,     4096, 0x86e7f740
> +0,     202752,     202752,     1024,     4096, 0x09fff8d2
> +0,     203776,     203776,     1024,     4096, 0xf0430838
> +0,     204800,     204800,     1024,     4096, 0x525bf9ec
> +0,     205824,     205824,     1024,     4096, 0x17c7ee8d
> +0,     206848,     206848,     1024,     4096, 0x7632fc3b
> +0,     207872,     207872,     1024,     4096, 0xf12aefe9
> +0,     208896,     208896,     1024,     4096, 0x0d72ed83
> +0,     209920,     209920,     1024,     4096, 0x3dcbf8d0
> +0,     210944,     210944,     1024,     4096, 0x80fbf978
> +0,     211968,     211968,     1024,     4096, 0xbe60f05b
> +0,     212992,     212992,     1024,     4096, 0xf12ffb83
> +0,     214016,     214016,     1024,     4096, 0xfed0f81a
> +0,     215040,     215040,     1024,     4096, 0x892eede2
> +0,     216064,     216064,     1024,     4096, 0x4101f200
> +0,     217088,     217088,     1024,     4096, 0x08759c99
> +0,     218112,     218112,     1024,     4096, 0xea80fab7
> +0,     219136,     219136,     1024,     4096, 0x2b47fcf4
> +0,     220160,     220160,     1024,     4096, 0x2933f949
> +0,     221184,     221184,     1024,     4096, 0x10c3eaed
> +0,     222208,     222208,     1024,     4096, 0x38bb0089
> +0,     223232,     223232,     1024,     4096, 0x4fa4f4b6
> +0,     224256,     224256,     1024,     4096, 0x47c9fd4c
> +0,     225280,     225280,     1024,     4096, 0x6e95d5d1
> +0,     226304,     226304,     1024,     4096, 0x6deaf758
> +0,     227328,     227328,     1024,     4096, 0x96a2f230
> +0,     228352,     228352,     1024,     4096, 0x6515fa5b
> +0,     229376,     229376,     1024,     4096, 0xbdf6f5a6
> +0,     230400,     230400,     1024,     4096, 0x74d4f365
> +0,     231424,     231424,     1024,     4096, 0x932903e3
> +0,     232448,     232448,     1024,     4096, 0x7468085e
> +0,     233472,     233472,     1024,     4096, 0x0d908b65
> +0,     234496,     234496,     1024,     4096, 0x86e7f740
> +0,     235520,     235520,     1024,     4096, 0x09fff8d2
> +0,     236544,     236544,     1024,     4096, 0xf0430838
> +0,     237568,     237568,     1024,     4096, 0x525bf9ec
> +0,     238592,     238592,     1024,     4096, 0x17c7ee8d
> +0,     239616,     239616,     1024,     4096, 0x7632fc3b
> +0,     240640,     240640,     1024,     4096, 0xf12aefe9
> +0,     241664,     241664,     1024,     4096, 0x0d72ed83
> +0,     242688,     242688,     1024,     4096, 0x3dcbf8d0
> +0,     243712,     243712,     1024,     4096, 0x80fbf978
> +0,     244736,     244736,     1024,     4096, 0xbe60f05b
> +0,     245760,     245760,     1024,     4096, 0xf12ffb83
> +0,     246784,     246784,     1024,     4096, 0xfed0f81a
> +0,     247808,     247808,     1024,     4096, 0x892eede2
> +0,     248832,     248832,     1024,     4096, 0x4101f200
> +0,     249856,     249856,     1024,     4096, 0x08759c99
> +0,     250880,     250880,     1024,     4096, 0xea80fab7
> +0,     251904,     251904,     1024,     4096, 0x2b47fcf4
> +0,     252928,     252928,     1024,     4096, 0x2933f949
> +0,     253952,     253952,     1024,     4096, 0x10c3eaed
> +0,     254976,     254976,     1024,     4096, 0x38bb0089
> +0,     256000,     256000,     1024,     4096, 0x4fa4f4b6
> +0,     257024,     257024,     1024,     4096, 0x47c9fd4c
> +0,     258048,     258048,     1024,     4096, 0x6e95d5d1
> +0,     259072,     259072,     1024,     4096, 0x6deaf758
> +0,     260096,     260096,     1024,     4096, 0x96a2f230
> +0,     261120,     261120,     1024,     4096, 0x6515fa5b
> +0,     262144,     262144,     1024,     4096, 0xbdf6f5a6
> +0,     263168,     263168,     1024,     4096, 0x74d4f365
> +0,     264192,     264192,      408,     1632, 0x637b3c21
> --
> 2.35.1.1094.g7c7d902a7c-goog
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
>
diff mbox series

Patch

diff --git a/doc/filters.texi b/doc/filters.texi
index d70ac3e237..5d1adf88e1 100644
--- a/doc/filters.texi
+++ b/doc/filters.texi
@@ -1943,8 +1943,6 @@  aiir=z=1.3057 0 0 0:p=1.3057 2.3892 2.1860 1:f=sf:r=d
 
 The limiter prevents an input signal from rising over a desired threshold.
 This limiter uses lookahead technology to prevent your signal from distorting.
-It means that there is a small delay after the signal is processed. Keep in mind
-that the delay it produces is the attack time you set.
 
 The filter accepts the following options:
 
diff --git a/libavfilter/af_alimiter.c b/libavfilter/af_alimiter.c
index 133f98f165..e1fcf98574 100644
--- a/libavfilter/af_alimiter.c
+++ b/libavfilter/af_alimiter.c
@@ -30,6 +30,7 @@ 
 
 #include "audio.h"
 #include "avfilter.h"
+#include "bufferqueue.h"
 #include "formats.h"
 #include "internal.h"
 
@@ -55,6 +56,13 @@  typedef struct AudioLimiterContext {
     int *nextpos;
     double *nextdelta;
 
+    int total_samples_to_flush;
+    int lookahead_buffer_full;
+
+    struct FFBufQueue output_frame_queue;
+    int output_sample_pos;
+    int output_frame_pos;
+
     double delta;
     int nextiter;
     int nextlen;
@@ -129,6 +137,8 @@  static int filter_frame(AVFilterLink *inlink, AVFrame *in)
     AVFrame *out;
     double *buf;
     int n, c, i;
+    int can_free_input_frame = 0;
+    double peak = 0;
 
     if (av_frame_is_writable(in)) {
         out = in;
@@ -138,12 +148,23 @@  static int filter_frame(AVFilterLink *inlink, AVFrame *in)
             av_frame_free(&in);
             return AVERROR(ENOMEM);
         }
+        can_free_input_frame = 1;
         av_frame_copy_props(out, in);
     }
-    dst = (double *)out->data[0];
+
+    if (ff_bufqueue_is_full(&s->output_frame_queue)) {
+        // In the runtime, the total number of frames in the queue is bounded by
+        // attack_time, sample rate and frame size.
+        return AVERROR_BUG;
+    }
+
+    ff_bufqueue_add(ctx, &s->output_frame_queue, out);
 
     for (n = 0; n < in->nb_samples; n++) {
-        double peak = 0;
+        out = ff_bufqueue_peek(&s->output_frame_queue, s->output_frame_pos);
+        dst = (double *)out->data[0];
+        dst += s->output_sample_pos * channels;
+        peak = 0;
 
         for (c = 0; c < channels; c++) {
             double sample = src[c] * level_in;
@@ -213,8 +234,21 @@  static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 
         s->att += s->delta;
 
-        for (c = 0; c < channels; c++)
-            dst[c] = buf[c] * s->att;
+        // Checks lookahead buffer (s->buffer) has been filled
+        if (!s->lookahead_buffer_full && (s->pos + channels) % buffer_size == 0) {
+            s->lookahead_buffer_full = 1;
+        }
+        if (s->lookahead_buffer_full) {
+            for (c = 0; c < channels; c++) {
+                dst[c] = buf[c] * s->att;
+                dst[c] = av_clipd(dst[c], -limit, limit) * level * level_out;
+            }
+            s->output_sample_pos++;
+            if (s->output_sample_pos == out->nb_samples) {
+                s->output_frame_pos++;
+                s->output_sample_pos = 0;
+            }
+        }
 
         if ((s->pos + channels) % buffer_size == nextpos[s->nextiter]) {
             if (s->auto_release) {
@@ -261,18 +295,55 @@  static int filter_frame(AVFilterLink *inlink, AVFrame *in)
         if (s->delta != 0. && fabs(s->delta) < 0.00000000000001)
             s->delta = 0.;
 
-        for (c = 0; c < channels; c++)
-            dst[c] = av_clipd(dst[c], -limit, limit) * level * level_out;
-
         s->pos = (s->pos + channels) % buffer_size;
         src += channels;
-        dst += channels;
     }
-
-    if (in != out)
+    if (can_free_input_frame) {
         av_frame_free(&in);
+    }
 
-    return ff_filter_frame(outlink, out);
+    if (s->output_frame_pos > 0) {
+        s->output_frame_pos--;
+        out = ff_bufqueue_get(&s->output_frame_queue);
+        return ff_filter_frame(outlink, out);
+    }
+    return 0;
+}
+
+static int request_frame(AVFilterLink* outlink) 
+{
+    AVFilterContext *ctx = outlink->src;
+    AudioLimiterContext *s = (AudioLimiterContext*)ctx->priv;
+    int ret;
+    AVFilterLink *inlink;
+    AVFrame *out;
+    AVFrame *silence_frame;
+
+    ret = ff_request_frame(ctx->inputs[0]);
+
+    if (ret != AVERROR_EOF || s->total_samples_to_flush == 0) {
+      // Not necessarily an error, just not EOF.
+      return ret;
+    }
+
+    // Flush the frames in the internal buffer
+    if (s->output_frame_pos > 0) {
+        out = ff_bufqueue_get(&s->output_frame_queue);
+        s->output_frame_pos--;
+        return ff_filter_frame(outlink, out);
+    }
+
+    // We reach here when input filters have finished producing data (i.e. EOF),
+    // but because of the attack param, s->buffer still has meaningful
+    // audio content that needs flushing. 
+    inlink = ctx->inputs[0];
+    // Pushes silence frame to flush valid audio in the s->buffer
+    silence_frame = ff_get_audio_buffer(inlink, s->total_samples_to_flush);
+    ret = filter_frame(inlink, silence_frame);
+    if (ret < 0) {
+      return ret;
+    }
+    return AVERROR_EOF;
 }
 
 static int config_input(AVFilterLink *inlink)
@@ -292,7 +363,8 @@  static int config_input(AVFilterLink *inlink)
         return AVERROR(ENOMEM);
 
     memset(s->nextpos, -1, obuffer_size * sizeof(*s->nextpos));
-    s->buffer_size = inlink->sample_rate * s->attack * inlink->ch_layout.nb_channels;
+    s->total_samples_to_flush = inlink->sample_rate * s->attack;
+    s->buffer_size = s->total_samples_to_flush * inlink->ch_layout.nb_channels;
     s->buffer_size -= s->buffer_size % inlink->ch_layout.nb_channels;
 
     if (s->buffer_size <= 0) {
@@ -325,6 +397,7 @@  static const AVFilterPad alimiter_outputs[] = {
     {
         .name = "default",
         .type = AVMEDIA_TYPE_AUDIO,
+        .request_frame = request_frame,
     },
 };
 
diff --git a/tests/ref/fate/filter-alimiter b/tests/ref/fate/filter-alimiter
index 56cfb614da..93daba92c6 100644
--- a/tests/ref/fate/filter-alimiter
+++ b/tests/ref/fate/filter-alimiter
@@ -3,262 +3,262 @@ 
 #codec_id 0: pcm_s16le
 #sample_rate 0: 44100
 #channel_layout_name 0: stereo
-0,          0,          0,     1024,     4096, 0xd4194af4
-0,       1024,       1024,     1024,     4096, 0x686af4ab
-0,       2048,       2048,     1024,     4096, 0xe80cee61
-0,       3072,       3072,     1024,     4096, 0xa686fbad
-0,       4096,       4096,     1024,     4096, 0x191e062c
-0,       5120,       5120,     1024,     4096, 0x1a13edb1
-0,       6144,       6144,     1024,     4096, 0xab21f8ef
-0,       7168,       7168,     1024,     4096, 0xaa30e757
-0,       8192,       8192,     1024,     4096, 0x5afdf69f
-0,       9216,       9216,     1024,     4096, 0x765e05ec
-0,      10240,      10240,     1024,     4096, 0x6484f551
-0,      11264,      11264,     1024,     4096, 0x61b9e9f7
-0,      12288,      12288,     1024,     4096, 0xa735feb3
-0,      13312,      13312,     1024,     4096, 0xb47203aa
-0,      14336,      14336,     1024,     4096, 0xb6b5fbf5
-0,      15360,      15360,     1024,     4096, 0xbc66f14f
-0,      16384,      16384,     1024,     4096, 0x2003ff5b
-0,      17408,      17408,     1024,     4096, 0x1160f17d
-0,      18432,      18432,     1024,     4096, 0x308001a4
-0,      19456,      19456,     1024,     4096, 0x9df9f429
-0,      20480,      20480,     1024,     4096, 0x3e6eec0f
-0,      21504,      21504,     1024,     4096, 0xca3301f2
-0,      22528,      22528,     1024,     4096, 0x9eb1f961
-0,      23552,      23552,     1024,     4096, 0xd0a50c8c
-0,      24576,      24576,     1024,     4096, 0x071ee96b
-0,      25600,      25600,     1024,     4096, 0x7a46f05b
-0,      26624,      26624,     1024,     4096, 0x2cb2f475
-0,      27648,      27648,     1024,     4096, 0x5bda0a52
-0,      28672,      28672,     1024,     4096, 0x33c0f727
-0,      29696,      29696,     1024,     4096, 0x53cfee59
-0,      30720,      30720,     1024,     4096, 0x1588f221
-0,      31744,      31744,     1024,     4096, 0x95d400d6
-0,      32768,      32768,     1024,     4096, 0x0078009a
-0,      33792,      33792,     1024,     4096, 0x686af4ab
-0,      34816,      34816,     1024,     4096, 0xe80cee61
-0,      35840,      35840,     1024,     4096, 0xa686fbad
-0,      36864,      36864,     1024,     4096, 0x191e062c
-0,      37888,      37888,     1024,     4096, 0x1a13edb1
-0,      38912,      38912,     1024,     4096, 0xab21f8ef
-0,      39936,      39936,     1024,     4096, 0xaa30e757
-0,      40960,      40960,     1024,     4096, 0x5afdf69f
-0,      41984,      41984,     1024,     4096, 0x765e05ec
-0,      43008,      43008,     1024,     4096, 0x6484f551
-0,      44032,      44032,     1024,     4096, 0x755e0600
-0,      45056,      45056,     1024,     4096, 0x5056ecb9
-0,      46080,      46080,     1024,     4096, 0xdcb609a8
-0,      47104,      47104,     1024,     4096, 0xc87bf4a1
-0,      48128,      48128,     1024,     4096, 0xecdfef95
-0,      49152,      49152,     1024,     4096, 0x905ff13f
-0,      50176,      50176,     1024,     4096, 0x4e69eeb3
-0,      51200,      51200,     1024,     4096, 0x16e1082c
-0,      52224,      52224,     1024,     4096, 0x606c0a22
-0,      53248,      53248,     1024,     4096, 0x9f94f351
-0,      54272,      54272,     1024,     4096, 0x2c47f63f
-0,      55296,      55296,     1024,     4096, 0x9e14ebf9
-0,      56320,      56320,     1024,     4096, 0x7804fbcb
-0,      57344,      57344,     1024,     4096, 0xc7c6ffb7
-0,      58368,      58368,     1024,     4096, 0xa547f68d
-0,      59392,      59392,     1024,     4096, 0x0c87fed7
-0,      60416,      60416,     1024,     4096, 0x88b5fef1
-0,      61440,      61440,     1024,     4096, 0x325af00d
-0,      62464,      62464,     1024,     4096, 0xd826edd9
-0,      63488,      63488,     1024,     4096, 0x1fbe1138
-0,      64512,      64512,     1024,     4096, 0xdf85da7b
-0,      65536,      65536,     1024,     4096, 0xf987f9b3
-0,      66560,      66560,     1024,     4096, 0x5df5e12f
-0,      67584,      67584,     1024,     4096, 0x259cf8ef
-0,      68608,      68608,     1024,     4096, 0xa191eb4f
-0,      69632,      69632,     1024,     4096, 0xfe5bf1fd
-0,      70656,      70656,     1024,     4096, 0x7675e2cb
-0,      71680,      71680,     1024,     4096, 0x796a2f90
-0,      72704,      72704,     1024,     4096, 0xaa52e7a5
-0,      73728,      73728,     1024,     4096, 0x2b56fd81
-0,      74752,      74752,     1024,     4096, 0xbf7c02ee
-0,      75776,      75776,     1024,     4096, 0xfe4cebb1
-0,      76800,      76800,     1024,     4096, 0xe5b7fdf7
-0,      77824,      77824,     1024,     4096, 0xd271ece7
-0,      78848,      78848,     1024,     4096, 0x96e0f69f
-0,      79872,      79872,     1024,     4096, 0x6e5eef33
-0,      80896,      80896,     1024,     4096, 0x78b70b6e
-0,      81920,      81920,     1024,     4096, 0x61f2f075
-0,      82944,      82944,     1024,     4096, 0xf1dc47dc
-0,      83968,      83968,     1024,     4096, 0xf4b406d2
-0,      84992,      84992,     1024,     4096, 0xe33806fe
-0,      86016,      86016,     1024,     4096, 0x5b5ef087
-0,      87040,      87040,     1024,     4096, 0x3fa207da
-0,      88064,      88064,     1024,     4096, 0x4719f201
-0,      89088,      89088,     1024,     4096, 0x641feaad
-0,      90112,      90112,     1024,     4096, 0x905402ec
-0,      91136,      91136,     1024,     4096, 0xf529e11f
-0,      92160,      92160,     1024,     4096, 0x65a41838
-0,      93184,      93184,     1024,     4096, 0x651efb6f
-0,      94208,      94208,     1024,     4096, 0x251b1390
-0,      95232,      95232,     1024,     4096, 0x45ea05a8
-0,      96256,      96256,     1024,     4096, 0xe65be141
-0,      97280,      97280,     1024,     4096, 0xd452d3dd
-0,      98304,      98304,     1024,     4096, 0x3bdff821
-0,      99328,      99328,     1024,     4096, 0x74da00e6
-0,     100352,     100352,     1024,     4096, 0x4474fa19
-0,     101376,     101376,     1024,     4096, 0x11ddedef
-0,     102400,     102400,     1024,     4096, 0xf027d72b
-0,     103424,     103424,     1024,     4096, 0xaa0a1ce6
-0,     104448,     104448,     1024,     4096, 0x7168145e
-0,     105472,     105472,     1024,     4096, 0x94a710a4
-0,     106496,     106496,     1024,     4096, 0x6f55ecf1
-0,     107520,     107520,     1024,     4096, 0xc12de6d7
-0,     108544,     108544,     1024,     4096, 0x8ff7db15
-0,     109568,     109568,     1024,     4096, 0x366d0cc6
-0,     110592,     110592,     1024,     4096, 0xb04afa4f
-0,     111616,     111616,     1024,     4096, 0xf6abbee7
-0,     112640,     112640,     1024,     4096, 0xbe9910dc
-0,     113664,     113664,     1024,     4096, 0x96c3047e
-0,     114688,     114688,     1024,     4096, 0x9dc1e8e1
-0,     115712,     115712,     1024,     4096, 0x4b2c1092
-0,     116736,     116736,     1024,     4096, 0x592d212c
-0,     117760,     117760,     1024,     4096, 0x5c3bda15
-0,     118784,     118784,     1024,     4096, 0x43c8e90f
-0,     119808,     119808,     1024,     4096, 0x3bfa074e
-0,     120832,     120832,     1024,     4096, 0xa2d7d443
-0,     121856,     121856,     1024,     4096, 0xd4b02844
-0,     122880,     122880,     1024,     4096, 0x9f5d2a92
-0,     123904,     123904,     1024,     4096, 0xc19bf69d
-0,     124928,     124928,     1024,     4096, 0x47b8fe75
-0,     125952,     125952,     1024,     4096, 0x337334b0
-0,     126976,     126976,     1024,     4096, 0x96ed14f0
-0,     128000,     128000,     1024,     4096, 0x9af0f67b
-0,     129024,     129024,     1024,     4096, 0xdf541a60
-0,     130048,     130048,     1024,     4096, 0x684f0c06
-0,     131072,     131072,     1024,     4096, 0xe3d0015e
-0,     132096,     132096,     1024,     4096, 0xf648d73c
-0,     133120,     133120,     1024,     4096, 0x4041f3ee
-0,     134144,     134144,     1024,     4096, 0x1421025f
-0,     135168,     135168,     1024,     4096, 0x4eb5fc97
-0,     136192,     136192,     1024,     4096, 0x510f02fe
-0,     137216,     137216,     1024,     4096, 0x85e9e95e
-0,     138240,     138240,     1024,     4096, 0xb1d0fe10
-0,     139264,     139264,     1024,     4096, 0xda66f5f8
-0,     140288,     140288,     1024,     4096, 0x3826eaa8
-0,     141312,     141312,     1024,     4096, 0xa7cc0176
-0,     142336,     142336,     1024,     4096, 0x71e8fe5a
-0,     143360,     143360,     1024,     4096, 0x0149fcfa
-0,     144384,     144384,     1024,     4096, 0xbd36fd8e
-0,     145408,     145408,     1024,     4096, 0xec1afcc6
-0,     146432,     146432,     1024,     4096, 0xea80ec5e
-0,     147456,     147456,     1024,     4096, 0x8da1f0ac
-0,     148480,     148480,     1024,     4096, 0x63c3e61c
-0,     149504,     149504,     1024,     4096, 0x188cf09b
-0,     150528,     150528,     1024,     4096, 0x7eebea85
-0,     151552,     151552,     1024,     4096, 0x7ef6f718
-0,     152576,     152576,     1024,     4096, 0xcd9fecfb
-0,     153600,     153600,     1024,     4096, 0x1aa7f624
-0,     154624,     154624,     1024,     4096, 0xcab5f1e3
-0,     155648,     155648,     1024,     4096, 0x36e9f795
-0,     156672,     156672,     1024,     4096, 0x952cf54d
-0,     157696,     157696,     1024,     4096, 0x54a4ed3b
-0,     158720,     158720,     1024,     4096, 0x1e24f992
-0,     159744,     159744,     1024,     4096, 0xab6bfa09
-0,     160768,     160768,     1024,     4096, 0xa021020b
-0,     161792,     161792,     1024,     4096, 0xaa0600f5
-0,     162816,     162816,     1024,     4096, 0xadf7ec92
-0,     163840,     163840,     1024,     4096, 0x5dd5f63f
-0,     164864,     164864,     1024,     4096, 0xc01bff89
-0,     165888,     165888,     1024,     4096, 0x05dbf1e7
-0,     166912,     166912,     1024,     4096, 0x44f00038
-0,     167936,     167936,     1024,     4096, 0x6dc5f886
-0,     168960,     168960,     1024,     4096, 0xeb88e729
-0,     169984,     169984,     1024,     4096, 0xfe5cf53e
-0,     171008,     171008,     1024,     4096, 0x2692f7a0
-0,     172032,     172032,     1024,     4096, 0xe984f24b
-0,     173056,     173056,     1024,     4096, 0x1a4ef732
-0,     174080,     174080,     1024,     4096, 0x3b60010b
-0,     175104,     175104,     1024,     4096, 0x6dd0eaf2
-0,     176128,     176128,     1024,     4096, 0x313de851
-0,     177152,     177152,     1024,     4096, 0x239ef043
-0,     178176,     178176,     1024,     4096, 0x2366fe43
-0,     179200,     179200,     1024,     4096, 0xbfd6f3b9
-0,     180224,     180224,     1024,     4096, 0xb34bf67b
-0,     181248,     181248,     1024,     4096, 0x00def7c1
-0,     182272,     182272,     1024,     4096, 0xa6d0f466
-0,     183296,     183296,     1024,     4096, 0xd1a1f1c2
-0,     184320,     184320,     1024,     4096, 0x32f8923c
-0,     185344,     185344,     1024,     4096, 0x137001d2
-0,     186368,     186368,     1024,     4096, 0xb881f6cd
-0,     187392,     187392,     1024,     4096, 0xf44e034a
-0,     188416,     188416,     1024,     4096, 0xb43fecf7
-0,     189440,     189440,     1024,     4096, 0xe62ced50
-0,     190464,     190464,     1024,     4096, 0x221dfd0d
-0,     191488,     191488,     1024,     4096, 0x85400147
-0,     192512,     192512,     1024,     4096, 0x8bf8d054
-0,     193536,     193536,     1024,     4096, 0x08370170
-0,     194560,     194560,     1024,     4096, 0xec62effa
-0,     195584,     195584,     1024,     4096, 0xd58cf67c
-0,     196608,     196608,     1024,     4096, 0xf597f9a1
-0,     197632,     197632,     1024,     4096, 0x63fcf0b0
-0,     198656,     198656,     1024,     4096, 0x8cc8fd32
-0,     199680,     199680,     1024,     4096, 0xf8c2072c
-0,     200704,     200704,     1024,     4096, 0x0c7e93a5
-0,     201728,     201728,     1024,     4096, 0x1cc3f612
-0,     202752,     202752,     1024,     4096, 0x83adf8ee
-0,     203776,     203776,     1024,     4096, 0x680e0195
-0,     204800,     204800,     1024,     4096, 0x9d34fd2e
-0,     205824,     205824,     1024,     4096, 0x44cdfb34
-0,     206848,     206848,     1024,     4096, 0x193df790
-0,     207872,     207872,     1024,     4096, 0xb337ef64
-0,     208896,     208896,     1024,     4096, 0x0074ee38
-0,     209920,     209920,     1024,     4096, 0x239ef043
-0,     210944,     210944,     1024,     4096, 0x2366fe43
-0,     211968,     211968,     1024,     4096, 0xbfd6f3b9
-0,     212992,     212992,     1024,     4096, 0xb34bf67b
-0,     214016,     214016,     1024,     4096, 0x00def7c1
-0,     215040,     215040,     1024,     4096, 0xa6d0f466
-0,     216064,     216064,     1024,     4096, 0xd1a1f1c2
-0,     217088,     217088,     1024,     4096, 0x32f8923c
-0,     218112,     218112,     1024,     4096, 0x137001d2
-0,     219136,     219136,     1024,     4096, 0xb881f6cd
-0,     220160,     220160,     1024,     4096, 0xf44e034a
-0,     221184,     221184,     1024,     4096, 0xb43fecf7
-0,     222208,     222208,     1024,     4096, 0xe62ced50
-0,     223232,     223232,     1024,     4096, 0x221dfd0d
-0,     224256,     224256,     1024,     4096, 0x85400147
-0,     225280,     225280,     1024,     4096, 0x8bf8d054
-0,     226304,     226304,     1024,     4096, 0x08370170
-0,     227328,     227328,     1024,     4096, 0xec62effa
-0,     228352,     228352,     1024,     4096, 0xd58cf67c
-0,     229376,     229376,     1024,     4096, 0xf597f9a1
-0,     230400,     230400,     1024,     4096, 0x63fcf0b0
-0,     231424,     231424,     1024,     4096, 0x8cc8fd32
-0,     232448,     232448,     1024,     4096, 0xf8c2072c
-0,     233472,     233472,     1024,     4096, 0x0c7e93a5
-0,     234496,     234496,     1024,     4096, 0x1cc3f612
-0,     235520,     235520,     1024,     4096, 0x83adf8ee
-0,     236544,     236544,     1024,     4096, 0x680e0195
-0,     237568,     237568,     1024,     4096, 0x9d34fd2e
-0,     238592,     238592,     1024,     4096, 0x44cdfb34
-0,     239616,     239616,     1024,     4096, 0x193df790
-0,     240640,     240640,     1024,     4096, 0xb337ef64
-0,     241664,     241664,     1024,     4096, 0x0074ee38
-0,     242688,     242688,     1024,     4096, 0x239ef043
-0,     243712,     243712,     1024,     4096, 0x2366fe43
-0,     244736,     244736,     1024,     4096, 0xbfd6f3b9
-0,     245760,     245760,     1024,     4096, 0xb34bf67b
-0,     246784,     246784,     1024,     4096, 0x00def7c1
-0,     247808,     247808,     1024,     4096, 0xa6d0f466
-0,     248832,     248832,     1024,     4096, 0xd1a1f1c2
-0,     249856,     249856,     1024,     4096, 0x32f8923c
-0,     250880,     250880,     1024,     4096, 0x137001d2
-0,     251904,     251904,     1024,     4096, 0xb881f6cd
-0,     252928,     252928,     1024,     4096, 0xf44e034a
-0,     253952,     253952,     1024,     4096, 0xb43fecf7
-0,     254976,     254976,     1024,     4096, 0xe62ced50
-0,     256000,     256000,     1024,     4096, 0x221dfd0d
-0,     257024,     257024,     1024,     4096, 0x85400147
-0,     258048,     258048,     1024,     4096, 0x8bf8d054
-0,     259072,     259072,     1024,     4096, 0x08370170
-0,     260096,     260096,     1024,     4096, 0xec62effa
-0,     261120,     261120,     1024,     4096, 0xd58cf67c
-0,     262144,     262144,     1024,     4096, 0xf597f9a1
-0,     263168,     263168,     1024,     4096, 0x63fcf0b0
-0,     264192,     264192,      408,     1632, 0xedfa314a
+0,          0,          0,     1024,     4096, 0xd0b20048
+0,       1024,       1024,     1024,     4096, 0x8abaf0ab
+0,       2048,       2048,     1024,     4096, 0x5a00f489
+0,       3072,       3072,     1024,     4096, 0x6d87f3d3
+0,       4096,       4096,     1024,     4096, 0x27fc04bc
+0,       5120,       5120,     1024,     4096, 0x6d18f2e1
+0,       6144,       6144,     1024,     4096, 0x6a11f0c9
+0,       7168,       7168,     1024,     4096, 0xadf8ec27
+0,       8192,       8192,     1024,     4096, 0xf0e2fcf9
+0,       9216,       9216,     1024,     4096, 0x55280372
+0,      10240,      10240,     1024,     4096, 0x898ffad3
+0,      11264,      11264,     1024,     4096, 0x06a5eb6b
+0,      12288,      12288,     1024,     4096, 0x9fadfe07
+0,      13312,      13312,     1024,     4096, 0x6f32fd99
+0,      14336,      14336,     1024,     4096, 0x7856f871
+0,      15360,      15360,     1024,     4096, 0xf742f893
+0,      16384,      16384,     1024,     4096, 0x7955f7e7
+0,      17408,      17408,     1024,     4096, 0xbb32f521
+0,      18432,      18432,     1024,     4096, 0x8302fda9
+0,      19456,      19456,     1024,     4096, 0x0d3cfdeb
+0,      20480,      20480,     1024,     4096, 0xd034ed5f
+0,      21504,      21504,     1024,     4096, 0xd3c1fb11
+0,      22528,      22528,     1024,     4096, 0x80bc0734
+0,      23552,      23552,     1024,     4096, 0x82a60000
+0,      24576,      24576,     1024,     4096, 0xaf6ceb09
+0,      25600,      25600,     1024,     4096, 0x0c0dec9f
+0,      26624,      26624,     1024,     4096, 0x8ca8f335
+0,      27648,      27648,     1024,     4096, 0xc75604bc
+0,      28672,      28672,     1024,     4096, 0x0a22f7b9
+0,      29696,      29696,     1024,     4096, 0x237cf4a5
+0,      30720,      30720,     1024,     4096, 0x5276f36f
+0,      31744,      31744,     1024,     4096, 0x148a0194
+0,      32768,      32768,     1024,     4096, 0xd0b20048
+0,      33792,      33792,     1024,     4096, 0x8abaf0ab
+0,      34816,      34816,     1024,     4096, 0x5a00f489
+0,      35840,      35840,     1024,     4096, 0x6d87f3d3
+0,      36864,      36864,     1024,     4096, 0x27fc04bc
+0,      37888,      37888,     1024,     4096, 0x6d18f2e1
+0,      38912,      38912,     1024,     4096, 0x6a11f0c9
+0,      39936,      39936,     1024,     4096, 0xadf8ec27
+0,      40960,      40960,     1024,     4096, 0xf0e2fcf9
+0,      41984,      41984,     1024,     4096, 0x55280372
+0,      43008,      43008,     1024,     4096, 0x8ac5fad5
+0,      44032,      44032,     1024,     4096, 0x934007ba
+0,      45056,      45056,     1024,     4096, 0x84acf4a3
+0,      46080,      46080,     1024,     4096, 0x7c8ff49b
+0,      47104,      47104,     1024,     4096, 0x79030244
+0,      48128,      48128,     1024,     4096, 0x28d0e5f5
+0,      49152,      49152,     1024,     4096, 0xf12df059
+0,      50176,      50176,     1024,     4096, 0xd0eef7a7
+0,      51200,      51200,     1024,     4096, 0x2e2e02e4
+0,      52224,      52224,     1024,     4096, 0x7c421656
+0,      53248,      53248,     1024,     4096, 0x79fcea35
+0,      54272,      54272,     1024,     4096, 0xb566e88b
+0,      55296,      55296,     1024,     4096, 0xad66f8e9
+0,      56320,      56320,     1024,     4096, 0xe0d001dc
+0,      57344,      57344,     1024,     4096, 0xfc5df6cd
+0,      58368,      58368,     1024,     4096, 0x9dcefad5
+0,      59392,      59392,     1024,     4096, 0xbde90702
+0,      60416,      60416,     1024,     4096, 0x4feef329
+0,      61440,      61440,     1024,     4096, 0xbb30ef39
+0,      62464,      62464,     1024,     4096, 0x131ff1e3
+0,      63488,      63488,     1024,     4096, 0x994c0184
+0,      64512,      64512,     1024,     4096, 0xc981e10b
+0,      65536,      65536,     1024,     4096, 0xceff022a
+0,      66560,      66560,     1024,     4096, 0x07d1e1d3
+0,      67584,      67584,     1024,     4096, 0x7ea5f31d
+0,      68608,      68608,     1024,     4096, 0x16e1e885
+0,      69632,      69632,     1024,     4096, 0x2a92fb45
+0,      70656,      70656,     1024,     4096, 0x9f90ef6b
+0,      71680,      71680,     1024,     4096, 0xed961010
+0,      72704,      72704,     1024,     4096, 0x6169f659
+0,      73728,      73728,     1024,     4096, 0xbe830c50
+0,      74752,      74752,     1024,     4096, 0x1744ea89
+0,      75776,      75776,     1024,     4096, 0x00bcf34f
+0,      76800,      76800,     1024,     4096, 0x91f7f7f3
+0,      77824,      77824,     1024,     4096, 0xa4e1f1fb
+0,      78848,      78848,     1024,     4096, 0xf3e5f73b
+0,      79872,      79872,     1024,     4096, 0x64d0eb95
+0,      80896,      80896,     1024,     4096, 0xe0c90d40
+0,      81920,      81920,     1024,     4096, 0xe9701e32
+0,      82944,      82944,     1024,     4096, 0x760d26b0
+0,      83968,      83968,     1024,     4096, 0x3f4303e4
+0,      84992,      84992,     1024,     4096, 0x1cc502bc
+0,      86016,      86016,     1024,     4096, 0x6d7bf089
+0,      87040,      87040,     1024,     4096, 0xe03807fc
+0,      88064,      88064,     1024,     4096, 0xf12fe897
+0,      89088,      89088,     1024,     4096, 0x0123e87d
+0,      90112,      90112,     1024,     4096, 0x869808d4
+0,      91136,      91136,     1024,     4096, 0x9538def3
+0,      92160,      92160,     1024,     4096, 0x92ed2ab0
+0,      93184,      93184,     1024,     4096, 0xc80bfe9d
+0,      94208,      94208,     1024,     4096, 0x56130220
+0,      95232,      95232,     1024,     4096, 0xd3a7f0f3
+0,      96256,      96256,     1024,     4096, 0xfca0eeaf
+0,      97280,      97280,     1024,     4096, 0xd409d82b
+0,      98304,      98304,     1024,     4096, 0x29ba0424
+0,      99328,      99328,     1024,     4096, 0x4e9cdf19
+0,     100352,     100352,     1024,     4096, 0xb0511cc0
+0,     101376,     101376,     1024,     4096, 0xd499e541
+0,     102400,     102400,     1024,     4096, 0x0910f25f
+0,     103424,     103424,     1024,     4096, 0x6e5d1c08
+0,     104448,     104448,     1024,     4096, 0xa07511a8
+0,     105472,     105472,     1024,     4096, 0xddd1ee73
+0,     106496,     106496,     1024,     4096, 0x5b46fb17
+0,     107520,     107520,     1024,     4096, 0xc558e301
+0,     108544,     108544,     1024,     4096, 0x9041e627
+0,     109568,     109568,     1024,     4096, 0xeadae195
+0,     110592,     110592,     1024,     4096, 0x663d0c5a
+0,     111616,     111616,     1024,     4096, 0x1c57d55b
+0,     112640,     112640,     1024,     4096, 0x7ce90702
+0,     113664,     113664,     1024,     4096, 0xf56c15d0
+0,     114688,     114688,     1024,     4096, 0xa2edd14d
+0,     115712,     115712,     1024,     4096, 0x93f1171c
+0,     116736,     116736,     1024,     4096, 0xe02e152a
+0,     117760,     117760,     1024,     4096, 0x55aaeba7
+0,     118784,     118784,     1024,     4096, 0xacabd7a7
+0,     119808,     119808,     1024,     4096, 0xaa18150a
+0,     120832,     120832,     1024,     4096, 0x065ed6a1
+0,     121856,     121856,     1024,     4096, 0x9df9268e
+0,     122880,     122880,     1024,     4096, 0x8e0a23e6
+0,     123904,     123904,     1024,     4096, 0x872d019e
+0,     124928,     124928,     1024,     4096, 0x3aff116c
+0,     125952,     125952,     1024,     4096, 0x4a1717f8
+0,     126976,     126976,     1024,     4096, 0xa3812998
+0,     128000,     128000,     1024,     4096, 0x8f12ee4f
+0,     129024,     129024,     1024,     4096, 0x1add13c4
+0,     130048,     130048,     1024,     4096, 0x4f3825da
+0,     131072,     131072,     1024,     4096, 0xf732d42b
+0,     132096,     132096,     1024,     4096, 0xa2b3e578
+0,     133120,     133120,     1024,     4096, 0xdc18ff83
+0,     134144,     134144,     1024,     4096, 0xd13df8c5
+0,     135168,     135168,     1024,     4096, 0x24c506ff
+0,     136192,     136192,     1024,     4096, 0xb58cf9d4
+0,     137216,     137216,     1024,     4096, 0x734cecba
+0,     138240,     138240,     1024,     4096, 0x9af5fb4e
+0,     139264,     139264,     1024,     4096, 0x8510f05f
+0,     140288,     140288,     1024,     4096, 0x81e0f2c3
+0,     141312,     141312,     1024,     4096, 0x5c060641
+0,     142336,     142336,     1024,     4096, 0xb15bfc84
+0,     143360,     143360,     1024,     4096, 0xe7dafcaa
+0,     144384,     144384,     1024,     4096, 0x5419faaa
+0,     145408,     145408,     1024,     4096, 0x6f97fa6f
+0,     146432,     146432,     1024,     4096, 0x5e69e975
+0,     147456,     147456,     1024,     4096, 0xd614f89e
+0,     148480,     148480,     1024,     4096, 0x2532e193
+0,     149504,     149504,     1024,     4096, 0x0ce9f04c
+0,     150528,     150528,     1024,     4096, 0x0935ec67
+0,     151552,     151552,     1024,     4096, 0x92d6f5d9
+0,     152576,     152576,     1024,     4096, 0xccffea44
+0,     153600,     153600,     1024,     4096, 0x81e3eea0
+0,     154624,     154624,     1024,     4096, 0xc5c2fe66
+0,     155648,     155648,     1024,     4096, 0x75dbf93c
+0,     156672,     156672,     1024,     4096, 0x6294f023
+0,     157696,     157696,     1024,     4096, 0xf39eef54
+0,     158720,     158720,     1024,     4096, 0x03b1fa13
+0,     159744,     159744,     1024,     4096, 0xacc0faf2
+0,     160768,     160768,     1024,     4096, 0xcd9ffc79
+0,     161792,     161792,     1024,     4096, 0x4ffc023f
+0,     162816,     162816,     1024,     4096, 0x3126ed15
+0,     163840,     163840,     1024,     4096, 0x611ff8d6
+0,     164864,     164864,     1024,     4096, 0x6a9bfa1a
+0,     165888,     165888,     1024,     4096, 0xb06cfb10
+0,     166912,     166912,     1024,     4096, 0x1c9f00bb
+0,     167936,     167936,     1024,     4096, 0xc0bbeebf
+0,     168960,     168960,     1024,     4096, 0x383eea91
+0,     169984,     169984,     1024,     4096, 0xf927f893
+0,     171008,     171008,     1024,     4096, 0xbfc3f9b4
+0,     172032,     172032,     1024,     4096, 0x9faaef83
+0,     173056,     173056,     1024,     4096, 0x4dc6f411
+0,     174080,     174080,     1024,     4096, 0x9432ff0f
+0,     175104,     175104,     1024,     4096, 0x62d5e7d6
+0,     176128,     176128,     1024,     4096, 0x1af9ea59
+0,     177152,     177152,     1024,     4096, 0x3dcbf8d0
+0,     178176,     178176,     1024,     4096, 0x80fbf978
+0,     179200,     179200,     1024,     4096, 0xbe60f05b
+0,     180224,     180224,     1024,     4096, 0xf12ffb83
+0,     181248,     181248,     1024,     4096, 0xfed0f81a
+0,     182272,     182272,     1024,     4096, 0x892eede2
+0,     183296,     183296,     1024,     4096, 0x4101f200
+0,     184320,     184320,     1024,     4096, 0x08759c99
+0,     185344,     185344,     1024,     4096, 0xea80fab7
+0,     186368,     186368,     1024,     4096, 0x2b47fcf4
+0,     187392,     187392,     1024,     4096, 0x2933f949
+0,     188416,     188416,     1024,     4096, 0x10c3eaed
+0,     189440,     189440,     1024,     4096, 0x38bb0089
+0,     190464,     190464,     1024,     4096, 0x4fa4f4b6
+0,     191488,     191488,     1024,     4096, 0x47c9fd4c
+0,     192512,     192512,     1024,     4096, 0x6e95d5d1
+0,     193536,     193536,     1024,     4096, 0x6deaf758
+0,     194560,     194560,     1024,     4096, 0x96a2f230
+0,     195584,     195584,     1024,     4096, 0x6515fa5b
+0,     196608,     196608,     1024,     4096, 0xbdf6f5a6
+0,     197632,     197632,     1024,     4096, 0x74d4f365
+0,     198656,     198656,     1024,     4096, 0x932903e3
+0,     199680,     199680,     1024,     4096, 0x7468085e
+0,     200704,     200704,     1024,     4096, 0x0d908b65
+0,     201728,     201728,     1024,     4096, 0x86e7f740
+0,     202752,     202752,     1024,     4096, 0x09fff8d2
+0,     203776,     203776,     1024,     4096, 0xf0430838
+0,     204800,     204800,     1024,     4096, 0x525bf9ec
+0,     205824,     205824,     1024,     4096, 0x17c7ee8d
+0,     206848,     206848,     1024,     4096, 0x7632fc3b
+0,     207872,     207872,     1024,     4096, 0xf12aefe9
+0,     208896,     208896,     1024,     4096, 0x0d72ed83
+0,     209920,     209920,     1024,     4096, 0x3dcbf8d0
+0,     210944,     210944,     1024,     4096, 0x80fbf978
+0,     211968,     211968,     1024,     4096, 0xbe60f05b
+0,     212992,     212992,     1024,     4096, 0xf12ffb83
+0,     214016,     214016,     1024,     4096, 0xfed0f81a
+0,     215040,     215040,     1024,     4096, 0x892eede2
+0,     216064,     216064,     1024,     4096, 0x4101f200
+0,     217088,     217088,     1024,     4096, 0x08759c99
+0,     218112,     218112,     1024,     4096, 0xea80fab7
+0,     219136,     219136,     1024,     4096, 0x2b47fcf4
+0,     220160,     220160,     1024,     4096, 0x2933f949
+0,     221184,     221184,     1024,     4096, 0x10c3eaed
+0,     222208,     222208,     1024,     4096, 0x38bb0089
+0,     223232,     223232,     1024,     4096, 0x4fa4f4b6
+0,     224256,     224256,     1024,     4096, 0x47c9fd4c
+0,     225280,     225280,     1024,     4096, 0x6e95d5d1
+0,     226304,     226304,     1024,     4096, 0x6deaf758
+0,     227328,     227328,     1024,     4096, 0x96a2f230
+0,     228352,     228352,     1024,     4096, 0x6515fa5b
+0,     229376,     229376,     1024,     4096, 0xbdf6f5a6
+0,     230400,     230400,     1024,     4096, 0x74d4f365
+0,     231424,     231424,     1024,     4096, 0x932903e3
+0,     232448,     232448,     1024,     4096, 0x7468085e
+0,     233472,     233472,     1024,     4096, 0x0d908b65
+0,     234496,     234496,     1024,     4096, 0x86e7f740
+0,     235520,     235520,     1024,     4096, 0x09fff8d2
+0,     236544,     236544,     1024,     4096, 0xf0430838
+0,     237568,     237568,     1024,     4096, 0x525bf9ec
+0,     238592,     238592,     1024,     4096, 0x17c7ee8d
+0,     239616,     239616,     1024,     4096, 0x7632fc3b
+0,     240640,     240640,     1024,     4096, 0xf12aefe9
+0,     241664,     241664,     1024,     4096, 0x0d72ed83
+0,     242688,     242688,     1024,     4096, 0x3dcbf8d0
+0,     243712,     243712,     1024,     4096, 0x80fbf978
+0,     244736,     244736,     1024,     4096, 0xbe60f05b
+0,     245760,     245760,     1024,     4096, 0xf12ffb83
+0,     246784,     246784,     1024,     4096, 0xfed0f81a
+0,     247808,     247808,     1024,     4096, 0x892eede2
+0,     248832,     248832,     1024,     4096, 0x4101f200
+0,     249856,     249856,     1024,     4096, 0x08759c99
+0,     250880,     250880,     1024,     4096, 0xea80fab7
+0,     251904,     251904,     1024,     4096, 0x2b47fcf4
+0,     252928,     252928,     1024,     4096, 0x2933f949
+0,     253952,     253952,     1024,     4096, 0x10c3eaed
+0,     254976,     254976,     1024,     4096, 0x38bb0089
+0,     256000,     256000,     1024,     4096, 0x4fa4f4b6
+0,     257024,     257024,     1024,     4096, 0x47c9fd4c
+0,     258048,     258048,     1024,     4096, 0x6e95d5d1
+0,     259072,     259072,     1024,     4096, 0x6deaf758
+0,     260096,     260096,     1024,     4096, 0x96a2f230
+0,     261120,     261120,     1024,     4096, 0x6515fa5b
+0,     262144,     262144,     1024,     4096, 0xbdf6f5a6
+0,     263168,     263168,     1024,     4096, 0x74d4f365
+0,     264192,     264192,      408,     1632, 0x637b3c21