Unified · Split
| @@ -6,6 +6,7 @@ · 5 unmodified lines | |||
| 6 | ** file at : https://github.com/libsndfile/libsamplerate/blob/master/COPYING | 6 | ** file at : https://github.com/libsndfile/libsamplerate/blob/master/COPYING |
| 7 | */ | 7 | */ |
| 8 | 8 | ||
| 9 | #include <assert.h> | ||
| 9 | #include <stdio.h> | 10 | #include <stdio.h> |
| 10 | #include <stdlib.h> | 11 | #include <stdlib.h> |
| 11 | #include <string.h> | 12 | #include <string.h> |
| @@ -299,9 +300,10 @@ calc_output_single (SINC_FILTER *filter, increment_t increment, increment_t star · 287 unmodified lines | |||
| 299 | { if (data_index >= 0) /* Avoid underflow access to filter->buffer. */ | 300 | { if (data_index >= 0) /* Avoid underflow access to filter->buffer. */ |
| 300 | { fraction = fp_to_double (filter_index) ; | 301 | { fraction = fp_to_double (filter_index) ; |
| 301 | indx = fp_to_int (filter_index) ; | 302 | indx = fp_to_int (filter_index) ; |
| 302 | 303 | assert (indx >= 0 && indx + 1 < filter->coeff_half_len + 2) ; | |
| 303 | icoeff = filter->coeffs [indx] + fraction * (filter->coeffs [indx + 1] - filter->coeffs [indx]) ; | 304 | icoeff = filter->coeffs [indx] + fraction * (filter->coeffs [indx + 1] - filter->coeffs [indx]) ; |
| 304 | 305 | assert (data_index >= 0 && data_index < filter->b_len) ; | |
| 306 | assert (data_index < filter->b_end) ; | ||
| 305 | left += icoeff * filter->buffer [data_index] ; | 307 | left += icoeff * filter->buffer [data_index] ; |
| 306 | } ; | 308 | } ; |
| 307 | 309 | ||
| @@ -320,9 +322,10 @@ calc_output_single (SINC_FILTER *filter, increment_t increment, increment_t star · 12 unmodified lines | |||
| 320 | do | 322 | do |
| 321 | { fraction = fp_to_double (filter_index) ; | 323 | { fraction = fp_to_double (filter_index) ; |
| 322 | indx = fp_to_int (filter_index) ; | 324 | indx = fp_to_int (filter_index) ; |
| 323 | 325 | assert (indx < filter->coeff_half_len + 2) ; | |
| 324 | icoeff = filter->coeffs [indx] + fraction * (filter->coeffs [indx + 1] - filter->coeffs [indx]) ; | 326 | icoeff = filter->coeffs [indx] + fraction * (filter->coeffs [indx + 1] - filter->coeffs [indx]) ; |
| 325 | 327 | assert (data_index >= 0 && data_index < filter->b_len) ; | |
| 328 | assert (data_index < filter->b_end) ; | ||
| 326 | right += icoeff * filter->buffer [data_index] ; | 329 | right += icoeff * filter->buffer [data_index] ; |
| 327 | 330 | ||
| 328 | filter_index -= increment ; | 331 | filter_index -= increment ; |
| @@ -446,9 +449,10 @@ calc_output_stereo (SINC_FILTER *filter, increment_t increment, increment_t star · 117 unmodified lines | |||
| 446 | { if (data_index >= 0) /* Avoid underflow access to filter->buffer. */ | 449 | { if (data_index >= 0) /* Avoid underflow access to filter->buffer. */ |
| 447 | { fraction = fp_to_double (filter_index) ; | 450 | { fraction = fp_to_double (filter_index) ; |
| 448 | indx = fp_to_int (filter_index) ; | 451 | indx = fp_to_int (filter_index) ; |
| 449 | 452 | assert (indx >= 0 && indx + 1 < filter->coeff_half_len + 2) ; | |
| 450 | icoeff = filter->coeffs [indx] + fraction * (filter->coeffs [indx + 1] - filter->coeffs [indx]) ; | 453 | icoeff = filter->coeffs [indx] + fraction * (filter->coeffs [indx + 1] - filter->coeffs [indx]) ; |
| 451 | 454 | assert (data_index >= 0 && data_index + 1 < filter->b_len) ; | |
| 455 | assert (data_index + 1 < filter->b_end) ; | ||
| 452 | left [0] += icoeff * filter->buffer [data_index] ; | 456 | left [0] += icoeff * filter->buffer [data_index] ; |
| 453 | left [1] += icoeff * filter->buffer [data_index + 1] ; | 457 | left [1] += icoeff * filter->buffer [data_index + 1] ; |
| 454 | } ; | 458 | } ; |
| @@ -468,9 +472,10 @@ calc_output_stereo (SINC_FILTER *filter, increment_t increment, increment_t star · 13 unmodified lines | |||
| 468 | do | 472 | do |
| 469 | { fraction = fp_to_double (filter_index) ; | 473 | { fraction = fp_to_double (filter_index) ; |
| 470 | indx = fp_to_int (filter_index) ; | 474 | indx = fp_to_int (filter_index) ; |
| 471 | 475 | assert (indx >= 0 && indx + 1 < filter->coeff_half_len + 2) ; | |
| 472 | icoeff = filter->coeffs [indx] + fraction * (filter->coeffs [indx + 1] - filter->coeffs [indx]) ; | 476 | icoeff = filter->coeffs [indx] + fraction * (filter->coeffs [indx + 1] - filter->coeffs [indx]) ; |
| 473 | 477 | assert (data_index >= 0 && data_index + 1 < filter->b_len) ; | |
| 478 | assert (data_index + 1 < filter->b_end) ; | ||
| 474 | right [0] += icoeff * filter->buffer [data_index] ; | 479 | right [0] += icoeff * filter->buffer [data_index] ; |
| 475 | right [1] += icoeff * filter->buffer [data_index + 1] ; | 480 | right [1] += icoeff * filter->buffer [data_index + 1] ; |
| 476 | 481 | ||
| @@ -595,9 +600,10 @@ calc_output_quad (SINC_FILTER *filter, increment_t increment, increment_t start_ · 118 unmodified lines | |||
| 595 | { if (data_index >= 0) /* Avoid underflow access to filter->buffer. */ | 600 | { if (data_index >= 0) /* Avoid underflow access to filter->buffer. */ |
| 596 | { fraction = fp_to_double (filter_index) ; | 601 | { fraction = fp_to_double (filter_index) ; |
| 597 | indx = fp_to_int (filter_index) ; | 602 | indx = fp_to_int (filter_index) ; |
| 598 | 603 | assert (indx >= 0 && indx + 1 < filter->coeff_half_len + 2) ; | |
| 599 | icoeff = filter->coeffs [indx] + fraction * (filter->coeffs [indx + 1] - filter->coeffs [indx]) ; | 604 | icoeff = filter->coeffs [indx] + fraction * (filter->coeffs [indx + 1] - filter->coeffs [indx]) ; |
| 600 | 605 | assert (data_index >= 0 && data_index + 3 < filter->b_len) ; | |
| 606 | assert (data_index + 3 < filter->b_end) ; | ||
| 601 | left [0] += icoeff * filter->buffer [data_index] ; | 607 | left [0] += icoeff * filter->buffer [data_index] ; |
| 602 | left [1] += icoeff * filter->buffer [data_index + 1] ; | 608 | left [1] += icoeff * filter->buffer [data_index + 1] ; |
| 603 | left [2] += icoeff * filter->buffer [data_index + 2] ; | 609 | left [2] += icoeff * filter->buffer [data_index + 2] ; |
| @@ -619,9 +625,10 @@ calc_output_quad (SINC_FILTER *filter, increment_t increment, increment_t start_ · 15 unmodified lines | |||
| 619 | do | 625 | do |
| 620 | { fraction = fp_to_double (filter_index) ; | 626 | { fraction = fp_to_double (filter_index) ; |
| 621 | indx = fp_to_int (filter_index) ; | 627 | indx = fp_to_int (filter_index) ; |
| 622 | 628 | assert (indx >= 0 && indx + 1 < filter->coeff_half_len + 2) ; | |
| 623 | icoeff = filter->coeffs [indx] + fraction * (filter->coeffs [indx + 1] - filter->coeffs [indx]) ; | 629 | icoeff = filter->coeffs [indx] + fraction * (filter->coeffs [indx + 1] - filter->coeffs [indx]) ; |
| 624 | 630 | assert (data_index >= 0 && data_index + 3 < filter->b_len) ; | |
| 631 | assert (data_index + 3 < filter->b_end) ; | ||
| 625 | right [0] += icoeff * filter->buffer [data_index] ; | 632 | right [0] += icoeff * filter->buffer [data_index] ; |
| 626 | right [1] += icoeff * filter->buffer [data_index + 1] ; | 633 | right [1] += icoeff * filter->buffer [data_index + 1] ; |
| 627 | right [2] += icoeff * filter->buffer [data_index + 2] ; | 634 | right [2] += icoeff * filter->buffer [data_index + 2] ; |
| @@ -750,9 +757,10 @@ calc_output_hex (SINC_FILTER *filter, increment_t increment, increment_t start_f · 122 unmodified lines | |||
| 750 | { if (data_index >= 0) /* Avoid underflow access to filter->buffer. */ | 757 | { if (data_index >= 0) /* Avoid underflow access to filter->buffer. */ |
| 751 | { fraction = fp_to_double (filter_index) ; | 758 | { fraction = fp_to_double (filter_index) ; |
| 752 | indx = fp_to_int (filter_index) ; | 759 | indx = fp_to_int (filter_index) ; |
| 753 | 760 | assert (indx >= 0 && indx + 1 < filter->coeff_half_len + 2) ; | |
| 754 | icoeff = filter->coeffs [indx] + fraction * (filter->coeffs [indx + 1] - filter->coeffs [indx]) ; | 761 | icoeff = filter->coeffs [indx] + fraction * (filter->coeffs [indx + 1] - filter->coeffs [indx]) ; |
| 755 | 762 | assert (data_index >= 0 && data_index + 5 < filter->b_len) ; | |
| 763 | assert (data_index + 5 < filter->b_end) ; | ||
| 756 | left [0] += icoeff * filter->buffer [data_index] ; | 764 | left [0] += icoeff * filter->buffer [data_index] ; |
| 757 | left [1] += icoeff * filter->buffer [data_index + 1] ; | 765 | left [1] += icoeff * filter->buffer [data_index + 1] ; |
| 758 | left [2] += icoeff * filter->buffer [data_index + 2] ; | 766 | left [2] += icoeff * filter->buffer [data_index + 2] ; |
| @@ -776,9 +784,10 @@ calc_output_hex (SINC_FILTER *filter, increment_t increment, increment_t start_f · 17 unmodified lines | |||
| 776 | do | 784 | do |
| 777 | { fraction = fp_to_double (filter_index) ; | 785 | { fraction = fp_to_double (filter_index) ; |
| 778 | indx = fp_to_int (filter_index) ; | 786 | indx = fp_to_int (filter_index) ; |
| 779 | 787 | assert (indx >= 0 && indx + 1 < filter->coeff_half_len + 2) ; | |
| 780 | icoeff = filter->coeffs [indx] + fraction * (filter->coeffs [indx + 1] - filter->coeffs [indx]) ; | 788 | icoeff = filter->coeffs [indx] + fraction * (filter->coeffs [indx + 1] - filter->coeffs [indx]) ; |
| 781 | 789 | assert (data_index >= 0 && data_index + 5 < filter->b_len) ; | |
| 790 | assert (data_index + 5 < filter->b_end) ; | ||
| 782 | right [0] += icoeff * filter->buffer [data_index] ; | 791 | right [0] += icoeff * filter->buffer [data_index] ; |
| 783 | right [1] += icoeff * filter->buffer [data_index + 1] ; | 792 | right [1] += icoeff * filter->buffer [data_index + 1] ; |
| 784 | right [2] += icoeff * filter->buffer [data_index + 2] ; | 793 | right [2] += icoeff * filter->buffer [data_index + 2] ; |
| @@ -916,7 +925,7 @@ calc_output_multi (SINC_FILTER *filter, increment_t increment, increment_t start · 131 unmodified lines | |||
| 916 | do | 925 | do |
| 917 | { fraction = fp_to_double (filter_index) ; | 926 | { fraction = fp_to_double (filter_index) ; |
| 918 | indx = fp_to_int (filter_index) ; | 927 | indx = fp_to_int (filter_index) ; |
| 919 | 928 | assert (indx >= 0 && indx + 1 < filter->coeff_half_len + 2) ; | |
| 920 | icoeff = filter->coeffs [indx] + fraction * (filter->coeffs [indx + 1] - filter->coeffs [indx]) ; | 929 | icoeff = filter->coeffs [indx] + fraction * (filter->coeffs [indx + 1] - filter->coeffs [indx]) ; |
| 921 | 930 | ||
| 922 | if (data_index >= 0) /* Avoid underflow access to filter->buffer. */ | 931 | if (data_index >= 0) /* Avoid underflow access to filter->buffer. */ |
| @@ -924,6 +933,8 @@ calc_output_multi (SINC_FILTER *filter, increment_t increment, increment_t start · 1 unmodified line | |||
| 924 | ** Duff's Device. | 933 | ** Duff's Device. |
| 925 | ** See : http://en.wikipedia.org/wiki/Duff's_device | 934 | ** See : http://en.wikipedia.org/wiki/Duff's_device |
| 926 | */ | 935 | */ |
| 936 | assert (data_index >= 0 && data_index + channels - 1 < filter->b_len) ; | ||
| 937 | assert (data_index + channels - 1 < filter->b_end) ; | ||
| 927 | ch = channels ; | 938 | ch = channels ; |
| 928 | do | 939 | do |
| 929 | { switch (ch % 8) | 940 | { switch (ch % 8) |
| @@ -978,9 +989,10 @@ calc_output_multi (SINC_FILTER *filter, increment_t increment, increment_t start · 48 unmodified lines | |||
| 978 | do | 989 | do |
| 979 | { fraction = fp_to_double (filter_index) ; | 990 | { fraction = fp_to_double (filter_index) ; |
| 980 | indx = fp_to_int (filter_index) ; | 991 | indx = fp_to_int (filter_index) ; |
| 981 | 992 | assert (indx >= 0 && indx + 1 < filter->coeff_half_len + 2) ; | |
| 982 | icoeff = filter->coeffs [indx] + fraction * (filter->coeffs [indx + 1] - filter->coeffs [indx]) ; | 993 | icoeff = filter->coeffs [indx] + fraction * (filter->coeffs [indx + 1] - filter->coeffs [indx]) ; |
| 983 | 994 | assert (data_index >= 0 && data_index + channels - 1 < filter->b_len) ; | |
| 995 | assert (data_index + channels - 1 < filter->b_end) ; | ||
| 984 | ch = channels ; | 996 | ch = channels ; |
| 985 | do | 997 | do |
| 986 | { | 998 | { |