[gegl/video-rejuvenation: 10/83] ff-load: fix audio sampling



commit 9d1c05893e25bdda660cc603f450165791bb3fd0
Author: Øyvind Kolås <pippin gimp org>
Date:   Wed Oct 7 19:56:34 2015 +0200

    ff-load: fix audio sampling

 operations/external/ff-load.c |   13 ++++++-------
 1 files changed, 6 insertions(+), 7 deletions(-)
---
diff --git a/operations/external/ff-load.c b/operations/external/ff-load.c
index 7745d81..1e9f50a 100644
--- a/operations/external/ff-load.c
+++ b/operations/external/ff-load.c
@@ -481,9 +481,9 @@ static void get_sample_data (Priv *p, long sample_no, float *left, float *right)
     int16_t *data = (void*) af->buf;
     if (p->audio_cursor_pos + af->len/4 > sample_no)
       {
-        int i = sample_no - no + af->len/4;
-        *left  = data[i*2+0] / 32768.0;
-        *right = data[i*2+0] / 32768.0;
+        int i = sample_no - p->audio_cursor_pos;
+        *left  = data[i*2+0] / 32767.0;
+        *right = data[i*2+1] / 32767.0;
         return;
       }
     l = p->audio_cursor;
@@ -495,10 +495,9 @@ static void get_sample_data (Priv *p, long sample_no, float *left, float *right)
     int16_t *data = (void*) af->buf;
     if (no + af->len/4 > sample_no)
       {
-        int i = sample_no - no + af->len/4;
-        *left  = data[i*2+0] / 32768.0;
-        *right = data[i*2+0] / 32768.0;
-
+        int i = sample_no - no;
+        *left  = data[i*2+0] / 32767.0;
+        *right = data[i*2+1] / 32767.0;
         p->audio_cursor     = l;
         p->audio_cursor_pos = no;
         return;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]