History

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 committed 16 years ago

Commit 34017fd1 parent e7eb2038 files · +59 −40Browse files

Unified · Split

8 files
  1. ffplay.c +2 −1
  2. libavcodec/avcodec.h +5 −5
  3. libavcodec/imgconvert.c +4 −30
  4. libavcore/avcore.h +1 −1
  5. libavcore/imgutils.c +34 −0
  6. libavcore/imgutils.h +10 −0
  7. libavfilter/avfilter.h +1 −1
  8. libavfilter/vsrc_buffer.c +2 −2
ffplay.c+2−1
@@ -28,6 +28,7 @@ · 27 unmodified lines
2828 #include "libavutil/avstring.h"
2929 #include "libavutil/colorspace.h"
3030 #include "libavutil/pixdesc.h"
31+#include "libavcore/imgutils.h"
3132 #include "libavcore/parseutils.h"
3233 #include "libavformat/avformat.h"
3334 #include "libavdevice/avdevice.h"
@@ -1734,7 +1735,7 @@ static int input_request_frame(AVFilterLink *link) · 1700 unmodified lines
17341735 picref = avfilter_ref_buffer(priv->frame->opaque, ~0);
17351736 } else {
17361737 picref = avfilter_get_video_buffer(link, AV_PERM_WRITE, link->w, link->h);
1737− av_picture_data_copy(picref->data, picref->linesize,
1738+ av_image_copy(picref->data, picref->linesize,
17381739 priv->frame->data, priv->frame->linesize,
17391740 picref->format, link->w, link->h);
17401741 }
libavcodec/avcodec.h+5−5
@@ -32,7 +32,7 @@ · 31 unmodified lines
3232
3333 #define LIBAVCODEC_VERSION_MAJOR 52
3434 #define LIBAVCODEC_VERSION_MINOR 87
35−#define LIBAVCODEC_VERSION_MICRO 3
35+#define LIBAVCODEC_VERSION_MICRO 4
3636
3737 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
3838 LIBAVCODEC_VERSION_MINOR, \
@@ -3950,15 +3950,15 @@ void *av_fast_realloc(void *ptr, unsigned int *size, unsigned int min_size); · 3911 unmodified lines
39503950 */
39513951 void av_fast_malloc(void *ptr, unsigned int *size, unsigned int min_size);
39523952
3953+#if LIBAVCODEC_VERSION_MAJOR < 53
39533954 /**
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().
39583956 */
3957+attribute_deprecated
39593958 void av_picture_data_copy(uint8_t *dst_data[4], int dst_linesize[4],
39603959 uint8_t *src_data[4], int src_linesize[4],
39613960 enum PixelFormat pix_fmt, int width, int height);
3961+#endif
39623962
39633963 /**
39643964 * Copy image src to dst. Wraps av_picture_data_copy() above.
libavcodec/imgconvert.c+4−30
@@ -793,46 +793,20 @@ int ff_get_plane_bytewidth(enum PixelFormat pix_fmt, int width, int plane) · 792 unmodified lines
793793 {
794794 return av_image_get_linesize(pix_fmt, width, plane);
795795 }
796−#endif
797796
798797 void av_picture_data_copy(uint8_t *dst_data[4], int dst_linesize[4],
799798 uint8_t *src_data[4], int src_linesize[4],
800799 enum PixelFormat pix_fmt, int width, int height)
801800 {
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);
830803 }
804+#endif
831805
832806 void av_picture_copy(AVPicture *dst, const AVPicture *src,
833807 enum PixelFormat pix_fmt, int width, int height)
834808 {
835− av_picture_data_copy(dst->data, dst->linesize, src->data,
809+ av_image_copy(dst->data, dst->linesize, src->data,
836810 src->linesize, pix_fmt, width, height);
837811 }
838812
libavcore/avcore.h+1−1
@@ -27,7 +27,7 @@ · 26 unmodified lines
2727 #include "libavutil/avutil.h"
2828
2929 #define LIBAVCORE_VERSION_MAJOR 0
30−#define LIBAVCORE_VERSION_MINOR 8
30+#define LIBAVCORE_VERSION_MINOR 9
3131 #define LIBAVCORE_VERSION_MICRO 0
3232
3333 #define LIBAVCORE_VERSION_INT AV_VERSION_INT(LIBAVCORE_VERSION_MAJOR, \
libavcore/imgutils.c+34−0
@@ -152,6 +152,40 @@ void av_image_copy_plane(uint8_t *dst, int dst_linesize, · 151 unmodified lines
152152 }
153153 }
154154
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+
155189 #if FF_API_OLD_IMAGE_NAMES
156190 void av_fill_image_max_pixsteps(int max_pixsteps[4], int max_pixstep_comps[4],
157191 const AVPixFmtDescriptor *pixdesc)
libavcore/imgutils.h+10−0
@@ -90,6 +90,16 @@ void av_image_copy_plane(uint8_t *dst, int dst_linesize, · 89 unmodified lines
9090 const uint8_t *src, int src_linesize,
9191 int bytewidth, int height);
9292
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+
93103 /**
94104 * Check if the given dimension of an image is valid, meaning that all
95105 * bytes of the image can be addressed with a signed int.
libavfilter/avfilter.h+1−1
@@ -26,7 +26,7 @@ · 25 unmodified lines
2626
2727 #define LIBAVFILTER_VERSION_MAJOR 1
2828 #define LIBAVFILTER_VERSION_MINOR 38
29−#define LIBAVFILTER_VERSION_MICRO 2
29+#define LIBAVFILTER_VERSION_MICRO 3
3030
3131 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
3232 LIBAVFILTER_VERSION_MINOR, \
libavfilter/vsrc_buffer.c+2−2
@@ -25,7 +25,7 @@ · 24 unmodified lines
2525
2626 #include "avfilter.h"
2727 #include "vsrc_buffer.h"
28−#include "libavutil/pixdesc.h"
28+#include "libavcore/imgutils.h"
2929
3030 typedef struct {
3131 int64_t pts;
@@ -119,7 +119,7 @@ static int request_frame(AVFilterLink *link) · 87 unmodified lines
119119 AV_PERM_REUSE2,
120120 link->w, link->h);
121121
122− av_picture_data_copy(picref->data, picref->linesize,
122+ av_image_copy(picref->data, picref->linesize,
123123 c->frame.data, c->frame.linesize,
124124 picref->format, link->w, link->h);
125125

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t