From d1e8caaa4bb2c1adf69f8f5e83569aa10bfddbd9 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Sun, 16 Oct 2011 22:44:47 +0200 Subject: [PATCH] WAV reader: Make DTS detection more resilient --- ChangeLog | 3 +++ src/input/r_wav.cpp | 10 +++++++--- tests/results.txt | 1 + tests/test-319wav_with_pcm_detected_as_dts.rb | 13 +++++++++++++ 4 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 tests/test-319wav_with_pcm_detected_as_dts.rb diff --git a/ChangeLog b/ChangeLog index 3ead38a59..9d18bca1c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2011-10-16 Moritz Bunkus + * mkvmerge: bug fix: Fixed PCM audio in WAV sometimes being + detected as DTS. + * mkvmerge: enhancement: The verbose identification mode will add the properties "default_duration", "audio_sampling_frequency" and "audio_channels" if appropriate and if the corresponding header diff --git a/src/input/r_wav.cpp b/src/input/r_wav.cpp index 05a48ed9b..b553dd3c2 100644 --- a/src/input/r_wav.cpp +++ b/src/input/r_wav.cpp @@ -107,7 +107,7 @@ protected: virtual int decode_buffer(int len); }; -#define DTS_READ_SIZE 16384 +#define DTS_READ_SIZE 65536 class wav_dts_demuxer_c: public wav_demuxer_c { private: @@ -318,8 +318,12 @@ wav_dts_demuxer_c::probe(mm_io_cptr &io) { io->restore_pos(); if (detect_dts(m_buf[m_cur_buf]->get_buffer(), len, m_pack_14_16, m_swap_bytes)) { - len = decode_buffer(len); - if (find_dts_header(m_buf[m_cur_buf]->get_buffer(), len, &m_dtsheader) >= 0) { + len = decode_buffer(len); + int pos = find_consecutive_dts_headers(m_buf[m_cur_buf]->get_buffer(), len, 5); + if (0 <= pos) { + if (0 > find_dts_header(m_buf[m_cur_buf]->get_buffer() + pos, len - pos, &m_dtsheader)) + return false; + mxverb(3, boost::format("DTSinWAV: 14->16 %1% swap %2%\n") % m_pack_14_16 % m_swap_bytes); return true; } diff --git a/tests/results.txt b/tests/results.txt index ded3c001a..8c6d22723 100644 --- a/tests/results.txt +++ b/tests/results.txt @@ -164,3 +164,4 @@ T_315ui_locale_uk_UA:23026ac2ed9767541e89f2261bcf8b60-3182bfa8c7ef57b56185285fbd T_316ui_locale_zh_CN:23026ac2ed9767541e89f2261bcf8b60-399cd00f7f8a16f553c448c97b560a70:passed:20111016-192532:0.719437777 T_317ui_locale_zh_TW:af26160704aa699ca03270813855ec7d-836878bf8118c2b708d4fcadd88245dc:passed:20111016-192531:0.705209719 T_318ui_locale_invalid:ok:passed:20111016-192531:0.044292216 +T_319wav_with_pcm_detected_as_dts:eb7f2acc6f008c40d13f068e911ce9c0:passed:20111016-224416:0.071996925 diff --git a/tests/test-319wav_with_pcm_detected_as_dts.rb b/tests/test-319wav_with_pcm_detected_as_dts.rb new file mode 100644 index 000000000..344534bc5 --- /dev/null +++ b/tests/test-319wav_with_pcm_detected_as_dts.rb @@ -0,0 +1,13 @@ +#!/usr/bin/ruby -w + +class T_319wav_with_pcm_detected_as_dts < Test + def description + "mkvmerge / WAV with PCM detected as DTS" + end + + def run + merge "data/simple/wav_with_pcm_detected_as_dts.wav" + hash_tmp + end +end +