]> git.sesse.net Git - ffmpeg/commitdiff
avfilter/af_astats: rework sample loops
authorMarton Balint <cus@passwd.hu>
Fri, 1 Mar 2019 22:48:04 +0000 (23:48 +0100)
committerMarton Balint <cus@passwd.hu>
Wed, 20 Mar 2019 23:39:57 +0000 (00:39 +0100)
The channel loop is now the outer loop for both planar and interleaved. This is
needed by the next patch, and the speed difference is negligable if any.

Signed-off-by: Marton Balint <cus@passwd.hu>
libavfilter/af_astats.c

index f45558909ad4f5d7c000710a4f109e4bdbba199b..9915a7965ebfa4ade2d4a66381e086102adf0c98 100644 (file)
@@ -410,17 +410,18 @@ static void set_metadata(AudioStatsContext *s, AVDictionary **metadata)
     for (int c = 0; c < channels; c++) {                                        \
         ChannelStats *p = &s->chstats[c];                                       \
         const type *src = (const type *)data[c];                                \
-        for (int i = 0; i < samples; i++, src++)                                \
+        const type * const srcend = src + samples;                              \
+        for (; src < srcend; src++)                                             \
             update_stat(s, p, double_sample, normalized_sample, int_sample);    \
     }
 
-#define UPDATE_STATS_I(type, double_sample, normalized_sample, int_sample)                    \
-    {                                                                                         \
-        const type *src = (const type *)data[0];                                              \
-        for (int i = 0; i < samples; i++) {                                                   \
-            for (int c = 0; c < channels; c++, src++)                                         \
-                update_stat(s, &s->chstats[c], double_sample, normalized_sample, int_sample); \
-        }                                                                                     \
+#define UPDATE_STATS_I(type, double_sample, normalized_sample, int_sample)      \
+    for (int c = 0; c < channels; c++) {                                        \
+        ChannelStats *p = &s->chstats[c];                                       \
+        const type *src = (const type *)data[0];                                \
+        const type * const srcend = src + samples * channels;                   \
+        for (src += c; src < srcend; src += channels)                           \
+            update_stat(s, p, double_sample, normalized_sample, int_sample);    \
     }
 
 #define UPDATE_STATS(planar, type, sample, normalizer_suffix, int_sample) \