1
mirror of https://github.com/mpv-player/mpv synced 2025-01-16 22:37:28 +01:00

Slightly simplify read_buffer code

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@25675 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
reimar 2008-01-11 20:32:42 +00:00
parent 1b4cd62e0b
commit 023340d6bd

View File

@ -136,18 +136,18 @@ static int write_buffer(unsigned char* data, int len) {
static int read_buffer(float **bufs, int cnt, int num_bufs) {
int buffered = buf_used();
int i, j;
int orig_cnt = cnt;
if (cnt * sizeof(float) * num_bufs > buffered)
if (cnt * sizeof(float) * num_bufs > buffered) {
int orig_cnt = cnt;
cnt = buffered / sizeof(float) / num_bufs;
for (i = 0; i < num_bufs; i++)
memset(&bufs[i][cnt], 0, (orig_cnt - cnt) * sizeof(float));
}
for (i = 0; i < cnt; i++) {
for (j = 0; j < num_bufs; j++) {
bufs[j][i] = *((float *)(&buffer[read_pos]));
bufs[j][i] = *(float *)&buffer[read_pos];
read_pos = (read_pos + sizeof(float)) % BUFFSIZE;
}
}
for (i = cnt; i < orig_cnt; i++)
for (j = 0; j < num_bufs; j++)
bufs[j][i] = 0;
return cnt;
}