From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> To: ffmpeg-devel@ffmpeg.org Cc: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> Subject: [FFmpeg-devel] [PATCH 12/42] avcodec/decode: Use RefStruct API for hwaccel_picture_private Date: Tue, 19 Sep 2023 21:57:04 +0200 Message-ID: <AS8P250MB0744E81AA2F80355FAC237718FFAA@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM> (raw) In-Reply-To: <AS8P250MB074487CAD933FE4F6325C8EB8FFAA@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM> Avoids allocations and therefore error checks: Syncing hwaccel_picture_private across threads can't fail any more. Also gets rid of an unnecessary pointer in structures and in the parameter list of ff_hwaccel_frame_priv_alloc(). Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> --- libavcodec/av1dec.c | 15 ++++----------- libavcodec/av1dec.h | 4 +--- libavcodec/decode.c | 28 ++++++---------------------- libavcodec/decode.h | 10 +++------- libavcodec/h264_picture.c | 19 +++++-------------- libavcodec/h264_slice.c | 3 +-- libavcodec/h264dec.h | 1 - libavcodec/hevc_refs.c | 7 +++---- libavcodec/hevcdec.c | 11 ++--------- libavcodec/hevcdec.h | 3 +-- libavcodec/hwaccel_internal.h | 3 ++- libavcodec/mpegpicture.c | 18 +++++------------- libavcodec/mpegpicture.h | 1 - libavcodec/vp8.c | 14 ++++---------- libavcodec/vp8.h | 4 +--- libavcodec/vp9.c | 15 +++++---------- libavcodec/vp9shared.h | 3 +-- libavcodec/vulkan_av1.c | 9 +++------ libavcodec/vulkan_h264.c | 9 +++------ libavcodec/vulkan_hevc.c | 9 +++------ 20 files changed, 53 insertions(+), 133 deletions(-) diff --git a/libavcodec/av1dec.c b/libavcodec/av1dec.c index 87056520dd..c02408548c 100644 --- a/libavcodec/av1dec.c +++ b/libavcodec/av1dec.c @@ -27,7 +27,6 @@ #include "libavutil/opt.h" #include "avcodec.h" #include "av1_parse.h" -#include "decode.h" #include "av1dec.h" #include "atsc_a53.h" #include "bytestream.h" @@ -640,8 +639,7 @@ static int get_pixel_format(AVCodecContext *avctx) static void av1_frame_unref(AVCodecContext *avctx, AV1Frame *f) { ff_thread_release_buffer(avctx, f->f); - av_buffer_unref(&f->hwaccel_priv_buf); - f->hwaccel_picture_private = NULL; + ff_refstruct_unref(&f->hwaccel_picture_private); ff_refstruct_unref(&f->header_ref); f->raw_frame_header = NULL; f->spatial_id = f->temporal_id = 0; @@ -666,12 +664,8 @@ static int av1_frame_ref(AVCodecContext *avctx, AV1Frame *dst, const AV1Frame *s if (ret < 0) goto fail; - if (src->hwaccel_picture_private) { - dst->hwaccel_priv_buf = av_buffer_ref(src->hwaccel_priv_buf); - if (!dst->hwaccel_priv_buf) - goto fail; - dst->hwaccel_picture_private = dst->hwaccel_priv_buf->data; - } + ff_refstruct_replace(&dst->hwaccel_picture_private, + src->hwaccel_picture_private); dst->spatial_id = src->spatial_id; dst->temporal_id = src->temporal_id; @@ -915,8 +909,7 @@ static int av1_frame_alloc(AVCodecContext *avctx, AV1Frame *f) break; } - ret = ff_hwaccel_frame_priv_alloc(avctx, &f->hwaccel_picture_private, - &f->hwaccel_priv_buf); + ret = ff_hwaccel_frame_priv_alloc(avctx, &f->hwaccel_picture_private); if (ret < 0) goto fail; diff --git a/libavcodec/av1dec.h b/libavcodec/av1dec.h index acbeec4af3..b6a0c08e48 100644 --- a/libavcodec/av1dec.h +++ b/libavcodec/av1dec.h @@ -24,7 +24,6 @@ #include <stdint.h> #include "libavutil/fifo.h" -#include "libavutil/buffer.h" #include "libavutil/frame.h" #include "libavutil/pixfmt.h" #include "avcodec.h" @@ -35,8 +34,7 @@ typedef struct AV1Frame { AVFrame *f; - AVBufferRef *hwaccel_priv_buf; - void *hwaccel_picture_private; + void *hwaccel_picture_private; ///< RefStruct reference AV1RawOBU *header_ref; ///< RefStruct reference backing raw_frame_header. AV1RawFrameHeader *raw_frame_header; diff --git a/libavcodec/decode.c b/libavcodec/decode.c index 169ee79acd..7abfe7f0ce 100644 --- a/libavcodec/decode.c +++ b/libavcodec/decode.c @@ -28,18 +28,13 @@ #endif #include "libavutil/avassert.h" -#include "libavutil/avstring.h" -#include "libavutil/bprint.h" #include "libavutil/channel_layout.h" #include "libavutil/common.h" #include "libavutil/emms.h" -#include "libavutil/fifo.h" #include "libavutil/frame.h" #include "libavutil/hwcontext.h" #include "libavutil/imgutils.h" #include "libavutil/internal.h" -#include "libavutil/intmath.h" -#include "libavutil/opt.h" #include "avcodec.h" #include "avcodec_internal.h" @@ -51,6 +46,7 @@ #include "hwconfig.h" #include "internal.h" #include "packet_internal.h" +#include "refstruct.h" #include "thread.h" typedef struct DecodeContext { @@ -1790,34 +1786,22 @@ int ff_copy_palette(void *dst, const AVPacket *src, void *logctx) return 0; } -int ff_hwaccel_frame_priv_alloc(AVCodecContext *avctx, void **hwaccel_picture_private, - AVBufferRef **hwaccel_priv_buf) +int ff_hwaccel_frame_priv_alloc(AVCodecContext *avctx, void **hwaccel_picture_private) { const FFHWAccel *hwaccel = ffhwaccel(avctx->hwaccel); - AVBufferRef *ref; AVHWFramesContext *frames_ctx; - uint8_t *data; if (!hwaccel || !hwaccel->frame_priv_data_size) return 0; av_assert0(!*hwaccel_picture_private); - data = av_mallocz(hwaccel->frame_priv_data_size); - if (!data) - return AVERROR(ENOMEM); frames_ctx = (AVHWFramesContext *)avctx->hw_frames_ctx->data; - - ref = av_buffer_create(data, hwaccel->frame_priv_data_size, - hwaccel->free_frame_priv, - frames_ctx->device_ctx, 0); - if (!ref) { - av_free(data); + *hwaccel_picture_private = ff_refstruct_alloc_ext(hwaccel->frame_priv_data_size, 0, + frames_ctx->device_ctx, + hwaccel->free_frame_priv); + if (!*hwaccel_picture_private) return AVERROR(ENOMEM); - } - - *hwaccel_priv_buf = ref; - *hwaccel_picture_private = ref->data; return 0; } diff --git a/libavcodec/decode.h b/libavcodec/decode.h index a52152e4a7..ce97c53933 100644 --- a/libavcodec/decode.h +++ b/libavcodec/decode.h @@ -21,7 +21,6 @@ #ifndef AVCODEC_DECODE_H #define AVCODEC_DECODE_H -#include "libavutil/buffer.h" #include "libavutil/frame.h" #include "libavutil/hwcontext.h" @@ -141,16 +140,13 @@ int ff_side_data_update_matrix_encoding(AVFrame *frame, /** * Allocate a hwaccel frame private data if the provided avctx - * uses a hwaccel method that needs it. The private data will - * be refcounted via the AVBuffer API (if allocated). + * uses a hwaccel method that needs it. The returned data is + * a RefStruct reference (if allocated). * * @param avctx The codec context * @param hwaccel_picture_private Pointer to return hwaccel_picture_private - * @param hwaccel_priv_buf Pointer to return the AVBufferRef owning - * hwaccel_picture_private * @return 0 on success, < 0 on error */ -int ff_hwaccel_frame_priv_alloc(AVCodecContext *avctx, void **hwaccel_picture_private, - AVBufferRef **hwaccel_priv_buf); +int ff_hwaccel_frame_priv_alloc(AVCodecContext *avctx, void **hwaccel_picture_private); #endif /* AVCODEC_DECODE_H */ diff --git a/libavcodec/h264_picture.c b/libavcodec/h264_picture.c index 25d0d96ddb..9353e4b445 100644 --- a/libavcodec/h264_picture.c +++ b/libavcodec/h264_picture.c @@ -46,7 +46,7 @@ void ff_h264_unref_picture(H264Context *h, H264Picture *pic) ff_thread_release_ext_buffer(h->avctx, &pic->tf); ff_thread_release_buffer(h->avctx, pic->f_grain); - av_buffer_unref(&pic->hwaccel_priv_buf); + ff_refstruct_unref(&pic->hwaccel_picture_private); av_buffer_unref(&pic->qscale_table_buf); av_buffer_unref(&pic->mb_type_buf); @@ -129,14 +129,8 @@ int ff_h264_ref_picture(H264Context *h, H264Picture *dst, H264Picture *src) } } - if (src->hwaccel_picture_private) { - dst->hwaccel_priv_buf = av_buffer_ref(src->hwaccel_priv_buf); - if (!dst->hwaccel_priv_buf) { - ret = AVERROR(ENOMEM); - goto fail; - } - dst->hwaccel_picture_private = dst->hwaccel_priv_buf->data; - } + ff_refstruct_replace(&dst->hwaccel_picture_private, + src->hwaccel_picture_private); ret = av_buffer_replace(&dst->decode_error_flags, src->decode_error_flags); if (ret < 0) @@ -185,11 +179,8 @@ int ff_h264_replace_picture(H264Context *h, H264Picture *dst, const H264Picture goto fail; } - ret = av_buffer_replace(&dst->hwaccel_priv_buf, src->hwaccel_priv_buf); - if (ret < 0) - goto fail; - - dst->hwaccel_picture_private = src->hwaccel_picture_private; + ff_refstruct_replace(&dst->hwaccel_picture_private, + src->hwaccel_picture_private); ret = av_buffer_replace(&dst->decode_error_flags, src->decode_error_flags); if (ret < 0) diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c index 632f5b23b2..6df80c9522 100644 --- a/libavcodec/h264_slice.c +++ b/libavcodec/h264_slice.c @@ -206,8 +206,7 @@ static int alloc_picture(H264Context *h, H264Picture *pic) goto fail; } - ret = ff_hwaccel_frame_priv_alloc(h->avctx, &pic->hwaccel_picture_private, - &pic->hwaccel_priv_buf); + ret = ff_hwaccel_frame_priv_alloc(h->avctx, &pic->hwaccel_picture_private); if (ret < 0) goto fail; diff --git a/libavcodec/h264dec.h b/libavcodec/h264dec.h index 513856749a..7436e0a54f 100644 --- a/libavcodec/h264dec.h +++ b/libavcodec/h264dec.h @@ -117,7 +117,6 @@ typedef struct H264Picture { AVBufferRef *mb_type_buf; uint32_t *mb_type; - AVBufferRef *hwaccel_priv_buf; void *hwaccel_picture_private; ///< hardware accelerator private data AVBufferRef *ref_index_buf[2]; diff --git a/libavcodec/hevc_refs.c b/libavcodec/hevc_refs.c index c5c1203ef8..8f49704b54 100644 --- a/libavcodec/hevc_refs.c +++ b/libavcodec/hevc_refs.c @@ -27,6 +27,7 @@ #include "thread.h" #include "hevc.h" #include "hevcdec.h" +#include "refstruct.h" #include "threadframe.h" void ff_hevc_unref_frame(HEVCContext *s, HEVCFrame *frame, int flags) @@ -51,8 +52,7 @@ void ff_hevc_unref_frame(HEVCContext *s, HEVCFrame *frame, int flags) frame->collocated_ref = NULL; - av_buffer_unref(&frame->hwaccel_priv_buf); - frame->hwaccel_picture_private = NULL; + ff_refstruct_unref(&frame->hwaccel_picture_private); } } @@ -118,8 +118,7 @@ static HEVCFrame *alloc_frame(HEVCContext *s) (s->sei.picture_timing.picture_struct == AV_PICTURE_STRUCTURE_BOTTOM_FIELD)) frame->frame->flags |= AV_FRAME_FLAG_INTERLACED; - ret = ff_hwaccel_frame_priv_alloc(s->avctx, &frame->hwaccel_picture_private, - &frame->hwaccel_priv_buf); + ret = ff_hwaccel_frame_priv_alloc(s->avctx, &frame->hwaccel_picture_private); if (ret < 0) goto fail; diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c index 44a9680415..8316a815e7 100644 --- a/libavcodec/hevcdec.c +++ b/libavcodec/hevcdec.c @@ -28,7 +28,6 @@ #include "libavutil/attributes.h" #include "libavutil/avstring.h" #include "libavutil/common.h" -#include "libavutil/display.h" #include "libavutil/film_grain_params.h" #include "libavutil/internal.h" #include "libavutil/md5.h" @@ -37,13 +36,11 @@ #include "libavutil/timecode.h" #include "bswapdsp.h" -#include "bytestream.h" #include "cabac_functions.h" #include "codec_internal.h" #include "decode.h" #include "golomb.h" #include "hevc.h" -#include "hevc_data.h" #include "hevc_parse.h" #include "hevcdec.h" #include "hwaccel_internal.h" @@ -3416,12 +3413,8 @@ static int hevc_ref_frame(HEVCContext *s, HEVCFrame *dst, HEVCFrame *src) dst->flags = src->flags; dst->sequence = src->sequence; - if (src->hwaccel_picture_private) { - dst->hwaccel_priv_buf = av_buffer_ref(src->hwaccel_priv_buf); - if (!dst->hwaccel_priv_buf) - goto fail; - dst->hwaccel_picture_private = dst->hwaccel_priv_buf->data; - } + ff_refstruct_replace(&dst->hwaccel_picture_private, + src->hwaccel_picture_private); return 0; fail: diff --git a/libavcodec/hevcdec.h b/libavcodec/hevcdec.h index 94609e4699..1d29fc24d7 100644 --- a/libavcodec/hevcdec.h +++ b/libavcodec/hevcdec.h @@ -419,8 +419,7 @@ typedef struct HEVCFrame { AVBufferRef *rpl_tab_buf; AVBufferRef *rpl_buf; - AVBufferRef *hwaccel_priv_buf; - void *hwaccel_picture_private; + void *hwaccel_picture_private; ///< RefStruct reference /** * A sequence counter, so that old frames are output first diff --git a/libavcodec/hwaccel_internal.h b/libavcodec/hwaccel_internal.h index edfe283150..057b07323d 100644 --- a/libavcodec/hwaccel_internal.h +++ b/libavcodec/hwaccel_internal.h @@ -26,6 +26,7 @@ #include <stdint.h> #include "avcodec.h" +#include "refstruct.h" #define HWACCEL_CAP_ASYNC_SAFE (1 << 0) #define HWACCEL_CAP_THREAD_SAFE (1 << 1) @@ -154,7 +155,7 @@ typedef struct FFHWAccel { * @param hwctx a pointer to an AVHWDeviceContext. * @param data the per-frame hardware accelerator private data to be freed. */ - void (*free_frame_priv)(void *hwctx, uint8_t *data); + void (*free_frame_priv)(FFRefStructOpaque hwctx, void *data); /** * Callback to flush the hwaccel state. diff --git a/libavcodec/mpegpicture.c b/libavcodec/mpegpicture.c index b7c804c8ec..4126756e9b 100644 --- a/libavcodec/mpegpicture.c +++ b/libavcodec/mpegpicture.c @@ -27,11 +27,11 @@ #include "avcodec.h" #include "encode.h" -#include "internal.h" #include "decode.h" #include "motion_est.h" #include "mpegpicture.h" #include "mpegutils.h" +#include "refstruct.h" #include "threadframe.h" static void av_noinline free_picture_tables(Picture *pic) @@ -171,8 +171,7 @@ static int alloc_frame_buffer(AVCodecContext *avctx, Picture *pic, pic->f->height = avctx->height; } - ret = ff_hwaccel_frame_priv_alloc(avctx, &pic->hwaccel_picture_private, - &pic->hwaccel_priv_buf); + ret = ff_hwaccel_frame_priv_alloc(avctx, &pic->hwaccel_picture_private); if (ret < 0) return ret; @@ -316,12 +315,11 @@ void ff_mpeg_unref_picture(AVCodecContext *avctx, Picture *pic) else if (pic->f) av_frame_unref(pic->f); - av_buffer_unref(&pic->hwaccel_priv_buf); + ff_refstruct_unref(&pic->hwaccel_picture_private); if (pic->needs_realloc) free_picture_tables(pic); - pic->hwaccel_picture_private = NULL; pic->field_picture = 0; pic->b_frame_score = 0; pic->needs_realloc = 0; @@ -380,14 +378,8 @@ int ff_mpeg_ref_picture(AVCodecContext *avctx, Picture *dst, Picture *src) if (ret < 0) goto fail; - if (src->hwaccel_picture_private) { - dst->hwaccel_priv_buf = av_buffer_ref(src->hwaccel_priv_buf); - if (!dst->hwaccel_priv_buf) { - ret = AVERROR(ENOMEM); - goto fail; - } - dst->hwaccel_picture_private = dst->hwaccel_priv_buf->data; - } + ff_refstruct_replace(&dst->hwaccel_picture_private, + src->hwaccel_picture_private); dst->field_picture = src->field_picture; dst->b_frame_score = src->b_frame_score; diff --git a/libavcodec/mpegpicture.h b/libavcodec/mpegpicture.h index 7919aa402c..477b3ac535 100644 --- a/libavcodec/mpegpicture.h +++ b/libavcodec/mpegpicture.h @@ -66,7 +66,6 @@ typedef struct Picture { int alloc_mb_height; ///< mb_height used to allocate tables int alloc_mb_stride; ///< mb_stride used to allocate tables - AVBufferRef *hwaccel_priv_buf; void *hwaccel_picture_private; ///< Hardware accelerator private data int field_picture; ///< whether or not the picture was encoded in separate fields diff --git a/libavcodec/vp8.c b/libavcodec/vp8.c index db325dc90b..4a51c551b8 100644 --- a/libavcodec/vp8.c +++ b/libavcodec/vp8.c @@ -108,8 +108,7 @@ static int vp8_alloc_frame(VP8Context *s, VP8Frame *f, int ref) return ret; if (!(f->seg_map = ff_refstruct_allocz(s->mb_width * s->mb_height))) goto fail; - ret = ff_hwaccel_frame_priv_alloc(s->avctx, &f->hwaccel_picture_private, - &f->hwaccel_priv_buf); + ret = ff_hwaccel_frame_priv_alloc(s->avctx, &f->hwaccel_picture_private); if (ret < 0) goto fail; @@ -124,8 +123,7 @@ fail: static void vp8_release_frame(VP8Context *s, VP8Frame *f) { ff_refstruct_unref(&f->seg_map); - av_buffer_unref(&f->hwaccel_priv_buf); - f->hwaccel_picture_private = NULL; + ff_refstruct_unref(&f->hwaccel_picture_private); ff_thread_release_ext_buffer(s->avctx, &f->tf); } @@ -139,12 +137,8 @@ static int vp8_ref_frame(VP8Context *s, VP8Frame *dst, const VP8Frame *src) if ((ret = ff_thread_ref_frame(&dst->tf, &src->tf)) < 0) return ret; ff_refstruct_replace(&dst->seg_map, src->seg_map); - if (src->hwaccel_picture_private) { - dst->hwaccel_priv_buf = av_buffer_ref(src->hwaccel_priv_buf); - if (!dst->hwaccel_priv_buf) - return AVERROR(ENOMEM); - dst->hwaccel_picture_private = dst->hwaccel_priv_buf->data; - } + ff_refstruct_replace(&dst->hwaccel_picture_private, + src->hwaccel_picture_private); return 0; } diff --git a/libavcodec/vp8.h b/libavcodec/vp8.h index cb752d4498..eb9fa2f166 100644 --- a/libavcodec/vp8.h +++ b/libavcodec/vp8.h @@ -28,7 +28,6 @@ #include <stdatomic.h> -#include "libavutil/buffer.h" #include "libavutil/mem_internal.h" #include "libavutil/thread.h" @@ -154,8 +153,7 @@ typedef struct VP8Frame { ThreadFrame tf; uint8_t *seg_map; ///< RefStruct reference - AVBufferRef *hwaccel_priv_buf; - void *hwaccel_picture_private; + void *hwaccel_picture_private; ///< RefStruct reference } VP8Frame; #define MAX_THREADS 8 diff --git a/libavcodec/vp9.c b/libavcodec/vp9.c index 3cc27aa812..c9cc81ec94 100644 --- a/libavcodec/vp9.c +++ b/libavcodec/vp9.c @@ -30,6 +30,7 @@ #include "hwaccel_internal.h" #include "hwconfig.h" #include "profiles.h" +#include "refstruct.h" #include "thread.h" #include "threadframe.h" #include "pthread_internal.h" @@ -100,9 +101,8 @@ static void vp9_frame_unref(AVCodecContext *avctx, VP9Frame *f) { ff_thread_release_ext_buffer(avctx, &f->tf); av_buffer_unref(&f->extradata); - av_buffer_unref(&f->hwaccel_priv_buf); + ff_refstruct_unref(&f->hwaccel_picture_private); f->segmentation_map = NULL; - f->hwaccel_picture_private = NULL; } static int vp9_frame_alloc(AVCodecContext *avctx, VP9Frame *f) @@ -135,8 +135,7 @@ static int vp9_frame_alloc(AVCodecContext *avctx, VP9Frame *f) f->segmentation_map = f->extradata->data; f->mv = (VP9mvrefPair *) (f->extradata->data + sz); - ret = ff_hwaccel_frame_priv_alloc(avctx, &f->hwaccel_picture_private, - &f->hwaccel_priv_buf); + ret = ff_hwaccel_frame_priv_alloc(avctx, &f->hwaccel_picture_private); if (ret < 0) goto fail; @@ -163,12 +162,8 @@ static int vp9_frame_ref(AVCodecContext *avctx, VP9Frame *dst, VP9Frame *src) dst->mv = src->mv; dst->uses_2pass = src->uses_2pass; - if (src->hwaccel_picture_private) { - dst->hwaccel_priv_buf = av_buffer_ref(src->hwaccel_priv_buf); - if (!dst->hwaccel_priv_buf) - goto fail; - dst->hwaccel_picture_private = dst->hwaccel_priv_buf->data; - } + ff_refstruct_replace(&dst->hwaccel_picture_private, + src->hwaccel_picture_private); return 0; diff --git a/libavcodec/vp9shared.h b/libavcodec/vp9shared.h index 543a496df8..e54f23544e 100644 --- a/libavcodec/vp9shared.h +++ b/libavcodec/vp9shared.h @@ -69,8 +69,7 @@ typedef struct VP9Frame { VP9mvrefPair *mv; int uses_2pass; - AVBufferRef *hwaccel_priv_buf; - void *hwaccel_picture_private; + void *hwaccel_picture_private; ///< RefStruct reference } VP9Frame; enum BlockLevel { diff --git a/libavcodec/vulkan_av1.c b/libavcodec/vulkan_av1.c index b1373722ef..7c8dda7798 100644 --- a/libavcodec/vulkan_av1.c +++ b/libavcodec/vulkan_av1.c @@ -536,10 +536,10 @@ static int vk_av1_end_frame(AVCodecContext *avctx) return ff_vk_decode_frame(avctx, pic->f, vp, rav, rvp); } -static void vk_av1_free_frame_priv(void *_hwctx, uint8_t *data) +static void vk_av1_free_frame_priv(FFRefStructOpaque _hwctx, void *data) { - AVHWDeviceContext *hwctx = _hwctx; - AV1VulkanDecodePicture *ap = (AV1VulkanDecodePicture *)data; + AVHWDeviceContext *hwctx = _hwctx.nc; + AV1VulkanDecodePicture *ap = data; /* Workaround for a spec issue. */ if (ap->frame_id_set) @@ -547,9 +547,6 @@ static void vk_av1_free_frame_priv(void *_hwctx, uint8_t *data) /* Free frame resources, this also destroys the session parameters. */ ff_vk_decode_free_frame(hwctx, &ap->vp); - - /* Free frame context */ - av_free(ap); } const FFHWAccel ff_av1_vulkan_hwaccel = { diff --git a/libavcodec/vulkan_h264.c b/libavcodec/vulkan_h264.c index cdc2c7fe30..2cb54bb1ff 100644 --- a/libavcodec/vulkan_h264.c +++ b/libavcodec/vulkan_h264.c @@ -530,16 +530,13 @@ static int vk_h264_end_frame(AVCodecContext *avctx) return ff_vk_decode_frame(avctx, pic->f, vp, rav, rvp); } -static void vk_h264_free_frame_priv(void *_hwctx, uint8_t *data) +static void vk_h264_free_frame_priv(FFRefStructOpaque _hwctx, void *data) { - AVHWDeviceContext *hwctx = _hwctx; - H264VulkanDecodePicture *hp = (H264VulkanDecodePicture *)data; + AVHWDeviceContext *hwctx = _hwctx.nc; + H264VulkanDecodePicture *hp = data; /* Free frame resources, this also destroys the session parameters. */ ff_vk_decode_free_frame(hwctx, &hp->vp); - - /* Free frame context */ - av_free(hp); } const FFHWAccel ff_h264_vulkan_hwaccel = { diff --git a/libavcodec/vulkan_hevc.c b/libavcodec/vulkan_hevc.c index 395cbd3008..d5116bb48c 100644 --- a/libavcodec/vulkan_hevc.c +++ b/libavcodec/vulkan_hevc.c @@ -901,16 +901,13 @@ static int vk_hevc_end_frame(AVCodecContext *avctx) return ff_vk_decode_frame(avctx, pic->frame, vp, rav, rvp); } -static void vk_hevc_free_frame_priv(void *_hwctx, uint8_t *data) +static void vk_hevc_free_frame_priv(FFRefStructOpaque _hwctx, void *data) { - AVHWDeviceContext *hwctx = _hwctx; - HEVCVulkanDecodePicture *hp = (HEVCVulkanDecodePicture *)data; + AVHWDeviceContext *hwctx = _hwctx.nc; + HEVCVulkanDecodePicture *hp = data; /* Free frame resources */ ff_vk_decode_free_frame(hwctx, &hp->vp); - - /* Free frame context */ - av_free(hp); } const FFHWAccel ff_hevc_vulkan_hwaccel = { -- 2.34.1 _______________________________________________ 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:[~2023-09-19 19:58 UTC|newest] Thread overview: 106+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-09-19 19:38 [FFmpeg-devel] [PATCH 00/42] New API for reference counting and ThreadFrames Andreas Rheinhardt 2023-09-19 19:56 ` [FFmpeg-devel] [PATCH 01/42] tests/fate-run: Ensure that THREADS=random is actually random Andreas Rheinhardt 2023-09-25 20:01 ` Andreas Rheinhardt 2023-09-19 19:56 ` [FFmpeg-devel] [PATCH 02/42] avcodec/refstruct: Add simple API for refcounted objects Andreas Rheinhardt 2023-09-21 19:58 ` Nicolas George 2023-09-21 23:07 ` Andreas Rheinhardt 2023-10-06 18:24 ` Andreas Rheinhardt 2023-10-06 19:43 ` Nicolas George 2023-10-06 20:20 ` Andreas Rheinhardt 2023-10-06 20:37 ` Nicolas George 2023-10-06 20:50 ` Andreas Rheinhardt 2023-10-06 21:22 ` Nicolas George 2023-10-07 21:03 ` James Almer 2023-09-19 19:56 ` [FFmpeg-devel] [PATCH 03/42] avcodec/get_buffer: Use RefStruct API for FramePool Andreas Rheinhardt 2023-09-28 12:36 ` Anton Khirnov 2023-09-19 19:56 ` [FFmpeg-devel] [PATCH 04/42] avcodec/h264_ps: Use RefStruct API for SPS/PPS Andreas Rheinhardt 2023-09-28 13:03 ` Anton Khirnov 2023-09-28 15:49 ` Andreas Rheinhardt 2023-10-02 9:39 ` Anton Khirnov 2023-09-19 19:56 ` [FFmpeg-devel] [PATCH 05/42] avcodec/hevc_ps: Use RefStruct API for parameter sets Andreas Rheinhardt 2023-09-28 13:13 ` Anton Khirnov 2023-09-19 19:56 ` [FFmpeg-devel] [PATCH 06/42] avcodec/vp8: Use RefStruct API for seg_map Andreas Rheinhardt 2023-10-02 9:44 ` Anton Khirnov 2023-10-02 10:04 ` Andreas Rheinhardt 2023-10-02 10:14 ` Anton Khirnov 2023-09-19 19:56 ` [FFmpeg-devel] [PATCH 07/42] avcodec/wavpack: Use RefStruct API for DSD context Andreas Rheinhardt 2023-10-02 9:46 ` Anton Khirnov 2023-09-19 19:57 ` [FFmpeg-devel] [PATCH 08/42] avcodec/dovi_rpu: Use RefStruct API for Vdr data Andreas Rheinhardt 2023-10-02 9:51 ` Anton Khirnov 2023-09-19 19:57 ` [FFmpeg-devel] [PATCH 09/42] avcodec/refstruct: Allow checking for exclusive ownership Andreas Rheinhardt 2023-09-19 19:57 ` [FFmpeg-devel] [PATCH 10/42] avcodec/cbs: Use RefStruct-API for unit content Andreas Rheinhardt 2023-09-19 19:57 ` [FFmpeg-devel] [PATCH 11/42] avcodec/cbs_sei: Use RefStruct API for SEI messages Andreas Rheinhardt 2023-09-19 19:57 ` Andreas Rheinhardt [this message] 2023-10-02 10:39 ` [FFmpeg-devel] [PATCH 12/42] avcodec/decode: Use RefStruct API for hwaccel_picture_private Anton Khirnov 2023-10-02 12:30 ` Lynne 2023-09-19 19:57 ` [FFmpeg-devel] [PATCH 13/42] avcodec/vulkan_decode: Use RefStruct API for shared_ref Andreas Rheinhardt 2023-10-02 12:31 ` Lynne 2023-09-19 19:57 ` [FFmpeg-devel] [PATCH 14/42] avcodec/hevcdec: Use RefStruct API for RefPicListTap buffer Andreas Rheinhardt 2023-10-02 10:47 ` Anton Khirnov 2023-10-02 11:07 ` Andreas Rheinhardt 2023-10-04 8:10 ` Anton Khirnov 2023-09-19 19:57 ` [FFmpeg-devel] [PATCH 15/42] avcodec/pthread_frame: Use RefStruct API for ThreadFrame.progress Andreas Rheinhardt 2023-10-02 11:01 ` Anton Khirnov 2023-09-19 19:57 ` [FFmpeg-devel] [PATCH 16/42] avcodec/nvdec: Use RefStruct API for decoder_ref Andreas Rheinhardt 2023-10-02 10:58 ` Anton Khirnov 2023-09-19 19:57 ` [FFmpeg-devel] [PATCH 17/42] avcodec/refstruct: Add RefStruct pool API Andreas Rheinhardt 2023-09-20 19:58 ` Michael Niedermayer 2023-09-21 0:28 ` Andreas Rheinhardt 2023-10-04 8:39 ` Anton Khirnov 2023-10-04 11:09 ` Andreas Rheinhardt 2023-09-19 19:57 ` [FFmpeg-devel] [PATCH 18/42] avcodec/h264dec: Use RefStruct-pool API instead of AVBufferPool API Andreas Rheinhardt 2023-10-04 14:07 ` Anton Khirnov 2023-09-19 19:57 ` [FFmpeg-devel] [PATCH 19/42] avcodec/hevcdec: " Andreas Rheinhardt 2023-10-04 14:12 ` Anton Khirnov 2023-09-19 19:57 ` [FFmpeg-devel] [PATCH 20/42] avcodec/nvdec: Use RefStruct-pool API for decoder pool Andreas Rheinhardt 2023-10-04 14:28 ` Anton Khirnov 2023-09-19 19:57 ` [FFmpeg-devel] [PATCH 21/42] avcodec/refstruct: Allow to always return zeroed pool entries Andreas Rheinhardt 2023-10-12 12:45 ` Anton Khirnov 2023-10-12 13:25 ` Andreas Rheinhardt 2023-10-12 13:56 ` Anton Khirnov 2023-09-19 19:57 ` [FFmpeg-devel] [PATCH 22/42] avcodec/vp9: Use RefStruct-pool API for extradata Andreas Rheinhardt 2023-09-19 19:57 ` [FFmpeg-devel] [PATCH 23/42] avcodec/vaapi_encode: Use RefStruct pool API, stop abusing AVBuffer API Andreas Rheinhardt 2023-09-19 19:57 ` [FFmpeg-devel] [PATCH 24/42] avcodec/refstruct: Allow to share pools Andreas Rheinhardt 2023-10-12 13:04 ` Anton Khirnov 2023-10-12 13:51 ` Andreas Rheinhardt 2023-10-12 14:04 ` Anton Khirnov 2023-10-12 14:10 ` Andreas Rheinhardt 2023-10-12 17:09 ` Andreas Rheinhardt 2023-09-19 19:57 ` [FFmpeg-devel] [PATCH 25/42] avcodec/vp9: Join extradata buffer pools Andreas Rheinhardt 2023-09-19 19:57 ` [FFmpeg-devel] [PATCH 26/42] avcodec/refstruct: Allow to use a dynamic opaque Andreas Rheinhardt 2023-09-19 19:57 ` [FFmpeg-devel] [PATCH 27/42] avcodec/pthread_frame: Add new progress API Andreas Rheinhardt 2023-10-21 10:34 ` Anton Khirnov 2023-09-19 19:57 ` [FFmpeg-devel] [PATCH 28/42] avcodec/mimic: Switch to ProgressFrames Andreas Rheinhardt 2023-10-21 10:38 ` Anton Khirnov 2023-09-19 19:57 ` [FFmpeg-devel] [PATCH 29/42] avcodec/vp3: " Andreas Rheinhardt 2023-10-21 10:48 ` Anton Khirnov 2023-09-19 19:57 ` [FFmpeg-devel] [PATCH 30/42] avcodec/vp9: " Andreas Rheinhardt 2023-10-21 11:04 ` Anton Khirnov 2023-09-19 19:57 ` [FFmpeg-devel] [PATCH 31/42] avcodec/vp9: Fix race when attaching side-data for show-existing frame Andreas Rheinhardt 2023-09-19 19:57 ` [FFmpeg-devel] [PATCH 32/42] avcodec/vp9: Reduce wait times Andreas Rheinhardt 2023-09-19 19:57 ` [FFmpeg-devel] [PATCH 33/42] avcodec/vp9: Simplify replacing VP9Frame Andreas Rheinhardt 2023-09-19 19:57 ` [FFmpeg-devel] [PATCH 34/42] avcodec/vp9: Replace atomic_store() by atomic_init() Andreas Rheinhardt 2023-09-19 19:57 ` [FFmpeg-devel] [PATCH 35/42] avcodec/threadprogress: Add new API for frame-threaded progress Andreas Rheinhardt 2023-09-20 19:44 ` Michael Niedermayer 2023-09-21 0:28 ` Andreas Rheinhardt 2023-10-25 13:25 ` Anton Khirnov 2023-09-19 19:57 ` [FFmpeg-devel] [PATCH 36/42] avcodec/wavpack: Use ThreadProgress API Andreas Rheinhardt 2023-09-19 19:57 ` [FFmpeg-devel] [PATCH 37/42] avcodec/vp8: Convert to ProgressFrame API Andreas Rheinhardt 2023-10-25 13:35 ` Anton Khirnov 2023-09-19 19:57 ` [FFmpeg-devel] [PATCH 38/42] avcodec/codec_internal: Remove FF_CODEC_CAP_ALLOCATE_PROGRESS Andreas Rheinhardt 2023-10-25 13:38 ` Anton Khirnov 2023-09-19 19:57 ` [FFmpeg-devel] [PATCH 39/42] avcodec/hevcdec: Move collocated_ref to HEVCContext Andreas Rheinhardt 2023-10-25 13:42 ` Anton Khirnov 2023-09-19 19:57 ` [FFmpeg-devel] [PATCH 40/42] avcodec/hevcdec: Switch to ProgressFrames Andreas Rheinhardt 2023-11-09 9:50 ` Anton Khirnov 2023-09-19 19:57 ` [FFmpeg-devel] [PATCH 41/42] avcodec/pngdec: " Andreas Rheinhardt 2023-11-09 9:52 ` Anton Khirnov 2023-09-19 19:57 ` [FFmpeg-devel] [PATCH 42/42] avcodec/ffv1dec: " Andreas Rheinhardt 2023-11-09 9:56 ` Anton Khirnov 2023-10-02 18:13 ` [FFmpeg-devel] [PATCH 43/49] avcodec/qsv: Use RefStruct API for memory id (mids) array Andreas Rheinhardt 2023-10-02 18:13 ` [FFmpeg-devel] [PATCH 44/49] avcodec/rkmppdec: Fix double-free on error Andreas Rheinhardt 2023-10-02 18:13 ` [FFmpeg-devel] [PATCH 45/49] avcodec/rkmppdec: Check av_buffer_ref() Andreas Rheinhardt 2023-10-02 18:13 ` [FFmpeg-devel] [PATCH 46/49] avcodec/rkmppdec: Use RefStruct API for references to decoder itself Andreas Rheinhardt 2023-10-02 18:13 ` [FFmpeg-devel] [PATCH 47/49] avcodec/rkmppdec: Allocate AVDRMFrameDescriptor and frame ctx jointly Andreas Rheinhardt 2023-10-02 18:13 ` [FFmpeg-devel] [PATCH 48/49] avcodec/v4l2_m2m: Remove redundant av_frame_unref() Andreas Rheinhardt 2023-10-02 18:13 ` [FFmpeg-devel] [PATCH 49/49] avcodec/v4l2_(m2m|buffers): Use RefStruct API for context references Andreas Rheinhardt
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=AS8P250MB0744E81AA2F80355FAC237718FFAA@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM \ --to=andreas.rheinhardt@outlook.com \ --cc=ffmpeg-devel@ffmpeg.org \ /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