[FFmpeg-devel] [PATCH 1/1] Reimplement ff_img_copy_plane() as av_img_copy_plane() in libavcore, and deprecate the old function.

Michael Niedermayer michaelni
Thu Aug 19 12:44:34 CEST 2010


On Thu, Aug 19, 2010 at 12:37:39PM +0200, Stefano Sabatini wrote:
> ---
>  libavcodec/dsputil.c    |    3 ++-
>  libavcodec/dsputil.h    |    7 +++++++
>  libavcodec/imgconvert.c |   14 ++++----------
>  libavcore/imgutils.h    |   20 ++++++++++++++++++++
>  4 files changed, 33 insertions(+), 11 deletions(-)
> 
> diff --git a/libavcodec/dsputil.c b/libavcodec/dsputil.c
> index 534f03f..57ea273 100644
> --- a/libavcodec/dsputil.c
> +++ b/libavcodec/dsputil.c
> @@ -27,6 +27,7 @@
>   * DSP utils
>   */
>  
> +#include "libavcore/imgutils.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]= av_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 9ef0270..3dc091e 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 av_copy_image_plane_data() 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 33bc354..ddf8741 100644
> --- a/libavcodec/imgconvert.c
> +++ b/libavcodec/imgconvert.c
> @@ -781,20 +781,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;
> -    }
> +    av_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 +813,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],
> +            av_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],
> +        av_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.h b/libavcore/imgutils.h
> index 874bef1..03e2e88 100644
> --- a/libavcore/imgutils.h
> +++ b/libavcore/imgutils.h
> @@ -104,4 +104,24 @@ int av_fill_image_pointers(uint8_t *data[4], enum PixelFormat pix_fmt, int heigh
>   */
>  int av_check_image_size(unsigned int w, unsigned int h, int log_offset, void *log_ctx);
>  
> +/**
> + * Copy image plane 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
> + */
> +static inline
> +void av_copy_image_plane(uint8_t       *dst_data, int dst_linesize,

why static inline?

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

While the State exists there can be no freedom; when there is freedom there
will be no State. -- Vladimir Lenin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 190 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100819/e807df19/attachment.pgp>



More information about the ffmpeg-devel mailing list