aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/spdifenc.c
diff options
context:
space:
mode:
authorCarl Eugen Hoyos <ceffmpeg@gmail.com>2019-02-14 20:16:18 +0100
committerCarl Eugen Hoyos <ceffmpeg@gmail.com>2019-03-20 17:36:29 +0100
commit5247c4328bb96d1b4e2953eef722833c8dbde358 (patch)
tree0247ff58c31f83caf1307db1a9fd92d4b39e570b /libavformat/spdifenc.c
parent801d78f0d89867b7451798112265f735efa800ef (diff)
downloadffmpeg-5247c4328bb96d1b4e2953eef722833c8dbde358.tar.gz
lavf/spdifenc: Do not overwrite buffer when muxing TrueHD.
Fixes ticket #7733. Tested-by: Moritz Barsnick
Diffstat (limited to 'libavformat/spdifenc.c')
-rw-r--r--libavformat/spdifenc.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/libavformat/spdifenc.c b/libavformat/spdifenc.c
index 9514ff8e10..4307942a44 100644
--- a/libavformat/spdifenc.c
+++ b/libavformat/spdifenc.c
@@ -422,8 +422,13 @@ static int spdif_header_truehd(AVFormatContext *s, AVPacket *pkt)
memcpy(&ctx->hd_buf[ctx->hd_buf_count * TRUEHD_FRAME_OFFSET - BURST_HEADER_SIZE + mat_code_length],
pkt->data, pkt->size);
- memset(&ctx->hd_buf[ctx->hd_buf_count * TRUEHD_FRAME_OFFSET - BURST_HEADER_SIZE + mat_code_length + pkt->size],
- 0, TRUEHD_FRAME_OFFSET - pkt->size - mat_code_length);
+ if (ctx->hd_buf_count < 23) {
+ memset(&ctx->hd_buf[ctx->hd_buf_count * TRUEHD_FRAME_OFFSET - BURST_HEADER_SIZE + mat_code_length + pkt->size],
+ 0, TRUEHD_FRAME_OFFSET - pkt->size - mat_code_length);
+ } else {
+ size_t padding = MAT_FRAME_SIZE - (ctx->hd_buf_count * TRUEHD_FRAME_OFFSET - BURST_HEADER_SIZE + pkt->size);
+ memset(&ctx->hd_buf[MAT_FRAME_SIZE - padding], 0, padding);
+ }
if (++ctx->hd_buf_count < 24){
ctx->pkt_offset = 0;