[FFmpeg-devel] [PATCH 1/5] avutil/pixelutils: add av_pixelutils_bdiff()

Clément Bœsch u at pkh.me
Thu Aug 14 23:05:11 CEST 2014


---
 doc/APIchanges         |  3 +++
 libavutil/pixelutils.c | 21 +++++++++++++++++++++
 libavutil/pixelutils.h | 23 +++++++++++++++++++++++
 libavutil/version.h    |  2 +-
 4 files changed, 48 insertions(+), 1 deletion(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 067f60f..72cfe96 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -15,6 +15,9 @@ libavutil:     2014-08-09
 
 API changes, most recent first:
 
+2014-08-xx - xxxxxxx - lavu 54.04.100 - pixelutils.h
+  Add av_pixelutils_bdiff().
+
 2014-08-xx - xxxxxxx - lavu 54.03.0 - mem.h
   Add av_strndup().
 
diff --git a/libavutil/pixelutils.c b/libavutil/pixelutils.c
index 10ff7e8..473d394 100644
--- a/libavutil/pixelutils.c
+++ b/libavutil/pixelutils.c
@@ -85,6 +85,27 @@ av_pixelutils_sad_fn av_pixelutils_get_sad_fn(int w_bits, int h_bits, int aligne
 #endif
 }
 
+int64_t av_pixelutils_bdiff(const uint8_t *s1, ptrdiff_t stride1,
+                            const uint8_t *s2, ptrdiff_t stride2,
+                            av_pixelutils_sad_fn sadfn,
+                            int w, int h, int bsize)
+{
+#if !CONFIG_PIXELUTILS
+    return -1;
+#else
+    int x, y;
+    int64_t sad = 0;
+
+    for (y = 0; y < h - bsize + 1; y += bsize) {
+        for (x = 0; x < w - bsize + 1; x += bsize)
+            sad += sadfn(s1 + x, stride1, s2 + x, stride2);
+        s1 += bsize * stride1;
+        s2 += bsize * stride2;
+    }
+    return sad;
+#endif
+}
+
 #ifdef TEST
 #define W1 320
 #define H1 240
diff --git a/libavutil/pixelutils.h b/libavutil/pixelutils.h
index a8dbc15..aafe78e 100644
--- a/libavutil/pixelutils.h
+++ b/libavutil/pixelutils.h
@@ -49,4 +49,27 @@ typedef int (*av_pixelutils_sad_fn)(const uint8_t *src1, ptrdiff_t stride1,
 av_pixelutils_sad_fn av_pixelutils_get_sad_fn(int w_bits, int h_bits,
                                               int aligned, void *log_ctx);
 
+/**
+ * Compute the SAD of two large buffers block per block with the specified
+ * block SAD function.
+ *
+ * @param sadfn SAD function which can be obtained with av_pixelutils_get_sad_fn
+ * @param w     buffers width to process (the latest sad function call will be
+ *              on w-bsize+1)
+ * @param h     buffers height to process (the latest sad function call will be
+ *              on h-bsize+1)
+ * @param bsize block size (width and height, e.g: 8 for a 8x8 block)
+ *
+ * @return SAD or -1 in case libavutil is not compiled with the pixelutils.
+ *
+ * @note The function will not compute w % bsize remaining bytes on the right
+ * if any, even if the linesize is large enough to allow such read (this
+ * linesize can stay uninitialized). Same thing for the h % bsize remaining
+ * lines at the bottom.
+ */
+int64_t av_pixelutils_bdiff(const uint8_t *s1, ptrdiff_t stride1,
+                            const uint8_t *s2, ptrdiff_t stride2,
+                            av_pixelutils_sad_fn sadfn,
+                            int w, int h, int bsize);
+
 #endif /* AVUTIL_PIXELUTILS_H */
diff --git a/libavutil/version.h b/libavutil/version.h
index f5b9277..b86609b 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -56,7 +56,7 @@
  */
 
 #define LIBAVUTIL_VERSION_MAJOR  54
-#define LIBAVUTIL_VERSION_MINOR   3
+#define LIBAVUTIL_VERSION_MINOR   4
 #define LIBAVUTIL_VERSION_MICRO 100
 
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
-- 
2.0.4



More information about the ffmpeg-devel mailing list