diff options
Diffstat (limited to 'libavutil/audio_fifo.c')
-rw-r--r-- | libavutil/audio_fifo.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/libavutil/audio_fifo.c b/libavutil/audio_fifo.c index d5298cce4d..e4d38e0524 100644 --- a/libavutil/audio_fifo.c +++ b/libavutil/audio_fifo.c @@ -155,6 +155,30 @@ int av_audio_fifo_peek(AVAudioFifo *af, void **data, int nb_samples) return nb_samples; } +int av_audio_fifo_peek_at(AVAudioFifo *af, void **data, int nb_samples, int offset) +{ + int i, ret, size; + + if (offset < 0 || offset >= af->nb_samples) + return AVERROR(EINVAL); + if (nb_samples < 0) + return AVERROR(EINVAL); + nb_samples = FFMIN(nb_samples, af->nb_samples); + if (!nb_samples) + return 0; + if (offset > af->nb_samples - nb_samples) + return AVERROR(EINVAL); + + offset *= af->sample_size; + size = nb_samples * af->sample_size; + for (i = 0; i < af->nb_buffers; i++) { + if ((ret = av_fifo_generic_peek_at(af->buf[i], data[i], offset, size, NULL)) < 0) + return AVERROR_BUG; + } + + return nb_samples; +} + int av_audio_fifo_read(AVAudioFifo *af, void **data, int nb_samples) { int i, ret, size; |