Bug 57007 - WAV ripping is wrong endianness on powerpc
Summary: WAV ripping is wrong endianness on powerpc
Status: RESOLVED FIXED
Alias: None
Product: kio
Classification: Frameworks and Libraries
Component: audiocd (show other bugs)
Version: unspecified
Platform: Debian testing Linux
: NOR normal
Target Milestone: ---
Assignee: rik
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-04-08 16:49 UTC by Fjm Maillists
Modified: 2003-05-01 02:14 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Fjm Maillists 2003-04-08 16:49:05 UTC
Version:           0.89 (using KDE KDE 3.1.1)
Installed from:    Debian testing/unstable Packages
OS:          Linux

Trying to use kaudiocreator on an iBook. The first track I tried ripping to ogg came out as static, a normal problem of endian mistake. I hunted around a bit, and it seems that the problem is in reading from the CD. Running the cdparanoia command-line program directly ended up with a wav file that worked fine. However, when using kaudiocreator with the WAV option (just mv the file), the file sounds corrupted.

Using the `file` command showed both files as "little endian." However, looking at the files directly in vi showed that the data in the files were different, and looked like they were reversed like an endian problem would reverse them.

I imagine that the KDE WAV writer has hard coded (or mis-detected) the WAV header as little endian, but is correctly detecting the data as big endian.

As a workaround for ogg encoding, adding the --raw-endianness 1 option makes a valid ogg file. I don't know if that encodes the header as data though, but it doesn't sound like it.
Comment 1 icefox 2003-04-11 07:18:06 UTC
This bug is in the audiocd ioslave. 
Comment 2 Michael Matz 2003-04-11 15:27:55 UTC
Please try current HEAD.  I committed a possible fix for this problem. 
Note, that the encoding of .ogg or .mp3, when produced direcltly by the ioslave 
should already have been correct.  Only the .wav output was broken. 
Comment 3 Fjm Maillists 2003-04-11 16:18:58 UTC
 
Ah, OK. I'll have to wait for the next release, as I don't have the space to build a new version. 
 
Also, it would be nice if kaudiocreator used the audiocd slave to do the ogg conversion, if it was 
possible 
Comment 4 Scott Wheeler 2003-05-01 02:14:44 UTC
Subject: KDE_3_1_BRANCH: kdemultimedia/kioslave/audiocd

CVS commit by wheeler: 

Backporting Matz's fix to the branch.  George (and/or other Mac users)
please test soon.  Closing the related bug for now.  If this fix doesn't work
I'll reopen it.  This should make ripping of wav files work on Mac now.

CCMAIL:staikos@kde.org, 57007-done@bugs.kde.org


  M +11 -0     audiocd.cpp   1.59.2.6


--- kdemultimedia/kioslave/audiocd/audiocd.cpp  #1.59.2.5:1.59.2.6
@@ -1375,4 +1375,9 @@ AudioCDProtocol::parseArgs(const KURL & 
 }
 
+inline int16_t swap16 (int16_t i)
+{
+  return (((i >> 8) & 0xFF) | ((i << 8) & 0xFF00));
+}
+
   void
 AudioCDProtocol::paranoiaRead(
@@ -1554,4 +1559,10 @@ static char mp3buffer[mp3buffer_size];
       if (filetype == "wav" || filetype == "cda") {
         QByteArray output;
+        int16_t i16 = 1;
+        /* WAV is defined to be little endian, so we need to swap it
+           on big endian platforms.  */
+        if (((char*)&i16)[0] == 0)
+          for (int i=0; i < 2 * CD_FRAMESAMPLES; i++)
+            buf[i] = swap16 (buf[i]);
         char * cbuf = reinterpret_cast<char *>(buf);
         output.setRawData(cbuf, CD_FRAMESIZE_RAW);