diff options
author | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2024-03-22 14:44:21 +0100 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2024-03-22 23:38:16 +0100 |
commit | b7bec5d3c9ec0d38175d3385b37d85de26c96470 (patch) | |
tree | e9dbe6e57edfbb4d30e79df988a865e33040ce68 /libavutil | |
parent | 26398da8f3001518e6d229e69f8dedd50ef7d5f9 (diff) |
avutil/frame: Rename av_frame_side_data_get and add wrapper for it
av_frame_side_data_get() has a const AVFrameSideData * const *sd
parameter; so calling it with an AVFramesSideData **sd like
AVCodecContext.decoded_side_data (or with a AVFramesSideData * const
*sd) is safe, but the conversion is not performed automatically
in C. All users of this function therefore resort to a cast.
This commit changes this: av_frame_side_data_get() is renamed
to av_frame_side_data_get_c(); furthermore, a static inline
wrapper for it name av_frame_side_data_get() is added
that accepts an AVFramesSideData * const * and converts this
to const AVFramesSideData * const * in a Wcast-qual safe way.
This also allows to remove the casts from the current users.
Reviewed-by: Jan Ekström <jeebjp@gmail.com>
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavutil')
-rw-r--r-- | libavutil/frame.c | 8 | ||||
-rw-r--r-- | libavutil/frame.h | 19 |
2 files changed, 21 insertions, 6 deletions
diff --git a/libavutil/frame.c b/libavutil/frame.c index 8598aa98a2..7dd37e5490 100644 --- a/libavutil/frame.c +++ b/libavutil/frame.c @@ -813,9 +813,9 @@ int av_frame_side_data_clone(AVFrameSideData ***sd, int *nb_sd, return 0; } -const AVFrameSideData *av_frame_side_data_get(const AVFrameSideData * const *sd, - const int nb_sd, - enum AVFrameSideDataType type) +const AVFrameSideData *av_frame_side_data_get_c(const AVFrameSideData * const *sd, + const int nb_sd, + enum AVFrameSideDataType type) { for (int i = 0; i < nb_sd; i++) { if (sd[i]->type == type) @@ -828,7 +828,7 @@ AVFrameSideData *av_frame_get_side_data(const AVFrame *frame, enum AVFrameSideDataType type) { return (AVFrameSideData *)av_frame_side_data_get( - (const AVFrameSideData **)frame->side_data, frame->nb_side_data, + frame->side_data, frame->nb_side_data, type ); } diff --git a/libavutil/frame.h b/libavutil/frame.h index cf9ffe1ba9..373866c600 100644 --- a/libavutil/frame.h +++ b/libavutil/frame.h @@ -1051,9 +1051,24 @@ int av_frame_side_data_clone(AVFrameSideData ***sd, int *nb_sd, * @return a pointer to the side data of a given type on success, NULL if there * is no side data with such type in this set. */ -const AVFrameSideData *av_frame_side_data_get(const AVFrameSideData * const *sd, +const AVFrameSideData *av_frame_side_data_get_c(const AVFrameSideData * const *sd, + const int nb_sd, + enum AVFrameSideDataType type); + +/** + * Wrapper around av_frame_side_data_get_c() to workaround the limitation + * that for any type T the conversion from T * const * to const T * const * + * is not performed automatically in C. + * @see av_frame_side_data_get_c() + */ +static inline +const AVFrameSideData *av_frame_side_data_get(AVFrameSideData * const *sd, const int nb_sd, - enum AVFrameSideDataType type); + enum AVFrameSideDataType type) +{ + return av_frame_side_data_get_c((const AVFrameSideData * const *)sd, + nb_sd, type); +} /** * @} |