[FFmpeg-devel,1/2] avutil: export av_memset_bytes()

Submitted by Michael Niedermayer on Jan. 31, 2019, 1:09 p.m.

Details

Message ID 20190131130902.26536-1-michael@niedermayer.cc
State New
Headers show

Commit Message

Michael Niedermayer Jan. 31, 2019, 1:09 p.m.
This function is useful in more cases than just imgutils

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 doc/APIchanges       |  3 +++
 libavutil/imgutils.c |  8 ++------
 libavutil/imgutils.h | 10 ++++++++++
 3 files changed, 15 insertions(+), 6 deletions(-)

Comments

Moritz Barsnick Jan. 31, 2019, 2:38 p.m.
On Thu, Jan 31, 2019 at 14:09:01 +0100, Michael Niedermayer wrote:
> This function is useful in more cases than just imgutils
[...]
>  libavutil/imgutils.c |  8 ++------
>  libavutil/imgutils.h | 10 ++++++++++

If so, couldn't it be placed in libavutil/mem.[ch]? It seems
appropriate.

Moritz

Patch hide | download patch | download mbox

diff --git a/doc/APIchanges b/doc/APIchanges
index 784a5e5bd2..dc239cbd47 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -21,6 +21,9 @@  API changes, most recent first:
 2019-01-08 - xxxxxxxxxx - lavu 56.26.100 - frame.h
   Add AV_FRAME_DATA_REGIONS_OF_INTEREST
 
+201x-xx-xx - xxxxxxxxxx - lavu 56.xx.xxx - imgutils.h
+  Add av_memset_bytes()
+
 2018-12-21 - 2744d6b364 - lavu 56.25.100 - hdr_dynamic_metadata.h
   Add AV_FRAME_DATA_DYNAMIC_HDR_PLUS enum value, av_dynamic_hdr_plus_alloc(),
   av_dynamic_hdr_plus_create_side_data() functions, and related structs.
diff --git a/libavutil/imgutils.c b/libavutil/imgutils.c
index afc73e2def..3cc186b79f 100644
--- a/libavutil/imgutils.c
+++ b/libavutil/imgutils.c
@@ -494,11 +494,7 @@  int av_image_copy_to_buffer(uint8_t *dst, int dst_size,
     return size;
 }
 
-// Fill dst[0..dst_size] with the bytes in clear[0..clear_size]. The clear
-// bytes are repeated until dst_size is reached. If dst_size is unaligned (i.e.
-// dst_size%clear_size!=0), the remaining data will be filled with the beginning
-// of the clear data only.
-static void memset_bytes(uint8_t *dst, size_t dst_size, uint8_t *clear,
+void av_memset_bytes(uint8_t *dst, size_t dst_size, uint8_t *clear,
                          size_t clear_size)
 {
     int same = 1;
@@ -636,7 +632,7 @@  int av_image_fill_black(uint8_t *dst_data[4], const ptrdiff_t dst_linesize[4],
         int plane_h = ((height + ( 1 << chroma_div) - 1)) >> chroma_div;
 
         for (; plane_h > 0; plane_h--) {
-            memset_bytes(data, bytewidth, &clear_block[plane][0], clear_block_size[plane]);
+            av_memset_bytes(data, bytewidth, &clear_block[plane][0], clear_block_size[plane]);
             data += dst_linesize[plane];
         }
     }
diff --git a/libavutil/imgutils.h b/libavutil/imgutils.h
index 5b790ecf0a..2f0f4b9106 100644
--- a/libavutil/imgutils.h
+++ b/libavutil/imgutils.h
@@ -269,6 +269,16 @@  int av_image_fill_black(uint8_t *dst_data[4], const ptrdiff_t dst_linesize[4],
                         enum AVPixelFormat pix_fmt, enum AVColorRange range,
                         int width, int height);
 
+/**
+ * Fill dst[0..dst_size] with the bytes in clear[0..clear_size]. The clear
+ * bytes are repeated until dst_size is reached. If dst_size is unaligned (i.e.
+ * dst_size%clear_size!=0), the remaining data will be filled with the beginning
+ * of the clear data only.
+ */
+void av_memset_bytes(uint8_t *dst, size_t dst_size, uint8_t *clear,
+                     size_t clear_size);
+
+
 /**
  * @}
  */