From b0fe01d55c18272ca9e879d8a9fa7723d2d7c6a7 Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 27 Aug 2020 11:40:32 +0200 Subject: audio: adjust frame clipping for spdif formats Allow mp_aframe_clip_timestamps() to discard a spdif frame if it's entirely out of the timestamp range. Just a minor thing that might make handling these dumb formats easier. --- audio/aframe.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/audio/aframe.c b/audio/aframe.c index 0bb2f872b4..cc73bbd2a7 100644 --- a/audio/aframe.c +++ b/audio/aframe.c @@ -461,13 +461,13 @@ void mp_aframe_clip_timestamps(struct mp_aframe *f, double start, double end) double rate = mp_aframe_get_effective_rate(f); if (f_end == MP_NOPTS_VALUE) return; - if (af_fmt_is_spdif(mp_aframe_get_format(f))) - return; if (end != MP_NOPTS_VALUE) { if (f_end >= end) { if (f->pts >= end) { f->av_frame->nb_samples = 0; } else { + if (af_fmt_is_spdif(mp_aframe_get_format(f))) + return; int new = (end - f->pts) * rate; f->av_frame->nb_samples = MPCLAMP(new, 0, f->av_frame->nb_samples); } @@ -479,6 +479,8 @@ void mp_aframe_clip_timestamps(struct mp_aframe *f, double start, double end) f->av_frame->nb_samples = 0; f->pts = f_end; } else { + if (af_fmt_is_spdif(mp_aframe_get_format(f))) + return; int skip = (start - f->pts) * rate; skip = MPCLAMP(skip, 0, f->av_frame->nb_samples); mp_aframe_skip_samples(f, skip); -- cgit v1.2.3