[FFmpeg-cvslog] truehd_core: Correct output size
Andreas Rheinhardt
git at videolan.org
Tue Jul 9 14:59:50 EEST 2019
ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at gmail.com> | Sat Jul 6 16:18:00 2019 +0200| [cbe23e40ae9120f6d5bc444b9b9970e67cbfdcc0] | committer: Paul B Mahol
truehd_core: Correct output size
If truehd_core strips Atmos data away, three parts of the output differ
in size compared to the input access unit: a) The major_sync_info block
if the extra_channel_meaning_data is present, as the newly written
output never contains said block; b) the substream_directory (because
entries relating to discarded substreams are discarded, too); and c)
the actual substream data. b) and c) have already been taken into account
when choosing the size of the output packet, but a) has been forgotten.
This is also the reason behind the end of the output buffer having been
uninitialized until 801d78f0. The workaround added in said commit has
been removed, too.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=cbe23e40ae9120f6d5bc444b9b9970e67cbfdcc0
---
libavcodec/truehd_core_bsf.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/libavcodec/truehd_core_bsf.c b/libavcodec/truehd_core_bsf.c
index 757d26a10d..83f2b16e3d 100644
--- a/libavcodec/truehd_core_bsf.c
+++ b/libavcodec/truehd_core_bsf.c
@@ -46,7 +46,7 @@ static int truehd_core_filter(AVBSFContext *ctx, AVPacket *out)
int in_size, out_size;
int have_header = 0;
int substream_bits = 0;
- int start, end;
+ int end;
uint16_t dts;
ret = ff_bsf_get_packet(ctx, &in);
@@ -81,7 +81,6 @@ static int truehd_core_filter(AVBSFContext *ctx, AVPacket *out)
if (s->hdr.num_substreams > MAX_SUBSTREAMS)
goto fail;
- start = get_bits_count(&gbc);
for (i = 0; i < s->hdr.num_substreams; i++) {
for (int j = 0; j < 4; j++)
units[i].bits[j] = get_bits1(&gbc);
@@ -104,7 +103,7 @@ static int truehd_core_filter(AVBSFContext *ctx, AVPacket *out)
if (size >= 0 && size <= in->size)
out_size = size;
if (out_size < in_size) {
- int bpos = 0, reduce = (end - start - substream_bits) >> 4;
+ int bpos = 0, reduce = (end - have_header * 28 * 8 - substream_bits) >> 4;
uint16_t parity_nibble = 0;
uint16_t auheader;
@@ -117,8 +116,6 @@ static int truehd_core_filter(AVBSFContext *ctx, AVPacket *out)
out->size -= reduce * 2;
parity_nibble ^= out->size / 2;
- if (out_size > 8)
- AV_WN64(out->data + out_size - 8, 0);
if (have_header) {
memcpy(out->data + 4, in->data + 4, 28);
out->data[16 + 4] = (out->data[16 + 4] & 0x0c) | (FFMIN(s->hdr.num_substreams, 3) << 4);
More information about the ffmpeg-cvslog
mailing list