Changeset eaa8fb6d9f44b149bdcd4e5252794765e620ad83
- Timestamp:
- 28/06/08 12:07:02
(4 months ago)
- Author:
- Rémi Denis-Courmont <rdenis@simphalempin.com>
- git-committer:
- Rémi Denis-Courmont <rdenis@simphalempin.com> 1214647622 +0300
- git-parent:
[1f03f5e7d63405106b7fc4f34101d04ce61c78d0]
- git-author:
- Rémi Denis-Courmont <rdenis@simphalempin.com> 1214647622 +0300
- Message:
uint is not standard (and breaks Win32) - use unsigned
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r3c5f3a2 |
reaa8fb6 |
|
| 82 | 82 | double scale; |
|---|
| 83 | 83 | /* parameters */ |
|---|
| 84 | | uint ms_stride; |
|---|
| | 84 | unsigned ms_stride; |
|---|
| 85 | 85 | double percent_overlap; |
|---|
| 86 | | uint ms_search; |
|---|
| | 86 | unsigned ms_search; |
|---|
| 87 | 87 | /* audio format */ |
|---|
| 88 | | uint samples_per_frame; /* AKA number of channels */ |
|---|
| 89 | | uint bytes_per_sample; |
|---|
| 90 | | uint bytes_per_frame; |
|---|
| 91 | | uint sample_rate; |
|---|
| | 88 | unsigned samples_per_frame; /* AKA number of channels */ |
|---|
| | 89 | unsigned bytes_per_sample; |
|---|
| | 90 | unsigned bytes_per_frame; |
|---|
| | 91 | unsigned sample_rate; |
|---|
| 92 | 92 | /* stride */ |
|---|
| 93 | 93 | double frames_stride_scaled; |
|---|
| 94 | 94 | double frames_stride_error; |
|---|
| 95 | | uint bytes_stride; |
|---|
| | 95 | unsigned bytes_stride; |
|---|
| 96 | 96 | double bytes_stride_scaled; |
|---|
| 97 | | uint bytes_queue_max; |
|---|
| 98 | | uint bytes_queued; |
|---|
| 99 | | uint bytes_to_slide; |
|---|
| | 97 | unsigned bytes_queue_max; |
|---|
| | 98 | unsigned bytes_queued; |
|---|
| | 99 | unsigned bytes_to_slide; |
|---|
| 100 | 100 | uint8_t *buf_queue; |
|---|
| 101 | 101 | /* overlap */ |
|---|
| 102 | | uint samples_overlap; |
|---|
| 103 | | uint samples_standing; |
|---|
| 104 | | uint bytes_overlap; |
|---|
| 105 | | uint bytes_standing; |
|---|
| | 102 | unsigned samples_overlap; |
|---|
| | 103 | unsigned samples_standing; |
|---|
| | 104 | unsigned bytes_overlap; |
|---|
| | 105 | unsigned bytes_standing; |
|---|
| 106 | 106 | void *buf_overlap; |
|---|
| 107 | 107 | void *table_blend; |
|---|
| 108 | | void (*output_overlap)( aout_filter_t *p_filter, void *p_out_buf, uint bytes_off ); |
|---|
| | 108 | void (*output_overlap)( aout_filter_t *p_filter, void *p_out_buf, unsigned bytes_off ); |
|---|
| 109 | 109 | /* best overlap */ |
|---|
| 110 | | uint frames_search; |
|---|
| | 110 | unsigned frames_search; |
|---|
| 111 | 111 | void *buf_pre_corr; |
|---|
| 112 | 112 | void *table_window; |
|---|
| 113 | | uint (*best_overlap_offset)( aout_filter_t *p_filter ); |
|---|
| | 113 | unsigned(*best_overlap_offset)( aout_filter_t *p_filter ); |
|---|
| 114 | 114 | /* for "audio filter" only, manage own buffers */ |
|---|
| 115 | 115 | int i_buf; |
|---|
| … | … | |
| 120 | 120 | * best_overlap_offset: calculate best offset for overlap |
|---|
| 121 | 121 | *****************************************************************************/ |
|---|
| 122 | | static uint best_overlap_offset_float( aout_filter_t *p_filter ) |
|---|
| | 122 | static unsigned best_overlap_offset_float( aout_filter_t *p_filter ) |
|---|
| 123 | 123 | { |
|---|
| 124 | 124 | aout_filter_sys_t *p = p_filter->p_sys; |
|---|
| 125 | 125 | float *pw, *po, *ppc, *search_start; |
|---|
| 126 | 126 | float best_corr = INT_MIN; |
|---|
| 127 | | uint best_off = 0; |
|---|
| 128 | | uint i, off; |
|---|
| | 127 | unsigned best_off = 0; |
|---|
| | 128 | unsigned i, off; |
|---|
| 129 | 129 | |
|---|
| 130 | 130 | pw = p->table_window; |
|---|
| … | … | |
| 159 | 159 | static void output_overlap_float( aout_filter_t *p_filter, |
|---|
| 160 | 160 | void *buf_out, |
|---|
| 161 | | uint bytes_off ) |
|---|
| | 161 | unsigned bytes_off ) |
|---|
| 162 | 162 | { |
|---|
| 163 | 163 | aout_filter_sys_t *p = p_filter->p_sys; |
|---|
| … | … | |
| 166 | 166 | float *po = p->buf_overlap; |
|---|
| 167 | 167 | float *pin = (float *)( p->buf_queue + bytes_off ); |
|---|
| 168 | | uint i; |
|---|
| | 168 | unsigned i; |
|---|
| 169 | 169 | for( i = 0; i < p->samples_overlap; i++ ) { |
|---|
| 170 | 170 | *pout++ = *po - *pb++ * ( *po - *pin++ ); po++; |
|---|
| … | … | |
| 181 | 181 | { |
|---|
| 182 | 182 | aout_filter_sys_t *p = p_filter->p_sys; |
|---|
| 183 | | uint bytes_in = i_buffer - offset; |
|---|
| | 183 | unsigned bytes_in = i_buffer - offset; |
|---|
| 184 | 184 | size_t offset_unchanged = offset; |
|---|
| 185 | 185 | |
|---|
| 186 | 186 | if( p->bytes_to_slide > 0 ) { |
|---|
| 187 | 187 | if( p->bytes_to_slide < p->bytes_queued ) { |
|---|
| 188 | | uint bytes_in_move = p->bytes_queued - p->bytes_to_slide; |
|---|
| | 188 | unsigned bytes_in_move = p->bytes_queued - p->bytes_to_slide; |
|---|
| 189 | 189 | memmove( p->buf_queue, |
|---|
| 190 | 190 | p->buf_queue + p->bytes_to_slide, |
|---|
| … | … | |
| 193 | 193 | p->bytes_queued = bytes_in_move; |
|---|
| 194 | 194 | } else { |
|---|
| 195 | | uint bytes_in_skip; |
|---|
| | 195 | unsigned bytes_in_skip; |
|---|
| 196 | 196 | p->bytes_to_slide -= p->bytes_queued; |
|---|
| 197 | 197 | bytes_in_skip = __MIN( p->bytes_to_slide, bytes_in ); |
|---|
| … | … | |
| 204 | 204 | |
|---|
| 205 | 205 | if( bytes_in > 0 ) { |
|---|
| 206 | | uint bytes_in_copy = __MIN( p->bytes_queue_max - p->bytes_queued, bytes_in ); |
|---|
| | 206 | unsigned bytes_in_copy = __MIN( p->bytes_queue_max - p->bytes_queued, bytes_in ); |
|---|
| 207 | 207 | memcpy( p->buf_queue + p->bytes_queued, |
|---|
| 208 | 208 | p_buffer + offset, |
|---|
| … | … | |
| 226 | 226 | |
|---|
| 227 | 227 | size_t offset_in = fill_queue( p_filter, p_buffer, i_buffer, 0 ); |
|---|
| 228 | | uint bytes_out = 0; |
|---|
| | 228 | unsigned bytes_out = 0; |
|---|
| 229 | 229 | while( p->bytes_queued >= p->bytes_queue_max ) { |
|---|
| 230 | | uint bytes_off = 0; |
|---|
| | 230 | unsigned bytes_off = 0; |
|---|
| 231 | 231 | |
|---|
| 232 | 232 | // output stride |
|---|
| … | … | |
| 248 | 248 | p->bytes_overlap ); |
|---|
| 249 | 249 | double frames_to_slide = p->frames_stride_scaled + p->frames_stride_error; |
|---|
| 250 | | uint frames_to_stride_whole = (int)frames_to_slide; |
|---|
| | 250 | unsigned frames_to_stride_whole = (int)frames_to_slide; |
|---|
| 251 | 251 | p->bytes_to_slide = frames_to_stride_whole * p->bytes_per_frame; |
|---|
| 252 | 252 | p->frames_stride_error = frames_to_slide - frames_to_stride_whole; |
|---|
| … | … | |
| 269 | 269 | if( bytes_to_out >= (int)p->bytes_queue_max ) { |
|---|
| 270 | 270 | /* while (total_buffered - stride_length * n >= queue_max) n++ */ |
|---|
| 271 | | bytes_out = p->bytes_stride * ( (uint)( |
|---|
| | 271 | bytes_out = p->bytes_stride * ( (unsigned)( |
|---|
| 272 | 272 | ( bytes_to_out - p->bytes_queue_max + /* rounding protection */ p->bytes_per_frame ) |
|---|
| 273 | 273 | / p->bytes_stride_scaled ) + 1 ); |
|---|
| … | … | |
| 282 | 282 | { |
|---|
| 283 | 283 | aout_filter_sys_t *p = p_filter->p_sys; |
|---|
| 284 | | uint i,j; |
|---|
| 285 | | |
|---|
| 286 | | uint frames_stride = p->ms_stride * p->sample_rate / 1000.0; |
|---|
| | 284 | unsigned i,j; |
|---|
| | 285 | |
|---|
| | 286 | unsigned frames_stride = p->ms_stride * p->sample_rate / 1000.0; |
|---|
| 287 | 287 | p->bytes_stride = frames_stride * p->bytes_per_frame; |
|---|
| 288 | 288 | |
|---|
| 289 | 289 | /* overlap */ |
|---|
| 290 | | uint frames_overlap = frames_stride * p->percent_overlap; |
|---|
| | 290 | unsigned frames_overlap = frames_stride * p->percent_overlap; |
|---|
| 291 | 291 | if( frames_overlap < 1 ) { /* if no overlap */ |
|---|
| 292 | 292 | p->bytes_overlap = 0; |
|---|
| … | … | |
| 295 | 295 | p->output_overlap = NULL; |
|---|
| 296 | 296 | } else { |
|---|
| 297 | | uint prev_overlap = p->bytes_overlap; |
|---|
| | 297 | unsigned prev_overlap = p->bytes_overlap; |
|---|
| 298 | 298 | p->bytes_overlap = frames_overlap * p->bytes_per_frame; |
|---|
| 299 | 299 | p->samples_overlap = frames_overlap * p->samples_per_frame; |
|---|
| … | … | |
| 324 | 324 | p->best_overlap_offset = NULL; |
|---|
| 325 | 325 | } else { |
|---|
| 326 | | uint bytes_pre_corr = ( p->samples_overlap - p->samples_per_frame ) * 4; /* sizeof (int32|float) */ |
|---|
| | 326 | unsigned bytes_pre_corr = ( p->samples_overlap - p->samples_per_frame ) * 4; /* sizeof (int32|float) */ |
|---|
| 327 | 327 | p->buf_pre_corr = malloc( bytes_pre_corr ); |
|---|
| 328 | 328 | p->table_window = malloc( bytes_pre_corr ); |
|---|
| … | … | |
| 340 | 340 | } |
|---|
| 341 | 341 | |
|---|
| 342 | | uint new_size = ( p->frames_search + frames_stride + frames_overlap ) * p->bytes_per_frame; |
|---|
| | 342 | unsigned new_size = ( p->frames_search + frames_stride + frames_overlap ) * p->bytes_per_frame; |
|---|
| 343 | 343 | if( p->bytes_queued > new_size ) { |
|---|
| 344 | 344 | if( p->bytes_to_slide > p->bytes_queued ) { |
|---|
| … | … | |
| 346 | 346 | p->bytes_queued = 0; |
|---|
| 347 | 347 | } else { |
|---|
| 348 | | uint new_queued = __MIN( p->bytes_queued - p->bytes_to_slide, new_size ); |
|---|
| | 348 | unsigned new_queued = __MIN( p->bytes_queued - p->bytes_to_slide, new_size ); |
|---|
| 349 | 349 | memmove( p->buf_queue, |
|---|
| 350 | 350 | p->buf_queue + p->bytes_queued - new_queued, |
|---|