11#define SINC_MAGIC_MARKER MAKE_MAGIC (' ', 's', 'i', 'n', 'c', ' ')
16#define MAKE_INCREMENT_T(x) ((increment_t) (x))
19#define FP_ONE ((double) (((increment_t) 1) << SHIFT_BITS))
20#define INV_FP_ONE (1.0 / FP_ONE)
48 double left_calc [128], right_calc [128] ;
98 return "Best Sinc Interpolator" ;
101 return "Medium Sinc Interpolator" ;
104 return "Fastest Sinc Interpolator" ;
117 return "Band limited sinc interpolation, fastest, 97dB SNR, 80% BW." ;
120 return "Band limited sinc interpolation, medium quality, 121dB SNR, 90% BW." ;
123 return "Band limited sinc interpolation, best quality, 144dB SNR, 96% BW." ;
147 memset (&temp_filter, 0,
sizeof (temp_filter)) ;
215 memset (&temp_filter, 0xEE,
sizeof (temp_filter)) ;
258 int data_index, coeff_count, indx ;
264 filter_index = start_filter_index ;
265 coeff_count = (max_filter_index - filter_index) / increment ;
266 filter_index = filter_index + coeff_count * increment ;
267 data_index =
filter->b_current - coeff_count ;
274 icoeff =
filter->coeffs [indx] + fraction * (
filter->coeffs [indx + 1] -
filter->coeffs [indx]) ;
276 left += icoeff *
filter->buffer [data_index] ;
278 filter_index -= increment ;
279 data_index = data_index + 1 ;
284 filter_index = increment - start_filter_index ;
285 coeff_count = (max_filter_index - filter_index) / increment ;
286 filter_index = filter_index + coeff_count * increment ;
287 data_index =
filter->b_current + 1 + coeff_count ;
294 icoeff =
filter->coeffs [indx] + fraction * (
filter->coeffs [indx + 1] -
filter->coeffs [indx]) ;
298 filter_index -= increment ;
299 data_index = data_index - 1 ;
309 double input_index, src_ratio,
count, float_increment,
terminate, rem ;
311 int half_filter_chan_len, samples_in_hand ;
319 if (
sizeof (
filter->buffer [0]) !=
sizeof (
data->data_in [0]))
340 float_increment =
filter->index_inc ;
354 if (samples_in_hand <= half_filter_chan_len)
359 if (samples_in_hand <= half_filter_chan_len)
364 if (
filter->b_real_end >= 0)
372 float_increment =
filter->index_inc * (src_ratio < 1.0 ? src_ratio : 1.0) ;
375 start_filter_index =
double_to_fp (input_index * float_increment) ;
382 input_index += 1.0 / src_ratio ;
402{
double fraction,
left [2],
right [2], icoeff ;
404 int data_index, coeff_count, indx ;
410 filter_index = start_filter_index ;
411 coeff_count = (max_filter_index - filter_index) / increment ;
412 filter_index = filter_index + coeff_count * increment ;
413 data_index =
filter->b_current -
filter->channels * coeff_count ;
420 icoeff =
filter->coeffs [indx] + fraction * (
filter->coeffs [indx + 1] -
filter->coeffs [indx]) ;
422 left [0] += icoeff *
filter->buffer [data_index] ;
423 left [1] += icoeff *
filter->buffer [data_index + 1] ;
425 filter_index -= increment ;
426 data_index = data_index + 2 ;
431 filter_index = increment - start_filter_index ;
432 coeff_count = (max_filter_index - filter_index) / increment ;
433 filter_index = filter_index + coeff_count * increment ;
434 data_index =
filter->b_current +
filter->channels * (1 + coeff_count) ;
441 icoeff =
filter->coeffs [indx] + fraction * (
filter->coeffs [indx + 1] -
filter->coeffs [indx]) ;
443 right [0] += icoeff *
filter->buffer [data_index] ;
444 right [1] += icoeff *
filter->buffer [data_index + 1] ;
446 filter_index -= increment ;
447 data_index = data_index - 2 ;
458 double input_index, src_ratio,
count, float_increment,
terminate, rem ;
460 int half_filter_chan_len, samples_in_hand ;
468 if (
sizeof (
filter->buffer [0]) !=
sizeof (
data->data_in [0]))
489 float_increment =
filter->index_inc ;
503 if (samples_in_hand <= half_filter_chan_len)
508 if (samples_in_hand <= half_filter_chan_len)
513 if (
filter->b_real_end >= 0)
521 float_increment =
filter->index_inc * (src_ratio < 1.0 ? src_ratio : 1.0) ;
524 start_filter_index =
double_to_fp (input_index * float_increment) ;
530 input_index += 1.0 / src_ratio ;
550{
double fraction,
left [4],
right [4], icoeff ;
552 int data_index, coeff_count, indx ;
558 filter_index = start_filter_index ;
559 coeff_count = (max_filter_index - filter_index) / increment ;
560 filter_index = filter_index + coeff_count * increment ;
561 data_index =
filter->b_current -
filter->channels * coeff_count ;
568 icoeff =
filter->coeffs [indx] + fraction * (
filter->coeffs [indx + 1] -
filter->coeffs [indx]) ;
570 left [0] += icoeff *
filter->buffer [data_index] ;
571 left [1] += icoeff *
filter->buffer [data_index + 1] ;
572 left [2] += icoeff *
filter->buffer [data_index + 2] ;
573 left [3] += icoeff *
filter->buffer [data_index + 3] ;
575 filter_index -= increment ;
576 data_index = data_index + 4 ;
581 filter_index = increment - start_filter_index ;
582 coeff_count = (max_filter_index - filter_index) / increment ;
583 filter_index = filter_index + coeff_count * increment ;
584 data_index =
filter->b_current +
filter->channels * (1 + coeff_count) ;
591 icoeff =
filter->coeffs [indx] + fraction * (
filter->coeffs [indx + 1] -
filter->coeffs [indx]) ;
593 right [0] += icoeff *
filter->buffer [data_index] ;
594 right [1] += icoeff *
filter->buffer [data_index + 1] ;
595 right [2] += icoeff *
filter->buffer [data_index + 2] ;
596 right [3] += icoeff *
filter->buffer [data_index + 3] ;
598 filter_index -= increment ;
599 data_index = data_index - 4 ;
612 double input_index, src_ratio,
count, float_increment,
terminate, rem ;
614 int half_filter_chan_len, samples_in_hand ;
622 if (
sizeof (
filter->buffer [0]) !=
sizeof (
data->data_in [0]))
643 float_increment =
filter->index_inc ;
657 if (samples_in_hand <= half_filter_chan_len)
662 if (samples_in_hand <= half_filter_chan_len)
667 if (
filter->b_real_end >= 0)
675 float_increment =
filter->index_inc * (src_ratio < 1.0 ? src_ratio : 1.0) ;
678 start_filter_index =
double_to_fp (input_index * float_increment) ;
684 input_index += 1.0 / src_ratio ;
704{
double fraction,
left [6],
right [6], icoeff ;
706 int data_index, coeff_count, indx ;
712 filter_index = start_filter_index ;
713 coeff_count = (max_filter_index - filter_index) / increment ;
714 filter_index = filter_index + coeff_count * increment ;
715 data_index =
filter->b_current -
filter->channels * coeff_count ;
722 icoeff =
filter->coeffs [indx] + fraction * (
filter->coeffs [indx + 1] -
filter->coeffs [indx]) ;
724 left [0] += icoeff *
filter->buffer [data_index] ;
725 left [1] += icoeff *
filter->buffer [data_index + 1] ;
726 left [2] += icoeff *
filter->buffer [data_index + 2] ;
727 left [3] += icoeff *
filter->buffer [data_index + 3] ;
728 left [4] += icoeff *
filter->buffer [data_index + 4] ;
729 left [5] += icoeff *
filter->buffer [data_index + 5] ;
731 filter_index -= increment ;
732 data_index = data_index + 6 ;
737 filter_index = increment - start_filter_index ;
738 coeff_count = (max_filter_index - filter_index) / increment ;
739 filter_index = filter_index + coeff_count * increment ;
740 data_index =
filter->b_current +
filter->channels * (1 + coeff_count) ;
747 icoeff =
filter->coeffs [indx] + fraction * (
filter->coeffs [indx + 1] -
filter->coeffs [indx]) ;
749 right [0] += icoeff *
filter->buffer [data_index] ;
750 right [1] += icoeff *
filter->buffer [data_index + 1] ;
751 right [2] += icoeff *
filter->buffer [data_index + 2] ;
752 right [3] += icoeff *
filter->buffer [data_index + 3] ;
753 right [4] += icoeff *
filter->buffer [data_index + 4] ;
754 right [5] += icoeff *
filter->buffer [data_index + 5] ;
756 filter_index -= increment ;
757 data_index = data_index - 6 ;
772 double input_index, src_ratio,
count, float_increment,
terminate, rem ;
774 int half_filter_chan_len, samples_in_hand ;
782 if (
sizeof (
filter->buffer [0]) !=
sizeof (
data->data_in [0]))
803 float_increment =
filter->index_inc ;
817 if (samples_in_hand <= half_filter_chan_len)
822 if (samples_in_hand <= half_filter_chan_len)
827 if (
filter->b_real_end >= 0)
835 float_increment =
filter->index_inc * (src_ratio < 1.0 ? src_ratio : 1.0) ;
838 start_filter_index =
double_to_fp (input_index * float_increment) ;
844 input_index += 1.0 / src_ratio ;
864{
double fraction, icoeff ;
868 int data_index, coeff_count, indx, ch ;
877 filter_index = start_filter_index ;
878 coeff_count = (max_filter_index - filter_index) / increment ;
879 filter_index = filter_index + coeff_count * increment ;
888 icoeff =
filter->coeffs [indx] + fraction * (
filter->coeffs [indx + 1] -
filter->coeffs [indx]) ;
900 left [ch] += icoeff *
filter->buffer [data_index + ch] ;
903 left [ch] += icoeff *
filter->buffer [data_index + ch] ;
906 left [ch] += icoeff *
filter->buffer [data_index + ch] ;
909 left [ch] += icoeff *
filter->buffer [data_index + ch] ;
912 left [ch] += icoeff *
filter->buffer [data_index + ch] ;
915 left [ch] += icoeff *
filter->buffer [data_index + ch] ;
918 left [ch] += icoeff *
filter->buffer [data_index + ch] ;
921 left [ch] += icoeff *
filter->buffer [data_index + ch] ;
926 filter_index -= increment ;
927 data_index = data_index +
channels ;
932 filter_index = increment - start_filter_index ;
933 coeff_count = (max_filter_index - filter_index) / increment ;
934 filter_index = filter_index + coeff_count * increment ;
942 icoeff =
filter->coeffs [indx] + fraction * (
filter->coeffs [indx + 1] -
filter->coeffs [indx]) ;
950 right [ch] += icoeff *
filter->buffer [data_index + ch] ;
953 right [ch] += icoeff *
filter->buffer [data_index + ch] ;
956 right [ch] += icoeff *
filter->buffer [data_index + ch] ;
959 right [ch] += icoeff *
filter->buffer [data_index + ch] ;
962 right [ch] += icoeff *
filter->buffer [data_index + ch] ;
965 right [ch] += icoeff *
filter->buffer [data_index + ch] ;
968 right [ch] += icoeff *
filter->buffer [data_index + ch] ;
971 right [ch] += icoeff *
filter->buffer [data_index + ch] ;
976 filter_index -= increment ;
977 data_index = data_index -
channels ;
1019 double input_index, src_ratio,
count, float_increment,
terminate, rem ;
1021 int half_filter_chan_len, samples_in_hand ;
1029 if (
sizeof (
filter->buffer [0]) !=
sizeof (
data->data_in [0]))
1050 float_increment =
filter->index_inc ;
1064 if (samples_in_hand <= half_filter_chan_len)
1066 return psrc->
error ;
1069 if (samples_in_hand <= half_filter_chan_len)
1074 if (
filter->b_real_end >= 0)
1082 float_increment =
filter->index_inc * (src_ratio < 1.0 ? src_ratio : 1.0) ;
1085 start_filter_index =
double_to_fp (input_index * float_increment) ;
1091 input_index += 1.0 / src_ratio ;
1116 if (
filter->b_real_end >= 0)
1119 if (
filter->b_current == 0)
1123 len =
filter->b_len - 2 * half_filter_chan_len ;
1125 filter->b_current =
filter->b_end = half_filter_chan_len ;
1137 filter->b_current = half_filter_chan_len ;
1147 if (len < 0 || filter->b_end +
len >
filter->b_len)
1157 filter->b_end -
filter->b_current < 2 * half_filter_chan_len &&
data->end_of_input)
1162 if (
filter->b_len -
filter->b_end < half_filter_chan_len + 5)
1168 filter->b_current = half_filter_chan_len ;
1173 len = half_filter_chan_len + 5 ;
1175 if (len < 0 || filter->b_end +
len >
filter->b_len)
while(CdLookupNextInitialFileDirent(IrpContext, Fcb, FileContext))
static const struct fastest_coeffs_s fastest_coeffs
GLint GLint GLint GLint GLint x
GLuint GLuint GLsizei count
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
GLenum GLenum GLenum GLenum GLenum scale
GLenum GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * bits
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
static const struct slow_high_qual_coeffs_s slow_high_qual_coeffs
_Check_return_ _CRT_JIT_INTRINSIC double __cdecl fabs(_In_ double x)
_Check_return_ __CRT_INLINE long lrint(_In_ double x)
void MSVCRT() terminate()
static const struct slow_mid_qual_coeffs_s slow_mid_qual_coeffs
#define memcpy(s1, s2, n)
#define memmove(s1, s2, n)
static float(__cdecl *square_half_float)(float x
@ SRC_SINC_MEDIUM_QUALITY
static int is_bad_src_ratio(double ratio)
@ SRC_ERR_SIZE_INCOMPATIBILITY
@ SRC_ERR_BAD_INTERNAL_STATE
@ SRC_ERR_BAD_CHANNEL_COUNT
@ SRC_ERR_SINC_PREPARE_DATA_BAD_LEN
static double fmod_one(double x)
static double calc_output_single(SINC_FILTER *filter, increment_t increment, increment_t start_filter_index)
static increment_t double_to_fp(double x)
static void calc_output_hex(SINC_FILTER *filter, increment_t increment, increment_t start_filter_index, double scale, float *output)
static int sinc_multichan_vari_process(SRC_PRIVATE *psrc, SRC_DATA *data)
const char * sinc_get_description(int src_enum)
static void calc_output_stereo(SINC_FILTER *filter, increment_t increment, increment_t start_filter_index, double scale, float *output)
static increment_t fp_fraction_part(increment_t x)
static int sinc_quad_vari_process(SRC_PRIVATE *psrc, SRC_DATA *data)
int sinc_set_converter(SRC_PRIVATE *psrc, int src_enum)
static void calc_output_multi(SINC_FILTER *filter, increment_t increment, increment_t start_filter_index, int channels, double scale, float *output)
static increment_t int_to_fp(int x)
static int sinc_hex_vari_process(SRC_PRIVATE *psrc, SRC_DATA *data)
static int sinc_stereo_vari_process(SRC_PRIVATE *psrc, SRC_DATA *data)
static void sinc_reset(SRC_PRIVATE *psrc)
static void calc_output_quad(SINC_FILTER *filter, increment_t increment, increment_t start_filter_index, double scale, float *output)
static int sinc_mono_vari_process(SRC_PRIVATE *psrc, SRC_DATA *data)
static int fp_to_int(increment_t x)
static double fp_to_double(increment_t x)
#define SINC_MAGIC_MARKER
const char * sinc_get_name(int src_enum)
#define MAKE_INCREMENT_T(x)
static int prepare_data(SINC_FILTER *filter, SRC_DATA *data, int half_filter_chan_len) WARN_UNUSED
int(* const_process)(struct SRC_PRIVATE_tag *psrc, SRC_DATA *data)
int(* vari_process)(struct SRC_PRIVATE_tag *psrc, SRC_DATA *data)
void(* reset)(struct SRC_PRIVATE_tag *psrc)
ActualNumberDriverObjects * sizeof(PDRIVER_OBJECT)) PDRIVER_OBJECT *DriverObjectList