aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2019-07-06 16:18:00 +0200
committerPaul B Mahol <onemda@gmail.com>2019-07-09 13:23:06 +0200
commitcbe23e40ae9120f6d5bc444b9b9970e67cbfdcc0 (patch)
treef7276dd720eda53c9dd1250b97932b1513cc7178
parent99c191151a716d8315e938297bd9b50a6a0902d3 (diff)
downloadffmpeg-cbe23e40ae9120f6d5bc444b9b9970e67cbfdcc0.tar.gz
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@gmail.com>
-rw-r--r--libavcodec/truehd_core_bsf.c7
1 files 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);