summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2020-08-27 11:40:32 +0200
committerwm4 <wm4@nowhere>2020-08-27 11:55:20 +0200
commitb0fe01d55c18272ca9e879d8a9fa7723d2d7c6a7 (patch)
tree7eb30e11e0e89e89c298659bf61aece838b402f4
parent6b13d71cdc7e59e8522ed911752788938e5f8ce0 (diff)
downloadmpv-b0fe01d55c18272ca9e879d8a9fa7723d2d7c6a7.tar.bz2
mpv-b0fe01d55c18272ca9e879d8a9fa7723d2d7c6a7.tar.xz
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.
-rw-r--r--audio/aframe.c6
1 files 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);