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
|
b
|
|
27 | 27 | #include <QFile> |
28 | 28 | |
29 | 29 | // Myth headers |
| 30 | #include <mythconfig.h> |
30 | 31 | #include <mythcontext.h> |
31 | 32 | #include <audiooutput.h> |
32 | 33 | #include <mythverbose.h> |
… |
… |
bool avfDecoder::initialize() |
192 | 193 | // Given we are outputing to a sound card, this will always |
193 | 194 | // be a PCM format |
194 | 195 | |
195 | | #ifdef WORDS_BIGENDIAN |
| 196 | #if HAVE_BIGENDIAN |
196 | 197 | m_outputFormat = guess_format("s16be", NULL, NULL); |
197 | 198 | #else |
198 | 199 | 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
|
b
|
bool AudioOutputALSA::OpenDevice() |
221 | 221 | else if (audio_bits == 16) |
222 | 222 | // is the sound data coming in really little-endian or is it |
223 | 223 | // CPU-endian? |
224 | | #ifdef WORDS_BIGENDIAN |
| 224 | #if HAVE_BIGENDIAN |
225 | 225 | format = SND_PCM_FORMAT_S16; |
226 | 226 | #else |
227 | 227 | format = SND_PCM_FORMAT_S16_LE; |
228 | 228 | #endif |
229 | 229 | else if (audio_bits == 24) |
230 | | #ifdef WORDS_BIGENDIAN |
| 230 | #if HAVE_BIGENDIAN |
231 | 231 | format = SND_PCM_FORMAT_S24; |
232 | 232 | #else |
233 | 233 | 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
|
b
|
bool CoreAudioData::OpenAnalog() |
176 | 176 | conv_in_desc.mSampleRate = mCA->audio_samplerate; |
177 | 177 | conv_in_desc.mFormatID = kAudioFormatLinearPCM; |
178 | 178 | conv_in_desc.mFormatFlags = kLinearPCMFormatFlagIsSignedInteger; |
179 | | #ifdef WORDS_BIGENDIAN |
| 179 | #if HAVE_BIGENDIAN |
180 | 180 | conv_in_desc.mFormatFlags |= kLinearPCMFormatFlagIsBigEndian; |
181 | 181 | #endif |
182 | 182 | 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
|
b
|
bool AudioOutputOSS::OpenDevice() |
123 | 123 | format = AFMT_S8; |
124 | 124 | break; |
125 | 125 | case 16: |
126 | | #ifdef WORDS_BIGENDIAN |
| 126 | #if HAVE_BIGENDIAN |
127 | 127 | format = AFMT_S16_BE; |
128 | 128 | #else |
129 | 129 | 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
|
b
|
|
12 | 12 | |
13 | 13 | #include "mythcdrom.h" |
14 | 14 | #include "mythcdrom-linux.h" |
15 | | #include "mythconfig.h" // for WORDS_BIGENDIAN |
| 15 | #include "mythconfig.h" // for HAVE_BIGENDIAN |
16 | 16 | #include "mythcontext.h" |
17 | 17 | #include "mythverbose.h" |
18 | 18 | |
… |
… |
typedef struct cdrom_generic_command CDROMgenericCmd; |
35 | 35 | typedef struct |
36 | 36 | { |
37 | 37 | uint16_t data_len[2]; |
38 | | #ifdef WORDS_BIGENDIAN |
| 38 | #if HAVE_BIGENDIAN |
| 39 | #warning "BIG" |
39 | 40 | uint8_t nea : 1; |
40 | 41 | uint8_t reserved1 : 4; |
41 | 42 | uint8_t notification_class : 3; |
42 | 43 | #else |
| 44 | #warning "littl" |
43 | 45 | uint8_t notification_class : 3; |
44 | 46 | uint8_t reserved1 : 4; |
45 | 47 | uint8_t nea : 1; |
46 | 48 | #endif |
47 | 49 | uint8_t supp_event_class; |
48 | | #ifdef WORDS_BIGENDIAN |
| 50 | #if HAVE_BIGENDIAN |
49 | 51 | uint8_t reserved2 : 4; |
50 | 52 | uint8_t media_event_code : 4; |
51 | 53 | uint8_t reserved3 : 6; |
… |
… |
typedef struct |
65 | 67 | // and this is returned by GPCMD_READ_DISC_INFO |
66 | 68 | typedef struct { |
67 | 69 | uint16_t disc_information_length; |
68 | | #ifdef WORDS_BIGENDIAN |
| 70 | #if HAVE_BIGENDIAN |
69 | 71 | uint8_t reserved1 : 3; |
70 | 72 | uint8_t erasable : 1; |
71 | 73 | uint8_t border_status : 2; |
… |
… |
typedef struct { |
80 | 82 | uint8_t n_sessions_lsb; |
81 | 83 | uint8_t first_track_lsb; |
82 | 84 | uint8_t last_track_lsb; |
83 | | #ifdef WORDS_BIGENDIAN |
| 85 | #if HAVE_BIGENDIAN |
84 | 86 | uint8_t did_v : 1; |
85 | 87 | uint8_t dbc_v : 1; |
86 | 88 | uint8_t uru : 1; |
diff --git a/mythtv/libs/libmythtv/NuppelVideoRecorder.cpp b/mythtv/libs/libmythtv/NuppelVideoRecorder.cpp
index 12ea0ab..86d4c41 100644
a
|
b
|
using namespace std; |
33 | 33 | #include "audioinput.h" |
34 | 34 | #include "myth_imgconvert.h" |
35 | 35 | |
36 | | #ifdef WORDS_BIGENDIAN |
| 36 | #if HAVE_BIGENDIAN |
37 | 37 | extern "C" { |
38 | 38 | #include "bswap.h" |
39 | 39 | } |
… |
… |
void NuppelVideoRecorder::BufferIt(unsigned char *buf, int len, bool forcekey) |
1873 | 1873 | |
1874 | 1874 | inline void NuppelVideoRecorder::WriteFrameheader(rtframeheader *fh) |
1875 | 1875 | { |
1876 | | #ifdef WORDS_BIGENDIAN |
| 1876 | #if HAVE_BIGENDIAN |
1877 | 1877 | fh->timecode = bswap_32(fh->timecode); |
1878 | 1878 | fh->packetlength = bswap_32(fh->packetlength); |
1879 | 1879 | #endif |
… |
… |
void NuppelVideoRecorder::WriteFileHeader(void) |
1921 | 1921 | fileheader.textsblocks = -1; // TODO: make only -1 if VBI support active? |
1922 | 1922 | fileheader.keyframedist = KEYFRAMEDIST; |
1923 | 1923 | |
1924 | | #ifdef WORDS_BIGENDIAN |
| 1924 | #if HAVE_BIGENDIAN |
1925 | 1925 | fileheader.width = bswap_32(fileheader.width); |
1926 | 1926 | fileheader.height = bswap_32(fileheader.height); |
1927 | 1927 | fileheader.desiredwidth = bswap_32(fileheader.desiredwidth); |
… |
… |
void NuppelVideoRecorder::WriteHeader(void) |
2030 | 2030 | |
2031 | 2031 | extendeddataOffset = ringBuffer->GetWritePosition(); |
2032 | 2032 | |
2033 | | #ifdef WORDS_BIGENDIAN |
| 2033 | #if HAVE_BIGENDIAN |
2034 | 2034 | moredata.version = bswap_32(moredata.version); |
2035 | 2035 | moredata.video_fourcc = bswap_32(moredata.video_fourcc); |
2036 | 2036 | moredata.audio_fourcc = bswap_32(moredata.audio_fourcc); |
… |
… |
void NuppelVideoRecorder::WriteVideo(VideoFrame *frame, bool skipsync, |
3147 | 3147 | lf = fnum; |
3148 | 3148 | } |
3149 | 3149 | |
3150 | | #ifdef WORDS_BIGENDIAN |
| 3150 | #if HAVE_BIGENDIAN |
3151 | 3151 | static void bswap_16_buf(short int *buf, int buf_cnt, int audio_channels) |
3152 | 3152 | __attribute__ ((unused)); /* <- suppress compiler warning */ |
3153 | 3153 | |
… |
… |
void NuppelVideoRecorder::WriteAudio(unsigned char *buf, int fnum, int timecode) |
3214 | 3214 | |
3215 | 3215 | int sample_cnt = audio_buffer_size / audio_bytes_per_sample; |
3216 | 3216 | |
3217 | | #ifdef WORDS_BIGENDIAN |
| 3217 | #if HAVE_BIGENDIAN |
3218 | 3218 | bswap_16_buf((short int*) buf, sample_cnt, audio_channels); |
3219 | 3219 | #endif |
3220 | 3220 | |
diff --git a/mythtv/libs/libmythtv/RTjpegN.h b/mythtv/libs/libmythtv/RTjpegN.h
index 2342f30..b3dc470 100644
a
|
b
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
33 | 33 | #define RTJPEG_FILE_VERSION 0 |
34 | 34 | #define RTJPEG_HEADER_SIZE 12 |
35 | 35 | |
36 | | #ifdef WORDS_BIGENDIAN |
| 36 | #if HAVE_BIGENDIAN |
37 | 37 | #define RTJPEG_SWAP_WORD(a) ( ((a) << 24) | \ |
38 | 38 | (((a) << 8) & 0x00ff0000) | \ |
39 | 39 | (((a) >> 8) & 0x0000ff00) | \ |
diff --git a/mythtv/libs/libmythtv/nuppeldecoder.cpp b/mythtv/libs/libmythtv/nuppeldecoder.cpp
index 1450a9a..495de67 100644
a
|
b
|
using namespace std; |
27 | 27 | |
28 | 28 | #include "minilzo.h" |
29 | 29 | |
30 | | #ifdef WORDS_BIGENDIAN |
| 30 | #if HAVE_BIGENDIAN |
31 | 31 | extern "C" { |
32 | 32 | #include "bswap.h" |
33 | 33 | } |
… |
… |
NuppelDecoder::NuppelDecoder(NuppelVideoPlayer *parent, |
41 | 41 | : DecoderBase(parent, pginfo), |
42 | 42 | rtjd(0), video_width(0), video_height(0), video_size(0), |
43 | 43 | video_frame_rate(0.0f), audio_samplerate(44100), |
44 | | #ifdef WORDS_BIGENDIAN |
| 44 | #if HAVE_BIGENDIAN |
45 | 45 | audio_bits_per_sample(0), |
46 | 46 | #endif |
47 | 47 | ffmpeg_extradatasize(0), ffmpeg_extradata(0), usingextradata(false), |
… |
… |
bool NuppelDecoder::ReadFileheader(struct rtfileheader *fh) |
139 | 139 | if (ringBuffer->Read(fh, FILEHEADERSIZE) != FILEHEADERSIZE) |
140 | 140 | return false; |
141 | 141 | |
142 | | #ifdef WORDS_BIGENDIAN |
| 142 | #if HAVE_BIGENDIAN |
143 | 143 | fh->width = bswap_32(fh->width); |
144 | 144 | fh->height = bswap_32(fh->height); |
145 | 145 | fh->desiredwidth = bswap_32(fh->desiredwidth); |
… |
… |
bool NuppelDecoder::ReadFrameheader(struct rtframeheader *fh) |
160 | 160 | if (ringBuffer->Read(fh, FRAMEHEADERSIZE) != FRAMEHEADERSIZE) |
161 | 161 | return false; |
162 | 162 | |
163 | | #ifdef WORDS_BIGENDIAN |
| 163 | #if HAVE_BIGENDIAN |
164 | 164 | fh->timecode = bswap_32(fh->timecode); |
165 | 165 | fh->packetlength = bswap_32(fh->packetlength); |
166 | 166 | #endif |
… |
… |
int NuppelDecoder::OpenFile(RingBuffer *rbuffer, bool novideo, |
287 | 287 | else |
288 | 288 | { |
289 | 289 | ringBuffer->Read(&extradata, frameheader.packetlength); |
290 | | #ifdef WORDS_BIGENDIAN |
| 290 | #if HAVE_BIGENDIAN |
291 | 291 | struct extendeddata *ed = &extradata; |
292 | 292 | ed->version = bswap_32(ed->version); |
293 | 293 | ed->video_fourcc = bswap_32(ed->video_fourcc); |
… |
… |
int NuppelDecoder::OpenFile(RingBuffer *rbuffer, bool novideo, |
353 | 353 | { |
354 | 354 | memcpy(&ste, seekbuf + offset, |
355 | 355 | sizeof(struct seektable_entry)); |
356 | | #ifdef WORDS_BIGENDIAN |
| 356 | #if HAVE_BIGENDIAN |
357 | 357 | ste.file_offset = bswap_64(ste.file_offset); |
358 | 358 | ste.keyframe_number = bswap_32(ste.keyframe_number); |
359 | 359 | #endif |
… |
… |
int NuppelDecoder::OpenFile(RingBuffer *rbuffer, bool novideo, |
422 | 422 | { |
423 | 423 | memcpy(&kfate, kfa_buf + offset, |
424 | 424 | sizeof(struct kfatable_entry)); |
425 | | #ifdef WORDS_BIGENDIAN |
| 425 | #if HAVE_BIGENDIAN |
426 | 426 | kfate.adjust = bswap_32(kfate.adjust); |
427 | 427 | kfate.keyframe_number = bswap_32(kfate.keyframe_number); |
428 | 428 | #endif |
… |
… |
int NuppelDecoder::OpenFile(RingBuffer *rbuffer, bool novideo, |
495 | 495 | effdsp = extradata.audio_sample_rate * 100; |
496 | 496 | GetNVP()->SetEffDsp(effdsp); |
497 | 497 | audio_samplerate = extradata.audio_sample_rate; |
498 | | #ifdef WORDS_BIGENDIAN |
| 498 | #if HAVE_BIGENDIAN |
499 | 499 | // Why only if using extradata? |
500 | 500 | audio_bits_per_sample = extradata.audio_bits_per_sample; |
501 | 501 | #endif |
… |
… |
bool NuppelDecoder::GetFrame(DecodeType decodetype) |
1242 | 1242 | else |
1243 | 1243 | { |
1244 | 1244 | getrawframes = 0; |
1245 | | #ifdef WORDS_BIGENDIAN |
| 1245 | #if HAVE_BIGENDIAN |
1246 | 1246 | // Why endian correct the audio buffer here? |
1247 | 1247 | // Don't big-endian clients have to do it in audiooutBlah.cpp? |
1248 | 1248 | if (audio_bits_per_sample == 16) { |
… |
… |
bool NuppelDecoder::GetFrame(DecodeType decodetype) |
1290 | 1290 | |
1291 | 1291 | if (QString(fh->finfo) == "MythTVVideo") |
1292 | 1292 | { |
1293 | | #ifdef WORDS_BIGENDIAN |
| 1293 | #if HAVE_BIGENDIAN |
1294 | 1294 | fh->width = bswap_32(fh->width); |
1295 | 1295 | fh->height = bswap_32(fh->height); |
1296 | 1296 | 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
|
b
|
|
1 | 1 | #ifndef NUPPELDECODER_H_ |
2 | 2 | #define NUPPELDECODER_H_ |
3 | 3 | |
| 4 | #include "config.h" |
| 5 | |
4 | 6 | #include <list> |
5 | 7 | using namespace std; |
6 | 8 | |
… |
… |
class NuppelDecoder : public DecoderBase |
81 | 83 | int video_width, video_height, video_size; |
82 | 84 | double video_frame_rate; |
83 | 85 | int audio_samplerate; |
84 | | #ifdef WORDS_BIGENDIAN |
| 86 | #if HAVE_BIGENDIAN |
85 | 87 | int audio_bits_per_sample; |
86 | 88 | #endif |
87 | 89 | |
diff --git a/mythtv/libs/libmythtv/yuv2rgb.cpp b/mythtv/libs/libmythtv/yuv2rgb.cpp
index a488d1b..87a63b9 100644
a
|
b
|
static void yuv420_argb32_non_mmx(unsigned char *image, unsigned char *py, |
417 | 417 | int dstwidth; |
418 | 418 | |
419 | 419 | // byte indices |
420 | | #ifdef WORDS_BIGENDIAN |
| 420 | #if HAVE_BIGENDIAN |
421 | 421 | #define R_OI 1 |
422 | 422 | #define G_OI 2 |
423 | 423 | #define B_OI 3 |
… |
… |
void rgb32_to_yuv420p(unsigned char *lum, unsigned char *cb, unsigned char *cr, |
490 | 490 | unsigned char *p; |
491 | 491 | |
492 | 492 | // byte indices |
493 | | #ifdef WORDS_BIGENDIAN |
| 493 | #if HAVE_BIGENDIAN |
494 | 494 | #define R_II 3 |
495 | 495 | #define G_II 2 |
496 | 496 | #define B_II 1 |