summaryrefslogtreecommitdiff
path: root/third_party
diff options
context:
space:
mode:
authorNanang Izzuddin <nanang@teluu.com>2010-02-01 11:23:54 +0000
committerNanang Izzuddin <nanang@teluu.com>2010-02-01 11:23:54 +0000
commitdc61d27b5e6b321067e38cb830ead225ae0b9829 (patch)
tree561e2fb2f7d12e1d6cb07e46d0a8f680aa5413af /third_party
parente13dbde5e2e020f31bebd8ca48e10e2c2d3900d3 (diff)
Ticket #766:
- Applied patch provided by Bram Kuijvenhoven related to truncation issue in floating-point to integer type-casts in pjmedia components. - Original patch proposal and description can be found here: http://lists.pjsip.org/pipermail/pjsip_lists.pjsip.org/2010-January/010258.html. git-svn-id: http://svn.pjsip.org/repos/pjproject/trunk@3085 74dad513-b988-da41-8d7b-12977e46ad98
Diffstat (limited to 'third_party')
-rw-r--r--third_party/resample/src/resamplesubs.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/third_party/resample/src/resamplesubs.c b/third_party/resample/src/resamplesubs.c
index 242844d5..23f2f252 100644
--- a/third_party/resample/src/resamplesubs.c
+++ b/third_party/resample/src/resamplesubs.c
@@ -118,9 +118,13 @@ static int
dtb = dt*(1<<Np) + 0.5; /* Fixed-point representation */
Ystart = Y;
- Yend = Ystart + (unsigned)(nx * pFactor);
+ Yend = Ystart + (unsigned)(nx * pFactor + 0.5);
endTime = time + (1<<Np)*(RES_WORD)nx;
- while (time < endTime)
+
+ // Integer round down in dtb calculation may cause (endTime % dtb > 0),
+ // so it may cause resample write pass the output buffer (Y >= Yend).
+ // while (time < endTime)
+ while (Y < Yend)
{
iconst = (time) & Pmask;
xp = &X[(time)>>Np]; /* Ptr to current input sample */
@@ -257,7 +261,7 @@ static int SrcUp(const RES_HWORD X[], RES_HWORD Y[], double pFactor,
dtb = dt*(1<<Np) + 0.5; /* Fixed-point representation */
Ystart = Y;
- Yend = Ystart + (unsigned)(nx * pFactor);
+ Yend = Ystart + (unsigned)(nx * pFactor + 0.5);
endTime = time + (1<<Np)*(RES_WORD)nx;
// Integer round down in dtb calculation may cause (endTime % dtb > 0),
@@ -305,7 +309,7 @@ static int SrcUD(const RES_HWORD X[], RES_HWORD Y[], double pFactor,
dhb = dh*(1<<Na) + 0.5; /* Fixed-point representation */
Ystart = Y;
- Yend = Ystart + (unsigned)(nx * pFactor);
+ Yend = Ystart + (unsigned)(nx * pFactor + 0.5);
endTime = time + (1<<Np)*(RES_WORD)nx;
// Integer round down in dtb calculation may cause (endTime % dtb > 0),