From: softworkz <ffmpegagent@gmail.com> To: ffmpeg-devel@ffmpeg.org Cc: Mark Thompson <sw@jkqxz.net>, softworkz <softworkz@hotmail.com> Subject: [FFmpeg-devel] [PATCH v2 1/4] avutil/buffer: add av_ref_from_buffer() function Date: Sat, 21 May 2022 14:07:39 +0000 Message-ID: <e9c920c2376837726abcc6f6c272ee3575a35bc6.1653142062.git.ffmpegagent@gmail.com> (raw) In-Reply-To: <pull.25.v2.ffstaging.FFmpeg.1653142062.ffmpegagent@gmail.com> From: softworkz <softworkz@hotmail.com> This allows to create AVBufferRef from AVBuffer directly. Signed-off-by: softworkz <softworkz@hotmail.com> --- libavutil/buffer.c | 16 ++++++++++++++++ libavutil/buffer.h | 8 ++++++++ 2 files changed, 24 insertions(+) diff --git a/libavutil/buffer.c b/libavutil/buffer.c index 54590be566..f9df0ad6ea 100644 --- a/libavutil/buffer.c +++ b/libavutil/buffer.c @@ -100,6 +100,22 @@ AVBufferRef *av_buffer_allocz(size_t size) return ret; } +AVBufferRef *av_ref_from_buffer(AVBuffer *buf) +{ + AVBufferRef *ref = av_mallocz(sizeof(*ref)); + + if (!ref) + return NULL; + + ref->buffer = buf; + ref->data = buf->data; + ref->size = buf->size; + + atomic_fetch_add_explicit(&buf->refcount, 1, memory_order_relaxed); + + return ref; +} + AVBufferRef *av_buffer_ref(const AVBufferRef *buf) { AVBufferRef *ret = av_mallocz(sizeof(*ret)); diff --git a/libavutil/buffer.h b/libavutil/buffer.h index e1ef5b7f07..491734b9ca 100644 --- a/libavutil/buffer.h +++ b/libavutil/buffer.h @@ -139,6 +139,14 @@ AVBufferRef *av_buffer_create(uint8_t *data, size_t size, */ void av_buffer_default_free(void *opaque, uint8_t *data); +/** + * Create a new reference to an AVBuffer. + * + * @return a new AVBufferRef referring to the same AVBuffer as buf or NULL on + * failure. + */ +AVBufferRef *av_ref_from_buffer(AVBuffer *buf); + /** * Create a new reference to an AVBuffer. * -- ffmpeg-codebot _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
next prev parent reply other threads:[~2022-05-21 14:08 UTC|newest] Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-04-30 20:07 [FFmpeg-devel] [PATCH 0/3] Add derive-device function which searches for existing devices in both directions ffmpegagent 2022-04-30 20:07 ` [FFmpeg-devel] [PATCH 1/3] avutils/hwcontext: add " softworkz 2022-04-30 21:38 ` Mark Thompson 2022-04-30 22:42 ` Soft Works 2022-05-01 22:00 ` Mark Thompson 2022-05-02 6:49 ` Soft Works 2022-05-02 8:14 ` Soft Works 2022-05-02 22:11 ` Mark Thompson 2022-05-02 22:59 ` Soft Works 2022-05-02 23:57 ` Mark Thompson 2022-05-03 0:11 ` Soft Works 2022-05-03 20:22 ` Mark Thompson 2022-05-03 21:04 ` Soft Works 2022-05-27 16:12 ` Soft Works 2022-05-02 8:28 ` Soft Works 2022-04-30 20:07 ` [FFmpeg-devel] [PATCH 2/3] lavu: bump minor version and add doc/APIchanges entry for av_hwdevice_ctx_get_or_create_derived() softworkz 2022-04-30 20:07 ` [FFmpeg-devel] [PATCH 3/3] avfilter/hwmap, hwupload: use new av_hwdevice_ctx_get_or_create_derived method softworkz 2022-05-21 14:07 ` [FFmpeg-devel] [PATCH v2 0/4] Add derive-device function which searches for existing devices in both directions ffmpegagent 2022-05-21 14:07 ` softworkz [this message] 2022-05-21 14:07 ` [FFmpeg-devel] [PATCH v2 2/4] avutils/hwcontext: add " softworkz 2022-05-21 14:07 ` [FFmpeg-devel] [PATCH v2 3/4] lavu: bump minor version and add doc/APIchanges entry for av_hwdevice_ctx_get_or_create_derived() softworkz 2022-05-21 14:07 ` [FFmpeg-devel] [PATCH v2 4/4] avfilter/hwmap, hwupload: use new av_hwdevice_ctx_get_or_create_derived method softworkz 2022-07-21 23:39 ` [FFmpeg-devel] [PATCH v3 0/4] Add derive-device function which searches for existing devices in both directions ffmpegagent 2022-07-21 23:39 ` [FFmpeg-devel] [PATCH v3 1/4] avutil/buffer: add av_ref_from_buffer() function softworkz 2022-07-21 23:39 ` [FFmpeg-devel] [PATCH v3 2/4] avutils/hwcontext: add derive-device function which searches for existing devices in both directions softworkz 2022-07-21 23:39 ` [FFmpeg-devel] [PATCH v3 3/4] lavu: bump minor version and add doc/APIchanges entry for av_hwdevice_ctx_get_or_create_derived() softworkz 2022-07-21 23:39 ` [FFmpeg-devel] [PATCH v3 4/4] avfilter/hwmap, hwupload: use new av_hwdevice_ctx_get_or_create_derived method softworkz 2022-10-21 7:06 ` [FFmpeg-devel] [PATCH v3 0/4] Add derive-device function which searches for existing devices in both directions Soft Works
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=e9c920c2376837726abcc6f6c272ee3575a35bc6.1653142062.git.ffmpegagent@gmail.com \ --to=ffmpegagent@gmail.com \ --cc=ffmpeg-devel@ffmpeg.org \ --cc=softworkz@hotmail.com \ --cc=sw@jkqxz.net \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git