libcdio-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Libcdio-devel] paranoia and byte-swapping


From: R. Bernstein
Subject: [Libcdio-devel] paranoia and byte-swapping
Date: Tue, 25 Jan 2005 21:01:08 -0500

I've noticed that paranoia seems to have an affinity for 16-bit
numbers as numbers rather than possibly byte-swapped bytes.

I imagine this has something to do with being able to analyze audio
data better, but is this why? 

Recently I started using the paranoia library in my first CDDA media
plugin (for vlc). In the process I noted something a little at odds
with parnoia's predilection for 16-bit units. Since the underlying
ioctls or MMC read's return byte units, it seems that that is the way
the media players expect to get the data back. Indeed when I looked at
Mplayer's plugin it in fact swaps the bytes if on a big-endian box.

So we have this sequence of events. In cdda_read() of interface.c :
   if(d->bigendianp!=bigendianp()){
    *swap bytes*
   }

And then in mplayers cdda-handler fill_buffer() of cdda.c :
  #ifdef WORDS_BIGENDIAN 
   *swap bytes*
  #endif

Note that this is probably incorrect since it doesn't take into
account the Endian-ness of the drive. However as a separate
question/comment I'm guessing that most drives now return bytes back
Little Endian. (Or that's what the mplayer code assumes.)

And I would not be surprised there is yet another swapping before the
real audio rendering. It's enough to make one cross-eyed.

The thought has come up that perhaps there should be a way to tell
paranoia *not* to do any sort of byte swapping which would save two loops above.

In fact, this is what I've just done in the libcdio version. I've
taken a bit from modeset flag for such purposes. 

#define PARANOIA_MODE_NOSWAP      64 

But what is a little bit odd about this is that it really doesn't have
anything to do with the paranoia detection/correction. It is however
something that one would conveniently set along with the other
paranoia parameters. Since it isn't a paranoia thing, adding this also
suggested changing PARANOIA_MODE_FULL from 0xff to 63. 

Can one get into trouble in paranoia if one *doesn't* swap bytes when
one is supposed to? Other suggestions or comments?





reply via email to

[Prev in Thread] Current Thread [Next in Thread]