/[rdesktop]/sourceforge.net/trunk/rdesktop/rdpsnd_dsp.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /sourceforge.net/trunk/rdesktop/rdpsnd_dsp.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1276 by stargo, Sun Oct 1 12:16:50 2006 UTC revision 1277 by stargo, Sun Oct 1 12:26:01 2006 UTC
# Line 159  rdpsnd_dsp_resample(unsigned char **out, Line 159  rdpsnd_dsp_resample(unsigned char **out,
159          int samplewidth = format->wBitsPerSample / 8;          int samplewidth = format->wBitsPerSample / 8;
160          int i;          int i;
161    
162            if ((resample_to_bitspersample == format->wBitsPerSample) &&
163                (resample_to_channels == format->nChannels) &&
164                (resample_to_srate == format->nSamplesPerSec))
165                    return 0;
166    
167          if ((resample_to_bitspersample != format->wBitsPerSample) ||          if ((resample_to_bitspersample != format->wBitsPerSample) ||
168              (resample_to_channels != format->nChannels) ||              (resample_to_channels != format->nChannels) || (format->nSamplesPerSec != 22050))
             ((format->nSamplesPerSec != 44100) && (format->nSamplesPerSec != 22050)))  
169          {          {
170                  if (!warned)                  if (!warned)
171                  {                  {
# Line 172  rdpsnd_dsp_resample(unsigned char **out, Line 176  rdpsnd_dsp_resample(unsigned char **out,
176                  return 0;                  return 0;
177          }          }
178    
179          if (format->nSamplesPerSec == 22050)          outsize = size * 2;
180          {          *out = xmalloc(outsize);
                 outsize = size * 2;  
                 *out = xmalloc(outsize);  
   
                 /* Resample to 44100 */  
                 for (i = 0; i < (size / samplewidth); i++)  
                 {  
                         /* On a stereo-channel we must make sure that left and right  
                            does not get mixed up, so we need to expand the sample-  
                            data with channels in mind: 1234 -> 12123434  
                            If we have a mono-channel, we can expand the data by simply  
                            doubling the sample-data: 1234 -> 11223344 */  
                         if (resample_to_channels == 2)  
                                 offset = ((i * 2) - (i & 1)) * samplewidth;  
                         else  
                                 offset = (i * 2) * samplewidth;  
   
                         memcpy(*out + offset, in + (i * samplewidth), samplewidth);  
                         memcpy(*out + (resample_to_channels * samplewidth + offset),  
                                in + (i * samplewidth), samplewidth);  
181    
182                  }          /* Resample from 22050 to 44100 */
183          }          for (i = 0; i < (size / samplewidth); i++)
         else  
184          {          {
185                  outsize = 0;                  /* On a stereo-channel we must make sure that left and right
186                       does not get mixed up, so we need to expand the sample-
187                       data with channels in mind: 1234 -> 12123434
188                       If we have a mono-channel, we can expand the data by simply
189                       doubling the sample-data: 1234 -> 11223344 */
190                    if (resample_to_channels == 2)
191                            offset = ((i * 2) - (i & 1)) * samplewidth;
192                    else
193                            offset = (i * 2) * samplewidth;
194    
195                    memcpy(*out + offset, in + (i * samplewidth), samplewidth);
196                    memcpy(*out + (resample_to_channels * samplewidth + offset),
197                           in + (i * samplewidth), samplewidth);
198    
199          }          }
200    
201          return outsize;          return outsize;
# Line 222  rdpsnd_dsp_process(STREAM s, struct audi Line 219  rdpsnd_dsp_process(STREAM s, struct audi
219          out.data = NULL;          out.data = NULL;
220    
221          if (current_driver->wave_out_format_supported == rdpsnd_dsp_resample_supported)          if (current_driver->wave_out_format_supported == rdpsnd_dsp_resample_supported)
         {  
222                  out.size = rdpsnd_dsp_resample(&out.data, s->data, s->size, format);                  out.size = rdpsnd_dsp_resample(&out.data, s->data, s->size, format);
         }  
223    
224          if (out.data == NULL)          if (out.data == NULL)
225          {          {

Legend:
Removed from v.1276  
changed lines
  Added in v.1277

  ViewVC Help
Powered by ViewVC 1.1.26