[PATCH 3/3] Move av_picture_data_copy() to libavcore, and rename it av_copy_image().
--- ffplay.c | 2 +- libavcodec/avcodec.h | 8 ++++---- libavcodec/imgconvert.c | 34 ++++------------------------------ libavcore/imgutils.c | 34 ++++++++++++++++++++++++++++++++++ libavcore/imgutils.h | 10 ++++++++++ libavfilter/vsrc_buffer.c | 2 +- 6 files changed, 54 insertions(+), 36 deletions(-) diff --git a/ffplay.c b/ffplay.c index efc079b..754faff 100644 --- a/ffplay.c +++ b/ffplay.c @@ -1732,7 +1732,7 @@ static int input_request_frame(AVFilterLink *link) picref = avfilter_ref_buffer(priv->frame->opaque, ~0); } else { picref = avfilter_get_video_buffer(link, AV_PERM_WRITE, link->w, link->h); - av_picture_data_copy(picref->data, picref->linesize, + av_copy_image(picref->data, picref->linesize, priv->frame->data, priv->frame->linesize, picref->format, link->w, link->h); } diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 7fba268..bcce7aa 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -3936,15 +3936,15 @@ void *av_fast_realloc(void *ptr, unsigned int *size, unsigned int min_size); */ void av_fast_malloc(void *ptr, unsigned int *size, unsigned int min_size); +#if LIBAVCODEC_VERSION_MAJOR < 53 /** - * Copy image data 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 + * @deprecated Deprecated in favor of av_copy_image(). */ +attribute_deprecated void av_picture_data_copy(uint8_t *dst_data[4], int dst_linesize[4], uint8_t *src_data[4], int src_linesize[4], enum PixelFormat pix_fmt, int width, int height); +#endif /** * Copy image src to dst. Wraps av_picture_data_copy() above. diff --git a/libavcodec/imgconvert.c b/libavcodec/imgconvert.c index 57c919b..a8b65f2 100644 --- a/libavcodec/imgconvert.c +++ b/libavcodec/imgconvert.c @@ -793,46 +793,20 @@ int ff_get_plane_bytewidth(enum PixelFormat pix_fmt, int width, int plane) { return av_get_image_linesize(pix_fmt, width, plane); } -#endif void av_picture_data_copy(uint8_t *dst_data[4], int dst_linesize[4], uint8_t *src_data[4], 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_copy_image_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_get_image_linesize(pix_fmt, width, i); - if (i == 1 || i == 2) { - h= -((-height)>>desc->log2_chroma_h); - } - av_copy_image_plane(dst_data[i], dst_linesize[i], - src_data[i], src_linesize[i], - bwidth, h); - } - } + av_copy_image(dst_data, dst_linesize, src_data, src_linesize, + pix_fmt, width, height); } +#endif void av_picture_copy(AVPicture *dst, const AVPicture *src, enum PixelFormat pix_fmt, int width, int height) { - av_picture_data_copy(dst->data, dst->linesize, src->data, + av_copy_image(dst->data, dst->linesize, src->data, src->linesize, pix_fmt, width, height); } diff --git a/libavcore/imgutils.c b/libavcore/imgutils.c index 1fdaaae..3db6f85 100644 --- a/libavcore/imgutils.c +++ b/libavcore/imgutils.c @@ -120,3 +120,37 @@ 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 av_copy_image(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_copy_image_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_get_image_linesize(pix_fmt, width, i); + if (i == 1 || i == 2) { + h= -((-height)>>desc->log2_chroma_h); + } + av_copy_image_plane(dst_data[i], dst_linesize[i], + src_data[i], src_linesize[i], + bwidth, h); + } + } +} diff --git a/libavcore/imgutils.h b/libavcore/imgutils.h index 03e2e88..3ccfeda 100644 --- a/libavcore/imgutils.h +++ b/libavcore/imgutils.h @@ -124,4 +124,14 @@ void av_copy_image_plane(uint8_t *dst_data, int dst_linesize, } } +/** + * 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_copy_image(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); + #endif /* AVCORE_IMGUTILS_H */ diff --git a/libavfilter/vsrc_buffer.c b/libavfilter/vsrc_buffer.c index 03cf5ec..1134504 100644 --- a/libavfilter/vsrc_buffer.c +++ b/libavfilter/vsrc_buffer.c @@ -119,7 +119,7 @@ static int request_frame(AVFilterLink *link) AV_PERM_REUSE2, link->w, link->h); - av_picture_data_copy(picref->data, picref->linesize, + av_copy_image(picref->data, picref->linesize, c->frame.data, c->frame.linesize, picref->format, link->w, link->h); -- 1.7.0.4
On date Thursday 2010-08-19 13:34:41 +0200, Stefano Sabatini encoded:
--- ffplay.c | 2 +- libavcodec/avcodec.h | 8 ++++---- libavcodec/imgconvert.c | 34 ++++------------------------------ libavcore/imgutils.c | 34 ++++++++++++++++++++++++++++++++++ libavcore/imgutils.h | 10 ++++++++++ libavfilter/vsrc_buffer.c | 2 +- 6 files changed, 54 insertions(+), 36 deletions(-)
Ping. -- FFmpeg = Friendly & Fierce Meaningless Peaceful Excellent Gnome
On Thu, Aug 19, 2010 at 01:34:41PM +0200, Stefano Sabatini wrote:
--- ffplay.c | 2 +- libavcodec/avcodec.h | 8 ++++---- libavcodec/imgconvert.c | 34 ++++------------------------------ libavcore/imgutils.c | 34 ++++++++++++++++++++++++++++++++++ libavcore/imgutils.h | 10 ++++++++++ libavfilter/vsrc_buffer.c | 2 +- 6 files changed, 54 insertions(+), 36 deletions(-)
ok [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB I have never wished to cater to the crowd; for what I know they do not approve, and what they approve I do not know. -- Epicurus
On date Tuesday 2010-08-24 12:56:37 +0200, Michael Niedermayer encoded:
On Thu, Aug 19, 2010 at 01:34:41PM +0200, Stefano Sabatini wrote:
--- ffplay.c | 2 +- libavcodec/avcodec.h | 8 ++++---- libavcodec/imgconvert.c | 34 ++++------------------------------ libavcore/imgutils.c | 34 ++++++++++++++++++++++++++++++++++ libavcore/imgutils.h | 10 ++++++++++ libavfilter/vsrc_buffer.c | 2 +- 6 files changed, 54 insertions(+), 36 deletions(-)
ok
Applied. -- FFmpeg = Faithful and Fiendish Magical Puristic Eretic Guru
participants (2)
-
michaelni@gmx.at -
stefano.sabatini-lala@poste.it