This is an automated email from the git hooks/post-receive script. Git pushed a commit to branch master in repository ffmpeg.
commit 501d815ec45d38aed403e4db576d2439a6c61127 Author: Michael Niedermayer <[email protected]> AuthorDate: Sun Oct 4 02:50:51 2026 +0200 Commit: michaelni <[email protected]> CommitDate: Wed Oct 21 19:32:23 2026 +0000 avutil/frame: let libavutil allocate a video frame's buffer with its own allocator ff_frame_get_video_buffer() lays a video frame out like av_frame_get_buffer() does, but takes the buffer from a callback, so that the memory can come from a pool or from a device specific allocator. Assisted-by: Claude --- libavutil/frame.c | 9 ++++++--- libavutil/{side_data.h => frame_internal.h} | 21 ++++++++++++++------- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/libavutil/frame.c b/libavutil/frame.c index ca8e8486a3..185adbef68 100644 --- a/libavutil/frame.c +++ b/libavutil/frame.c @@ -21,6 +21,7 @@ #include "buffer.h" #include "dict.h" #include "frame.h" +#include "frame_internal.h" #include "imgutils.h" #include "mem.h" #include "refstruct.h" @@ -72,7 +73,9 @@ void av_frame_free(AVFrame **frame) #define ALIGN (HAVE_SIMD_ALIGN_64 ? 64 : 32) -static int get_video_buffer(AVFrame *frame, int align) +int ff_frame_get_video_buffer(AVFrame *frame, int align, + AVBufferRef *(*alloc)(void *opaque, size_t size), + void *opaque) { const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(frame->format); int ret, padded_height; @@ -119,7 +122,7 @@ static int get_video_buffer(AVFrame *frame, int align) total_size += sizes[i]; } - frame->buf[0] = av_buffer_alloc(total_size); + frame->buf[0] = alloc ? alloc(opaque, total_size) : av_buffer_alloc(total_size); if (!frame->buf[0]) { ret = AVERROR(ENOMEM); goto fail; @@ -209,7 +212,7 @@ int av_frame_get_buffer(AVFrame *frame, int align) return AVERROR(EINVAL); if (frame->width > 0 && frame->height > 0) - return get_video_buffer(frame, align); + return ff_frame_get_video_buffer(frame, align, NULL, NULL); else if (frame->nb_samples > 0 && (av_channel_layout_check(&frame->ch_layout))) return get_audio_buffer(frame, align); diff --git a/libavutil/side_data.h b/libavutil/frame_internal.h similarity index 62% copy from libavutil/side_data.h copy to libavutil/frame_internal.h index 8275aa35a5..a9f1c61805 100644 --- a/libavutil/side_data.h +++ b/libavutil/frame_internal.h @@ -16,15 +16,22 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef AVUTIL_SIDE_DATA_H -#define AVUTIL_SIDE_DATA_H +#ifndef AVUTIL_FRAME_INTERNAL_H +#define AVUTIL_FRAME_INTERNAL_H + +#include <stddef.h> #include "buffer.h" #include "frame.h" -AVFrameSideData *ff_frame_side_data_add_from_buf(AVFrameSideData ***sd, - int *nb_sd, - enum AVFrameSideDataType type, - AVBufferRef *buf); +/** + * Allocate the buffer of a video frame like av_frame_get_buffer(). + * + * @param alloc allocates the buffer, av_buffer_alloc() is used if NULL + * @param opaque passed to alloc + */ +int ff_frame_get_video_buffer(AVFrame *frame, int align, + AVBufferRef *(*alloc)(void *opaque, size_t size), + void *opaque); -#endif // AVUTIL_SIDE_DATA_H +#endif /* AVUTIL_FRAME_INTERNAL_H */ -- To stop receiving notification emails like this one, please contact [email protected]. _______________________________________________ ffmpeg-cvslog mailing list -- [email protected] To unsubscribe send an email to [email protected]
