[FFmpeg-devel] [PATCH v2 16/22] avutil/imgutils: Constify some pointees

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Sun Sep 10 14:09:02 EEST 2023


Andreas Rheinhardt:
> This is done immediately without waiting for the next major bump
> just as in 9546b3a1cbcd94e9107f85c8f1d2175efc6cf083 and
> 4eaaa38d3dfb8863a62f3646a62e4098b1c078d5.
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
> ---
>  doc/APIchanges       |  4 ++++
>  libavutil/imgutils.c | 14 +++++++-------
>  libavutil/imgutils.h | 10 +++++-----
>  3 files changed, 16 insertions(+), 12 deletions(-)
> 
> diff --git a/doc/APIchanges b/doc/APIchanges
> index 963ad477bf..048232b2eb 100644
> --- a/doc/APIchanges
> +++ b/doc/APIchanges
> @@ -2,6 +2,10 @@ The last version increases of all libraries were on 2023-02-09
>  
>  API changes, most recent first:
>  
> +2023-09-07 - xxxxxxxxxx - lavu 58.xx.100 - imgutils.h
> +  Constify some pointees in av_image_copy(), av_image_copy_uc_from() and
> +  av_image_fill_black().
> +
>  2023-09-07 - xxxxxxxxxx - lavf 60.xx.100 - avio.h
>    Constify the buffer pointees in the write_packet and write_data_type
>    callbacks of AVIOContext.
> diff --git a/libavutil/imgutils.c b/libavutil/imgutils.c
> index 9ab5757cf6..da3812698e 100644
> --- a/libavutil/imgutils.c
> +++ b/libavutil/imgutils.c
> @@ -378,8 +378,8 @@ void av_image_copy_plane(uint8_t       *dst, int dst_linesize,
>      image_copy_plane(dst, dst_linesize, src, src_linesize, bytewidth, height);
>  }
>  
> -static void image_copy(uint8_t *dst_data[4], const ptrdiff_t dst_linesizes[4],
> -                       const uint8_t *src_data[4], const ptrdiff_t src_linesizes[4],
> +static void image_copy(uint8_t *const dst_data[4], const ptrdiff_t dst_linesizes[4],
> +                       const uint8_t *const src_data[4], const ptrdiff_t src_linesizes[4],
>                         enum AVPixelFormat pix_fmt, int width, int height,
>                         void (*copy_plane)(uint8_t *, ptrdiff_t, const uint8_t *,
>                                            ptrdiff_t, ptrdiff_t, int))
> @@ -419,8 +419,8 @@ static void image_copy(uint8_t *dst_data[4], const ptrdiff_t dst_linesizes[4],
>      }
>  }
>  
> -void av_image_copy(uint8_t *dst_data[4], int dst_linesizes[4],
> -                   const uint8_t *src_data[4], const int src_linesizes[4],
> +void av_image_copy(uint8_t *const dst_data[4], const int dst_linesizes[4],
> +                   const uint8_t * const src_data[4], const int src_linesizes[4],
>                     enum AVPixelFormat pix_fmt, int width, int height)
>  {
>      ptrdiff_t dst_linesizes1[4], src_linesizes1[4];
> @@ -435,8 +435,8 @@ void av_image_copy(uint8_t *dst_data[4], int dst_linesizes[4],
>                 width, height, image_copy_plane);
>  }
>  
> -void av_image_copy_uc_from(uint8_t *dst_data[4], const ptrdiff_t dst_linesizes[4],
> -                           const uint8_t *src_data[4], const ptrdiff_t src_linesizes[4],
> +void av_image_copy_uc_from(uint8_t * const dst_data[4], const ptrdiff_t dst_linesizes[4],
> +                           const uint8_t * const src_data[4], const ptrdiff_t src_linesizes[4],
>                             enum AVPixelFormat pix_fmt, int width, int height)
>  {
>      image_copy(dst_data, dst_linesizes, src_data, src_linesizes, pix_fmt,
> @@ -579,7 +579,7 @@ static void memset_bytes(uint8_t *dst, size_t dst_size, uint8_t *clear,
>  // if it's a subsampled packed format).
>  #define MAX_BLOCK_SIZE 32
>  
> -int av_image_fill_black(uint8_t *dst_data[4], const ptrdiff_t dst_linesize[4],
> +int av_image_fill_black(uint8_t * const dst_data[4], const ptrdiff_t dst_linesize[4],
>                          enum AVPixelFormat pix_fmt, enum AVColorRange range,
>                          int width, int height)
>  {
> diff --git a/libavutil/imgutils.h b/libavutil/imgutils.h
> index e10ac14952..91312a72d3 100644
> --- a/libavutil/imgutils.h
> +++ b/libavutil/imgutils.h
> @@ -170,8 +170,8 @@ void av_image_copy_plane_uc_from(uint8_t       *dst, ptrdiff_t dst_linesize,
>   * @param width         width of the image in pixels
>   * @param height        height of the image in pixels
>   */
> -void av_image_copy(uint8_t *dst_data[4], int dst_linesizes[4],
> -                   const uint8_t *src_data[4], const int src_linesizes[4],
> +void av_image_copy(uint8_t * const dst_data[4], const int dst_linesizes[4],
> +                   const uint8_t * const src_data[4], const int src_linesizes[4],
>                     enum AVPixelFormat pix_fmt, int width, int height);
>  
>  /**
> @@ -188,8 +188,8 @@ void av_image_copy(uint8_t *dst_data[4], int dst_linesizes[4],
>   * @note On x86, the linesizes currently need to be aligned to the cacheline
>   *       size (i.e. 64) to get improved performance.
>   */
> -void av_image_copy_uc_from(uint8_t *dst_data[4],       const ptrdiff_t dst_linesizes[4],
> -                           const uint8_t *src_data[4], const ptrdiff_t src_linesizes[4],
> +void av_image_copy_uc_from(uint8_t * const dst_data[4],       const ptrdiff_t dst_linesizes[4],
> +                           const uint8_t * const src_data[4], const ptrdiff_t src_linesizes[4],
>                             enum AVPixelFormat pix_fmt, int width, int height);
>  
>  /**
> @@ -319,7 +319,7 @@ int av_image_check_sar(unsigned int w, unsigned int h, AVRational sar);
>   * @param height        the height of the image in pixels
>   * @return 0 if the image data was cleared, a negative AVERROR code otherwise
>   */
> -int av_image_fill_black(uint8_t *dst_data[4], const ptrdiff_t dst_linesize[4],
> +int av_image_fill_black(uint8_t * const dst_data[4], const ptrdiff_t dst_linesize[4],
>                          enum AVPixelFormat pix_fmt, enum AVColorRange range,
>                          int width, int height);
>  

Will apply this patch and the other constification patches (i.e. patches
#16-#19 as well as #21) in two days unless there are objections.

- Andreas



More information about the ffmpeg-devel mailing list