Browse code

Move av_picture_data_copy() to libavcore, and rename it av_image_copy().

Originally committed as revision 25067 to svn://svn.ffmpeg.org/ffmpeg/trunk

Stefano Sabatini authored on 2010/09/08 06:23:55
Showing 8 changed files
... ...
@@ -28,6 +28,7 @@
28 28
 #include "libavutil/avstring.h"
29 29
 #include "libavutil/colorspace.h"
30 30
 #include "libavutil/pixdesc.h"
31
+#include "libavcore/imgutils.h"
31 32
 #include "libavcore/parseutils.h"
32 33
 #include "libavformat/avformat.h"
33 34
 #include "libavdevice/avdevice.h"
... ...
@@ -1734,7 +1735,7 @@ static int input_request_frame(AVFilterLink *link)
1734 1734
         picref = avfilter_ref_buffer(priv->frame->opaque, ~0);
1735 1735
     } else {
1736 1736
         picref = avfilter_get_video_buffer(link, AV_PERM_WRITE, link->w, link->h);
1737
-        av_picture_data_copy(picref->data, picref->linesize,
1737
+        av_image_copy(picref->data, picref->linesize,
1738 1738
                              priv->frame->data, priv->frame->linesize,
1739 1739
                              picref->format, link->w, link->h);
1740 1740
     }
... ...
@@ -32,7 +32,7 @@
32 32
 
33 33
 #define LIBAVCODEC_VERSION_MAJOR 52
34 34
 #define LIBAVCODEC_VERSION_MINOR 87
35
-#define LIBAVCODEC_VERSION_MICRO  3
35
+#define LIBAVCODEC_VERSION_MICRO  4
36 36
 
37 37
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
38 38
                                                LIBAVCODEC_VERSION_MINOR, \
... ...
@@ -3950,15 +3950,15 @@ void *av_fast_realloc(void *ptr, unsigned int *size, unsigned int min_size);
3950 3950
  */
3951 3951
 void av_fast_malloc(void *ptr, unsigned int *size, unsigned int min_size);
3952 3952
 
3953
+#if LIBAVCODEC_VERSION_MAJOR < 53
3953 3954
 /**
3954
- * Copy image data in src_data to dst_data.
3955
- *
3956
- * @param dst_linesize linesizes for the image in dst_data
3957
- * @param src_linesize linesizes for the image in src_data
3955
+ * @deprecated Deprecated in favor of av_image_copy().
3958 3956
  */
3957
+attribute_deprecated
3959 3958
 void av_picture_data_copy(uint8_t *dst_data[4], int dst_linesize[4],
3960 3959
                           uint8_t *src_data[4], int src_linesize[4],
3961 3960
                           enum PixelFormat pix_fmt, int width, int height);
3961
+#endif
3962 3962
 
3963 3963
 /**
3964 3964
  * Copy image src to dst. Wraps av_picture_data_copy() above.
... ...
@@ -793,46 +793,20 @@ int ff_get_plane_bytewidth(enum PixelFormat pix_fmt, int width, int plane)
793 793
 {
794 794
     return av_image_get_linesize(pix_fmt, width, plane);
795 795
 }
796
-#endif
797 796
 
798 797
 void av_picture_data_copy(uint8_t *dst_data[4], int dst_linesize[4],
799 798
                           uint8_t *src_data[4], int src_linesize[4],
800 799
                           enum PixelFormat pix_fmt, int width, int height)
801 800
 {
802
-    const AVPixFmtDescriptor *desc = &av_pix_fmt_descriptors[pix_fmt];
803
-
804
-    if (desc->flags & PIX_FMT_HWACCEL)
805
-        return;
806
-
807
-    if (desc->flags & PIX_FMT_PAL) {
808
-        av_image_copy_plane(dst_data[0], dst_linesize[0],
809
-                            src_data[0], src_linesize[0],
810
-                            width, height);
811
-        /* copy the palette */
812
-        memcpy(dst_data[1], src_data[1], 4*256);
813
-    } else {
814
-        int i, planes_nb = 0;
815
-
816
-        for (i = 0; i < desc->nb_components; i++)
817
-            planes_nb = FFMAX(planes_nb, desc->comp[i].plane + 1);
818
-
819
-        for (i = 0; i < planes_nb; i++) {
820
-            int h = height;
821
-            int bwidth = av_image_get_linesize(pix_fmt, width, i);
822
-            if (i == 1 || i == 2) {
823
-                h= -((-height)>>desc->log2_chroma_h);
824
-            }
825
-            av_image_copy_plane(dst_data[i], dst_linesize[i],
826
-                                src_data[i], src_linesize[i],
827
-                                bwidth, h);
828
-        }
829
-    }
801
+    av_image_copy(dst_data, dst_linesize, src_data, src_linesize,
802
+                  pix_fmt, width, height);
830 803
 }
804
+#endif
831 805
 
832 806
 void av_picture_copy(AVPicture *dst, const AVPicture *src,
833 807
                      enum PixelFormat pix_fmt, int width, int height)
834 808
 {
835
-    av_picture_data_copy(dst->data, dst->linesize, src->data,
809
+    av_image_copy(dst->data, dst->linesize, src->data,
836 810
                          src->linesize, pix_fmt, width, height);
837 811
 }
838 812
 
... ...
@@ -27,7 +27,7 @@
27 27
 #include "libavutil/avutil.h"
28 28
 
29 29
 #define LIBAVCORE_VERSION_MAJOR  0
30
-#define LIBAVCORE_VERSION_MINOR  8
30
+#define LIBAVCORE_VERSION_MINOR  9
31 31
 #define LIBAVCORE_VERSION_MICRO  0
32 32
 
33 33
 #define LIBAVCORE_VERSION_INT   AV_VERSION_INT(LIBAVCORE_VERSION_MAJOR, \
... ...
@@ -152,6 +152,40 @@ void av_image_copy_plane(uint8_t       *dst, int dst_linesize,
152 152
     }
153 153
 }
154 154
 
155
+void av_image_copy(uint8_t *dst_data[4], int dst_linesize[4],
156
+                   const uint8_t *src_data[4], const int src_linesize[4],
157
+                   enum PixelFormat pix_fmt, int width, int height)
158
+{
159
+    const AVPixFmtDescriptor *desc = &av_pix_fmt_descriptors[pix_fmt];
160
+
161
+    if (desc->flags & PIX_FMT_HWACCEL)
162
+        return;
163
+
164
+    if (desc->flags & PIX_FMT_PAL) {
165
+        av_image_copy_plane(dst_data[0], dst_linesize[0],
166
+                            src_data[0], src_linesize[0],
167
+                            width, height);
168
+        /* copy the palette */
169
+        memcpy(dst_data[1], src_data[1], 4*256);
170
+    } else {
171
+        int i, planes_nb = 0;
172
+
173
+        for (i = 0; i < desc->nb_components; i++)
174
+            planes_nb = FFMAX(planes_nb, desc->comp[i].plane + 1);
175
+
176
+        for (i = 0; i < planes_nb; i++) {
177
+            int h = height;
178
+            int bwidth = av_image_get_linesize(pix_fmt, width, i);
179
+            if (i == 1 || i == 2) {
180
+                h= -((-height)>>desc->log2_chroma_h);
181
+            }
182
+            av_image_copy_plane(dst_data[i], dst_linesize[i],
183
+                                src_data[i], src_linesize[i],
184
+                                bwidth, h);
185
+        }
186
+    }
187
+}
188
+
155 189
 #if FF_API_OLD_IMAGE_NAMES
156 190
 void av_fill_image_max_pixsteps(int max_pixsteps[4], int max_pixstep_comps[4],
157 191
                                 const AVPixFmtDescriptor *pixdesc)
... ...
@@ -91,6 +91,16 @@ void av_image_copy_plane(uint8_t       *dst, int dst_linesize,
91 91
                          int bytewidth, int height);
92 92
 
93 93
 /**
94
+ * Copy image in src_data to dst_data.
95
+ *
96
+ * @param dst_linesize linesizes for the image in dst_data
97
+ * @param src_linesize linesizes for the image in src_data
98
+ */
99
+void av_image_copy(uint8_t *dst_data[4], int dst_linesize[4],
100
+                   const uint8_t *src_data[4], const int src_linesize[4],
101
+                   enum PixelFormat pix_fmt, int width, int height);
102
+
103
+/**
94 104
  * Check if the given dimension of an image is valid, meaning that all
95 105
  * bytes of the image can be addressed with a signed int.
96 106
  *
... ...
@@ -26,7 +26,7 @@
26 26
 
27 27
 #define LIBAVFILTER_VERSION_MAJOR  1
28 28
 #define LIBAVFILTER_VERSION_MINOR 38
29
-#define LIBAVFILTER_VERSION_MICRO  2
29
+#define LIBAVFILTER_VERSION_MICRO  3
30 30
 
31 31
 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
32 32
                                                LIBAVFILTER_VERSION_MINOR, \
... ...
@@ -25,7 +25,7 @@
25 25
 
26 26
 #include "avfilter.h"
27 27
 #include "vsrc_buffer.h"
28
-#include "libavutil/pixdesc.h"
28
+#include "libavcore/imgutils.h"
29 29
 
30 30
 typedef struct {
31 31
     int64_t           pts;
... ...
@@ -119,7 +119,7 @@ static int request_frame(AVFilterLink *link)
119 119
                                        AV_PERM_REUSE2,
120 120
                                        link->w, link->h);
121 121
 
122
-    av_picture_data_copy(picref->data, picref->linesize,
122
+    av_image_copy(picref->data, picref->linesize,
123 123
                          c->frame.data, c->frame.linesize,
124 124
                          picref->format, link->w, link->h);
125 125