From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 7C05642D24 for ; Tue, 3 May 2022 20:31:57 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5987A68B22C; Tue, 3 May 2022 23:31:55 +0300 (EEST) Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A659068B18C for ; Tue, 3 May 2022 23:31:49 +0300 (EEST) Received: by mail-wm1-f47.google.com with SMTP id bg25so10499907wmb.4 for ; Tue, 03 May 2022 13:31:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jkqxz-net.20210112.gappssmtp.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language:to :references:from:in-reply-to:content-transfer-encoding; bh=HqbXI+M8qhScD/Ph9aTt3AOkkXwHd2dNzI91d+kme+M=; b=RcDcY2kKewMWZPRy8uCiU7er2nGG8rqmQlThVZD1Nk4y/OjcA9B0YvNH1utW7B/Lc1 zHiWtQzn4/2ZQYdDhfcKGe9rutVdbDK7O60C25TOgo6Z2/4t0bw31JDidceFpFD/9/Zs LMAX7uRxiQNgJ+YiwOzhbIZ2I/juoRfC57X7TxQDlagEIgudi6I44OAYn/P1mxCO20+G UIyEtoPxCkdGQc2VFZmwe5Djf62PYjVuXgFlzvsJ2t1JWvWn7t/lp4apFQimIdZIEfuo MJSJgxbQzVhWFnTzN1mOJAU1SrXbXexoVcS8jEz41C8D94v7Nc97GwXZDXSZQzqOi7kr volA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:references:from:in-reply-to :content-transfer-encoding; bh=HqbXI+M8qhScD/Ph9aTt3AOkkXwHd2dNzI91d+kme+M=; b=d5RJhr9QcFRkeSgCGj2aW5w1C0j4nJEeLrGN26y8z3PfFvq7wqgMizdFkpC0cwbeho 8BzL7R2QH4crbp/3SQK/iJj73jCbs24KXrFmeyQQT26x41qiUoysoFmez/N0G+zFv78h cv4CwLs5GXeginyTDNt1IDqcfqDEGXjf6UtJP3zyxeqvJxVv2gj26NyCUVLqfxGJvOcZ 9IhW2AUzciGaUGa+Ya3e5nz6+NcfoOXYnXR7huuYOMGskEGXQt+zaB8Dt7ZQ2X+mUQBV i3Lcu+QwZ075V1CDOlScTYS3leP7pnaqB8cfxryXNkjwYqyVfcaqzBvFd6N1oNlivpCN DaZw== X-Gm-Message-State: AOAM5336uoaBntwe31FNm18i/BjcXYnL9nmyuX2lnpjIWr77FHIYwZp4 N8U8WEMNPvtefUh0Psg3pFJxxWc38h6NFc4d X-Google-Smtp-Source: ABdhPJzaUzZFbY57D1xuzaxbr6cuDhR08jkzWhK5D3IEec8/M9bRrVv1lcqRDUP4fkVVYxuDz39xKQ== X-Received: by 2002:a7b:c4d9:0:b0:394:41a:d36f with SMTP id g25-20020a7bc4d9000000b00394041ad36fmr4798230wmk.152.1651609908905; Tue, 03 May 2022 13:31:48 -0700 (PDT) Received: from [192.168.0.14] (cpc91222-cmbg18-2-0-cust46.5-4.cable.virginm.net. [81.106.30.47]) by smtp.gmail.com with ESMTPSA id j28-20020a05600c1c1c00b003942a244f39sm2337906wms.18.2022.05.03.13.31.48 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 03 May 2022 13:31:48 -0700 (PDT) Message-ID: <4f6deb7a-61e1-ee16-90e4-5184b7bd8230@jkqxz.net> Date: Tue, 3 May 2022 21:31:53 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.1 Content-Language: en-US To: ffmpeg-devel@ffmpeg.org References: From: Mark Thompson In-Reply-To: Subject: Re: [FFmpeg-devel] [PATCH] hwcontext: Skip derivation checking for an existing device if options are set X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On 03/05/2022 01:14, Soft Works wrote: >> -----Original Message----- >> From: ffmpeg-devel On Behalf Of Mark >> Thompson >> Sent: Tuesday, May 3, 2022 2:09 AM >> To: FFmpeg development discussions and patches > devel@ffmpeg.org> >> Subject: [FFmpeg-devel] [PATCH] hwcontext: Skip derivation checking >> for an existing device if options are set >> >> If options are set then the user definitely intends to create a new >> device, so we shouldn't attempt to return an existing one. >> --- >> libavutil/hwcontext.c | 26 ++++++++++++++++---------- >> 1 file changed, 16 insertions(+), 10 deletions(-) >> >> diff --git a/libavutil/hwcontext.c b/libavutil/hwcontext.c >> index ab9ad3703e..c4e01e0e78 100644 >> --- a/libavutil/hwcontext.c >> +++ b/libavutil/hwcontext.c >> @@ -653,18 +653,24 @@ int >> av_hwdevice_ctx_create_derived_opts(AVBufferRef **dst_ref_ptr, >> AVHWDeviceContext *dst_ctx, *tmp_ctx; >> int ret = 0; >> >> - tmp_ref = src_ref; >> - while (tmp_ref) { >> - tmp_ctx = (AVHWDeviceContext*)tmp_ref->data; >> - if (tmp_ctx->type == type) { >> - dst_ref = av_buffer_ref(tmp_ref); >> - if (!dst_ref) { >> - ret = AVERROR(ENOMEM); >> - goto fail; >> + // If we were derived (possibly transitively) from a device of >> the >> + // target type then we want to return that original device, >> unless >> + // options are set in which case we can skip this check because >> it >> + // is definitely intended to create a new device. >> + if (!options) { >> + tmp_ref = src_ref; >> + while (tmp_ref) { >> + tmp_ctx = (AVHWDeviceContext*)tmp_ref->data; >> + if (tmp_ctx->type == type) { >> + dst_ref = av_buffer_ref(tmp_ref); >> + if (!dst_ref) { >> + ret = AVERROR(ENOMEM); >> + goto fail; >> + } >> + goto done; >> } >> - goto done; >> + tmp_ref = tmp_ctx->internal->source_device; >> } >> - tmp_ref = tmp_ctx->internal->source_device; >> } >> >> dst_ref = av_hwdevice_ctx_alloc(type); >> -- > > This doesn't implement the matching of device parameters, which you > were talking about: > > You said that when deriving a device, an existing device should > only be returned when the parameters are the same. > > This patch is doing something quite different. Why would that be useful in the current design? As the documentation on create_derived states, it has two independent uses - this is the "retrieve source device" case, and for that it does not make sense to set the options argument because no new device is being created. I will clarify the doxy on _opts. - Mark _______________________________________________ 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".