[FFmpeg-cvslog] imgutils: expose av_image_copy_plane_uc_from()

Lynne git at videolan.org
Sat Aug 14 01:54:37 EEST 2021


ffmpeg | branch: master | Lynne <dev at lynne.ee> | Tue Aug 10 12:38:49 2021 +0200| [d5de9965ef680dad76ffca162afb20ddd9fd35d3] | committer: Lynne

imgutils: expose av_image_copy_plane_uc_from()

The reason why the generic av_image_copy_uc_from() doesn't really
fit in the case for Vulkan is because some planes may be copied via
other methods (such as mapping GPU memory), and if they don't satisfy
the strict alignment requirements, a gpu image->gpu buffer->cpu ram
copy is performed.

We need this for hwcontext_vulkan, and I think this will also be
useful to API users like libplacebo who would rather not write
a custom SIMD memcpy.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d5de9965ef680dad76ffca162afb20ddd9fd35d3
---

 doc/APIchanges       |  3 +++
 libavutil/imgutils.c |  8 ++++----
 libavutil/imgutils.h | 18 ++++++++++++++++++
 libavutil/version.h  |  2 +-
 4 files changed, 26 insertions(+), 5 deletions(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 6eefc7fc33..28cc0344ad 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -14,6 +14,9 @@ libavutil:     2021-04-27
 
 API changes, most recent first:
 
+2021-08-14 - xxxxxxxxxx - lavu 57.4.100 - imgutils.h
+  Add av_image_copy_plane_uc_from()
+
 2021-08-02 - xxxxxxxxxx - lavc 59.4.100 - packet.h
   Add AVPacket.opaque, AVPacket.opaque_ref, AVPacket.time_base.
 
diff --git a/libavutil/imgutils.c b/libavutil/imgutils.c
index 6c32a71cc5..9ab5757cf6 100644
--- a/libavutil/imgutils.c
+++ b/libavutil/imgutils.c
@@ -356,9 +356,9 @@ static void image_copy_plane(uint8_t       *dst, ptrdiff_t dst_linesize,
     }
 }
 
-static void image_copy_plane_uc_from(uint8_t       *dst, ptrdiff_t dst_linesize,
-                                     const uint8_t *src, ptrdiff_t src_linesize,
-                                     ptrdiff_t bytewidth, int height)
+void av_image_copy_plane_uc_from(uint8_t *dst, ptrdiff_t dst_linesize,
+                                 const uint8_t *src, ptrdiff_t src_linesize,
+                                 ptrdiff_t bytewidth, int height)
 {
     int ret = -1;
 
@@ -440,7 +440,7 @@ void av_image_copy_uc_from(uint8_t *dst_data[4], const ptrdiff_t dst_linesizes[4
                            enum AVPixelFormat pix_fmt, int width, int height)
 {
     image_copy(dst_data, dst_linesizes, src_data, src_linesizes, pix_fmt,
-               width, height, image_copy_plane_uc_from);
+               width, height, av_image_copy_plane_uc_from);
 }
 
 int av_image_fill_arrays(uint8_t *dst_data[4], int dst_linesize[4],
diff --git a/libavutil/imgutils.h b/libavutil/imgutils.h
index 5eccbf0bf7..cb2d74728e 100644
--- a/libavutil/imgutils.h
+++ b/libavutil/imgutils.h
@@ -124,6 +124,24 @@ void av_image_copy_plane(uint8_t       *dst, int dst_linesize,
                          const uint8_t *src, int src_linesize,
                          int bytewidth, int height);
 
+/**
+ * Copy image data located in uncacheable (e.g. GPU mapped) memory. Where
+ * available, this function will use special functionality for reading from such
+ * memory, which may result in greatly improved performance compared to plain
+ * av_image_copy_plane().
+ *
+ * bytewidth must be contained by both absolute values of dst_linesize
+ * and src_linesize, otherwise the function behavior is undefined.
+ *
+ * @note The linesize parameters have the type ptrdiff_t here, while they are
+ *       int for av_image_copy_plane().
+ * @note On x86, the linesizes currently need to be aligned to the cacheline
+ *       size (i.e. 64) to get improved performance.
+ */
+void av_image_copy_plane_uc_from(uint8_t       *dst, ptrdiff_t dst_linesize,
+                                 const uint8_t *src, ptrdiff_t src_linesize,
+                                 ptrdiff_t bytewidth, int height);
+
 /**
  * Copy image in src_data to dst_data.
  *
diff --git a/libavutil/version.h b/libavutil/version.h
index 6b4a265457..201b012596 100644
--- a/libavutil/version.h
+++ b/libavutil/version.h
@@ -79,7 +79,7 @@
  */
 
 #define LIBAVUTIL_VERSION_MAJOR  57
-#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, \



More information about the ffmpeg-cvslog mailing list