]> git.tue.mpg.de Git - paraslash.git/commitdiff
fix compress filter for big endian systems
authorAndre Noll <maan@systemlinux.org>
Wed, 4 Apr 2007 08:22:10 +0000 (10:22 +0200)
committerAndre Noll <maan@systemlinux.org>
Wed, 4 Apr 2007 08:22:10 +0000 (10:22 +0200)
This time for real. It's almost the same patch as the one just
reverted, but this one is tested on both ppc and x86.

NEWS
aacdec.c
configure.ac
filter.h
mp3dec.c
oggdec.c
osx_write.c

diff --git a/NEWS b/NEWS
index 9277d1cfd0701e497a84c188710c51848b7314dd..59c847b5c4582be6887251f66d53c6b9ea3f64b6 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -21,6 +21,7 @@ of other improvements/changes/bugfixes also made it into the release.
          to start only after a few seconds.
        - fix osx_writer hangs
        - simplified dccp code (thanks to Gerrit Renker)
+       - the compress filter works also on big endian systems (ppc)
 
 -----------------------------------------
 0.2.15 (2007-02-16) "inductive resonance"
index 9ed120120de7af297a0760ad237135ae535a72af..89781c528d9f107a65d75cf120cd9eb412c47271 100644 (file)
--- a/aacdec.c
+++ b/aacdec.c
@@ -154,8 +154,8 @@ static ssize_t aacdec(char *input_buffer, size_t len, struct filter_node *fn)
                goto out;
        for (i = 0; i < padd->frame_info.samples; i++) {
                short *s = (short *)outbuffer;
-               fn->buf[fn->loaded++] = s[i] & 0xff;
-               fn->buf[fn->loaded++] = (s[i] >> 8) & 0xff;
+               write_int16_host_endian(fn->buf + fn->loaded, s[i]);
+               fn->loaded += 2;
        }
 success:
        ret = consumed;
index aeb6f8d4bf3aed0ff3b1fb5e98d608ede0a7c935..316f95c74679613748e0fcc0f12c00b707d2f4a2 100644 (file)
@@ -15,6 +15,8 @@ AC_MSG_CHECKING(os type)
 OSTYPE="`$UNAMEPATH -s`"
 AC_MSG_RESULT("$OSTYPE")
 
+AC_C_BIGENDIAN()
+
 AC_PROG_CC
 AC_PROG_CPP
 AC_PROG_INSTALL
index 321d763c1f9cb5b743db1cbbbf3f95f2f68774cb..456a50de3a79c942299ddea50f21fc2169fac9f4 100644 (file)
--- a/filter.h
+++ b/filter.h
@@ -299,6 +299,20 @@ void (*print_help)(void);
  */
 void *(*parse_config)(int argc, char **argv);
 };
+
+
+static inline void write_int16_host_endian(char *buf, int16_t val)
+{
+#ifdef WORDS_BIGENDIAN
+       *buf = val >> 8;
+       *(buf + 1) = val & 0xff;
+#else
+       *buf = val & 0xff;
+       *(buf + 1) = val >> 8;
+#endif
+}
+
+
 /** \cond */
 extern struct filter filters[];
 #define DECLARE_EXTERN_FILTER_INIT(name) \
@@ -348,3 +362,5 @@ DECLARE_EXTERN_FILTER_INIT(oggdec);
        AACDEC_FILTER \
        OGGDEC_FILTER \
        { .name = NULL } };
+
+
index 401a03c582f418d6590a7fc27007becdfab6d73d..a1374b7319b1e66167ab316c3ee03a588f5a8327 100644 (file)
--- a/mp3dec.c
+++ b/mp3dec.c
@@ -74,14 +74,13 @@ next_frame:
        mad_synth_frame(&pmd->synth, &pmd->frame);
 
        for (i = 0; i < pmd->synth.pcm.length; i++) {
-               /* output format: unsigned 16 bit little endian */
                signed short s = MAD_TO_SHORT(pmd->synth.pcm.samples[0][i]);
-               fn->buf[fn->loaded++] = s & 0xff;
-               fn->buf[fn->loaded++] = s >> 8;
+               write_int16_host_endian(fn->buf + fn->loaded, s);
+               fn->loaded += 2;
                if (MAD_NCHANNELS(&pmd->frame.header) == 2) { /* stereo */
                        s = MAD_TO_SHORT(pmd->synth.pcm.samples[1][i]);
-                       fn->buf[fn->loaded++] = s & 0xff;
-                       fn->buf[fn->loaded++] = s >> 8;
+                       write_int16_host_endian(fn->buf + fn->loaded, s);
+                       fn->loaded += 2;
                }
                if (fn->loaded != fn->bufsize) /* output buffer not full */
                        continue;
index 929e2eccf7df08435b2d59f17561a6012f7822ee..82ac9b43884675cbffcd9f79bf2cadd9c38e8a56 100644 (file)
--- a/oggdec.c
+++ b/oggdec.c
 
 /** \cond some internal constants */
 #define BITS 16
+#ifdef WORDS_BIGENDIAN
+#define ENDIAN 1
+#else
 #define ENDIAN 0
+#endif
 #define SIGN 1
 /** \endcond */
 
index 107746c78e83f8f875d640a27114ee0d57eb01fa..f13ec6e1988e00ebce5a9639167650fceea24d6d 100644 (file)
@@ -111,14 +111,8 @@ static void fill_buffer(struct osx_buffer *b, short *source, long size)
                b->size = size;
        }
        dest = b->buffer;
-       while (size--) {
-               char *tmp = (char *)source;
-               char c = *tmp;
-               *tmp = *(tmp + 1);
-               *(tmp + 1) = c;
-               /* *dest++ = ((*source++) + 32768) / 65536.0; */
+       while (size--)
                *dest++ = (*source++) / 32768.0;
-       }
        b->ptr = b->buffer;
        b->remaining = b->size;
 }