changeset 24:c063c88b1309 libavcore

Move av_picture_data_copy() to libavcore, and rename it av_image_copy().
author stefano
date Tue, 07 Sep 2010 21:23:55 +0000
parents 478992775cf8
children 63d8168fa16a
files avcore.h imgutils.c imgutils.h
diffstat 3 files changed, 45 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/avcore.h	Tue Sep 07 21:23:45 2010 +0000
+++ b/avcore.h	Tue Sep 07 21:23:55 2010 +0000
@@ -27,7 +27,7 @@
 #include "libavutil/avutil.h"
 
 #define LIBAVCORE_VERSION_MAJOR  0
-#define LIBAVCORE_VERSION_MINOR  8
+#define LIBAVCORE_VERSION_MINOR  9
 #define LIBAVCORE_VERSION_MICRO  0
 
 #define LIBAVCORE_VERSION_INT   AV_VERSION_INT(LIBAVCORE_VERSION_MAJOR, \
--- a/imgutils.c	Tue Sep 07 21:23:45 2010 +0000
+++ b/imgutils.c	Tue Sep 07 21:23:55 2010 +0000
@@ -152,6 +152,40 @@
     }
 }
 
+void av_image_copy(uint8_t *dst_data[4], int dst_linesize[4],
+                   const uint8_t *src_data[4], const int src_linesize[4],
+                   enum PixelFormat pix_fmt, int width, int height)
+{
+    const AVPixFmtDescriptor *desc = &av_pix_fmt_descriptors[pix_fmt];
+
+    if (desc->flags & PIX_FMT_HWACCEL)
+        return;
+
+    if (desc->flags & PIX_FMT_PAL) {
+        av_image_copy_plane(dst_data[0], dst_linesize[0],
+                            src_data[0], src_linesize[0],
+                            width, height);
+        /* copy the palette */
+        memcpy(dst_data[1], src_data[1], 4*256);
+    } else {
+        int i, planes_nb = 0;
+
+        for (i = 0; i < desc->nb_components; i++)
+            planes_nb = FFMAX(planes_nb, desc->comp[i].plane + 1);
+
+        for (i = 0; i < planes_nb; i++) {
+            int h = height;
+            int bwidth = av_image_get_linesize(pix_fmt, width, i);
+            if (i == 1 || i == 2) {
+                h= -((-height)>>desc->log2_chroma_h);
+            }
+            av_image_copy_plane(dst_data[i], dst_linesize[i],
+                                src_data[i], src_linesize[i],
+                                bwidth, h);
+        }
+    }
+}
+
 #if FF_API_OLD_IMAGE_NAMES
 void av_fill_image_max_pixsteps(int max_pixsteps[4], int max_pixstep_comps[4],
                                 const AVPixFmtDescriptor *pixdesc)
--- a/imgutils.h	Tue Sep 07 21:23:45 2010 +0000
+++ b/imgutils.h	Tue Sep 07 21:23:55 2010 +0000
@@ -91,6 +91,16 @@
                          int bytewidth, int height);
 
 /**
+ * Copy image in src_data to dst_data.
+ *
+ * @param dst_linesize linesizes for the image in dst_data
+ * @param src_linesize linesizes for the image in src_data
+ */
+void av_image_copy(uint8_t *dst_data[4], int dst_linesize[4],
+                   const uint8_t *src_data[4], const int src_linesize[4],
+                   enum PixelFormat pix_fmt, int width, int height);
+
+/**
  * Check if the given dimension of an image is valid, meaning that all
  * bytes of the image can be addressed with a signed int.
  *