Browse code

avfilter/af_afade: fix fading very long durations

Signed-off-by: Paul B Mahol <onemda@gmail.com>

Paul B Mahol authored on 2017/05/18 05:59:11
Showing 1 changed files
... ...
@@ -33,7 +33,7 @@ typedef struct AudioFadeContext {
33 33
     const AVClass *class;
34 34
     int type;
35 35
     int curve, curve2;
36
-    int nb_samples;
36
+    int64_t nb_samples;
37 37
     int64_t start_sample;
38 38
     int64_t duration;
39 39
     int64_t start_time;
... ...
@@ -45,7 +45,7 @@ typedef struct AudioFadeContext {
45 45
 
46 46
     void (*fade_samples)(uint8_t **dst, uint8_t * const *src,
47 47
                          int nb_samples, int channels, int direction,
48
-                         int64_t start, int range, int curve);
48
+                         int64_t start, int64_t range, int curve);
49 49
     void (*crossfade_samples)(uint8_t **dst, uint8_t * const *cf0,
50 50
                               uint8_t * const *cf1,
51 51
                               int nb_samples, int channels,
... ...
@@ -90,7 +90,7 @@ static int query_formats(AVFilterContext *ctx)
90 90
     return ff_set_common_samplerates(ctx, formats);
91 91
 }
92 92
 
93
-static double fade_gain(int curve, int64_t index, int range)
93
+static double fade_gain(int curve, int64_t index, int64_t range)
94 94
 {
95 95
 #define CUBE(a) ((a)*(a)*(a))
96 96
     double gain;
... ...
@@ -154,7 +154,7 @@ static double fade_gain(int curve, int64_t index, int range)
154 154
 #define FADE_PLANAR(name, type)                                             \
155 155
 static void fade_samples_## name ##p(uint8_t **dst, uint8_t * const *src,   \
156 156
                                      int nb_samples, int channels, int dir, \
157
-                                     int64_t start, int range, int curve)   \
157
+                                     int64_t start, int64_t range, int curve) \
158 158
 {                                                                           \
159 159
     int i, c;                                                               \
160 160
                                                                             \
... ...
@@ -172,7 +172,7 @@ static void fade_samples_## name ##p(uint8_t **dst, uint8_t * const *src,   \
172 172
 #define FADE(name, type)                                                    \
173 173
 static void fade_samples_## name (uint8_t **dst, uint8_t * const *src,      \
174 174
                                   int nb_samples, int channels, int dir,    \
175
-                                  int64_t start, int range, int curve)      \
175
+                                  int64_t start, int64_t range, int curve)  \
176 176
 {                                                                           \
177 177
     type *d = (type *)dst[0];                                               \
178 178
     const type *s = (type *)src[0];                                         \
... ...
@@ -228,10 +228,10 @@ static const AVOption afade_options[] = {
228 228
     { "out",          "fade-out",                                    0,                    AV_OPT_TYPE_CONST,  {.i64 = 1    }, 0, 0, FLAGS, "type" },
229 229
     { "start_sample", "set number of first sample to start fading",  OFFSET(start_sample), AV_OPT_TYPE_INT64,  {.i64 = 0    }, 0, INT64_MAX, FLAGS },
230 230
     { "ss",           "set number of first sample to start fading",  OFFSET(start_sample), AV_OPT_TYPE_INT64,  {.i64 = 0    }, 0, INT64_MAX, FLAGS },
231
-    { "nb_samples",   "set number of samples for fade duration",     OFFSET(nb_samples),   AV_OPT_TYPE_INT,    {.i64 = 44100}, 1, INT32_MAX, FLAGS },
232
-    { "ns",           "set number of samples for fade duration",     OFFSET(nb_samples),   AV_OPT_TYPE_INT,    {.i64 = 44100}, 1, INT32_MAX, FLAGS },
233
-    { "start_time",   "set time to start fading",                    OFFSET(start_time),   AV_OPT_TYPE_DURATION, {.i64 = 0. }, 0, INT32_MAX, FLAGS },
234
-    { "st",           "set time to start fading",                    OFFSET(start_time),   AV_OPT_TYPE_DURATION, {.i64 = 0. }, 0, INT32_MAX, FLAGS },
231
+    { "nb_samples",   "set number of samples for fade duration",     OFFSET(nb_samples),   AV_OPT_TYPE_INT64,  {.i64 = 44100}, 1, INT64_MAX, FLAGS },
232
+    { "ns",           "set number of samples for fade duration",     OFFSET(nb_samples),   AV_OPT_TYPE_INT64,  {.i64 = 44100}, 1, INT64_MAX, FLAGS },
233
+    { "start_time",   "set time to start fading",                    OFFSET(start_time),   AV_OPT_TYPE_DURATION, {.i64 = 0. }, 0, INT64_MAX, FLAGS },
234
+    { "st",           "set time to start fading",                    OFFSET(start_time),   AV_OPT_TYPE_DURATION, {.i64 = 0. }, 0, INT64_MAX, FLAGS },
235 235
     { "duration",     "set fade duration",                           OFFSET(duration),     AV_OPT_TYPE_DURATION, {.i64 = 0. }, 0, INT32_MAX, FLAGS },
236 236
     { "d",            "set fade duration",                           OFFSET(duration),     AV_OPT_TYPE_DURATION, {.i64 = 0. }, 0, INT32_MAX, FLAGS },
237 237
     { "curve",        "set fade curve type",                         OFFSET(curve),        AV_OPT_TYPE_INT,    {.i64 = TRI  }, 0, NB_CURVES - 1, FLAGS, "curve" },