diff options
Diffstat (limited to 'audio/decode/dec_audio.c')
-rw-r--r-- | audio/decode/dec_audio.c | 33 |
1 files changed, 13 insertions, 20 deletions
diff --git a/audio/decode/dec_audio.c b/audio/decode/dec_audio.c index 1351cb8ecd..401e26fb7b 100644 --- a/audio/decode/dec_audio.c +++ b/audio/decode/dec_audio.c @@ -38,8 +38,6 @@ #include "dec_audio.h" #include "ad.h" #include "audio/format.h" -#include "audio/audio.h" -#include "audio/audio_buffer.h" #include "audio/filter/af.h" @@ -179,25 +177,24 @@ static void fix_audio_pts(struct dec_audio *da) if (!da->current_frame) return; - if (da->current_frame->pts != MP_NOPTS_VALUE) { - double newpts = da->current_frame->pts; - + double frame_pts = mp_aframe_get_pts(da->current_frame); + if (frame_pts != MP_NOPTS_VALUE) { if (da->pts != MP_NOPTS_VALUE) - MP_STATS(da, "value %f audio-pts-err", da->pts - newpts); + MP_STATS(da, "value %f audio-pts-err", da->pts - frame_pts); // Keep the interpolated timestamp if it doesn't deviate more // than 1 ms from the real one. (MKV rounded timestamps.) - if (da->pts == MP_NOPTS_VALUE || fabs(da->pts - newpts) > 0.001) - da->pts = newpts; + if (da->pts == MP_NOPTS_VALUE || fabs(da->pts - frame_pts) > 0.001) + da->pts = frame_pts; } if (da->pts == MP_NOPTS_VALUE && da->header->missing_timestamps) da->pts = 0; - da->current_frame->pts = da->pts; + mp_aframe_set_pts(da->current_frame, da->pts); if (da->pts != MP_NOPTS_VALUE) - da->pts += da->current_frame->samples / (double)da->current_frame->rate; + da->pts += mp_aframe_duration(da->current_frame); } void audio_work(struct dec_audio *da) @@ -228,11 +225,6 @@ void audio_work(struct dec_audio *da) bool progress = da->ad_driver->receive_frame(da, &da->current_frame); - if (da->current_frame && !mp_audio_config_valid(da->current_frame)) { - talloc_free(da->current_frame); - da->current_frame = NULL; - } - da->current_state = da->current_frame ? DATA_OK : DATA_AGAIN; if (!progress) da->current_state = DATA_EOF; @@ -242,10 +234,11 @@ void audio_work(struct dec_audio *da) bool segment_end = da->current_state == DATA_EOF; if (da->current_frame) { - mp_audio_clip_timestamps(da->current_frame, da->start, da->end); - if (da->current_frame->pts != MP_NOPTS_VALUE && da->start != MP_NOPTS_VALUE) - segment_end = da->current_frame->pts >= da->end; - if (da->current_frame->samples == 0) { + mp_aframe_clip_timestamps(da->current_frame, da->start, da->end); + double frame_pts = mp_aframe_get_pts(da->current_frame); + if (frame_pts != MP_NOPTS_VALUE && da->start != MP_NOPTS_VALUE) + segment_end = frame_pts >= da->end; + if (mp_aframe_get_size(da->current_frame) == 0) { talloc_free(da->current_frame); da->current_frame = NULL; } @@ -280,7 +273,7 @@ void audio_work(struct dec_audio *da) // DATA_WAIT: waiting for demuxer; will receive a wakeup signal // DATA_EOF: end of file, no more frames to be expected // DATA_AGAIN: dropped frame or something similar -int audio_get_frame(struct dec_audio *da, struct mp_audio **out_frame) +int audio_get_frame(struct dec_audio *da, struct mp_aframe **out_frame) { *out_frame = NULL; if (da->current_frame) { |