# HG changeset patch # User rtognimp # Date 1116085669 0 # Node ID bef6d46722ef4d0b8d677cbcd483150f0abf8acb # Parent fed9adae2f2601530d1fea7bead4ffb8ace91902 Fix for stereo files Patch by KAICHO > s_naray at yahoo dot co dot jp <, forwarded by mike diff -r fed9adae2f26 -r bef6d46722ef libmpdemux/demux_film.c --- 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); }