History

avutil/frame: add helper for getting side data from array

Jan Ekström committed 3 years ago

Commit f287a281 parent 3c52f732 files · +29 −5Browse files

Unified · Split

2 files
  1. libavutil/frame.c +15 −5
  2. libavutil/frame.h +14 −0
libavutil/frame.c+15−5
@@ -813,16 +813,26 @@ int av_frame_side_data_clone(AVFrameSideData ***sd, int *nb_sd, · 812 unmodified lines
813813 return 0;
814814 }
815815
816−AVFrameSideData *av_frame_get_side_data(const AVFrame *frame,
817− enum AVFrameSideDataType type)
816+const AVFrameSideData *av_frame_side_data_get(const AVFrameSideData **sd,
817+ const int nb_sd,
818+ enum AVFrameSideDataType type)
818819 {
819− for (int i = 0; i < frame->nb_side_data; i++) {
820− if (frame->side_data[i]->type == type)
821− return frame->side_data[i];
820+ for (int i = 0; i < nb_sd; i++) {
821+ if (sd[i]->type == type)
822+ return sd[i];
822823 }
823824 return NULL;
824825 }
825826
827+AVFrameSideData *av_frame_get_side_data(const AVFrame *frame,
828+ enum AVFrameSideDataType type)
829+{
830+ return (AVFrameSideData *)av_frame_side_data_get(
831+ (const AVFrameSideData **)frame->side_data, frame->nb_side_data,
832+ type
833+ );
834+}
835+
826836 static int frame_copy_video(AVFrame *dst, const AVFrame *src)
827837 {
828838 int planes;
libavutil/frame.h+14−0
@@ -1041,6 +1041,20 @@ AVFrameSideData *av_frame_side_data_new(AVFrameSideData ***sd, int *nb_sd, · 1040 unmodified lines
10411041 int av_frame_side_data_clone(AVFrameSideData ***sd, int *nb_sd,
10421042 const AVFrameSideData *src, unsigned int flags);
10431043
1044+/**
1045+ * Get a side data entry of a specific type from an array.
1046+ *
1047+ * @param sd array of side data.
1048+ * @param nb_sd integer containing the number of entries in the array.
1049+ * @param type type of side data to be queried
1050+ *
1051+ * @return a pointer to the side data of a given type on success, NULL if there
1052+ * is no side data with such type in this set.
1053+ */
1054+const AVFrameSideData *av_frame_side_data_get(const AVFrameSideData **sd,
1055+ const int nb_sd,
1056+ enum AVFrameSideDataType type);
1057+
10441058 /**
10451059 * @}
10461060 */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t