History

src/src_*.c : Validate internally stashed src_ratio value.

Erik de Castro Lopo committed 14 years ago

Commit f4e2bc31 parent a25ac784 files · +28 −2Browse files

Showing the changes to src (3 of 4 files). Show all

Unified · Split

3 files
  1. src/src_linear.c +5 −1
  2. src/src_sinc.c +15 −0
  3. src/src_zoh.c +5 −1
src/src_linear.c+5−1
@@ -1,5 +1,5 @@
1/*1/*
2** Copyright (C) 2002-2011 Erik de Castro Lopo <erikd@mega-nerd.com>2** Copyright (C) 2002-2012 Erik de Castro Lopo <erikd@mega-nerd.com>
3**3**
4** This program is free software; you can redistribute it and/or modify4** This program is free software; you can redistribute it and/or modify
5** it under the terms of the GNU General Public License as published by5** it under the terms of the GNU General Public License as published by
@@ -78,6 +78,10 @@ linear_vari_process (SRC_PRIVATE *psrc, SRC_DATA *data) · 72 unmodified lines
78 priv->in_used = priv->out_gen = 0 ;78 priv->in_used = priv->out_gen = 0 ;
79 79
80 src_ratio = psrc->last_ratio ;80 src_ratio = psrc->last_ratio ;
81
82 if (is_bad_src_ratio (src_ratio))
83 return SRC_ERR_BAD_INTERNAL_STATE ;
84
81 input_index = psrc->last_position ;85 input_index = psrc->last_position ;
82 86
83 /* Calculate samples before first sample in input array. */87 /* Calculate samples before first sample in input array. */
src/src_sinc.c+15−0
@@ -347,6 +347,9 @@ sinc_mono_vari_process (SRC_PRIVATE *psrc, SRC_DATA *data) · 346 unmodified lines
347 347
348 src_ratio = psrc->last_ratio ;348 src_ratio = psrc->last_ratio ;
349 349
350 if (is_bad_src_ratio (src_ratio))
351 return SRC_ERR_BAD_INTERNAL_STATE ;
352
350 /* Check the sample rate ratio wrt the buffer len. */353 /* Check the sample rate ratio wrt the buffer len. */
351 count = (filter->coeff_half_len + 2.0) / filter->index_inc ;354 count = (filter->coeff_half_len + 2.0) / filter->index_inc ;
352 if (MIN (psrc->last_ratio, data->src_ratio) < 1.0)355 if (MIN (psrc->last_ratio, data->src_ratio) < 1.0)
@@ -493,6 +496,9 @@ sinc_stereo_vari_process (SRC_PRIVATE *psrc, SRC_DATA *data) · 140 unmodified lines
493 496
494 src_ratio = psrc->last_ratio ;497 src_ratio = psrc->last_ratio ;
495 498
499 if (is_bad_src_ratio (src_ratio))
500 return SRC_ERR_BAD_INTERNAL_STATE ;
501
496 /* Check the sample rate ratio wrt the buffer len. */502 /* Check the sample rate ratio wrt the buffer len. */
497 count = (filter->coeff_half_len + 2.0) / filter->index_inc ;503 count = (filter->coeff_half_len + 2.0) / filter->index_inc ;
498 if (MIN (psrc->last_ratio, data->src_ratio) < 1.0)504 if (MIN (psrc->last_ratio, data->src_ratio) < 1.0)
@@ -644,6 +650,9 @@ sinc_quad_vari_process (SRC_PRIVATE *psrc, SRC_DATA *data) · 145 unmodified lines
644 650
645 src_ratio = psrc->last_ratio ;651 src_ratio = psrc->last_ratio ;
646 652
653 if (is_bad_src_ratio (src_ratio))
654 return SRC_ERR_BAD_INTERNAL_STATE ;
655
647 /* Check the sample rate ratio wrt the buffer len. */656 /* Check the sample rate ratio wrt the buffer len. */
648 count = (filter->coeff_half_len + 2.0) / filter->index_inc ;657 count = (filter->coeff_half_len + 2.0) / filter->index_inc ;
649 if (MIN (psrc->last_ratio, data->src_ratio) < 1.0)658 if (MIN (psrc->last_ratio, data->src_ratio) < 1.0)
@@ -801,6 +810,9 @@ sinc_hex_vari_process (SRC_PRIVATE *psrc, SRC_DATA *data) · 151 unmodified lines
801 810
802 src_ratio = psrc->last_ratio ;811 src_ratio = psrc->last_ratio ;
803 812
813 if (is_bad_src_ratio (src_ratio))
814 return SRC_ERR_BAD_INTERNAL_STATE ;
815
804 /* Check the sample rate ratio wrt the buffer len. */816 /* Check the sample rate ratio wrt the buffer len. */
805 count = (filter->coeff_half_len + 2.0) / filter->index_inc ;817 count = (filter->coeff_half_len + 2.0) / filter->index_inc ;
806 if (MIN (psrc->last_ratio, data->src_ratio) < 1.0)818 if (MIN (psrc->last_ratio, data->src_ratio) < 1.0)
@@ -1045,6 +1057,9 @@ sinc_multichan_vari_process (SRC_PRIVATE *psrc, SRC_DATA *data) · 238 unmodified lines
1045 1057
1046 src_ratio = psrc->last_ratio ;1058 src_ratio = psrc->last_ratio ;
1047 1059
1060 if (is_bad_src_ratio (src_ratio))
1061 return SRC_ERR_BAD_INTERNAL_STATE ;
1062
1048 /* Check the sample rate ratio wrt the buffer len. */1063 /* Check the sample rate ratio wrt the buffer len. */
1049 count = (filter->coeff_half_len + 2.0) / filter->index_inc ;1064 count = (filter->coeff_half_len + 2.0) / filter->index_inc ;
1050 if (MIN (psrc->last_ratio, data->src_ratio) < 1.0)1065 if (MIN (psrc->last_ratio, data->src_ratio) < 1.0)
src/src_zoh.c+5−1
@@ -1,5 +1,5 @@
1/*1/*
2** Copyright (C) 2002-2011 Erik de Castro Lopo <erikd@mega-nerd.com>2** Copyright (C) 2002-2012 Erik de Castro Lopo <erikd@mega-nerd.com>
3**3**
4** This program is free software; you can redistribute it and/or modify4** This program is free software; you can redistribute it and/or modify
5** it under the terms of the GNU General Public License as published by5** it under the terms of the GNU General Public License as published by
@@ -76,6 +76,10 @@ zoh_vari_process (SRC_PRIVATE *psrc, SRC_DATA *data) · 70 unmodified lines
76 priv->in_used = priv->out_gen = 0 ;76 priv->in_used = priv->out_gen = 0 ;
77 77
78 src_ratio = psrc->last_ratio ;78 src_ratio = psrc->last_ratio ;
79
80 if (is_bad_src_ratio (src_ratio))
81 return SRC_ERR_BAD_INTERNAL_STATE ;
82
79 input_index = psrc->last_position ;83 input_index = psrc->last_position ;
80 84
81 /* Calculate samples before first sample in input array. */85 /* Calculate samples before first sample in input array. */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t