From 500bca172a1b49c4faacf3355eb6e29d1f2cc5bb Mon Sep 17 00:00:00 2001
From: chris <chris@ rudorff com>
Date: Sat, 26 Jun 2010 19:22:05 +0200
Subject: [PATCH 4/5] PPC fixing endian:

WORDS_ENDIAN isn't defined by configure anymore.
Use HAVE_BIGENDIAN instead.

Fixes white noise instead sound on linux+osx/PPC

http://svn.mythtv.org/trac/ticket/8442
---
 mythplugins/mythmusic/mythmusic/avfdecoder.cpp |    3 ++-
 mythtv/libs/libmyth/audiooutputalsa.cpp        |    4 ++--
 mythtv/libs/libmyth/audiooutputca.cpp          |    2 +-
 mythtv/libs/libmyth/audiooutputoss.cpp         |    2 +-
 mythtv/libs/libmyth/mythcdrom-linux.cpp        |   12 +++++++-----
 mythtv/libs/libmythtv/NuppelVideoRecorder.cpp  |   12 ++++++------
 mythtv/libs/libmythtv/RTjpegN.h                |    2 +-
 mythtv/libs/libmythtv/nuppeldecoder.cpp        |   20 ++++++++++----------
 mythtv/libs/libmythtv/nuppeldecoder.h          |    4 +++-
 mythtv/libs/libmythtv/yuv2rgb.cpp              |    4 ++--
 10 files changed, 35 insertions(+), 30 deletions(-)

diff --git a/mythplugins/mythmusic/mythmusic/avfdecoder.cpp b/mythplugins/mythmusic/mythmusic/avfdecoder.cpp
index 4a47e63..51086d8 100644
--- a/mythplugins/mythmusic/mythmusic/avfdecoder.cpp
+++ b/mythplugins/mythmusic/mythmusic/avfdecoder.cpp
@@ -27,6 +27,7 @@
 #include <QFile>
 
 // Myth headers
+#include <mythconfig.h>
 #include <mythcontext.h>
 #include <audiooutput.h>
 #include <mythverbose.h>
@@ -192,7 +193,7 @@ bool avfDecoder::initialize()
     // Given we are outputing to a sound card, this will always
     // be a PCM format
 
-#ifdef WORDS_BIGENDIAN
+#if HAVE_BIGENDIAN
     m_outputFormat = guess_format("s16be", NULL, NULL);
 #else
     m_outputFormat = guess_format("s16le", NULL, NULL);
diff --git a/mythtv/libs/libmyth/audiooutputalsa.cpp b/mythtv/libs/libmyth/audiooutputalsa.cpp
index 73f094a..09fd358 100644
--- a/mythtv/libs/libmyth/audiooutputalsa.cpp
+++ b/mythtv/libs/libmyth/audiooutputalsa.cpp
@@ -221,13 +221,13 @@ bool AudioOutputALSA::OpenDevice()
     else if (audio_bits == 16)
         // is the sound data coming in really little-endian or is it
         // CPU-endian?
-#ifdef WORDS_BIGENDIAN
+#if HAVE_BIGENDIAN
         format = SND_PCM_FORMAT_S16;
 #else
         format = SND_PCM_FORMAT_S16_LE;
 #endif
     else if (audio_bits == 24)
-#ifdef WORDS_BIGENDIAN
+#if HAVE_BIGENDIAN
         format = SND_PCM_FORMAT_S24;
 #else
         format = SND_PCM_FORMAT_S24_LE;
diff --git a/mythtv/libs/libmyth/audiooutputca.cpp b/mythtv/libs/libmyth/audiooutputca.cpp
index 2d59454..ba67056 100644
--- a/mythtv/libs/libmyth/audiooutputca.cpp
+++ b/mythtv/libs/libmyth/audiooutputca.cpp
@@ -176,7 +176,7 @@ bool CoreAudioData::OpenAnalog()
     conv_in_desc.mSampleRate       = mCA->audio_samplerate;
     conv_in_desc.mFormatID         = kAudioFormatLinearPCM;
     conv_in_desc.mFormatFlags      = kLinearPCMFormatFlagIsSignedInteger;
-#ifdef WORDS_BIGENDIAN
+#if HAVE_BIGENDIAN
     conv_in_desc.mFormatFlags     |= kLinearPCMFormatFlagIsBigEndian;
 #endif
     conv_in_desc.mBytesPerPacket   = mCA->audio_bytes_per_sample;
diff --git a/mythtv/libs/libmyth/audiooutputoss.cpp b/mythtv/libs/libmyth/audiooutputoss.cpp
index 9bd4db1..2d4fc29 100644
--- a/mythtv/libs/libmyth/audiooutputoss.cpp
+++ b/mythtv/libs/libmyth/audiooutputoss.cpp
@@ -123,7 +123,7 @@ bool AudioOutputOSS::OpenDevice()
             format = AFMT_S8;
             break;
         case 16:
-#ifdef WORDS_BIGENDIAN
+#if HAVE_BIGENDIAN
             format = AFMT_S16_BE;
 #else
             format = AFMT_S16_LE;
diff --git a/mythtv/libs/libmyth/mythcdrom-linux.cpp b/mythtv/libs/libmyth/mythcdrom-linux.cpp
index 80820f2..5827a45 100644
--- a/mythtv/libs/libmyth/mythcdrom-linux.cpp
+++ b/mythtv/libs/libmyth/mythcdrom-linux.cpp
@@ -12,7 +12,7 @@
 
 #include "mythcdrom.h"
 #include "mythcdrom-linux.h"
-#include "mythconfig.h"      // for WORDS_BIGENDIAN
+#include "mythconfig.h"      // for HAVE_BIGENDIAN
 #include "mythcontext.h"
 #include "mythverbose.h"
 
@@ -35,17 +35,19 @@ typedef struct cdrom_generic_command CDROMgenericCmd;
 typedef struct
 {
     uint16_t data_len[2];
-#ifdef WORDS_BIGENDIAN
+#if HAVE_BIGENDIAN
+#warning "BIG"
     uint8_t  nea                : 1;
     uint8_t  reserved1          : 4;
     uint8_t  notification_class : 3;
 #else
+#warning "littl"
     uint8_t  notification_class : 3;
     uint8_t  reserved1          : 4;
     uint8_t  nea                : 1;
 #endif
     uint8_t  supp_event_class;
-#ifdef WORDS_BIGENDIAN
+#if HAVE_BIGENDIAN
     uint8_t  reserved2          : 4;
     uint8_t  media_event_code   : 4;
     uint8_t  reserved3          : 6;
@@ -65,7 +67,7 @@ typedef struct
 // and this is returned by GPCMD_READ_DISC_INFO
 typedef struct {
     uint16_t disc_information_length;
-#ifdef WORDS_BIGENDIAN
+#if HAVE_BIGENDIAN
     uint8_t  reserved1          : 3;
     uint8_t  erasable           : 1;
     uint8_t  border_status      : 2;
@@ -80,7 +82,7 @@ typedef struct {
     uint8_t  n_sessions_lsb;
     uint8_t  first_track_lsb;
     uint8_t  last_track_lsb;
-#ifdef WORDS_BIGENDIAN
+#if HAVE_BIGENDIAN
     uint8_t  did_v              : 1;
     uint8_t  dbc_v              : 1;
     uint8_t  uru                : 1;
diff --git a/mythtv/libs/libmythtv/NuppelVideoRecorder.cpp b/mythtv/libs/libmythtv/NuppelVideoRecorder.cpp
index 12ea0ab..86d4c41 100644
--- a/mythtv/libs/libmythtv/NuppelVideoRecorder.cpp
+++ b/mythtv/libs/libmythtv/NuppelVideoRecorder.cpp
@@ -33,7 +33,7 @@ using namespace std;
 #include "audioinput.h"
 #include "myth_imgconvert.h"
 
-#ifdef WORDS_BIGENDIAN
+#if HAVE_BIGENDIAN
 extern "C" {
 #include "bswap.h"
 }
@@ -1873,7 +1873,7 @@ void NuppelVideoRecorder::BufferIt(unsigned char *buf, int len, bool forcekey)
 
 inline void NuppelVideoRecorder::WriteFrameheader(rtframeheader *fh)
 {
-#ifdef WORDS_BIGENDIAN
+#if HAVE_BIGENDIAN
     fh->timecode     = bswap_32(fh->timecode);
     fh->packetlength = bswap_32(fh->packetlength);
 #endif
@@ -1921,7 +1921,7 @@ void NuppelVideoRecorder::WriteFileHeader(void)
     fileheader.textsblocks = -1; // TODO: make only -1 if VBI support active?
     fileheader.keyframedist = KEYFRAMEDIST;
 
-#ifdef WORDS_BIGENDIAN
+#if HAVE_BIGENDIAN
     fileheader.width         = bswap_32(fileheader.width);
     fileheader.height        = bswap_32(fileheader.height);
     fileheader.desiredwidth  = bswap_32(fileheader.desiredwidth);
@@ -2030,7 +2030,7 @@ void NuppelVideoRecorder::WriteHeader(void)
 
     extendeddataOffset = ringBuffer->GetWritePosition();
 
-#ifdef WORDS_BIGENDIAN
+#if HAVE_BIGENDIAN
     moredata.version                 = bswap_32(moredata.version);
     moredata.video_fourcc            = bswap_32(moredata.video_fourcc);
     moredata.audio_fourcc            = bswap_32(moredata.audio_fourcc);
@@ -3147,7 +3147,7 @@ void NuppelVideoRecorder::WriteVideo(VideoFrame *frame, bool skipsync,
     lf = fnum;
 }
 
-#ifdef WORDS_BIGENDIAN
+#if HAVE_BIGENDIAN
 static void bswap_16_buf(short int *buf, int buf_cnt, int audio_channels)
     __attribute__ ((unused)); /* <- suppress compiler warning */
 
@@ -3214,7 +3214,7 @@ void NuppelVideoRecorder::WriteAudio(unsigned char *buf, int fnum, int timecode)
 
         int sample_cnt = audio_buffer_size / audio_bytes_per_sample;
 
-#ifdef WORDS_BIGENDIAN
+#if HAVE_BIGENDIAN
         bswap_16_buf((short int*) buf, sample_cnt, audio_channels);
 #endif
 
diff --git a/mythtv/libs/libmythtv/RTjpegN.h b/mythtv/libs/libmythtv/RTjpegN.h
index 2342f30..b3dc470 100644
--- a/mythtv/libs/libmythtv/RTjpegN.h
+++ b/mythtv/libs/libmythtv/RTjpegN.h
@@ -33,7 +33,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 #define RTJPEG_FILE_VERSION 0
 #define RTJPEG_HEADER_SIZE 12
 
-#ifdef WORDS_BIGENDIAN
+#if HAVE_BIGENDIAN
 #define RTJPEG_SWAP_WORD(a) ( ((a) << 24) | \
 			(((a) << 8) & 0x00ff0000) | \
 			(((a) >> 8) & 0x0000ff00) | \
diff --git a/mythtv/libs/libmythtv/nuppeldecoder.cpp b/mythtv/libs/libmythtv/nuppeldecoder.cpp
index 1450a9a..495de67 100644
--- a/mythtv/libs/libmythtv/nuppeldecoder.cpp
+++ b/mythtv/libs/libmythtv/nuppeldecoder.cpp
@@ -27,7 +27,7 @@ using namespace std;
 
 #include "minilzo.h"
 
-#ifdef WORDS_BIGENDIAN
+#if HAVE_BIGENDIAN
 extern "C" {
 #include "bswap.h"
 }
@@ -41,7 +41,7 @@ NuppelDecoder::NuppelDecoder(NuppelVideoPlayer *parent,
     : DecoderBase(parent, pginfo),
       rtjd(0), video_width(0), video_height(0), video_size(0),
       video_frame_rate(0.0f), audio_samplerate(44100),
-#ifdef WORDS_BIGENDIAN
+#if HAVE_BIGENDIAN
       audio_bits_per_sample(0),
 #endif
       ffmpeg_extradatasize(0), ffmpeg_extradata(0), usingextradata(false),
@@ -139,7 +139,7 @@ bool NuppelDecoder::ReadFileheader(struct rtfileheader *fh)
     if (ringBuffer->Read(fh, FILEHEADERSIZE) != FILEHEADERSIZE)
         return false;
 
-#ifdef WORDS_BIGENDIAN
+#if HAVE_BIGENDIAN
     fh->width         = bswap_32(fh->width);
     fh->height        = bswap_32(fh->height);
     fh->desiredwidth  = bswap_32(fh->desiredwidth);
@@ -160,7 +160,7 @@ bool NuppelDecoder::ReadFrameheader(struct rtframeheader *fh)
     if (ringBuffer->Read(fh, FRAMEHEADERSIZE) != FRAMEHEADERSIZE)
         return false;
 
-#ifdef WORDS_BIGENDIAN
+#if HAVE_BIGENDIAN
     fh->timecode     = bswap_32(fh->timecode);
     fh->packetlength = bswap_32(fh->packetlength);
 #endif
@@ -287,7 +287,7 @@ int NuppelDecoder::OpenFile(RingBuffer *rbuffer, bool novideo,
         else
         {
             ringBuffer->Read(&extradata, frameheader.packetlength);
-#ifdef WORDS_BIGENDIAN
+#if HAVE_BIGENDIAN
             struct extendeddata *ed = &extradata;
             ed->version                 = bswap_32(ed->version);
             ed->video_fourcc            = bswap_32(ed->video_fourcc);
@@ -353,7 +353,7 @@ int NuppelDecoder::OpenFile(RingBuffer *rbuffer, bool novideo,
                 {
                     memcpy(&ste, seekbuf + offset,
                            sizeof(struct seektable_entry));
-#ifdef WORDS_BIGENDIAN
+#if HAVE_BIGENDIAN
                     ste.file_offset     = bswap_64(ste.file_offset);
                     ste.keyframe_number = bswap_32(ste.keyframe_number);
 #endif
@@ -422,7 +422,7 @@ int NuppelDecoder::OpenFile(RingBuffer *rbuffer, bool novideo,
                 {
                     memcpy(&kfate, kfa_buf + offset,
                            sizeof(struct kfatable_entry));
-#ifdef WORDS_BIGENDIAN
+#if HAVE_BIGENDIAN
                     kfate.adjust          = bswap_32(kfate.adjust);
                     kfate.keyframe_number = bswap_32(kfate.keyframe_number);
 #endif
@@ -495,7 +495,7 @@ int NuppelDecoder::OpenFile(RingBuffer *rbuffer, bool novideo,
         effdsp = extradata.audio_sample_rate * 100;
         GetNVP()->SetEffDsp(effdsp);
         audio_samplerate = extradata.audio_sample_rate;
-#ifdef WORDS_BIGENDIAN
+#if HAVE_BIGENDIAN
         // Why only if using extradata?
         audio_bits_per_sample = extradata.audio_bits_per_sample;
 #endif
@@ -1242,7 +1242,7 @@ bool NuppelDecoder::GetFrame(DecodeType decodetype)
             else
             {
                 getrawframes = 0;
-#ifdef WORDS_BIGENDIAN
+#if HAVE_BIGENDIAN
                 // Why endian correct the audio buffer here?
                 // Don't big-endian clients have to do it in audiooutBlah.cpp?
                 if (audio_bits_per_sample == 16) {
@@ -1290,7 +1290,7 @@ bool NuppelDecoder::GetFrame(DecodeType decodetype)
 
             if (QString(fh->finfo) == "MythTVVideo")
             {
-#ifdef WORDS_BIGENDIAN
+#if HAVE_BIGENDIAN
                 fh->width         = bswap_32(fh->width);
                 fh->height        = bswap_32(fh->height);
                 fh->desiredwidth  = bswap_32(fh->desiredwidth);
diff --git a/mythtv/libs/libmythtv/nuppeldecoder.h b/mythtv/libs/libmythtv/nuppeldecoder.h
index e0a61ad..0366b18 100644
--- a/mythtv/libs/libmythtv/nuppeldecoder.h
+++ b/mythtv/libs/libmythtv/nuppeldecoder.h
@@ -1,6 +1,8 @@
 #ifndef NUPPELDECODER_H_
 #define NUPPELDECODER_H_
 
+#include "config.h"
+
 #include <list>
 using namespace std;
 
@@ -81,7 +83,7 @@ class NuppelDecoder : public DecoderBase
     int video_width, video_height, video_size;
     double video_frame_rate;
     int audio_samplerate;
-#ifdef WORDS_BIGENDIAN
+#if HAVE_BIGENDIAN
     int audio_bits_per_sample;
 #endif
 
diff --git a/mythtv/libs/libmythtv/yuv2rgb.cpp b/mythtv/libs/libmythtv/yuv2rgb.cpp
index a488d1b..87a63b9 100644
--- a/mythtv/libs/libmythtv/yuv2rgb.cpp
+++ b/mythtv/libs/libmythtv/yuv2rgb.cpp
@@ -417,7 +417,7 @@ static void yuv420_argb32_non_mmx(unsigned char *image, unsigned char *py,
     int dstwidth;
 
 // byte indices
-#ifdef WORDS_BIGENDIAN
+#if HAVE_BIGENDIAN
 #define R_OI  1
 #define G_OI  2
 #define B_OI  3
@@ -490,7 +490,7 @@ void rgb32_to_yuv420p(unsigned char *lum, unsigned char *cb, unsigned char *cr,
     unsigned char *p;
 
 // byte indices
-#ifdef WORDS_BIGENDIAN
+#if HAVE_BIGENDIAN
 #define R_II  3
 #define G_II  2
 #define B_II  1
-- 
1.6.5.1

