Browse code

avfilter/af_volume: Use avpriv_float_dsp_alloc()

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>

Michael Niedermayer authored on 2014/11/18 20:24:41
Showing 2 changed files
... ...
@@ -111,6 +111,11 @@ static int set_expr(AVExpr **pexpr, const char *expr, void *log_ctx)
111 111
 static av_cold int init(AVFilterContext *ctx)
112 112
 {
113 113
     VolumeContext *vol = ctx->priv;
114
+
115
+    vol->fdsp = avpriv_float_dsp_alloc(0);
116
+    if (!vol->fdsp)
117
+        return AVERROR(ENOMEM);
118
+
114 119
     return set_expr(&vol->volume_pexpr, vol->volume_expr, ctx);
115 120
 }
116 121
 
... ...
@@ -119,6 +124,7 @@ static av_cold void uninit(AVFilterContext *ctx)
119 119
     VolumeContext *vol = ctx->priv;
120 120
     av_expr_free(vol->volume_pexpr);
121 121
     av_opt_free(vol);
122
+    av_freep(&vol->fdsp);
122 123
 }
123 124
 
124 125
 static int query_formats(AVFilterContext *ctx)
... ...
@@ -233,11 +239,9 @@ static av_cold void volume_init(VolumeContext *vol)
233 233
         vol->scale_samples = scale_samples_s32;
234 234
         break;
235 235
     case AV_SAMPLE_FMT_FLT:
236
-        avpriv_float_dsp_init(&vol->fdsp, 0);
237 236
         vol->samples_align = 4;
238 237
         break;
239 238
     case AV_SAMPLE_FMT_DBL:
240
-        avpriv_float_dsp_init(&vol->fdsp, 0);
241 239
         vol->samples_align = 8;
242 240
         break;
243 241
     }
... ...
@@ -428,13 +432,13 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *buf)
428 428
             }
429 429
         } else if (av_get_packed_sample_fmt(vol->sample_fmt) == AV_SAMPLE_FMT_FLT) {
430 430
             for (p = 0; p < vol->planes; p++) {
431
-                vol->fdsp.vector_fmul_scalar((float *)out_buf->extended_data[p],
431
+                vol->fdsp->vector_fmul_scalar((float *)out_buf->extended_data[p],
432 432
                                              (const float *)buf->extended_data[p],
433 433
                                              vol->volume, plane_samples);
434 434
             }
435 435
         } else {
436 436
             for (p = 0; p < vol->planes; p++) {
437
-                vol->fdsp.vector_dmul_scalar((double *)out_buf->extended_data[p],
437
+                vol->fdsp->vector_dmul_scalar((double *)out_buf->extended_data[p],
438 438
                                              (const double *)buf->extended_data[p],
439 439
                                              vol->volume, plane_samples);
440 440
             }
... ...
@@ -67,7 +67,7 @@ enum ReplayGainType {
67 67
 
68 68
 typedef struct VolumeContext {
69 69
     const AVClass *class;
70
-    AVFloatDSPContext fdsp;
70
+    AVFloatDSPContext *fdsp;
71 71
     enum PrecisionType precision;
72 72
     enum EvalMode eval_mode;
73 73
     const char *volume_expr;