⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 src.c

📁 au1200 linux2.6.11 硬件解码mae驱动和maiplayer播放器源码
💻 C
📖 第 1 页 / 共 2 页
字号:
        *length *= 8;        break;      case CSR_QUADRUPLE:        #ifdef USE_CUBIC_SPLINE_FILTER          upsample_cubic_spline4x(buf, conversion_buffer, loop, 1);        #else          for (jj = 0, ii = 0; ii < loop; ii++, jj += 4)          {            conversion_buffer[jj] = buf[ii];            conversion_buffer[jj+1] = buf[ii];            conversion_buffer[jj+2] = buf[ii];            conversion_buffer[jj+3] = buf[ii];          }        #endif        *length *= 4;        break;      case CSR_DOUBLE:        #ifdef USE_CUBIC_SPLINE_FILTER          upsample_cubic_spline2x(buf, conversion_buffer, loop, 1);        #else          for (jj = 0, ii = 0; ii < loop; ii++, jj += 2)          {            conversion_buffer[jj] = buf[ii];            conversion_buffer[jj+1] = buf[ii];          }        #endif        *length *= 2;        break;      case CSR_HALVE:        for (jj = 0, ii = 0; ii < loop; ii += 2, jj++)          conversion_buffer[jj] = buf[ii];        *length /= 2;        break;      case CSR_QUARTER:        for (jj = 0, ii = 0; ii < loop; ii += 4, jj++)          conversion_buffer[jj] = buf[ii];        *length /= 4;        break;      default: // one to one, no rate conversion        for (jj = 0; jj < loop; jj++)          conversion_buffer[jj] = buf[jj];        break;    }    return conversion_buffer;  }  else if (number_of_channels == 2) /* interleaved stereo loops */  {    switch (sampling_rate_conversion_factor)    {      case CSR_OCTUPLE:        for (jj = 0, ii = 0; ii < loop; ii += 2, jj += 16)        {          conversion_buffer[jj] = buf[ii];          conversion_buffer[jj+2] = buf[ii];          conversion_buffer[jj+4] = buf[ii];          conversion_buffer[jj+6] = buf[ii];          conversion_buffer[jj+8] = buf[ii];          conversion_buffer[jj+10] = buf[ii];          conversion_buffer[jj+12] = buf[ii];          conversion_buffer[jj+14] = buf[ii];          conversion_buffer[jj+1] = buf[ii+1];          conversion_buffer[jj+3] = buf[ii+1];          conversion_buffer[jj+5] = buf[ii+1];          conversion_buffer[jj+7] = buf[ii+1];          conversion_buffer[jj+9] = buf[ii+1];          conversion_buffer[jj+11] = buf[ii+1];          conversion_buffer[jj+13] = buf[ii+1];          conversion_buffer[jj+15] = buf[ii+1];        }        *length *= 8;        break;      case CSR_QUADRUPLE:        #ifdef USE_CUBIC_SPLINE_FILTER          upsample_cubic_spline4x(buf, conversion_buffer, loop, 2);        #else          for (jj = 0, ii = 0; ii < loop; ii += 2, jj += 8)          {            conversion_buffer[jj] = buf[ii];            conversion_buffer[jj+2] = buf[ii];            conversion_buffer[jj+4] = buf[ii];            conversion_buffer[jj+6] = buf[ii];            conversion_buffer[jj+1] = buf[ii+1];            conversion_buffer[jj+3] = buf[ii+1];            conversion_buffer[jj+5] = buf[ii+1];            conversion_buffer[jj+7] = buf[ii+1];          }        #endif        *length *= 4;        break;      case CSR_DOUBLE:        #ifdef USE_CUBIC_SPLINE_FILTER          upsample_cubic_spline2x(buf, conversion_buffer, loop, 2);        #else          for (jj = 0, ii = 0; ii < loop; ii += 2, jj += 4)          {            conversion_buffer[jj] = buf[ii];            conversion_buffer[jj+2] = buf[ii];            conversion_buffer[jj+1] = buf[ii+1];            conversion_buffer[jj+3] = buf[ii+1];          }        #endif        *length *= 2;        break;      case CSR_HALVE:        for (jj = 0, ii = 0; ii < loop; ii += 4, jj += 2)        {          conversion_buffer[jj] = buf[ii];          conversion_buffer[jj+1] = buf[ii+1];        }        *length /= 2;        break;      case CSR_QUARTER:        for (jj = 0, ii = 0; ii < loop; ii += 8, jj += 2)        {          conversion_buffer[jj] = buf[ii];          conversion_buffer[jj+1] = buf[ii+1];        }        *length /= 4;        break;      default: // one to one, no rate conversion        for (jj = 0; jj < loop; jj++)          conversion_buffer[jj] = buf[jj];        break;    }    return conversion_buffer;  }  else // error condition  {    *length = 0;  }  return NULL;}static int supported_rates[] ={     -1,  /* not a valid rate, but used for comparisons */   8000,  32000,  44100,  48000,  #ifdef DAC_MID_RATES_MIGHT_BE_SUPPORTED    200000, /* not a valid rate, but used for comparisons */    200000, /* not a valid rate, but used for comparisons */  #elif defined(DAC_MID_RATES_SUPPORTED)    88200,    96000,    #ifdef DAC_HIGH_RATES_SUPPORTED      176400,      192000,    #endif  #endif  200000, /* not a valid rate, but used for comparisons */};#ifdef DAC_MID_RATES_MIGHT_BE_SUPPORTEDstatic void check_for_mid_rates(int audio_output_stream){  #if defined(WIN32) || defined(UNDER_CE)    /* nothing to do? */  #else/* Linux */    int sampling_rate;    sampling_rate = 88200;  //printf("Trying to set %d \n", sampling_rate);    if (ioctl(audio_output_stream, SNDCTL_DSP_SPEED, &sampling_rate) != -1)    {  //printf("Has %d \n", sampling_rate);      if (sampling_rate == 88200)      {  //printf("Has 88200 \n");        supported_rates[5] = 88200;      }    }         sampling_rate = 96000;  //printf("Trying to set %d \n", sampling_rate);    if (ioctl(audio_output_stream, SNDCTL_DSP_SPEED, &sampling_rate) != -1)    {  //printf("Has %d \n", sampling_rate);      if (sampling_rate == 96000)      {  //printf("Has 96000 \n");        supported_rates[6] = 96000;      }    }  #endif}#endif int check_sampling_rate(int test_sampling_rate, int *sampling_rate, int buffer_max_size){  int ii;     csr_leftover = 0;  for (ii = 0; ii < ((sizeof(supported_rates)/sizeof(int))-1); ii++)  {    if ((*sampling_rate >= supported_rates[ii]) && (*sampling_rate < supported_rates[ii+1]))    {      DPRINTF(("%d: test rates %d %d %d\n", ii, supported_rates[ii], *sampling_rate, supported_rates[ii+1]));      *sampling_rate = supported_rates[ii];      if (supported_rates[ii] < 1)        *sampling_rate = supported_rates[ii+1];      break;    }  }  if (test_sampling_rate != *sampling_rate)  {    INFO_PRINTF(("sampling rate %d not supported (would clamp to %d)\n", test_sampling_rate, *sampling_rate));    DPRINTF(("sampling rate %d not supported (would clamp to %d)\n", test_sampling_rate, *sampling_rate));    switch (test_sampling_rate)    {      /*         Supported rates are 8, 32, 44.1, and 48 khz. With I2S add 88.2 and 96 khz.         Possible rates are 8, 11.025, 12, 16, 22.050, 24, 32, 44.1, 48, 64, 88.2, 96, 176.4, and 192.      */      case 4000:        *sampling_rate = 32000;        sampling_rate_conversion_factor = CSR_OCTUPLE;        break;      case 6000:        *sampling_rate = 48000;        sampling_rate_conversion_factor = CSR_OCTUPLE;        break;      case 8000:        *sampling_rate = 32000;        sampling_rate_conversion_factor = CSR_QUADRUPLE;        break;      case 11025:        *sampling_rate = 44100;        sampling_rate_conversion_factor = CSR_QUADRUPLE;        break;      case 12000:        *sampling_rate = 48000;        sampling_rate_conversion_factor = CSR_QUADRUPLE;        break;      case 16000:      case 16384:        *sampling_rate = 32000;        sampling_rate_conversion_factor = CSR_DOUBLE;        break;      case 22050:        *sampling_rate = 44100;        sampling_rate_conversion_factor = CSR_DOUBLE;        break;      case 24000:        *sampling_rate = 48000;        sampling_rate_conversion_factor = CSR_DOUBLE;        break;      case 32768:        *sampling_rate = 32000;        sampling_rate_conversion_factor = CSR_NONE;        break;      case 64000:        *sampling_rate = 32000;        sampling_rate_conversion_factor = CSR_HALVE;        break;      case 88200:        *sampling_rate = 44100;        sampling_rate_conversion_factor = CSR_HALVE;        break;      case 96000:        *sampling_rate = 48000;        sampling_rate_conversion_factor = CSR_HALVE;        break;      case 176400:        *sampling_rate = 44100;        sampling_rate_conversion_factor = CSR_QUARTER;        break;      case 192000:        *sampling_rate = 48000;        sampling_rate_conversion_factor = CSR_QUARTER;        break;      default:        {          int ii;           for (ii = 0; ii < (sizeof(supported_rates)/sizeof(int)); ii++)          {            if (test_sampling_rate <= supported_rates[ii])            {              *sampling_rate = supported_rates[ii];              break;            }          }        }        INFO_PRINTF(("sampling rate %d will be clamped to %d, which may alter the pitch significantly.\n", test_sampling_rate, *sampling_rate));        break;    }    INFO_PRINTF(("sampling rate %d will be changed to %d to conform to availble output rates.\n", test_sampling_rate, *sampling_rate));    #if !(defined(WIN32) || defined(UNDER_CE))//printf("Trying to set sampling rate to %d\n", *sampling_rate);       if (ioctl(audio_output_stream, SNDCTL_DSP_SPEED, sampling_rate) == -1)      {        INFO_PRINTF(("Bad sampling rate %d\n", *sampling_rate));        return -1;      }//printf("sampling rate is reportedly set to %d\n\n", *sampling_rate);    #endif  }  else    sampling_rate_conversion_factor = CSR_NONE;  DPRINTF(("sampling_rate_conversion_factor %d\n", sampling_rate_conversion_factor));  if (sampling_rate_conversion_factor)  {    #ifdef USE_CUBIC_SPLINE_FILTER      int cc;    #endif    if (conversion_buffer != NULL)      free(conversion_buffer);    /* The amount mallocked is base on the sampling_rate_conversion_factor which        is 8 times the real conversion, hence the divide by 8 (>>3). */    if ((conversion_buffer = (short *)malloc((sampling_rate_conversion_factor * buffer_max_size * sizeof(short) * number_of_channels)>>3)) == NULL)    {      DPRINTF(("Unable to allocate conversion buffer\n"));      return -1;    }    #ifdef USE_CUBIC_SPLINE_FILTER      for (cc = 0; cc < MAX_AUDIO_CHANNELS; cc++)           {        fir[cc].writeptr = fir[cc].delay_line;        fir[cc].readptr  = fir[cc].delay_line;        fir[cc].delay_line_length = SPLINE_FIR_LENGTH_MAX;      }    #endif  }  return 0;}#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -