Message ID | 20240311205844.3569895-9-jeebjp@gmail.com |
---|---|
State | New |
Headers | show |
Series | [FFmpeg-devel,v8,01/14] avutil/frame: split side data list wiping out to non-AVFrame function | expand |
Context | Check | Description |
---|---|---|
yinshiyou/make_loongarch64 | success | Make finished |
yinshiyou/make_fate_loongarch64 | success | Make fate finished |
andriy/make_x86 | success | Make finished |
andriy/make_fate_x86 | success | Make fate finished |
On 3/11/2024 5:58 PM, Jan Ekström wrote: > --- > libavutil/frame.c | 20 +++++++++++++++----- > libavutil/frame.h | 14 ++++++++++++++ > 2 files changed, 29 insertions(+), 5 deletions(-) > > diff --git a/libavutil/frame.c b/libavutil/frame.c > index 30db83a5e5..47ecd964b8 100644 > --- a/libavutil/frame.c > +++ b/libavutil/frame.c > @@ -830,16 +830,26 @@ int av_frame_side_data_clone(AVFrameSideData ***sd, int *nb_sd, > return 0; > } > > -AVFrameSideData *av_frame_get_side_data(const AVFrame *frame, > - enum AVFrameSideDataType type) > +const AVFrameSideData *av_frame_side_data_get(const AVFrameSideData **sd, > + const int nb_sd, > + enum AVFrameSideDataType type) > { > - for (int i = 0; i < frame->nb_side_data; i++) { > - if (frame->side_data[i]->type == type) > - return frame->side_data[i]; > + for (int i = 0; i < nb_sd; i++) { > + if (sd[i]->type == type) > + return sd[i]; > } > return NULL; > } > > +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, > + type > + ); > +} > + > static int frame_copy_video(AVFrame *dst, const AVFrame *src) > { > int planes; > diff --git a/libavutil/frame.h b/libavutil/frame.h > index a7e62ded15..e59f033cce 100644 > --- a/libavutil/frame.h > +++ b/libavutil/frame.h > @@ -1062,6 +1062,20 @@ AVFrameSideData *av_frame_side_data_add(AVFrameSideData ***sd, int *nb_sd, > int av_frame_side_data_clone(AVFrameSideData ***sd, int *nb_sd, > const AVFrameSideData *src, unsigned int flags); > > +/** > + * Get a side data entry of a specific type from an array. > + * > + * @param sd array of side data. > + * @param nb_sd integer containing the number of entries in the array. > + * @param type type of side data to be queried > + * > + * @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 **sd, > + const int nb_sd, > + enum AVFrameSideDataType type); > + > /** > * @} > */ LGTM.
diff --git a/libavutil/frame.c b/libavutil/frame.c index 30db83a5e5..47ecd964b8 100644 --- a/libavutil/frame.c +++ b/libavutil/frame.c @@ -830,16 +830,26 @@ int av_frame_side_data_clone(AVFrameSideData ***sd, int *nb_sd, return 0; } -AVFrameSideData *av_frame_get_side_data(const AVFrame *frame, - enum AVFrameSideDataType type) +const AVFrameSideData *av_frame_side_data_get(const AVFrameSideData **sd, + const int nb_sd, + enum AVFrameSideDataType type) { - for (int i = 0; i < frame->nb_side_data; i++) { - if (frame->side_data[i]->type == type) - return frame->side_data[i]; + for (int i = 0; i < nb_sd; i++) { + if (sd[i]->type == type) + return sd[i]; } return NULL; } +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, + type + ); +} + static int frame_copy_video(AVFrame *dst, const AVFrame *src) { int planes; diff --git a/libavutil/frame.h b/libavutil/frame.h index a7e62ded15..e59f033cce 100644 --- a/libavutil/frame.h +++ b/libavutil/frame.h @@ -1062,6 +1062,20 @@ AVFrameSideData *av_frame_side_data_add(AVFrameSideData ***sd, int *nb_sd, int av_frame_side_data_clone(AVFrameSideData ***sd, int *nb_sd, const AVFrameSideData *src, unsigned int flags); +/** + * Get a side data entry of a specific type from an array. + * + * @param sd array of side data. + * @param nb_sd integer containing the number of entries in the array. + * @param type type of side data to be queried + * + * @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 **sd, + const int nb_sd, + enum AVFrameSideDataType type); + /** * @} */