From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.ffmpeg.org (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id 99B214D250 for ; Fri, 14 Nov 2025 09:32:45 +0000 (UTC) Authentication-Results: ffbox; dkim=fail (body hash mismatch (got b'vH1NecepkjUfcWHozSkqbQHGTlltQ9Kr3zvOnjqZYnI=', expected b'oDMfc6u09dktPE2q6FQZGtkwNzqzG7Na/Rz8gd7w2kI=')) header.d=ffmpeg.org header.i=@ffmpeg.org header.a=rsa-sha256 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ffmpeg.org; i=@ffmpeg.org; q=dns/txt; s=mail; t=1763112745; h=mime-version : to : date : message-id : reply-to : subject : list-id : list-archive : list-archive : list-help : list-owner : list-post : list-subscribe : list-unsubscribe : from : cc : content-type : content-transfer-encoding : from; bh=vH1NecepkjUfcWHozSkqbQHGTlltQ9Kr3zvOnjqZYnI=; b=QADFk/5nJySMC1va4h5tz7slEkgpFlot5dAyVan/Ph+dhHOiy1IBDm1aTVG5+kNbEfRXH 4Gjj1/hjkuiA/Ivr8szJy/UriYvicSaGaespHC8pTYs05cRMAlQckB9MDNRZm9HAbu3AChM 1obcCxhNgZ+KAx4wWEwGUGV0K9CCd+q/GoXhVshohsSGhsj0jWI+c3s9wzkvLNZ4dbgktKa R+s0puZQ3A5UPlWK4I+vCa23t6e2AeAWEUfElt3wC0d3spW1+y79MlyzaZLAa+684cKC/eq jJBcIVHrwrvBuslGJh0qct0TdI64kFqIT/Uhbp3tDrSC6/IztK4UkCyuXAXA== Received: from [172.19.0.2] (unknown [172.19.0.2]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id 54A6468FE13; Fri, 14 Nov 2025 11:32:25 +0200 (EET) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=ffmpeg.org; s=arc; t=1763112720; b=RLECiEWf09n9bcXWJ7mjglehQKqWz/9yxdV1Byexfs62GmQ/NR0jdhKGjvgGw3/Dh3LCF BVoTTJ04aVscyKPKp7+FyGNPHnUD1qMwvOR0ahVJy5Lj444pZLdWrZS6zufFIpbY8l0aiu0 MJd1o03CK3zSquwHBEYBNTdgCo2DO70f+ZNW5yoMjWiHPlXyrkBdez82AMAwrPVic+rPxR8 OaBw90xBaER/xOCNeFC1euJUL3e/ozIVteMghoddteLXAP9E0cvbomy33UPkK0jAmSEYXl5 YZhM0Lnth6ka7cg/xtpYO/jWr/rGN6A2/AGvLZsV8MVVuzi58vs8GGjmnWow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=ffmpeg.org; s=arc; t=1763112720; h=from : sender : reply-to : subject : date : message-id : to : cc : mime-version : content-type : content-transfer-encoding : content-id : content-description : resent-date : resent-from : resent-sender : resent-to : resent-cc : resent-message-id : in-reply-to : references : list-id : list-help : list-unsubscribe : list-subscribe : list-post : list-owner : list-archive; bh=VyQrR+fmgX5VK6wV2ATU54SYmV6eYPzFlYe3rHxPwMM=; b=dOX+gExVH6xFOL0IWX/MDQ3XmOK9vFjruFCtZUDQhh5aoUvRMUFL0WLoCTdzPU4X07lmL YGsNFilDKKfUZPAoEiZNrl19vy3gPrVoIT9crsleJ7Ap102nKA3f3t3QUVG+PtrxK6nUf8p 58Mct9c1pLxlxNct52cBRlOFnaVSI/vSgx8/fWXezqrRX8XXdxcAOHE1Pnfc7zRA604khni gpQO9oQBNTko4pROFxOkgeORIs4AhCStoei00Gg1v00P8YREzE69+dhL7HEN0Dw+KTfKmEH NCyQ/foNEoxocI847JfkWiJDQ4j5vFPo3/f1aliEvAiKvQD+w2kZ+/aoIPoA== ARC-Authentication-Results: i=1; ffmpeg.org; dkim=pass header.d=ffmpeg.org header.i=@ffmpeg.org; arc=none; dmarc=pass header.from=ffmpeg.org policy.dmarc=quarantine Authentication-Results: ffmpeg.org; dkim=pass header.d=ffmpeg.org header.i=@ffmpeg.org; arc=none (Message is not ARC signed); dmarc=pass (Used From Domain Record) header.from=ffmpeg.org policy.dmarc=quarantine DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ffmpeg.org; i=@ffmpeg.org; q=dns/txt; s=mail; t=1763112709; h=content-type : mime-version : content-transfer-encoding : from : to : reply-to : subject : date : from; bh=oDMfc6u09dktPE2q6FQZGtkwNzqzG7Na/Rz8gd7w2kI=; b=SdO6C0ciDYvFmiZOAsDY/Yvji7ge0DAiVPd1J1CUMXk03Ym32FBgXitjLOn8pOgwsi59w QCuyOZLZgAOrBD/EuNMhz4e11XPlfE3v9Dl80SzJI7sb255i5qgIoEhq8j3MIMZx5jukP7M qjFF4KWqBrcMFqXjN3xhW/WJx3Gs/FMVrhwthtAidPASYL67qZFwqjQKeSKHCYnmKKNFFWD wUuNwcvE1F2Mefq4Nswr4E4fbFGV6MsSBIp8d1o5FmysoZ/aYqs5R+QwgJRmbYC0WBBiG4u +H/8y0W2NOM/CzXhZDpcRGFdWag74jsJF8OECFe3dCq7noUienzg1jRDT59Q== Received: from 188d6d40ca7a (code.ffmpeg.org [188.245.149.3]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTPS id 40FEB68FDA4 for ; Fri, 14 Nov 2025 11:31:49 +0200 (EET) MIME-Version: 1.0 To: ffmpeg-devel@ffmpeg.org Date: Fri, 14 Nov 2025 09:31:48 -0000 Message-ID: <176311270945.25.17511555861951567400@2cb04c0e5124> Message-ID-Hash: PSHGHZ2LRAFLPFLIEFG4KMCYULCI6ILS X-Message-ID-Hash: PSHGHZ2LRAFLPFLIEFG4KMCYULCI6ILS X-MailFrom: code@ffmpeg.org X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-ffmpeg-devel.ffmpeg.org-0; header-match-ffmpeg-devel.ffmpeg.org-1; header-match-ffmpeg-devel.ffmpeg.org-2; header-match-ffmpeg-devel.ffmpeg.org-3; emergency; member-moderation X-Mailman-Version: 3.3.10 Precedence: list Reply-To: FFmpeg development discussions and patches Subject: [FFmpeg-devel] [PATCH] avutil/hwcontext_amf: move AVMutex to internal context (PR #20915) List-Id: FFmpeg development discussions and patches Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Dmitrii Ovchinnikov via ffmpeg-devel Cc: Dmitrii Ovchinnikov Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Archived-At: List-Archive: List-Post: PR #20915 opened by Dmitrii Ovchinnikov (OvchinnikovDmitrii) URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20915 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20915.patch >>From bfcdc58dee88778c8f48a54d7d7989417bba79c2 Mon Sep 17 00:00:00 2001 From: Dmitrii Ovchinnikov Date: Thu, 13 Nov 2025 17:40:26 +0100 Subject: [PATCH] avutil/hwcontext_amf: move AVMutex to internal context --- libavcodec/amfenc.c | 4 ++-- libavutil/hwcontext_amf.c | 30 +++++++++++++++++++++++++----- libavutil/hwcontext_amf.h | 5 +++-- 3 files changed, 30 insertions(+), 9 deletions(-) diff --git a/libavcodec/amfenc.c b/libavcodec/amfenc.c index 2174c5bdb2..43eb393497 100644 --- a/libavcodec/amfenc.c +++ b/libavcodec/amfenc.c @@ -564,9 +564,9 @@ static int amf_submit_frame_locked(AVCodecContext *avctx, AVFrame *frame, AMFSur AVHWDeviceContext *hw_device_ctx = (AVHWDeviceContext*)ctx->device_ctx_ref->data; AVAMFDeviceContext *amf_device_ctx = (AVAMFDeviceContext *)hw_device_ctx->hwctx; - ff_mutex_lock(&amf_device_ctx->mutex); + av_amf_device_lock(amf_device_ctx); ret = amf_submit_frame(avctx, frame, surface_resubmit); - ff_mutex_unlock(&amf_device_ctx->mutex); + av_amf_device_unlock(amf_device_ctx); return ret; } diff --git a/libavutil/hwcontext_amf.c b/libavutil/hwcontext_amf.c index acd9627c68..bf0adee0c6 100644 --- a/libavutil/hwcontext_amf.c +++ b/libavutil/hwcontext_amf.c @@ -39,6 +39,7 @@ #include "pixdesc.h" #include "pixfmt.h" #include "imgutils.h" +#include "thread.h" #include "libavutil/avassert.h" #include #include @@ -49,6 +50,22 @@ #endif #define FFMPEG_AMF_WRITER_ID L"ffmpeg_amf" +typedef struct AVAMFDeviceContextInternal { + AVAMFDeviceContext p; + AVMutex mutex; +} AVAMFDeviceContextInternal ; + +void av_amf_device_lock(AVAMFDeviceContext *ctx) +{ + AVAMFDeviceContextInternal *priv = (AVAMFDeviceContextInternal*)ctx; + ff_mutex_lock(&priv->mutex); +} + +void av_amf_device_unlock(AVAMFDeviceContext *ctx) +{ + AVAMFDeviceContextInternal *priv = (AVAMFDeviceContextInternal*)ctx; + ff_mutex_unlock(&priv->mutex); +} typedef struct AmfTraceWriter { AMFTraceWriterVtbl *vtblp; @@ -352,7 +369,8 @@ static int amf_transfer_data_from(AVHWFramesContext *ctx, AVFrame *dst, static void amf_device_uninit(AVHWDeviceContext *device_ctx) { - AVAMFDeviceContext *amf_ctx = device_ctx->hwctx; + AVAMFDeviceContextInternal *priv = device_ctx->hwctx; + AVAMFDeviceContext *amf_ctx = &priv->p; AMF_RESULT res = AMF_NOT_INITIALIZED; AMFTrace *trace; @@ -378,12 +396,13 @@ static void amf_device_uninit(AVHWDeviceContext *device_ctx) } amf_ctx->version = 0; - ff_mutex_destroy(&amf_ctx->mutex); + ff_mutex_destroy(&priv->mutex); } static int amf_device_init(AVHWDeviceContext *ctx) { - AVAMFDeviceContext *amf_ctx = ctx->hwctx; + AVAMFDeviceContextInternal *priv = ctx->hwctx; + AVAMFDeviceContext *amf_ctx = &priv->p; AMFContext1 *context1 = NULL; AMF_RESULT res; @@ -415,7 +434,8 @@ static int amf_device_init(AVHWDeviceContext *ctx) } } #endif - ff_mutex_init(&amf_ctx->mutex, NULL); + + ff_mutex_init(&priv->mutex, NULL); return 0; } @@ -644,7 +664,7 @@ const HWContextType ff_hwcontext_type_amf = { .type = AV_HWDEVICE_TYPE_AMF, .name = "AMF", - .device_hwctx_size = sizeof(AVAMFDeviceContext), + .device_hwctx_size = sizeof(AVAMFDeviceContextInternal), .frames_hwctx_size = sizeof(AMFFramesContext), .device_create = amf_device_create, diff --git a/libavutil/hwcontext_amf.h b/libavutil/hwcontext_amf.h index 5b726e3b9e..56362e2e0b 100644 --- a/libavutil/hwcontext_amf.h +++ b/libavutil/hwcontext_amf.h @@ -26,7 +26,6 @@ #include #include #include -#include "thread.h" /** * This struct is allocated as AVHWDeviceContext.hwctx @@ -39,9 +38,11 @@ typedef struct AVAMFDeviceContext { int64_t version; ///< version of AMF runtime AMFContext *context; AMF_MEMORY_TYPE memory_type; - AVMutex mutex; } AVAMFDeviceContext; +void av_amf_device_lock (AVAMFDeviceContext *ctx); +void av_amf_device_unlock(AVAMFDeviceContext *ctx); + enum AMF_SURFACE_FORMAT av_av_to_amf_format(enum AVPixelFormat fmt); enum AVPixelFormat av_amf_to_av_format(enum AMF_SURFACE_FORMAT fmt); -- 2.49.1 _______________________________________________ ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org