Opened 9 years ago
Closed 9 years ago
#5785 closed defect (invalid)
swr_drop_output misbehaviour
Reported by: | Elon Musk | Owned by: | |
---|---|---|---|
Priority: | normal | Component: | swresample |
Version: | git-master | Keywords: | |
Cc: | Blocked By: | ||
Blocking: | Reproduced by developer: | no | |
Analyzed by developer: | no |
Description
Summary of the bug:
How to reproduce:
Try attached example code
Expected result: properly looped audio.
Actual result: Discarded samples.
Attachments (1)
Change History (7)
by , 9 years ago
Attachment: | resampling_audio.c added |
---|
comment:1 by , 9 years ago
comment:2 by , 9 years ago
You misunderstood the issue. Problem is swr dropping 1000 samples, and reporting it dropped 0 samples. While it should not drop any sample.
When feeding it another round of samples it take into account previous value.
comment:3 by , 9 years ago
swr_drop_output() drops exactly the number requested, thats how its documented as well. "Drops the specified number of output samples."
The return code is documented as ">= 0 on success, or a negative AVERROR code on failure" it has no relation to how many samples will be dropped, i would expect the number of actually dropped samples to be exactly what was requested.
Can you explain what you are trying to do ? / what usecase this is about ?
comment:4 by , 9 years ago
Usecase is seamless looping, without need to reinitializing swr.
See https://github.com/mpv-player/mpv/commit/814dacdd7d010407a4bea74b3a047079f49c5c39.
comment:5 by , 9 years ago
If you want to bring the state back to the initial state calling
swr_close() and swr_init() should do that efficiently, this will not reinitialize the resampler
you can drop output samples too but this will not return to exactly the initial state in general.
swr_drop_output(swr_ctx,swr_get_out_samples(swr_ctx, 0));
would drop all the old data, but when new data comes in the buffers will get filled before output comes out, so this will result in an apparent loss of a few audio samples
you can also resample into a dummy buffer and throw that away which will look correct but is possibly not what you actually want because old data remains in the buffer and will be output
If theres some variant missing or can be improved, please say so
comment:6 by , 9 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
The example seems buggy, it doesnt produce a sinewave that repeats every 1000 samples so droping 1000 will not produce a smooth output. If that is corrected with the patch below the output seems fine.
Or maybe iam missunderstanding the issue ?