summaryrefslogtreecommitdiff
path: root/fftools/ffmpeg.h
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2023-04-24 12:28:13 +0200
committerAnton Khirnov <anton@khirnov.net>2023-05-02 10:59:24 +0200
commitd85c6aba0cf27db2a6c4dfa3452cfb9c248d1b4a (patch)
tree2cc717199739690512fc066f32b6ad74ce71324f /fftools/ffmpeg.h
parent6bbea932ca9a0f124b713bef361a9e4ef19d2583 (diff)
downloadffmpeg-d85c6aba0cf27db2a6c4dfa3452cfb9c248d1b4a.tar.gz
fftools/ffmpeg: rework audio-decode timestamp handling
Stop using InputStream.dts for generating missing timestamps for decoded frames, because it contains pre-decoding timestamps and there may be arbitrary amount of delay between input packets and output frames (e.g. dependent on the thread count when frame threading is used). It is also in AV_TIME_BASE (i.e. microseconds), which may introduce unnecessary rounding issues. New code maintains a timebase that is the inverse of the LCM of all the samplerates seen so far, and thus can accurately represent every audio sample. This timebase is used to generate missing timestamps after decoding. Changes the result of the following FATE tests * pcm_dvd-16-5.1-96000 * lavf-smjpeg * adpcm-ima-smjpeg In all of these the timestamps now better correspond to actual frame durations.
Diffstat (limited to 'fftools/ffmpeg.h')
-rw-r--r--fftools/ffmpeg.h8
1 files changed, 5 insertions, 3 deletions
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index c07a1b86b6..c4abf89b58 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -359,7 +359,6 @@ typedef struct InputStream {
AVRational framerate_guessed;
- int64_t prev_pkt_pts;
int64_t start; /* time when read started */
/* predicted dts of the next packet read for this stream or (when there are
* several frames in a packet) of the next frame in current packet (in AV_TIME_BASE units) */
@@ -371,10 +370,13 @@ typedef struct InputStream {
int64_t next_pts;
int64_t pts; ///< current pts of the decoded frame (in AV_TIME_BASE units)
- // pts/estimated duration of the last decoded video frame
- // in decoder timebase
+ // pts/estimated duration of the last decoded frame
+ // * in decoder timebase for video,
+ // * in last_frame_tb (may change during decoding) for audio
int64_t last_frame_pts;
int64_t last_frame_duration_est;
+ AVRational last_frame_tb;
+ int last_frame_sample_rate;
int wrap_correction_done;