mirror of
https://github.com/mpv-player/mpv
synced 2025-02-06 15:11:58 +00:00
ad_spdif: better PTS sync
pts_bytes can't just be changed at the end. It must be offset to the pts value, which is reset with each packet read from the demuxer. Make sure the pts_byte field is always reset after receiving a new PTS, i.e. increment it after actually writing to the output buffer. Flush the AVFormatContext's write buffer, because otherwise the audio PTS will jump around too much: the calculation doesn't use the exact output buffer size if there's still data in the avio buffer.
This commit is contained in:
parent
995fe05254
commit
7a4f9cc4d2
@ -220,12 +220,14 @@ static int decode_audio(sh_audio_t *sh, unsigned char *buf,
|
||||
sh->pts = mpkt->pts;
|
||||
sh->pts_bytes = 0;
|
||||
}
|
||||
int out_len = spdif_ctx->out_buffer_len;
|
||||
int ret = lavf_ctx->oformat->write_packet(lavf_ctx, &pkt);
|
||||
avio_flush(lavf_ctx->pb);
|
||||
sh->pts_bytes += spdif_ctx->out_buffer_len - out_len;
|
||||
talloc_free(mpkt);
|
||||
if (ret < 0)
|
||||
break;
|
||||
}
|
||||
sh->pts_bytes += spdif_ctx->out_buffer_len;
|
||||
return spdif_ctx->out_buffer_len;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user