Lines Matching defs:psf
56 static sf_count_t host_read_f2s (SF_PRIVATE *psf, short *ptr, sf_count_t len) ;
57 static sf_count_t host_read_f2i (SF_PRIVATE *psf, int *ptr, sf_count_t len) ;
58 static sf_count_t host_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len) ;
59 static sf_count_t host_read_f2d (SF_PRIVATE *psf, double *ptr, sf_count_t len) ;
61 static sf_count_t host_write_s2f (SF_PRIVATE *psf, const short *ptr, sf_count_t len) ;
62 static sf_count_t host_write_i2f (SF_PRIVATE *psf, const int *ptr, sf_count_t len) ;
63 static sf_count_t host_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len) ;
64 static sf_count_t host_write_d2f (SF_PRIVATE *psf, const double *ptr, sf_count_t len) ;
66 static void float32_peak_update (SF_PRIVATE *psf, const float *buffer, int count, sf_count_t indx) ;
68 static sf_count_t replace_read_f2s (SF_PRIVATE *psf, short *ptr, sf_count_t len) ;
69 static sf_count_t replace_read_f2i (SF_PRIVATE *psf, int *ptr, sf_count_t len) ;
70 static sf_count_t replace_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len) ;
71 static sf_count_t replace_read_f2d (SF_PRIVATE *psf, double *ptr, sf_count_t len) ;
73 static sf_count_t replace_write_s2f (SF_PRIVATE *psf, const short *ptr, sf_count_t len) ;
74 static sf_count_t replace_write_i2f (SF_PRIVATE *psf, const int *ptr, sf_count_t len) ;
75 static sf_count_t replace_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len) ;
76 static sf_count_t replace_write_d2f (SF_PRIVATE *psf, const double *ptr, sf_count_t len) ;
81 static int float32_get_capability (SF_PRIVATE *psf) ;
88 float32_init (SF_PRIVATE *psf)
91 if (psf->sf.channels < 1)
92 { psf_log_printf (psf, "float32_init : internal error : channels = %d\n", psf->sf.channels) ;
96 float_caps = float32_get_capability (psf) ;
98 psf->blockwidth = sizeof (float) * psf->sf.channels ;
100 if (psf->file.mode == SFM_READ || psf->file.mode == SFM_RDWR)
101 { switch (psf->endian + float_caps)
103 psf->data_endswap = SF_FALSE ;
104 psf->read_short = host_read_f2s ;
105 psf->read_int = host_read_f2i ;
106 psf->read_float = host_read_f ;
107 psf->read_double = host_read_f2d ;
111 psf->data_endswap = SF_FALSE ;
112 psf->read_short = host_read_f2s ;
113 psf->read_int = host_read_f2i ;
114 psf->read_float = host_read_f ;
115 psf->read_double = host_read_f2d ;
119 psf->data_endswap = SF_TRUE ;
120 psf->read_short = host_read_f2s ;
121 psf->read_int = host_read_f2i ;
122 psf->read_float = host_read_f ;
123 psf->read_double = host_read_f2d ;
127 psf->data_endswap = SF_TRUE ;
128 psf->read_short = host_read_f2s ;
129 psf->read_int = host_read_f2i ;
130 psf->read_float = host_read_f ;
131 psf->read_double = host_read_f2d ;
136 psf->data_endswap = SF_TRUE ;
137 psf->read_short = replace_read_f2s ;
138 psf->read_int = replace_read_f2i ;
139 psf->read_float = replace_read_f ;
140 psf->read_double = replace_read_f2d ;
144 psf->data_endswap = SF_FALSE ;
145 psf->read_short = replace_read_f2s ;
146 psf->read_int = replace_read_f2i ;
147 psf->read_float = replace_read_f ;
148 psf->read_double = replace_read_f2d ;
152 psf->data_endswap = SF_FALSE ;
153 psf->read_short = replace_read_f2s ;
154 psf->read_int = replace_read_f2i ;
155 psf->read_float = replace_read_f ;
156 psf->read_double = replace_read_f2d ;
160 psf->data_endswap = SF_TRUE ;
161 psf->read_short = replace_read_f2s ;
162 psf->read_int = replace_read_f2i ;
163 psf->read_float = replace_read_f ;
164 psf->read_double = replace_read_f2d ;
171 if (psf->file.mode == SFM_WRITE || psf->file.mode == SFM_RDWR)
172 { switch (psf->endian + float_caps)
174 psf->data_endswap = SF_FALSE ;
175 psf->write_short = host_write_s2f ;
176 psf->write_int = host_write_i2f ;
177 psf->write_float = host_write_f ;
178 psf->write_double = host_write_d2f ;
182 psf->data_endswap = SF_FALSE ;
183 psf->write_short = host_write_s2f ;
184 psf->write_int = host_write_i2f ;
185 psf->write_float = host_write_f ;
186 psf->write_double = host_write_d2f ;
190 psf->data_endswap = SF_TRUE ;
191 psf->write_short = host_write_s2f ;
192 psf->write_int = host_write_i2f ;
193 psf->write_float = host_write_f ;
194 psf->write_double = host_write_d2f ;
198 psf->data_endswap = SF_TRUE ;
199 psf->write_short = host_write_s2f ;
200 psf->write_int = host_write_i2f ;
201 psf->write_float = host_write_f ;
202 psf->write_double = host_write_d2f ;
207 psf->data_endswap = SF_TRUE ;
208 psf->write_short = replace_write_s2f ;
209 psf->write_int = replace_write_i2f ;
210 psf->write_float = replace_write_f ;
211 psf->write_double = replace_write_d2f ;
215 psf->data_endswap = SF_FALSE ;
216 psf->write_short = replace_write_s2f ;
217 psf->write_int = replace_write_i2f ;
218 psf->write_float = replace_write_f ;
219 psf->write_double = replace_write_d2f ;
223 psf->data_endswap = SF_FALSE ;
224 psf->write_short = replace_write_s2f ;
225 psf->write_int = replace_write_i2f ;
226 psf->write_float = replace_write_f ;
227 psf->write_double = replace_write_d2f ;
231 psf->data_endswap = SF_TRUE ;
232 psf->write_short = replace_write_s2f ;
233 psf->write_int = replace_write_i2f ;
234 psf->write_float = replace_write_f ;
235 psf->write_double = replace_write_d2f ;
242 if (psf->filelength > psf->dataoffset)
243 { psf->datalength = (psf->dataend > 0) ? psf->dataend - psf->dataoffset :
244 psf->filelength - psf->dataoffset ;
247 psf->datalength = 0 ;
249 psf->sf.frames = psf->blockwidth > 0 ? psf->datalength / psf->blockwidth : 0 ;
385 float32_peak_update (SF_PRIVATE *psf, const float *buffer, int count, sf_count_t indx)
390 for (chan = 0 ; chan < psf->sf.channels ; chan++)
393 for (k = chan ; k < count ; k += psf->sf.channels)
399 if (fmaxval > psf->peak_info->peaks [chan].value)
400 { psf->peak_info->peaks [chan].value = fmaxval ;
401 psf->peak_info->peaks [chan].position = psf->write_current + indx + (position / psf->sf.channels) ;
409 float32_get_capability (SF_PRIVATE *psf)
418 if (! psf->ieee_replace)
429 psf_log_printf (psf, "Using IEEE replacement code for float.\n") ;
512 host_read_f2s (SF_PRIVATE *psf, short *ptr, sf_count_t len)
519 convert = (psf->add_clipping) ? f2s_clip_array : f2s_array ;
521 scale = (psf->float_int_mult == 0) ? 1.0 : 0x7FFF / psf->float_max ;
526 readcount = (int) psf_fread (ubuf.fbuf, sizeof (float), bufferlen, psf) ;
529 if (psf->data_endswap == SF_TRUE)
543 host_read_f2i (SF_PRIVATE *psf, int *ptr, sf_count_t len)
550 convert = (psf->add_clipping) ? f2i_clip_array : f2i_array ;
552 scale = (psf->float_int_mult == 0) ? 1.0 : 2147483648.0f / psf->float_max ;
557 readcount = (int) psf_fread (ubuf.fbuf, sizeof (float), bufferlen, psf) ;
559 if (psf->data_endswap == SF_TRUE)
573 host_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len)
578 if (psf->data_endswap != SF_TRUE)
579 return psf_fread (ptr, sizeof (float), len, psf) ;
586 readcount = (int) psf_fread (ubuf.fbuf, sizeof (float), bufferlen, psf) ;
600 host_read_f2d (SF_PRIVATE *psf, double *ptr, sf_count_t len)
610 readcount = (int) psf_fread (ubuf.fbuf, sizeof (float), bufferlen, psf) ;
612 if (psf->data_endswap == SF_TRUE)
627 host_write_s2f (SF_PRIVATE *psf, const short *ptr, sf_count_t len)
634 scale = (psf->scale_int_float == 0) ? 1.0 : 1.0 / 0x8000 ;
642 if (psf->peak_info)
643 float32_peak_update (psf, ubuf.fbuf, bufferlen, total / psf->sf.channels) ;
645 if (psf->data_endswap == SF_TRUE)
648 writecount = (int) psf_fwrite (ubuf.fbuf, sizeof (float), bufferlen, psf) ;
659 host_write_i2f (SF_PRIVATE *psf, const int *ptr, sf_count_t len)
665 scale = (psf->scale_int_float == 0) ? 1.0 : 1.0 / (8.0 * 0x10000000) ;
673 if (psf->peak_info)
674 float32_peak_update (psf, ubuf.fbuf, bufferlen, total / psf->sf.channels) ;
676 if (psf->data_endswap == SF_TRUE)
679 writecount = (int) psf_fwrite (ubuf.fbuf, sizeof (float) , bufferlen, psf) ;
690 host_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len)
695 if (psf->peak_info)
696 float32_peak_update (psf, ptr, len, 0) ;
698 if (psf->data_endswap != SF_TRUE)
699 return psf_fwrite (ptr, sizeof (float), len, psf) ;
709 writecount = (int) psf_fwrite (ubuf.fbuf, sizeof (float), bufferlen, psf) ;
720 host_write_d2f (SF_PRIVATE *psf, const double *ptr, sf_count_t len)
733 if (psf->peak_info)
734 float32_peak_update (psf, ubuf.fbuf, bufferlen, total / psf->sf.channels) ;
736 if (psf->data_endswap == SF_TRUE)
739 writecount = (int) psf_fwrite (ubuf.fbuf, sizeof (float), bufferlen, psf) ;
753 replace_read_f2s (SF_PRIVATE *psf, short *ptr, sf_count_t len)
760 scale = (psf->float_int_mult == 0) ? 1.0 : 0x7FFF / psf->float_max ;
765 readcount = (int) psf_fread (ubuf.fbuf, sizeof (float), bufferlen, psf) ;
767 if (psf->data_endswap == SF_TRUE)
783 replace_read_f2i (SF_PRIVATE *psf, int *ptr, sf_count_t len)
790 scale = (psf->float_int_mult == 0) ? 1.0 : 2147483648.0f / psf->float_max ;
795 readcount = (int) psf_fread (ubuf.fbuf, sizeof (float), bufferlen, psf) ;
797 if (psf->data_endswap == SF_TRUE)
813 replace_read_f (SF_PRIVATE *psf, float *ptr, sf_count_t len)
825 readcount = (int) psf_fread (ubuf.fbuf, sizeof (float), bufferlen, psf) ;
827 if (psf->data_endswap == SF_TRUE)
844 replace_read_f2d (SF_PRIVATE *psf, double *ptr, sf_count_t len)
854 readcount = (int) psf_fread (ubuf.fbuf, sizeof (float), bufferlen, psf) ;
856 if (psf->data_endswap == SF_TRUE)
872 replace_write_s2f (SF_PRIVATE *psf, const short *ptr, sf_count_t len)
878 scale = (psf->scale_int_float == 0) ? 1.0 : 1.0 / 0x8000 ;
886 if (psf->peak_info)
887 float32_peak_update (psf, ubuf.fbuf, bufferlen, total / psf->sf.channels) ;
891 if (psf->data_endswap == SF_TRUE)
894 writecount = (int) psf_fwrite (ubuf.fbuf, sizeof (float), bufferlen, psf) ;
905 replace_write_i2f (SF_PRIVATE *psf, const int *ptr, sf_count_t len)
911 scale = (psf->scale_int_float == 0) ? 1.0 : 1.0 / (8.0 * 0x10000000) ;
919 if (psf->peak_info)
920 float32_peak_update (psf, ubuf.fbuf, bufferlen, total / psf->sf.channels) ;
924 if (psf->data_endswap == SF_TRUE)
927 writecount = (int) psf_fwrite (ubuf.fbuf, sizeof (float), bufferlen, psf) ;
938 replace_write_f (SF_PRIVATE *psf, const float *ptr, sf_count_t len)
944 if (psf->peak_info)
945 float32_peak_update (psf, ptr, len, 0) ;
957 if (psf->data_endswap == SF_TRUE)
960 writecount = (int) psf_fwrite (ubuf.fbuf, sizeof (float) , bufferlen, psf) ;
971 replace_write_d2f (SF_PRIVATE *psf, const double *ptr, sf_count_t len)
983 if (psf->peak_info)
984 float32_peak_update (psf, ubuf.fbuf, bufferlen, total / psf->sf.channels) ;
988 if (psf->data_endswap == SF_TRUE)
991 writecount = (int) psf_fwrite (ubuf.fbuf, sizeof (float), bufferlen, psf) ;