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
This commit is contained in:
rtognimp 2005-05-14 15:47:49 +00:00
parent edee61232e
commit c9314d8a6b
1 changed files with 22 additions and 0 deletions

View File

@ -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);
}