[PATCH 1/6] Reimplement ff_img_copy_plane() as ff_copy_image_plane() in libavcore, and deprecate the old function.

Stefano Sabatini stefano.sabatini-lala
Thu Aug 19 12:22:08 CEST 2010


---
 libavcodec/dsputil.c    |    3 ++-
 libavcodec/dsputil.h    |    7 +++++++
 libavcodec/imgconvert.c |   15 +++++----------
 libavcore/imgutils.c    |   14 ++++++++++++++
 libavcore/internal.h    |   41 +++++++++++++++++++++++++++++++++++++++++
 5 files changed, 69 insertions(+), 11 deletions(-)
 create mode 100644 libavcore/internal.h

diff --git a/libavcodec/dsputil.c b/libavcodec/dsputil.c
index 534f03f..7341fff 100644
--- a/libavcodec/dsputil.c
+++ b/libavcodec/dsputil.c
@@ -27,6 +27,7 @@
  * DSP utils
  */
 
+#include "libavcore/internal.h"
 #include "avcodec.h"
 #include "dsputil.h"
 #include "simple_idct.h"
@@ -4466,7 +4467,7 @@ av_cold void dsputil_init(DSPContext* c, AVCodecContext *avctx)
     c->sv_fmul_scalar[0] = sv_fmul_scalar_2_c;
     c->sv_fmul_scalar[1] = sv_fmul_scalar_4_c;
 
-    c->shrink[0]= ff_img_copy_plane;
+    c->shrink[0]= ff_copy_image_plane;
     c->shrink[1]= ff_shrink22;
     c->shrink[2]= ff_shrink44;
     c->shrink[3]= ff_shrink88;
diff --git a/libavcodec/dsputil.h b/libavcodec/dsputil.h
index 31eeb7b..a8503de 100644
--- a/libavcodec/dsputil.h
+++ b/libavcodec/dsputil.h
@@ -114,7 +114,14 @@ void ff_avg_vc1_mspel_mc00_c(uint8_t *dst, const uint8_t *src, int stride, int r
 void ff_ea_idct_put_c(uint8_t *dest, int linesize, DCTELEM *block);
 
 /* 1/2^n downscaling functions from imgconvert.c */
+#if LIBAVCODEC_VERSION_MAJOR < 53
+/**
+ * @deprecated Use ff_copy_image_plane() instead.
+ */
+attribute_deprecated
 void ff_img_copy_plane(uint8_t *dst, int dst_wrap, const uint8_t *src, int src_wrap, int width, int height);
+#endif
+
 void ff_shrink22(uint8_t *dst, int dst_wrap, const uint8_t *src, int src_wrap, int width, int height);
 void ff_shrink44(uint8_t *dst, int dst_wrap, const uint8_t *src, int src_wrap, int width, int height);
 void ff_shrink88(uint8_t *dst, int dst_wrap, const uint8_t *src, int src_wrap, int width, int height);
diff --git a/libavcodec/imgconvert.c b/libavcodec/imgconvert.c
index c29d92b..9ef95b6 100644
--- a/libavcodec/imgconvert.c
+++ b/libavcodec/imgconvert.c
@@ -37,6 +37,7 @@
 #include "libavutil/colorspace.h"
 #include "libavutil/pixdesc.h"
 #include "libavcore/imgutils.h"
+#include "libavcore/internal.h"
 
 #if HAVE_MMX && HAVE_YASM
 #include "x86/dsputil_mmx.h"
@@ -781,20 +782,14 @@ enum PixelFormat avcodec_find_best_pix_fmt(int64_t pix_fmt_mask, enum PixelForma
     return dst_pix_fmt;
 }
 
+#if LIBAVCODEC_VERSION_MAJOR < 53
 void ff_img_copy_plane(uint8_t *dst, int dst_wrap,
                            const uint8_t *src, int src_wrap,
                            int width, int height)
 {
-    if (!dst || !src)
-        return;
-    for(;height > 0; height--) {
-        memcpy(dst, src, width);
-        dst += dst_wrap;
-        src += src_wrap;
-    }
+    ff_copy_image_plane(dst, dst_wrap, src, src_wrap, width, height);
 }
 
-#if LIBAVCODEC_VERSION_MAJOR < 53
 int ff_get_plane_bytewidth(enum PixelFormat pix_fmt, int width, int plane)
 {
     return av_get_image_linesize(pix_fmt, width, plane);
@@ -819,13 +814,13 @@ void av_picture_data_copy(uint8_t *dst_data[4], int dst_linesize[4],
             if (i == 1 || i == 2) {
                 h= -((-height)>>desc->log2_chroma_h);
             }
-            ff_img_copy_plane(dst_data[i], dst_linesize[i],
+            ff_copy_image_plane(dst_data[i], dst_linesize[i],
                               src_data[i], src_linesize[i],
                               bwidth, h);
         }
         break;
     case FF_PIXEL_PALETTE:
-        ff_img_copy_plane(dst_data[0], dst_linesize[0],
+        ff_copy_image_plane(dst_data[0], dst_linesize[0],
                           src_data[0], src_linesize[0],
                           width, height);
         /* copy the palette */
diff --git a/libavcore/imgutils.c b/libavcore/imgutils.c
index ebaeff1..af56dd8 100644
--- a/libavcore/imgutils.c
+++ b/libavcore/imgutils.c
@@ -21,6 +21,7 @@
  * misc image utilities
  */
 
+#include "internal.h"
 #include "imgutils.h"
 #include "libavutil/pixdesc.h"
 
@@ -120,3 +121,16 @@ int av_check_image_size(unsigned int w, unsigned int h, int log_offset, void *lo
     av_log(&imgutils, AV_LOG_ERROR, "Picture size %ux%u is invalid\n", w, h);
     return AVERROR(EINVAL);
 }
+
+void ff_copy_image_plane(uint8_t       *dst, int dst_linesize,
+                         const uint8_t *src, int src_linesize,
+                         int bytewidth, int height)
+{
+    if (!dst || !src)
+        return;
+    for (;height > 0; height--) {
+        memcpy(dst, src, bytewidth);
+        dst += dst_linesize;
+        src += src_linesize;
+    }
+}
diff --git a/libavcore/internal.h b/libavcore/internal.h
new file mode 100644
index 0000000..2a6fc47
--- /dev/null
+++ b/libavcore/internal.h
@@ -0,0 +1,41 @@
+/*
+ * 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
+ */
+
+#ifndef AVCORE_INTERNAL_H
+#define AVCORE_INTERNAL_H
+
+/**
+ * @file
+ * internal API functions
+ */
+
+#include <stdint.h>
+
+/**
+ * Copy image plane data in src to dst.
+ *
+ * @param dst_linesize linesize for the image plane in dst
+ * @param src_linesize linesize for the image plane in src
+ * @param bytewidth the width in bytes of the image
+ * @param height the height of the image
+ */
+void ff_copy_image_plane(uint8_t       *dst, int dst_linesize,
+                         const uint8_t *src, int src_linesize,
+                         int bytewidth, int height);
+
+#endif /* AVCORE_INTERNAL_H */
-- 
1.7.1


--mxv5cy4qt+RJ9ypb--



More information about the ffmpeg-devel mailing list