CVS: rdesktop rdpsnd_dsp.c,1.17,1.18
Michael Gernoth <[email protected]> Sun, 01 Oct 2006 14:46:40 -0700
| Newsgroups | gmane.network.rdesktop.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/rdesktop/rdesktop
In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv30977
Modified Files:
rdpsnd_dsp.c
Log Message:
convert between different numbers of input and output channels
Index: rdpsnd_dsp.c
===================================================================
RCS file: /cvsroot/rdesktop/rdesktop/rdpsnd_dsp.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** rdpsnd_dsp.c 1 Oct 2006 19:05:30 -0000 1.17
--- rdpsnd_dsp.c 1 Oct 2006 21:46:38 -0000 1.18
***************
*** 184,189 ****
#endif
int innum, outnum;
! static BOOL warned = False;
! unsigned char *tmpdata = NULL;
int samplewidth = format->wBitsPerSample / 8;
int outsize = 0;
--- 184,188 ----
#endif
int innum, outnum;
! unsigned char *tmpdata = NULL, *tmp = NULL;
int samplewidth = format->wBitsPerSample / 8;
int outsize = 0;
***************
*** 200,203 ****
--- 199,227 ----
#endif
+ if (resample_to_channels != format->nChannels)
+ {
+ int newsize = (size / format->nChannels) * resample_to_channels;
+ tmpdata = xmalloc(newsize);
+
+ for (i = 0; i < newsize / samplewidth; i++)
+ {
+ if (format->nChannels > resample_to_channels)
+ memcpy(tmpdata + (i * samplewidth),
+ in +
+ (((i * format->nChannels) / resample_to_channels) *
+ samplewidth), samplewidth);
+ else
+ memcpy(tmpdata + (i * samplewidth),
+ in +
+ (((i / resample_to_channels) * format->nChannels +
+ (i % format->nChannels)) * samplewidth), samplewidth);
+
+ }
+
+ in = tmpdata;
+ size = newsize;
+ }
+
+
/* Expand 8bit input-samples to 16bit */
#ifndef HAVE_LIBSAMPLERATE /* libsamplerate needs 16bit samples */
***************
*** 208,211 ****
--- 232,236 ----
if (format->wBitsPerSample == 8)
{
+ tmp = tmpdata;
tmpdata = xmalloc(size * 2);
for (i = 0; i < size; i++)
***************
*** 217,227 ****
samplewidth = 16 / 2;
size *= 2;
- }
- }
! if (resample_to_channels != format->nChannels)
! {
! warning("unsupported resample-settings (%u -> %u/%u -> %u/%u -> %u), not resampling!\n", format->nSamplesPerSec, resample_to_srate, format->wBitsPerSample, resample_to_bitspersample, format->nChannels, resample_to_channels);
! warned = True;
}
--- 242,249 ----
samplewidth = 16 / 2;
size *= 2;
! if (tmp != NULL)
! xfree(tmp);
! }
}
***************
*** 287,292 ****
{
memcpy(*out + (i * resample_to_channels * samplewidth) + (samplewidth * j),
! in + (source * resample_to_channels * samplewidth) + (samplewidth * j),
! samplewidth);
}
}
--- 309,314 ----
{
memcpy(*out + (i * resample_to_channels * samplewidth) + (samplewidth * j),
! in + (source * resample_to_channels * samplewidth) +
! (samplewidth * j), samplewidth);
}
}
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV