btstack_resample.c (e501bae08349e058caa4648e0af3dd01cbd89d20) | btstack_resample.c (c1ab6cc1beb14b16b46e74a3723644016d8c3cc7) |
---|---|
1/* 2 * Copyright (C) 2018 BlueKitchen GmbH 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright --- 47 unchanged lines hidden (view full) --- 56 uint16_t dest_samples = 0; 57 // samples between last sample of previous block and first sample in current block 58 while (context->src_pos >= 0xffff0000){ 59 const uint16_t t = context->src_pos & 0xffff; 60 int i; 61 for (i=0;i<context->num_channels;i++){ 62 int s1 = context->last_sample[i]; 63 int s2 = input_buffer[i]; | 1/* 2 * Copyright (C) 2018 BlueKitchen GmbH 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright --- 47 unchanged lines hidden (view full) --- 56 uint16_t dest_samples = 0; 57 // samples between last sample of previous block and first sample in current block 58 while (context->src_pos >= 0xffff0000){ 59 const uint16_t t = context->src_pos & 0xffff; 60 int i; 61 for (i=0;i<context->num_channels;i++){ 62 int s1 = context->last_sample[i]; 63 int s2 = input_buffer[i]; |
64 int os = (s1*(0x10000 - t) + s2*t) >> 16; | 64 int os = ((s1*(0x10000 - t)) + (s2*t)) >> 16; |
65 output_buffer[dest_samples++] = os; 66 } 67 dest_frames++; 68 context->src_pos += context->src_step; 69 } 70 // process current block 71 while (1){ 72 const uint16_t src_pos = context->src_pos >> 16; --- 7 unchanged lines hidden (view full) --- 80 } 81 // samples processed 82 context->src_pos -= num_frames << 16; 83 break; 84 } 85 for (i=0;i<context->num_channels;i++){ 86 int s1 = input_buffer[index]; 87 int s2 = input_buffer[index+context->num_channels]; | 65 output_buffer[dest_samples++] = os; 66 } 67 dest_frames++; 68 context->src_pos += context->src_step; 69 } 70 // process current block 71 while (1){ 72 const uint16_t src_pos = context->src_pos >> 16; --- 7 unchanged lines hidden (view full) --- 80 } 81 // samples processed 82 context->src_pos -= num_frames << 16; 83 break; 84 } 85 for (i=0;i<context->num_channels;i++){ 86 int s1 = input_buffer[index]; 87 int s2 = input_buffer[index+context->num_channels]; |
88 int os = (s1*(0x10000 - t) + s2*t) >> 16; | 88 int os = ((s1*(0x10000 - t)) + (s2*t)) >> 16; |
89 output_buffer[dest_samples++] = os; 90 index++; 91 } 92 dest_frames++; 93 context->src_pos += context->src_step; 94 } 95 return dest_frames; 96} | 89 output_buffer[dest_samples++] = os; 90 index++; 91 } 92 dest_frames++; 93 context->src_pos += context->src_step; 94 } 95 return dest_frames; 96} |