Here is my attempt on patch discussed on Febryary 2006 Thread called "[PATCH] Fix DTS in WAV file playback."
Kostya <kostya.shishkov at gmail.com> writes:
Here is my attempt on patch discussed on Febryary 2006 Thread called "[PATCH] Fix DTS in WAV file playback."
Wouldn't it be simpler to call av_probe_input_format or so on some data from the start of the data section of the file? That would also take care of AC3 in WAV masquerading as PCM. -- M?ns Rullg?rd mans at mansr.com
Hi On Fri, May 04, 2007 at 09:30:27AM +0100, M?ns Rullg?rd wrote:
Kostya <kostya.shishkov at gmail.com> writes:
Here is my attempt on patch discussed on Febryary 2006 Thread called "[PATCH] Fix DTS in WAV file playback."
Wouldn't it be simpler to call av_probe_input_format or so on some data from the start of the data section of the file? That would also take care of AC3 in WAV masquerading as PCM.
Note, also see av_find_stream_info() code releated to codec_identified [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB No human being will ever know the Truth, for even if they happen to say it by chance, they would not even known they had done so. -- Xenophanes
On Fri, May 04, 2007 at 11:50:37AM +0200, Michael Niedermayer wrote:
Hi
On Fri, May 04, 2007 at 09:30:27AM +0100, M?ns Rullg?rd wrote:
Kostya <kostya.shishkov at gmail.com> writes:
Here is my attempt on patch discussed on Febryary 2006 Thread called "[PATCH] Fix DTS in WAV file playback."
Wouldn't it be simpler to call av_probe_input_format or so on some data from the start of the data section of the file? That would also take care of AC3 in WAV masquerading as PCM.
Note, also see av_find_stream_info() code releated to codec_identified
I suppose that this is only WAV related and should be treated there. Also it is gladly is not the common practice so I think checking for those two formats is enough. While I haven't seen AC3 in WAV, DTS in WAV seems to be a common practice (but still a hack).
[...]
-- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
No human being will ever know the Truth, for even if they happen to say it by chance, they would not even known they had done so. -- Xenophanes
Kostya wrote:
On Fri, May 04, 2007 at 11:50:37AM +0200, Michael Niedermayer wrote:
Hi
On Fri, May 04, 2007 at 09:30:27AM +0100, M?ns Rullg?rd wrote:
Kostya <kostya.shishkov at gmail.com> writes:
Here is my attempt on patch discussed on Febryary 2006 Thread called "[PATCH] Fix DTS in WAV file playback."
Wouldn't it be simpler to call av_probe_input_format or so on some data from the start of the data section of the file? That would also take care of AC3 in WAV masquerading as PCM.
Note, also see av_find_stream_info() code releated to codec_identified
I suppose that this is only WAV related and should be treated there. Also it is gladly is not the common practice so I think checking for those two formats is enough. While I haven't seen AC3 in WAV, DTS in WAV seems to be a common practice (but still a hack).
I have seen AC3 in WAV done that way. There is a simple explanation for this ugly practice. Labeling the data as PCM allows one to use stupid CD-R software to burn the data as an audio track which can then be played back through a hardware DTS/AC3 decoder. It's not what I call an acceptable explanation, but it is an explanation nonetheless. -- M?ns Rullg?rd mans at mansr.com
On Fri, May 04, 2007 at 02:15:42PM +0100, M?ns Rullg?rd wrote:
Kostya wrote:
On Fri, May 04, 2007 at 11:50:37AM +0200, Michael Niedermayer wrote:
Hi
On Fri, May 04, 2007 at 09:30:27AM +0100, M?ns Rullg?rd wrote:
Kostya <kostya.shishkov at gmail.com> writes:
Here is my attempt on patch discussed on Febryary 2006 Thread called "[PATCH] Fix DTS in WAV file playback."
Wouldn't it be simpler to call av_probe_input_format or so on some data from the start of the data section of the file? That would also take care of AC3 in WAV masquerading as PCM.
Note, also see av_find_stream_info() code releated to codec_identified
I suppose that this is only WAV related and should be treated there. Also it is gladly is not the common practice so I think checking for those two formats is enough. While I haven't seen AC3 in WAV, DTS in WAV seems to be a common practice (but still a hack).
I have seen AC3 in WAV done that way. There is a simple explanation for this ugly practice. Labeling the data as PCM allows one to use stupid CD-R software to burn the data as an audio track which can then be played back through a hardware DTS/AC3 decoder. It's not what I call an acceptable explanation, but it is an explanation nonetheless.
If you think that is ugly then how can you comment the fact that actual data stored in WAV is bswap16()'ed (because it will be bswapped back while recording) While this has no difference for DCA (it accepts any endianness), AC3 parser (ff_ac3_parse_header) simply refuses to parse anything.
-- M?ns Rullg?rd mans at mansr.com
On Fri, 04 May 2007 15:38:05 +0300, Kostya scribed:
those two formats is enough. While I haven't seen AC3 in WAV, DTS in WAV seems to be a common practice (but still a hack).
ask for a sample, and you shall recieve! dts and ac3 in wav: http://www.diatonis.com/downloads_dts_ac3.html http://www.diatonis.com/downloads/diatonis_ac3_wav_anfos.zip mplayer diatonis_al_soal_dd.wav -ac +a52 AUDIO: 44100 Hz, 2 ch, s16le, 640.0 kbit/45.35% (ratio: 80000->176400) Selected audio codec: [a52] afm: liba52 (AC3-liba52) -compn
On Fri, May 04, 2007 at 09:40:01AM +0300, Kostya wrote:
Here is my attempt on patch discussed on Febryary 2006 Thread called "[PATCH] Fix DTS in WAV file playback."
ping
Hi On Fri, May 11, 2007 at 06:04:01AM +0300, Kostya wrote:
On Fri, May 04, 2007 at 09:40:01AM +0300, Kostya wrote:
Here is my attempt on patch discussed on Febryary 2006 Thread called "[PATCH] Fix DTS in WAV file playback."
ping
the code will not work with non seekable streams i think also i dont like it at all to have the dca detection code in wav.c it belongs into a dca specific file, no matter its called directly or over some *probe() [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB There will always be a question for which you do not know the correct awnser.
Michael Niedermayer <michaelni at gmx.at> writes:
Hi
On Fri, May 11, 2007 at 06:04:01AM +0300, Kostya wrote:
On Fri, May 04, 2007 at 09:40:01AM +0300, Kostya wrote:
Here is my attempt on patch discussed on Febryary 2006 Thread called "[PATCH] Fix DTS in WAV file playback."
ping
the code will not work with non seekable streams i think also i dont like it at all to have the dca detection code in wav.c it belongs into a dca specific file, no matter its called directly or over some *probe()
Agree. A proper solution should also detect AC3 in WAV, as I've mentioned previously in this thread. -- M?ns Rullg?rd mans at mansr.com
On 05/11/2007 05:04 AM, Kostya wrote:
On Fri, May 04, 2007 at 09:40:01AM +0300, Kostya wrote:
Here is my attempt on patch discussed on Febryary 2006 Thread called "[PATCH] Fix DTS in WAV file playback."
ping
Git-friendly patch attached. Hope that patchwork will catch it up. -Vitor
Hi, On Sun, Jan 23, 2011 at 11:46 AM, Vitor Sessak <vitor1001 at gmail.com> wrote:
On 05/11/2007 05:04 AM, Kostya wrote:
On Fri, May 04, 2007 at 09:40:01AM +0300, Kostya wrote:
Here is my attempt on patch discussed on Febryary 2006 Thread called "[PATCH] Fix DTS in WAV file playback."
ping
Git-friendly patch attached. Hope that patchwork will catch it up. [..] @@ -186,6 +238,10 @@ static int wav_read_header(AVFormatContext *s, size = find_tag(pb, MKTAG('d', 'a', 't', 'a')); if (size < 0) return -1; + + /* check if it's really PCM or hidden DTS */ + if (codec_get_id (codec_wav_tags, st->codec->codec_tag) == CODEC_ID_PCM_S16LE) + find_dts_header (pb, st->codec); wav->data_end= url_ftell(pb) + size; return 0; }
if (st->codec->codec_tag == 1) is fine here, no reason to run through that table twice. The detection itself looks good to me but is against an old git revision so probably needs to be hand-merged... Ronald
On 23.01.2011 18:46, Vitor Sessak wrote:
On 05/11/2007 05:04 AM, Kostya wrote:
On Fri, May 04, 2007 at 09:40:01AM +0300, Kostya wrote:
Here is my attempt on patch discussed on Febryary 2006 Thread called "[PATCH] Fix DTS in WAV file playback."
ping
Git-friendly patch attached. Hope that patchwork will catch it up.
-Vitor
From 5a24ffec96f58c1af68b7c87f65e29d9d8477507 Mon Sep 17 00:00:00 2001 From: Kostya Shishkov <kostya.shishkov at gmail.com> Date: Sun, 23 Jan 2011 17:43:37 +0100 Subject: [PATCH] DCA-in-WAV detection
--- libavformat/wav.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 56 insertions(+), 0 deletions(-)
diff --git a/libavformat/wav.c b/libavformat/wav.c index a6db698..90eb583 100644 --- a/libavformat/wav.c +++ b/libavformat/wav.c @@ -150,6 +150,58 @@ static int wav_probe(AVProbeData *p) return 0; }
+#define DCA_MARKER_RAW_BE 0x7FFE8001 +#define DCA_MARKER_RAW_LE 0xFE7F0180 +#define DCA_MARKER_14B_BE 0x1FFFE800 +#define DCA_MARKER_14B_LE 0xFF1F00E8
In libavcodec/dca.h.
+#define DCA_PROBE_SIZE 16384 + +/* Most WAV files with DTS audio are broken and use 0x01 (PCM) as format + ID instead of 0x2001 (DTS). If the format found is 0x01, check the first
For the record, they are probably intentionally broken so that non-DTS-aware equipment/software can handle them before the stream is fed to a DTS-capable receiver (think e.g. burning the .wav to an audio disc).
+ bytes after 'data' for a valid DTS header. */ +static void find_dts_header (ByteIOContext *pb, AVCodecContext *codec) +{ + uint32_t state = -1, marker; + unsigned int i; + offset_t pos; + int found = 0; + + pos = url_ftell(pb); + for (i = 0; i < DCA_PROBE_SIZE && !url_feof(pb) && !found; i += 2) { + state = (state << 16) | get_be16(pb); + /* raw stream markers */ + if (state == DCA_MARKER_RAW_BE || state == DCA_MARKER_RAW_LE) + found = 1; + /* 14 bits and big endian bitstream */ + if (state == DCA_MARKER_14B_BE) { + if ((get_be16(pb) & 0xFFF0) == 0x07F0) + found = 1; + else + url_fseek(pb, -2, SEEK_CUR); + } + /* 14 bits and big endian bitstream */
s/big/little/
+ if (state == DCA_MARKER_14B_LE) { + if ((get_be16(pb) & 0xF0FF) == 0xF007) + found = 1; + else + url_fseek(pb, -2, SEEK_CUR); + } + }
BTW, I don't think that any PCM_S16LE-declaring wav files contain big-endian DTS stream. The stream is little-endian so that when the wav file (or an audio disc track) is transmitted into S/PDIF and the byte order of the assumed-PCM_S16LE samples is reversed (as S/PDIF is big-endian), it becomes big-endian bitstream which is understood by the receivers (while little-endian may not be). I'm not against handling big-endian here just-in-case, though.
+ /* if marker is found then test stream for more markers to appear */ + if(found){ + marker = state; + for (i = 0; i < DCA_PROBE_SIZE*3 && !url_feof(pb) && found < 4; i++) { + state = (state << 8) | get_byte(pb); + if(state == marker) + found++; + } + } + if(found == 4) + codec->codec_id = CODEC_ID_DTS; + url_fseek(pb, pos, SEEK_SET); +} + /* wav input */ static int wav_read_header(AVFormatContext *s, AVFormatParameters *ap) @@ -186,6 +238,10 @@ static int wav_read_header(AVFormatContext *s, size = find_tag(pb, MKTAG('d', 'a', 't', 'a')); if (size < 0) return -1; + + /* check if it's really PCM or hidden DTS */ + if (codec_get_id (codec_wav_tags, st->codec->codec_tag) == CODEC_ID_PCM_S16LE) + find_dts_header (pb, st->codec); wav->data_end= url_ftell(pb) + size; return 0; } -- 1.7.1
-- Anssi Hannula
participants (7)
-
anssi.hannula@iki.fi -
kostya.shishkov@gmail.com -
mans@mansr.com -
michaelni@gmx.at -
rsbultje@gmail.com -
tempn@twmi.rr.com -
vitor1001@gmail.com