changeset 15468:bef6d46722ef

Fix for stereo files Patch by KAICHO > s_naray at yahoo dot co dot jp <, forwarded by mike
author rtognimp
date Sat, 14 May 2005 15:47:49 +0000
parents fed9adae2f26
children a2288868a116
files libmpdemux/demux_film.c
diffstat 1 files changed, 22 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/demux_film.c	Sat May 14 15:44:52 2005 +0000
+++ b/libmpdemux/demux_film.c	Sat May 14 15:47:49 2005 +0000
@@ -132,6 +132,28 @@
         dp->buffer[i + 1] = byte_swap;
       }
 
+    /* for SegaSaturn .cpk file, translate audio data if stereo */
+    if (sh_audio->wf->nChannels == 2) {
+      if (sh_audio->wf->wBitsPerSample == 8) {
+        unsigned char* tmp = dp->buffer;
+        unsigned char  buf[film_chunk.chunk_size];
+        for(i = 0; i < film_chunk.chunk_size/2; i++) {
+          buf[i*2] = tmp[i];
+          buf[i*2+1] = tmp[film_chunk.chunk_size/2+i];
+        }
+        memcpy( tmp, buf, film_chunk.chunk_size );
+      }
+      else {/* for 16bit */
+        unsigned short* tmp = dp->buffer;
+        unsigned short  buf[film_chunk.chunk_size/2];
+        for(i = 0; i < film_chunk.chunk_size/4; i++) {
+          buf[i*2] = tmp[i];
+          buf[i*2+1] = tmp[film_chunk.chunk_size/4+i];
+        }
+        memcpy( tmp, buf, film_chunk.chunk_size );
+      }
+    }
+
     // append packet to DS stream
     ds_add_packet(demuxer->audio, dp);
    }