diff options
author | Matthieu Bouron <matthieu.bouron@gmail.com> | 2020-10-30 15:38:51 +0100 |
---|---|---|
committer | Marton Balint <cus@passwd.hu> | 2021-01-09 17:08:27 +0100 |
commit | 2e174354805ea220b6a57f6b8755347c7f240077 (patch) | |
tree | ed9c9c400856e95a6eae2202b840256c83b72511 /libswresample/resample_template.c | |
parent | c4407a3e00033c7dd2260a3203fd5a5f104737b9 (diff) | |
download | ffmpeg-2e174354805ea220b6a57f6b8755347c7f240077.tar.gz |
avformat/mov: adjust skip_samples according to seek timestamp
Currently skip_samples is set to start_pad if sample_time is lesser or
equal to 0. This can cause issues if the stream starts with packets that
have negative pts. Calling avformat_seek_file() with ts set to 0 on such
streams makes the mov demuxer return the right corresponding packets
(near the 0 timestamp) but set skip_samples to start_pad which is
incorrect as the audio decoder will discard the returned samples
according to skip_samples from the first packet it receives (which has
its timestamp near 0).
For example, considering the following audio stream with start_pad=1344:
[PKT pts=-1344] [PKT pts=-320] [PKT pts=704] [PKT pts=1728] [...]
Calling avformat_seek_file() with ts=0 makes the next call to
av_read_frame() return the packet with pts=-320 and a skip samples
side data set to 1344 (start_pad). This makes the audio decoder
incorrectly discard (1344 - 320) samples.
This commit makes the move demuxer adjust skip_samples according to the
stream start_pad, seek timestamp and first sample timestamp.
The above example will now result in av_read_frame() still returning the
packet with pts=-320 but with a skip samples side data set to 320
(src_pad - (seek_timestamp - first_timestamp)). This makes the audio
decoder only discard 320 samples (from pts=-320 to pts=0).
Signed-off-by: Marton Balint <cus@passwd.hu>
Diffstat (limited to 'libswresample/resample_template.c')
0 files changed, 0 insertions, 0 deletions