summaryrefslogtreecommitdiffstats
path: root/audio/audio.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-06-27 15:02:41 +0200
committerwm4 <wm4@nowhere>2016-06-27 15:12:21 +0200
commit4ce53025cb475408bfb27a56a57322d9d0c48a4f (patch)
tree69f5b57518c80166334cf98a897e595bce1a6ee8 /audio/audio.c
parent3e58ce96acaec14adb840875c10b2b543be0b1e3 (diff)
downloadmpv-4ce53025cb475408bfb27a56a57322d9d0c48a4f.tar.bz2
mpv-4ce53025cb475408bfb27a56a57322d9d0c48a4f.tar.xz
audio: add a helper for getting frame end PTS
Although I don't see any use for it yet, why not.
Diffstat (limited to 'audio/audio.c')
-rw-r--r--audio/audio.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/audio/audio.c b/audio/audio.c
index ae85a4bf08..306401b5a4 100644
--- a/audio/audio.c
+++ b/audio/audio.c
@@ -257,13 +257,21 @@ void mp_audio_skip_samples(struct mp_audio *data, int samples)
data->pts += samples / (double)data->rate;
}
+// Return the timestamp of the sample just after the end of this frame.
+double mp_audio_end_pts(struct mp_audio *f)
+{
+ if (f->pts == MP_NOPTS_VALUE || f->rate < 1)
+ return MP_NOPTS_VALUE;
+ return f->pts + f->samples / (double)f->rate;
+}
+
// Clip the given frame to the given timestamp range. Adjusts the frame size
// and timestamp.
void mp_audio_clip_timestamps(struct mp_audio *f, double start, double end)
{
- if (f->pts == MP_NOPTS_VALUE || f->rate < 1)
+ double f_end = mp_audio_end_pts(f);
+ if (f_end == MP_NOPTS_VALUE)
return;
- double f_end = f->pts + f->samples / (double)f->rate;
if (end != MP_NOPTS_VALUE) {
if (f_end >= end) {
if (f->pts >= end) {