[FFmpeg-cvslog] avformat/dtsdec: make S16LE discrimination sharper
Michael Niedermayer
git at videolan.org
Sat Jan 18 19:59:49 EET 2020
ffmpeg | branch: master | Michael Niedermayer <michael at niedermayer.cc> | Tue Dec 31 14:05:28 2019 +0100| [934cc1faf4b474542a18a4ae28cb5e6e4ce67d88] | committer: Michael Niedermayer
avformat/dtsdec: make S16LE discrimination sharper
Both S16LE as well as DTS can have lots of 0 bytes in silent segments
Using these results in error. Thus this patch skips 0 bytes in
comparission.
Fixes Ticket6561
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=934cc1faf4b474542a18a4ae28cb5e6e4ce67d88
---
libavformat/dtsdec.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/libavformat/dtsdec.c b/libavformat/dtsdec.c
index ab59a56dfc..0215ee18bd 100644
--- a/libavformat/dtsdec.c
+++ b/libavformat/dtsdec.c
@@ -37,6 +37,7 @@ static int dts_probe(const AVProbeData *p)
int exss_markers = 0, exss_nextpos = 0;
int sum, max, pos, ret, i;
int64_t diff = 0;
+ int diffcount = 1;
uint8_t hdr[DCA_CORE_FRAME_HEADER_SIZE + AV_INPUT_BUFFER_PADDING_SIZE] = { 0 };
for (pos = FFMIN(4096, p->buf_size); pos < p->buf_size - 2; pos += 2) {
@@ -47,8 +48,12 @@ static int dts_probe(const AVProbeData *p)
bufp = buf = p->buf + pos;
state = (state << 16) | bytestream_get_be16(&bufp);
- if (pos >= 4)
- diff += FFABS(((int16_t)AV_RL16(buf)) - (int16_t)AV_RL16(buf-4));
+ if (pos >= 4) {
+ if (AV_RL16(buf) || AV_RL16(buf-4)) {
+ diff += FFABS(((int16_t)AV_RL16(buf)) - (int16_t)AV_RL16(buf-4));
+ diffcount ++;
+ }
+ }
/* extension substream (EXSS) */
if (state == DCA_SYNCWORD_SUBSTREAM) {
@@ -121,7 +126,7 @@ static int dts_probe(const AVProbeData *p)
if (markers[max] > 3 && p->buf_size / markers[max] < 32*1024 &&
markers[max] * 4 > sum * 3 &&
- diff / p->buf_size > 200)
+ diff / diffcount > 600)
return AVPROBE_SCORE_EXTENSION + 1;
return 0;
More information about the ffmpeg-cvslog
mailing list