From c9314d8a6bab23f0c5af345f90ff196b1e0c4d64 Mon Sep 17 00:00:00 2001 From: rtognimp Date: Sat, 14 May 2005 15:47:49 +0000 Subject: [PATCH] Fix for stereo files Patch by KAICHO > s_naray at yahoo dot co dot jp <, forwarded by mike git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@15469 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libmpdemux/demux_film.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/libmpdemux/demux_film.c b/libmpdemux/demux_film.c index 2b0b9a5948..4c19448785 100644 --- a/libmpdemux/demux_film.c +++ b/libmpdemux/demux_film.c @@ -132,6 +132,28 @@ int demux_film_fill_buffer(demuxer_t *demuxer) 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); }