aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul B Mahol <onemda@gmail.com>2023-01-12 09:56:57 +0100
committerPaul B Mahol <onemda@gmail.com>2023-01-16 09:59:31 +0100
commit2524d0b33b3e23b23d45c45820601644ba51c7bf (patch)
tree00d8a0fa5136f1331bb6de73b461ee7b58ea4d96
parentac7d21284bd3c2b7f7c6d15db450e4c58e93fef8 (diff)
downloadffmpeg-2524d0b33b3e23b23d45c45820601644ba51c7bf.tar.gz
avformat/dtshddec: also read trailing padding in samples
-rw-r--r--libavformat/dtshddec.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/libavformat/dtshddec.c b/libavformat/dtshddec.c
index edd02b4561..a3dea0668f 100644
--- a/libavformat/dtshddec.c
+++ b/libavformat/dtshddec.c
@@ -55,7 +55,7 @@ static int dtshd_read_header(AVFormatContext *s)
DTSHDDemuxContext *dtshd = s->priv_data;
AVIOContext *pb = s->pb;
uint64_t chunk_type, chunk_size;
- int64_t duration, data_start;
+ int64_t duration, orig_nb_samples, data_start;
AVStream *st;
int ret;
char *value;
@@ -103,9 +103,12 @@ static int dtshd_read_header(AVFormatContext *s)
duration = avio_rb32(pb); // num_frames
duration *= avio_rb16(pb); // samples_per_frames
st->duration = duration;
- avio_skip(pb, 5);
+ orig_nb_samples = avio_rb32(pb);
+ orig_nb_samples <<= 8;
+ orig_nb_samples |= avio_r8(pb);
st->codecpar->ch_layout.nb_channels = ff_dca_count_chs_for_mask(avio_rb16(pb));
st->codecpar->initial_padding = avio_rb16(pb);
+ st->codecpar->trailing_padding = FFMAX(st->duration - orig_nb_samples - st->codecpar->initial_padding, 0);
avio_skip(pb, chunk_size - 21);
break;
case FILEINFO: