Lines Matching refs:rsmp
52 struct resampler *rsmp = (struct resampler *)resampler; in resampler_reset() local
54 rsmp->frames_in = 0; in resampler_reset()
55 rsmp->frames_rq = 0; in resampler_reset()
57 if (rsmp != NULL && rsmp->speex_resampler != NULL) { in resampler_reset()
58 speex_resampler_reset_mem(rsmp->speex_resampler); in resampler_reset()
64 struct resampler *rsmp = (struct resampler *)resampler; in resampler_delay_ns() local
66 int32_t delay = (int32_t)((1000000000 * (int64_t)rsmp->frames_in) / rsmp->in_sample_rate); in resampler_delay_ns()
67 delay += rsmp->speex_delay_ns; in resampler_delay_ns()
78 struct resampler *rsmp = (struct resampler *)resampler; in resampler_resample_from_provider() local
80 if (rsmp == NULL || out == NULL || outFrameCount == NULL) { in resampler_resample_from_provider()
83 if (rsmp->provider == NULL) { in resampler_resample_from_provider()
91 if (framesRq != rsmp->frames_rq) { in resampler_resample_from_provider()
92 rsmp->frames_needed = (framesRq * rsmp->in_sample_rate) / rsmp->out_sample_rate + 1; in resampler_resample_from_provider()
93 rsmp->frames_rq = framesRq; in resampler_resample_from_provider()
99 if (rsmp->frames_in < rsmp->frames_needed) { in resampler_resample_from_provider()
103 if (rsmp->in_buf_size < rsmp->frames_needed) { in resampler_resample_from_provider()
104 rsmp->in_buf_size = rsmp->frames_needed; in resampler_resample_from_provider()
105 rsmp->in_buf = (int16_t *)realloc(rsmp->in_buf, in resampler_resample_from_provider()
106 rsmp->in_buf_size * rsmp->channel_count * sizeof(int16_t)); in resampler_resample_from_provider()
109 buf.frame_count = rsmp->frames_needed - rsmp->frames_in; in resampler_resample_from_provider()
110 rsmp->provider->get_next_buffer(rsmp->provider, &buf); in resampler_resample_from_provider()
114 memcpy(rsmp->in_buf + rsmp->frames_in * rsmp->channel_count, in resampler_resample_from_provider()
116 buf.frame_count * rsmp->channel_count * sizeof(int16_t)); in resampler_resample_from_provider()
117 rsmp->frames_in += buf.frame_count; in resampler_resample_from_provider()
118 rsmp->provider->release_buffer(rsmp->provider, &buf); in resampler_resample_from_provider()
122 inFrames = rsmp->frames_in; in resampler_resample_from_provider()
123 if (rsmp->channel_count == 1) { in resampler_resample_from_provider()
124 speex_resampler_process_int(rsmp->speex_resampler, in resampler_resample_from_provider()
126 rsmp->in_buf, in resampler_resample_from_provider()
131 speex_resampler_process_interleaved_int(rsmp->speex_resampler, in resampler_resample_from_provider()
132 rsmp->in_buf, in resampler_resample_from_provider()
134 out + framesWr * rsmp->channel_count, in resampler_resample_from_provider()
138 rsmp->frames_in -= inFrames; in resampler_resample_from_provider()
139 ALOGW_IF((framesWr != framesRq) && (rsmp->frames_in != 0), in resampler_resample_from_provider()
141 rsmp->frames_in, (framesRq - framesWr)); in resampler_resample_from_provider()
143 if (rsmp->frames_in) { in resampler_resample_from_provider()
144 memmove(rsmp->in_buf, in resampler_resample_from_provider()
145 rsmp->in_buf + inFrames * rsmp->channel_count, in resampler_resample_from_provider()
146 rsmp->frames_in * rsmp->channel_count * sizeof(int16_t)); in resampler_resample_from_provider()
159 struct resampler *rsmp = (struct resampler *)resampler; in resampler_resample_from_input() local
161 if (rsmp == NULL || in == NULL || inFrameCount == NULL || in resampler_resample_from_input()
165 if (rsmp->provider != NULL) { in resampler_resample_from_input()
170 if (rsmp->channel_count == 1) { in resampler_resample_from_input()
171 speex_resampler_process_int(rsmp->speex_resampler, in resampler_resample_from_input()
178 speex_resampler_process_interleaved_int(rsmp->speex_resampler, in resampler_resample_from_input()
198 struct resampler *rsmp; in create_resampler() local
213 rsmp = (struct resampler *)calloc(1, sizeof(struct resampler)); in create_resampler()
215 rsmp->speex_resampler = speex_resampler_init(channelCount, in create_resampler()
220 if (rsmp->speex_resampler == NULL) { in create_resampler()
222 free(rsmp); in create_resampler()
226 rsmp->itfe.reset = resampler_reset; in create_resampler()
227 rsmp->itfe.resample_from_provider = resampler_resample_from_provider; in create_resampler()
228 rsmp->itfe.resample_from_input = resampler_resample_from_input; in create_resampler()
229 rsmp->itfe.delay_ns = resampler_delay_ns; in create_resampler()
231 rsmp->provider = provider; in create_resampler()
232 rsmp->in_sample_rate = inSampleRate; in create_resampler()
233 rsmp->out_sample_rate = outSampleRate; in create_resampler()
234 rsmp->channel_count = channelCount; in create_resampler()
235 rsmp->in_buf = NULL; in create_resampler()
236 rsmp->in_buf_size = 0; in create_resampler()
238 resampler_reset(&rsmp->itfe); in create_resampler()
240 int frames = speex_resampler_get_input_latency(rsmp->speex_resampler); in create_resampler()
241 rsmp->speex_delay_ns = (int32_t)((1000000000 * (int64_t)frames) / rsmp->in_sample_rate); in create_resampler()
242 frames = speex_resampler_get_output_latency(rsmp->speex_resampler); in create_resampler()
243 rsmp->speex_delay_ns += (int32_t)((1000000000 * (int64_t)frames) / rsmp->out_sample_rate); in create_resampler()
245 *resampler = &rsmp->itfe; in create_resampler()
247 rsmp, &rsmp->itfe, rsmp->speex_resampler); in create_resampler()
253 struct resampler *rsmp = (struct resampler *)resampler; in release_resampler() local
255 if (rsmp == NULL) { in release_resampler()
259 free(rsmp->in_buf); in release_resampler()
261 if (rsmp->speex_resampler != NULL) { in release_resampler()
262 speex_resampler_destroy(rsmp->speex_resampler); in release_resampler()
264 free(rsmp); in release_resampler()