summaryrefslogtreecommitdiff
path: root/libavfilter/scene_sad.c
diff options
context:
space:
mode:
authorMarton Balint <cus@passwd.hu>2018-04-05 01:37:25 +0200
committerMarton Balint <cus@passwd.hu>2018-11-11 20:30:50 +0100
commit6c2a7a8e9a3698f37913d3f24723fbb8fa895798 (patch)
treee078a0d996756411dd2087fbdce35474cce539cf /libavfilter/scene_sad.c
parent6df9020f45eaff66ba2c2bac98cda9ddaacb03f3 (diff)
downloadffmpeg-6c2a7a8e9a3698f37913d3f24723fbb8fa895798.tar.gz
avfilter/vf_framerate: factorize SAD functions which compute SAD for a whole frame
Also add SIMD which works on lines because it is faster then calculating it on 8x8 blocks using pixelutils. Signed-off-by: Marton Balint <cus@passwd.hu>
Diffstat (limited to 'libavfilter/scene_sad.c')
-rw-r--r--libavfilter/scene_sad.c72
1 files changed, 72 insertions, 0 deletions
diff --git a/libavfilter/scene_sad.c b/libavfilter/scene_sad.c
new file mode 100644
index 0000000000..fa57a25961
--- /dev/null
+++ b/libavfilter/scene_sad.c
@@ -0,0 +1,72 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file
+ * Scene SAD funtions
+ */
+
+#include "scene_sad.h"
+
+void ff_scene_sad16_c(SCENE_SAD_PARAMS)
+{
+ uint64_t sad = 0;
+ const uint16_t *src1w = (const uint16_t *)src1;
+ const uint16_t *src2w = (const uint16_t *)src2;
+ int x, y;
+
+ stride1 /= 2;
+ stride2 /= 2;
+
+ for (y = 0; y < height; y++) {
+ for (x = 0; x < width; x++)
+ sad += FFABS(src1w[x] - src2w[x]);
+ src1w += stride1;
+ src2w += stride2;
+ }
+ *sum = sad;
+}
+
+void ff_scene_sad_c(SCENE_SAD_PARAMS)
+{
+ uint64_t sad = 0;
+ int x, y;
+
+ for (y = 0; y < height; y++) {
+ for (x = 0; x < width; x++)
+ sad += FFABS(src1[x] - src2[x]);
+ src1 += stride1;
+ src2 += stride2;
+ }
+ *sum = sad;
+}
+
+ff_scene_sad_fn ff_scene_sad_get_fn(int depth)
+{
+ ff_scene_sad_fn sad = NULL;
+ if (ARCH_X86)
+ sad = ff_scene_sad_get_fn_x86(depth);
+ if (!sad) {
+ if (depth == 8)
+ sad = ff_scene_sad_c;
+ if (depth == 16)
+ sad = ff_scene_sad16_c;
+ }
+ return sad;
+}
+