From patchwork Fri Feb 9 14:53:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 46134 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:a586:b0:19e:8a94:b663 with SMTP id gd6csp982148pzc; Fri, 9 Feb 2024 06:54:07 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCVbI/cV0zEudBWcpJsaE1ek/YBw6K7kM7jZv5pIimJJDWIVqDJQo8SoUepEzr6qh1TbaLbPMY6/+3fTtFr0wIb3CtPZayWMEY1MXA== X-Google-Smtp-Source: AGHT+IGu2PFQsguLR4135PCW7CDcTDDaM9PoTrN5KRZtA8llHPZo4HxPLHAcdIF7mkMQJBzf1OkB X-Received: by 2002:a05:6402:1f81:b0:55f:c4e9:60df with SMTP id c1-20020a0564021f8100b0055fc4e960dfmr1136401edc.20.1707490446771; Fri, 09 Feb 2024 06:54:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707490446; cv=none; d=google.com; s=arc-20160816; b=GozA8L9xfoLc8Vt5MFT9xksFj9gEbFU/Q3syRZmxEPvfOYbMXWlwdio2UVWvJKHDsp r4PO+pb6Rki4B0cDbyO4783hKkGyryGLxxjmOpmQyrLAcE1djpzXCSgcyEjyFJEFc9K8 5QZUOTD0gj7sLqZdQv9K1af+DWL7/nYnhapTNlJMl4jCSxu2VFYCukAIuY0SVmT+jipT fpTZkGaslzhbeDwFWrPFqNNQuIucDfdKhOeR3YlL/v6npHNzvHxrrOnHk/jXjveDhtp2 mBUymGXEEp+6iFBWzohP4izb0Hiltwi2YeXKLKrBFuy3UojJvalW3QOA7S1pDpyUpWLY insg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:message-id:date:to:from :dkim-signature:delivered-to; bh=ABdqJ2l7Kr9f6GpUL2XE3oD9sSJ/ORiMtqhXtHqsEOQ=; fh=uf8SLA/2sNHVcPRJyhdIoQtGBt+eevpeH9BgfhKLXR0=; b=rJ7J17dEbKwUGN4vxug8BFr3nTqjjaRZ2xUEfX8O+Ff7diQvZdqiTGYvU6f2C/vfHQ P2hQFy0vwI6ozdhiZtcESWDjkRyhciSDRqvJJrnMmvk+I6O3tR8eME8ZA2Qj5YCDjGDE OzvRBPjBde/+thPc6bcGct4+pyPprxiX7MjSb4UscEzFERCJR5QN+vkqyDFSyKjTx+Y9 AOEnH4GABhQNHj+nOMMHHUlDQqOOZS3NUCEnZ/osb+cJohp9Uwi2zmv+VAUwkNwm1ZVE ix3YkNL56GCvKC8UtM9O2o20k/SSOWvGj+SD6UBvh+l/An9Q+e2dB3aOgie0zOTNDTa4 z7hg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@haasn.xyz header.s=mail header.b=ggxcg7VV; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org X-Forwarded-Encrypted: i=1; AJvYcCU5WZ/HitoCwXnY1ahmBYQ310MAiJOJ4FGtJ0pG0fVmY9Hwg84/reUW2yPk8kbfwtibStajE1nujTz8ieVD5xACAozW1Pjwc+HkVYXpavT9UxSr4yA1R+dNzh45W83CCI/R57REPKVRUeTVmE2S8ApwT7Z+FXCGXZ3ZHALUYwXn6G1EMUBoDw1qbdasJT6UHZg/xCQIer9Kr4kc7EevnZgF2PxW9MZ6pT93nvf/b1IMf3b5bhII2FCEC0N4LMSWWbYx0nFCwP7BQYdd7HAFKkiWoRjRe6V2kXsUFBuQ+ZLDONKocI8DcwV65zGfX6ffRj2c6q8oFnNqoNrj79Wm4cW4IloiGMkpkXWGoTMAYfA4Ov8wU7DSd84jP5Y52MYKDO3pIjhH616JCCTHv5lfGsUzoKkKYzKp9wUKj5pKLDc7hhsJVGmuhtWAFQLrUnZxboT/F3YE8xFdWVd+86wzRt1stRUyKELEJ4ZannMaWbDI5t9y9w4d9xZqcNvwnKJmBDT6EBwrogos+9oGI7CO8GIlneW/hECWeImoSALv4phbbMoxORcLSr8VIvhxnBN21TldX31damINVbWfqkgUq4sRBU0qzEVkQ5lkqT2DLDwWwOOnxF2PwvQrxG8/HCpBhVW/1MyQNboDF0UxnQs0BD2vtI2pdn3acIZ4WWVa9fgAu1FOJPUTT7Zu4n7VtjWnBVhfOZuxmzjWTBUJYP59S7RgCpI8WAqmcioN3LGrPhgjG1BLDE1zY2hXAxNra0yBIuDzwigrZ0H32kz2N9Gwllij3MOmdA3xwmdxAZsYf927AroCJnwiZjDhy7QQhYb5CdPbhHJet00ra9F7u2i9cljYbmu/kfP57vPdWNEOS+PYtvmttk8U4ENiqN6owWzKOu4brdUKnpFFiL7sZu76qSPiN4HQZURMRH8PR3gIlmsQBvH9MnPzVEvkOQfGx87WSxzg55 7OieuQTsWlmEp3aL6pSdkpkx9V5VtbDfy46TsTi5RmzmmlmMgZvDi9HLtIPGERfVoGEd8GBAImgBJAavWz7Jbeh8jH9IlzmAnpwsECAvrwg3+dDgZXK5AAREAJdb0TogLzFJuVyKVqzrLLPYUS3YtnqCgumCR8+VwiPO4NdUma9nVGDPjD7ZdNbOEHQIBgerb3WLh8XLkl60LwXxpk3O1K19BiUrcWdwJNw4dQu13hkKQmMaybrj+pTit+Y8DUtyT7cGh9i6rUm/8/d6DPfIb0RpYYW5vs1WpyqvxhRx3szOJIGcHm0YsyYiLp3PMKvje/CWMByyQEpuBEgBw0aINBqBolp/XJOkHR1Jvvnkhe1/JniuKFOTVguKN4k0UfKNR62fKEBoU9fadcbwKfiCF+Y/xUgpKQQHlTLM+gf8iyIignbNBBr71EHyXSNu+pg4y6D6vOPr+VKy3q1h05VHSSB06aQQbTO2dy4Keloh1b/nsU/OQA9yL1inSG8LeOjQJ/Dxb18QGAAL+5iU3UL9tu2pnirptPraw3NKnco2Nq9c1oxChaeFPok3S8Nt+6Hpss23EB8QGvl4TSM0y1q0muS77ng91Fu17ZLQ7KXw/ELzSDyyn19UCvWnXykgZKdy47 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id k6-20020aa7d8c6000000b005610bb82540si919744eds.505.2024.02.09.06.54.06; Fri, 09 Feb 2024 06:54:06 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@haasn.xyz header.s=mail header.b=ggxcg7VV; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0BF4868D081; Fri, 9 Feb 2024 16:54:02 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from haasn.dev (haasn.dev [78.46.187.166]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E641D68A9C8 for ; Fri, 9 Feb 2024 16:53:54 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1707490434; bh=NdS9t9QE5Md6r1AyPCc/QIqDa3UEuyz1nQs3kwjy5AM=; h=From:To:Cc:Subject:Date:From; b=ggxcg7VVZuWlUichD5PPj3p175VU3CEcDc/SL4eAzdk+gmnClEg6PLKfzwfL/DFlB if3jfJQhprrsdaG+qhEsH4S9FzbWoBsMChQ9VvW+fSA2qRnFjSV+3jDjM2MtlQ/U6w 6B3HzK1uZ1Fqkn3k5u7MyHfxwgrYryBQzH+3mbwA= Received: from haasn.dev (unknown [10.30.0.2]) by haasn.dev (Postfix) with ESMTP id 938ED40A49; Fri, 9 Feb 2024 15:53:54 +0100 (CET) From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Fri, 9 Feb 2024 15:53:45 +0100 Message-ID: <20240209145349.104511-1-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/5] avfilter: tighten semantics on hw_device_ctx 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 Cc: Niklas Haas Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: VMMWpQ/1CKUO From: Niklas Haas Currently, such filters defer hardware device initialization to query_formats(), which is not really the correct place to have it. It would be far more logical for these filters to create the hardware context at init time, and error out otherwise. By contrast, filters which merely receive or process hardware frames typically do this at link config time, because they do not need access to the hwframe specifics in order to query supported formats. The intention here is to specifically stop creating hardware devices in query_formats. --- libavfilter/avfilter.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h index 246d000251..b6adcf2473 100644 --- a/libavfilter/avfilter.h +++ b/libavfilter/avfilter.h @@ -464,7 +464,8 @@ struct AVFilterContext { * * May be set by the caller on filters flagged with AVFILTER_FLAG_HWDEVICE * before initializing the filter with avfilter_init_str() or - * avfilter_init_dict(). + * avfilter_init_dict(). *Must* be set for filters which do not have another + * way of obtaining a hardware device context (e.g. from an input link). */ AVBufferRef *hw_device_ctx; From patchwork Fri Feb 9 14:53:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 46135 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:a586:b0:19e:8a94:b663 with SMTP id gd6csp982228pzc; Fri, 9 Feb 2024 06:54:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IG4shUsMEH5lXVC0kfW6sd3V5R1hWyy7HAKiSkL4t7OQtnPGQpo928rRfzmex6E7IBwg0Mb X-Received: by 2002:a17:906:74d:b0:a38:1673:682a with SMTP id z13-20020a170906074d00b00a381673682amr1441866ejb.32.1707490457466; Fri, 09 Feb 2024 06:54:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707490457; cv=none; d=google.com; s=arc-20160816; b=tmeVtD52FDEvA2pL0lrtAOvK4oYRGr4LTSuERYoJlKiG+D1jlli0/+viv7OiHZvWPH /GXYV7cfgWYbT2Iith/leHhDJTHvxwxOd4r5OeJDGWwEBr7Lz1dQwz3wtRTYrh1Pt2Ce nDli86hP9w/9Fv60Yvszc/Mx01wj8ogeooN3aFpDySzLy3Kr75VIK06yghtPz4pnKv6A F4RxHJmB4HJv13tBGSGJDDGjS3TP+qLe83tnS/vNi1UyfwASl0xmAsCUNIenE99rsMNF fM+qUBPsUIFiPippi9cwjIDCpbE5D3jzi5r7+ZiDfOFmAA9etd+sSs4nwza2MdoEHO1d uxWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=Ib8ukFvex5RPfHn4exZTxk8msZS00Mof48+KLDhS1No=; fh=MPns3DnIUr8wDc9ThMFndWAXrvqLgNiC8BqJLvmC/O8=; b=ugeykVg8IFVwG3fedqvPO8aa6HhKGfC1OI/F5GO4NEHGfhw71m9KNh27rjS8fqpJlw rpoimlaKbdAllycEfo+E2uFY42nxUDYc3zURRP/KqRjtWgXP4wI2uvUf0wfg66L+a2mR OQfYdJF9W+gUQfECi4K60VqXmVLCVofI+D8cv1H6C4jLbxdnT07RXFTM6nq9V+XRZYwj xcy3AKL+vafpVYcn+OpsGOFRKfkySrU/BMfIqTO/PojImvBcN8MdoKRnQ06ofSQMYWEI 5cSGt1UynjaP+hGlEM8JB1frJtf2JLibpJ+46+uGvUHnsRoV/6MuZ2Gfk+oQROUJvOO6 dRfw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@haasn.xyz header.s=mail header.b=JHcgKYHQ; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org X-Forwarded-Encrypted: i=1; AJvYcCWRHxfF7V1pP0VE52+ZbvONjfG/I8AD1c1QmxU4SzHiVcH/wTLa8NNXqQZgW8814blJKBmU6Y7XPmtlsi2ATajX0Sncr/zqNOw+YmSVi6Nuok44abntdS9vtmK9/ZrPFrOdsgrJjxuA+1BxuF4Gp/ZKc/yDRqBlHpXJoHja4slxD4qixGTZKOapB/nKb1SJNMpJJ9KXb7QKm9etq2Tchcfr71Fgs73JdC2HK8jBClgKVSedpvfFtdyWFZH+61OIU/gS2Lu+9K/Gd0OQUFc/LOf9clAHrUCwGTNIzsc1U3DjY8o/vQThU/hOxoXFP5HI2sVh44Zlu0O035g1JmB5YG4evdsZgwTo8gxLcIX5fXW8+rCxtq0NuG+PzG/5zddvq7BzqitZlBomaQT//NakxJWvhhRjajNQu5l/zllGWiN13K9VKLl6/qwrWJCc2hL797/BBmO3peSYSw5iyqaR83RrFePam4jlbVjoLlohvuKlA6wBFQV2X4f8YXG3lo1UHDBVWBiwGl4orzhSudY5Avvzf9Pv1JDp/wHErnchA7GgPnq8sztFwoHt/upS9qVluwMXaXHHYdQfiqA0vHhkCFWv/yBPh3t70WRLXTlTrhAA60RWM5+Hm/+nhfvYZ8cKlVfovpceRDoGU3yMeSMT2id2U4c614anWRiu3SKOGC83yzRqX8YEb/BsdlqigNUiZia8wnRKDaLwywmgMZpJ+hhIf94YsE3wlH+w3ugkWcvnxiYPXc92goy8dTLrdPE8BKB8eKOIMQwvuDpfSIKr+COx0kdTcUyGiJ50a1XEsnMSkOaLVZ+yMXDV+UbSSM4fawq8/gSdI9VNoQUiaDuVPTIJGZkVZRsT4YCgU0b9PLJKmH29WTiWIyeNHTsqECDzsh2L3IvdmE+82m/2o7yefV6HTdi561AtzifbkQyoZUt4MPYlMO0JNcgw+SH/jjPoH8/pXv tBPyaUhnMzzMNoRdPFIMoHWth6R9lY/08F0KHG13cVHli7xWyd7cltbi+9g69PLPaULRRv/yVt3HMBK8Tq8DnAKifrr1qWnBjtvrm6jjYYtFAI7bbK9wdcU4zu9YeWaQBMhUNjSM36t4yij9ybMHxNriAL0hv6chI3eJ2zWCf+gHFMhJ/hhpoKoRk5Nj//bg1cVxLv0T0IVr0pJISq88uU5o4/IGPOjGgQkTgU1wcea99eggmFbfs6/OccFiDeAgOsXeGxKH4XfTQY0r9JG4D3zVW732wxZEkCcSQ0fk6OHftgN/D13jkG1ZeCANVMEInj6iugiELDpSCLIl4gjZkrQ9O1VKfr12zo4SVyac+cASGU8PcY5l76f8zCSR7Fe1WVaGmM/9zjf0ePwklgIiECfC58opmWwnONkpGSv327XGL8ZdsLxXzXApCImiaET8DzLC3IZwRZ6QLhTbN3VBzx+LfniY0kFKshN1Zpqw+iXvjiMhbYOHH2ZYuMzrLWX0dOxgCuQcGxABDMOdrEGnv3mSgtK4apFmo93IZCm/TSgbxnUxZVynU65kb5aILa2l5maHoaWThdNYwV4nam/urb/auhM1839Go3uEyMdZzfr779eDtepbC/Qu5cUcPDOT3gmbrXcCi8uIkvTA== Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id lc15-20020a170906f90f00b00a361240236esi901369ejb.777.2024.02.09.06.54.17; Fri, 09 Feb 2024 06:54:17 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@haasn.xyz header.s=mail header.b=JHcgKYHQ; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 36C0A68D0F2; Fri, 9 Feb 2024 16:54:03 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from haasn.dev (haasn.dev [78.46.187.166]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 15E8868CD10 for ; Fri, 9 Feb 2024 16:53:55 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1707490434; bh=oWo/MFovr5dom++3eGO7WcyJlMl2DL2Xmd16ULRTP7E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JHcgKYHQMa99rJWP3SAWaFexnvKZrfJ+Ar3ZLFGfxhSTGPv3nXs+Adbde1kYF5Dq4 ABLRuOiK7suGaeGy95yXT5vmc+BUDGeZ+GxA6St6yUayveaBLme6KVRty2EwbXTZym 93J++ckwzkxmDTh0HbqH9k7QUcngU9geCuqkA0Oo= Received: from haasn.dev (unknown [10.30.0.2]) by haasn.dev (Postfix) with ESMTP id C619341818; Fri, 9 Feb 2024 15:53:54 +0100 (CET) From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Fri, 9 Feb 2024 15:53:46 +0100 Message-ID: <20240209145349.104511-2-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240209145349.104511-1-ffmpeg@haasn.xyz> References: <20240209145349.104511-1-ffmpeg@haasn.xyz> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/5] fftools/ffmpeg_filter: provide hwctx when probing graph 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 Cc: Niklas Haas Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 0ahFUw6/3vRv From: Niklas Haas Otherwise, filters that depend on a hw_device_ctx being present at init() time would fail configuring under the semantics outlined in the previous commit. --- fftools/ffmpeg_filter.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 38ddd1963a..46e1d790e7 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -931,6 +931,7 @@ int fg_create(FilterGraph **pfg, char *graph_desc, Scheduler *sch) AVFilterInOut *inputs, *outputs; AVFilterGraph *graph; + AVBufferRef *hw_device; int ret = 0; fgp = allocate_array_elem(&filtergraphs, sizeof(*fgp), &nb_filtergraphs); @@ -961,7 +962,9 @@ int fg_create(FilterGraph **pfg, char *graph_desc, Scheduler *sch) return AVERROR(ENOMEM);; graph->nb_threads = 1; - ret = graph_parse(graph, fgp->graph_desc, &inputs, &outputs, NULL); + hw_device = hw_device_for_filter(); + + ret = graph_parse(graph, fgp->graph_desc, &inputs, &outputs, hw_device); if (ret < 0) goto fail; From patchwork Fri Feb 9 14:53:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 46136 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:a586:b0:19e:8a94:b663 with SMTP id gd6csp982294pzc; Fri, 9 Feb 2024 06:54:25 -0800 (PST) X-Google-Smtp-Source: AGHT+IEhWohmENiDwa3+lRQBQtKKJ7qTllRzkE6XvRz8RuTPsI8ra5bSdhNp0M89eQdAUzkDfNIG X-Received: by 2002:aa7:ca55:0:b0:560:799:f802 with SMTP id j21-20020aa7ca55000000b005600799f802mr1409585edt.21.1707490465185; Fri, 09 Feb 2024 06:54:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707490465; cv=none; d=google.com; s=arc-20160816; b=AnTwOb+dg2VKwzknXOpEw1YkoyiMoGZums0TwDZrQzu3i+ggCpTxeDr5KT0i0ENbtx 1kXXuVro5BhZAjaeHqvPAngJL9OxPWCFEhsz89zHTpL6eZLT+lvL+ytH6rekYnxFz6F+ yPzU0VX6aR37EHxG0jSFP3in6NmYTP67drI1SnDeZVIiZFJDO4me6LjxCqvr/uQztcy7 mnZXI/tie/9SrcTG1HsA2WUYKJa4xWoH2P3/6ujISZLLy9VmMGdQiuBmt5FL1JzmWBmJ rsZLP19udi29U58trKMVyCGcizjH/Y6rVBwk/jyXDnXbp6TxMWu17WwzBMvhbKvSThXc 4X5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=RQYugCiyShYUGe1wlYDSzcbsUlbqibfcHI5mJK/F44M=; fh=RmlyRzGNcEV+yON6td8rQjpvFshrqLEMdq+NB3+dMac=; b=ncZzz/NYOzoM0hI8LpNbq1nQD92h1ZRzO1HmH6PQmiVrNRhsseg+FT/b1P3svu17sY 9QDQZtYMSKkUQ86Og4NurV4JDXeN+UgNWI9Wraatpx3OHZCyDVPUC0ZvdMmfb4OHpPx0 +DyZWYkmjHMhIJSdBpzmFBLYGRJkQCBoUFwUPEVa4ttTcgUyrly7q7SR0+irW3ksqcLB eie5OTbxcMq+tr/ixQG5cDRp1Tu6Mptrg7Ub+Q1AM/6O+vChOKhLeijj9wJNRgtkPu81 o77qE0kJVuy5VWiuAZj4xV4Y+Vkgjy3uUEhr0zQL0zJZGxig75EnCySWetZdXQ2Yjnia mOBA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@haasn.xyz header.s=mail header.b=QgATJ+Wc; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org X-Forwarded-Encrypted: i=1; AJvYcCUKkNNx0lsoSBlRAOyRHD7l+sVhU7yW5T9n1NvEm1OHM3WeQCyWNU+gzv8iSGjSmvLOQTP+3hher1IrvxB0Ezm8VSn2SvNh8ICO3om4EnaP5JJpQggw4sACgY15YziSD69MoyMig+3cGizPb2H//hTnC/27IkWhGVKMD3Ak2GLjpmgc0AfkRxD6mx5YOCStjNKdb68QA3Kc/I5ed/18AlbLZsDJauM8G+vQVIc4nSXUwTg+ffpSltsfRBK32KaOCawdNzNy8fF/dFhUg9awWk1q0aqmB9/KDeaG8XwcFsKvmifLd2fr74PHDcX8748rq5SueMUusmdKbbtLUpBeWscPzQB+Oj33I/mKUxvrqTsTlKB0ss02SUCf+7eYH5gKY/M6DWSCtXayYBjDwiq97+l/AKLWk4QIYaXwRT92lCeq39MDDF722zmcenqULJpQFLIP5NiOuGJelxE31lDqCP4cfNt1dKPx/PGlCX/8m+QNmIwITBhHPg23bz1N5Sx1QK7+jahx+RT0HTqGg3AF9dYBC4w/J6Cy3cfxlrLRko3Lk3uXMl05T27zH6fPb1CQ0kfOY2N46m/henu5ymIX4nWxnzOTP+xgEY8nONTUOMbAuFIOJwBXHX/mCqMRQg+55+jC5h0ftYvj+KEiikHLYDb1xAwL8ncSMhB+CEH0NnE7JB9fS+f+UfWsUTQbFYH6IEoMOBS5/4U2GeKUaQe/p7d2SwNwUqWS8Kx3eUgoPQrm+3VDLepp7gOaMZPD0D19CmdvIOsQAkEuNGNufGfX4r15x+ATbB/Z+z1AdJJ5XnvgUe+XIS3J1yeKCV6/XTYsQ4k/DMpMvqbGhcmEjo37RfvsyvYf2D0jp6VffRcXxjbCsScF1VstRDIZtmaxkbHREQdrJMnANF6n36MT6Tj0KSPAQ0EmL7tDCx9iuNlFE/Iwr7RludtpCdv+6Xm3Hbrhsqw0FH W3hT9GMluAY4QOhQLvNrz2pnbDQ0e9XMh//ddAC5nxhyPsoA//fAMbPM5O83eJxxOo203WnTWG81bkVY6Srl9SuXF5n1UR/b64Jf6Wz44G408rsIacrYx8uY9OHhEZT04r7fAQV/zdQ3fRn2D0NC1ePyQ4hr/T+7g0+Hz/FJ/s2HqNqlHqWItbT1VNrSARM6H0kwsVhY6qVRsjm2SJC4fITvrZGidI7Y8jOJfIJiNjkjnnTBGmvagSKTUgNKlAzmdVNwtqHX4J/avvqIEbIKWXBbsh1O7Du9oeZzAAGG2q+jZaNRSbG3AELI5IjHYeQkwep84KZvKSar43n123mDmaRF1xLRgtB1KfTFDe/u8uI0dxKfhYEjOKDwloPKBcpaDh0O6svDJb5rKHMFxmKecZQAn7keHpKdGx38CRnFzmVdzZKrjbAA+mYDXgsUBVvhtRTfRGnAcvHNXdBKJQhmBAx1xIvh+8RRXCj6ErWO4ULlh7yYLBF5ZG9NE2857yZsmJk1sjCrtEgarmXop1Dr+/DOJTujU0s9sFaPVncoUfsL7HZzIXcFtKNIBoRq4AcWJW0XzirGYFUSLUm9FgffEuN35mJfIu14xxF60TwIjTVL5Q87qhUdz3F0l3b88a4sMoVFkk Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id r11-20020aa7cfcb000000b005612fd31a0dsi866509edy.427.2024.02.09.06.54.24; Fri, 09 Feb 2024 06:54:25 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@haasn.xyz header.s=mail header.b=QgATJ+Wc; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5D3CC68D0F6; Fri, 9 Feb 2024 16:54:04 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from haasn.dev (haasn.dev [78.46.187.166]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 43C7768CD10 for ; Fri, 9 Feb 2024 16:53:55 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1707490435; bh=e7Mk2nKzHPnARdd2O3TaTbd8Di/Oh7URCTl9W4C9Iv8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QgATJ+WcLMdihGlNtDEqaguYb49b+ncS8BWAPdcmlkWPTYcRhDPgqIxp3NAwq+r6L CuFUU7c5Hf1+4LaQBYs3rzWwz3hv4Yrhha+2SxGkMuxk4YFG2UcqIfvbzcT7tmcv5/ lPWg+w/JGx3UfnPO2Ap8kFMnofSX8MF5nwzw0Htg= Received: from haasn.dev (unknown [10.30.0.2]) by haasn.dev (Postfix) with ESMTP id 05F0C41826; Fri, 9 Feb 2024 15:53:55 +0100 (CET) From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Fri, 9 Feb 2024 15:53:47 +0100 Message-ID: <20240209145349.104511-3-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240209145349.104511-1-ffmpeg@haasn.xyz> References: <20240209145349.104511-1-ffmpeg@haasn.xyz> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/5] avfilter/hwupload: move hwctx init to init() 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 Cc: Niklas Haas Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 5hfWx8LphBIK From: Niklas Haas --- libavfilter/vf_hwupload.c | 49 ++++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 21 deletions(-) diff --git a/libavfilter/vf_hwupload.c b/libavfilter/vf_hwupload.c index ef61bb4137..bc1e32af1a 100644 --- a/libavfilter/vf_hwupload.c +++ b/libavfilter/vf_hwupload.c @@ -39,35 +39,41 @@ typedef struct HWUploadContext { char *device_type; } HWUploadContext; -static int hwupload_query_formats(AVFilterContext *avctx) +static av_cold int hwupload_init(AVFilterContext *avctx) { HWUploadContext *ctx = avctx->priv; - AVHWFramesConstraints *constraints = NULL; - const enum AVPixelFormat *input_pix_fmts, *output_pix_fmts; - AVFilterFormats *input_formats = NULL; - int err, i; + int err; - if (ctx->hwdevice_ref) { - /* We already have a specified device. */ - } else if (avctx->hw_device_ctx) { - if (ctx->device_type) { - err = av_hwdevice_ctx_create_derived( - &ctx->hwdevice_ref, - av_hwdevice_find_type_by_name(ctx->device_type), - avctx->hw_device_ctx, 0); - if (err < 0) - return err; - } else { - ctx->hwdevice_ref = av_buffer_ref(avctx->hw_device_ctx); - if (!ctx->hwdevice_ref) - return AVERROR(ENOMEM); - } - } else { + if (!avctx->hw_device_ctx) { av_log(ctx, AV_LOG_ERROR, "A hardware device reference is required " "to upload frames to.\n"); return AVERROR(EINVAL); } + if (ctx->device_type) { + err = av_hwdevice_ctx_create_derived( + &ctx->hwdevice_ref, + av_hwdevice_find_type_by_name(ctx->device_type), + avctx->hw_device_ctx, 0); + if (err < 0) + return err; + } else { + ctx->hwdevice_ref = av_buffer_ref(avctx->hw_device_ctx); + if (!ctx->hwdevice_ref) + return AVERROR(ENOMEM); + } + + return 0; +} + +static int hwupload_query_formats(AVFilterContext *avctx) +{ + HWUploadContext *ctx = avctx->priv; + AVHWFramesConstraints *constraints = NULL; + const enum AVPixelFormat *input_pix_fmts, *output_pix_fmts; + AVFilterFormats *input_formats = NULL; + int err, i; + constraints = av_hwdevice_get_hwframe_constraints(ctx->hwdevice_ref, NULL); if (!constraints) { err = AVERROR(EINVAL); @@ -251,6 +257,7 @@ static const AVFilterPad hwupload_outputs[] = { const AVFilter ff_vf_hwupload = { .name = "hwupload", .description = NULL_IF_CONFIG_SMALL("Upload a normal frame to a hardware frame"), + .init = hwupload_init, .uninit = hwupload_uninit, .priv_size = sizeof(HWUploadContext), .priv_class = &hwupload_class, From patchwork Fri Feb 9 14:53:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 46137 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:a586:b0:19e:8a94:b663 with SMTP id gd6csp982363pzc; Fri, 9 Feb 2024 06:54:33 -0800 (PST) X-Google-Smtp-Source: AGHT+IGJy+nVssKKE0TIJV215mFWXQMywh+Qqkcv4S14sSqMYrupYwWmUdamoMnsuu5P6Zp/2FY8 X-Received: by 2002:a17:906:301b:b0:a38:916e:a503 with SMTP id 27-20020a170906301b00b00a38916ea503mr1290904ejz.1.1707490473422; Fri, 09 Feb 2024 06:54:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707490473; cv=none; d=google.com; s=arc-20160816; b=a/7v8k+qRWz+v53CzlvWrzJoXudGZBfxmZYkA4NbeVacgYKlInwxs+A/8F7hiADmUj p/cVZJbt6w1HgSz4mfXHG7jgtua1ZF4vmToifFzFfGYqpLylQJaDiClBdIUNwt9ZU+AF qxdWMJ368JMcEwRi4LgYC6onugSLqw4hhbUY+Xf7prumYG4ohMdM0TZ9QHOZa+gIk4Ys x6tjW3uS58aS1qY5Usj6tZgV2cVQgJofIA6AGLvdvE4tzj7ZaEQZiXnqFGj2wcTPvIYu NvvFqW2YOe+tt3hSC+iDynnHNA2TCuunA9sm//9RLSYJeK1cE1RjMN9o9UXY6DGRDv8U 6ShQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=7tJXaMUjP58G1JeB9f8zYhI/Z1N6fLIrtubgr/liCxs=; fh=1P28kNUzmGDAgZXaHemmChcSrNOCOwMW0G3MWey7xis=; b=AAkHpcTDQo2U1ak48JMCETxGBeOh+3Ffp3puPtPwV9V4ImR5JUIPum1ZDpF8e2R4/b HrwLvah6dC9vm54TgF/+NVUv8y1yC4pwKY5PnuOnevtE9amgROHLJSSpxMuFfyZ2qnJN H+bihjzLXoENaqRWu62uCVdZQsRZfhvPvkHQer815DeXUGo48h0DAfAOCqmg94vaDysX QGXZlZRC247rAS8fXPFdfpGKR3psZiHCbvmmDhVXmSpTrwGYNudRLqHIRs7+e79lsrNW +marGXCsloFkvKNBcoaKbr7UjWd9qyAy4XlBmmxVRbbLp5c+GxgjPthVbY/UHZiXqcjG WDnQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@haasn.xyz header.s=mail header.b=j+mGty5n; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org X-Forwarded-Encrypted: i=1; AJvYcCXU8nkuOXwU9oSrc6xddm2ttgM518+d0nl+U49In8044lgx9KYh9RfF8A37gvWNX7NOpJ1W7WFkXhAsAI1P9FnUgak/12Ij0CZXh5191oCsPkQc8awvluoPuaquSHboVOEUDe0A3KacRhW2cjHi3mz5hoob8sbc0tqxGkOBrvYd8vvzLSFAfXhSh/WWsfLbhz5A0kgQZfuyl60uSazBFHQgq0fRl6dgeNb+VZkdquxcvXTLa9LwUl6v36nNjqPC3zcbhobGLMHENN8TYLjhGYecx2hvCz7sMYGvm6bXOS0ll2QrrdcHYuhv9MqwsPBXkbkvvnArpIui+tCWMEEJ5/RL5wuDbqZdaDWHdE7exIWri9XQO3XLV9fFVWhlJaqTkaWMx+mZ2hzYlsXIq6Rp7+KSFFPkdIOsjR+mFjJUnn5xZQJJPuCq/i5l7xN4ze8l8pU3iZzy4jY3904/fM+PE2nc2UubApVVIUgaCzSLKwiSi2NJH0ctyNBdcdvN2UCQY9KSFh+P7JnnSsxbTE0ne/eh7VTT5QYjKLls1ck7mE/hJfUkwjGw2QOHD0DYoIyYe+cT9580oI7bjUe4mkAngz63VHNfmGEtkfQsfit1jgc0PGjFTHgATaAXXXt2O3qmSXrWilf268NoTWNhy84zBBRnmN5WkWhKSGsoILLrk5KePXr+/F1osUOr3IiPW+Z6RSwlDCE3yruxcNX7W1P6haEeh3PDvMJnPo916wd553kNp0nVJEKHkl1FK7uCwkYjEQkmHFGYQ3luSaBZK1TY5GXFGJZphsNCmscuWfh3SCgXSkQmHfDAv7/N0bolWrAFn1FTSmGBdQwTJaF8isMntEgUVwrrzCo2Qo0hU6V/IZdm2aczGVU2rOHCTvyGjWY6niFB3Dw3RKouhqJ06oLUdf6IAWOMpe7ikH0o9ommFfGilSJHcfB5ou/1VET8K/CV4ym0z8 KvJvSIa2XgeqOiiN6f8twUsl8Svqg0UftAKGMbDQdeLGeCNnrz1GsicoecGGl+8KbLEFG/y37e6KkgJn1UomfYu5PVj0gx9pcSQTzDgCtddCbUYVGLODKEKQs/fVqiPtnXEYY6tNfLrWNtiLDp1IH8TNxyvanj0ccvG0QWVR2n9Yja3NYrE9YV+gC6wNiOSL8IZkHKN4NidwPyCdcBHjvTRqtIDQp5MVaP/6n2yufQsOLp8LZWsUKxZy7WywHW1rQsUfwh1KDH9QXpp/CmZA2rh1Fle4zgYi6xwySafFmSI4k1RN86qbmYYNzdLyQ1roG5prjXAlREh+IC3v4U4o1nN9eJubIdIZnyGAOTN4AuPeUYrFv58S9Ke/rQ56dB3GCYCWvG8XaLNHwfPywccfR3WxIh86/qrhEYi6cO511GHK+NaQUscm2wuVv75mEjQHhzm62OCrX3w8HchJxZAyh9ob6kea93IU1EZO57tcitUde8dfDW9eO0Uxq6XHGXLSCLv2BF+LwAs3RT3wF5mWaTeGdoLeXRQQa2hv7IoPRDwzhY5T8ZlWyWnx25Rq2n7nesYP8IYzWWyaal274Ef6XwtHNy5g== Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id g5-20020a1709063b0500b00a394e84ddcfsi901108ejf.160.2024.02.09.06.54.33; Fri, 09 Feb 2024 06:54:33 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@haasn.xyz header.s=mail header.b=j+mGty5n; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 411C368CAFA; Fri, 9 Feb 2024 16:54:05 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from haasn.dev (haasn.dev [78.46.187.166]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 732F768CD10 for ; Fri, 9 Feb 2024 16:53:55 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1707490435; bh=J19phigtRYTip2hDAO1uOgml6xOBXBUrA3CzOKh3RCo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=j+mGty5nqzk6Pn+a4OYgN5ZSaCnghgadUxYGEFFYbbe9/GIcfqpukI6+SFEk1XUq+ gSI6ylVNJhjeH95mPdGoq14clfscL692Vu5FabfjZ9P4YnXPqJ+w3PLiwkfY8oWoEM 8FUAV0xthpeGaJq1twKekPMn0ayNj9HAuy+yy4uA= Received: from haasn.dev (unknown [10.30.0.2]) by haasn.dev (Postfix) with ESMTP id 3698341905; Fri, 9 Feb 2024 15:53:55 +0100 (CET) From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Fri, 9 Feb 2024 15:53:48 +0100 Message-ID: <20240209145349.104511-4-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240209145349.104511-1-ffmpeg@haasn.xyz> References: <20240209145349.104511-1-ffmpeg@haasn.xyz> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 4/5] avfilter/libplacebo: move hwctx init to init() 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 Cc: Niklas Haas Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: U/LW4liUlWTb From: Niklas Haas --- libavfilter/vf_libplacebo.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/libavfilter/vf_libplacebo.c b/libavfilter/vf_libplacebo.c index a9a3d884ce..f41d8be0c0 100644 --- a/libavfilter/vf_libplacebo.c +++ b/libavfilter/vf_libplacebo.c @@ -544,6 +544,7 @@ static int parse_shader(AVFilterContext *avctx, const void *shader, size_t len) static void libplacebo_uninit(AVFilterContext *avctx); static int libplacebo_config_input(AVFilterLink *inlink); +static int init_vulkan(AVFilterContext *avctx); static int libplacebo_init(AVFilterContext *avctx) { @@ -610,8 +611,7 @@ static int libplacebo_init(AVFilterContext *avctx) if (strcmp(s->fps_string, "none") != 0) RET(av_parse_video_rate(&s->fps, s->fps_string)); - /* Note: s->vulkan etc. are initialized later, when hwctx is available */ - return 0; + return init_vulkan(avctx); fail: return err; @@ -656,13 +656,20 @@ static void input_uninit(LibplaceboInput *input) av_fifo_freep2(&input->out_pts); } -static int init_vulkan(AVFilterContext *avctx, const AVVulkanDeviceContext *hwctx) +static int init_vulkan(AVFilterContext *avctx) { int err = 0; LibplaceboContext *s = avctx->priv; + const AVVulkanDeviceContext *hwctx = NULL; uint8_t *buf = NULL; size_t buf_len; + if (avctx->hw_device_ctx) { + const AVHWDeviceContext *avhwctx = (void *) avctx->hw_device_ctx->data; + if (avhwctx->type == AV_HWDEVICE_TYPE_VULKAN) + hwctx = s->vkctx.hwctx = avhwctx->hwctx; + } + if (hwctx) { #if PL_API_VER >= 278 /* Import libavfilter vulkan context into libplacebo */ @@ -1127,18 +1134,9 @@ static int libplacebo_query_format(AVFilterContext *ctx) { int err; LibplaceboContext *s = ctx->priv; - const AVVulkanDeviceContext *vkhwctx = NULL; const AVPixFmtDescriptor *desc = NULL; AVFilterFormats *infmts = NULL, *outfmts = NULL; - if (ctx->hw_device_ctx) { - const AVHWDeviceContext *avhwctx = (void *) ctx->hw_device_ctx->data; - if (avhwctx->type == AV_HWDEVICE_TYPE_VULKAN) - vkhwctx = avhwctx->hwctx; - } - - RET(init_vulkan(ctx, vkhwctx)); - while ((desc = av_pix_fmt_desc_next(desc))) { enum AVPixelFormat pixfmt = av_pix_fmt_desc_get_id(desc); @@ -1150,7 +1148,7 @@ static int libplacebo_query_format(AVFilterContext *ctx) #endif if (pixfmt == AV_PIX_FMT_VULKAN) { - if (!vkhwctx || vkhwctx->act_dev != s->vulkan->device) + if (!s->vkctx.hwctx || s->vkctx.hwctx->act_dev != s->vulkan->device) continue; } From patchwork Fri Feb 9 14:53:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 46138 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:a586:b0:19e:8a94:b663 with SMTP id gd6csp982430pzc; Fri, 9 Feb 2024 06:54:42 -0800 (PST) X-Google-Smtp-Source: AGHT+IEt0xXPVjC2zEtl7lrz7QznxWaDZ+poRZFwMv4usXuMaA93z48g9QEsLfmrgcWawD21O5K1 X-Received: by 2002:a05:6402:517:b0:560:c77f:a11c with SMTP id m23-20020a056402051700b00560c77fa11cmr1796588edv.10.1707490481768; Fri, 09 Feb 2024 06:54:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707490481; cv=none; d=google.com; s=arc-20160816; b=BRBG9QCfO8FNDRSezcwiV6xS0+NrRQIW2dWSc7UCgFA3U9Dzw8AnBfxaqGXOaAsXBB Elaa5nANrYDOxbke2hiVqdfh6hwzCni82XJtIJak0VNv5iYYz5w+o2k2ijRhXWwhnGmc eVnK+kK4pWR8IFSEqtgX+LSFccHYnM4CsYZDfvQENXW75JbfLfRuXo/U0We9jl4lERrJ SXpfiRDmtf+qyKJxUERNInMFXcsfHg0cp8bXetMpOqW8DG+aSsO4XLjRcuF4/QSnR8nW w3T9hiAARBWsaNJpmqqR/JK438PfNGuaUjetXTfB09C/DY5UzYl8iiPfqXc0iv8YmaSc jpeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=Pb+kIzwCo6fXPuK26YDOTCxCB3fAN6ePhRB1mkZD588=; fh=nAZlSrFjlbHRcjkFjD0UidgBwqr5JoErVupLcqyNk3M=; b=rH2mHLo0VldaqxoYKhL8lwRQh9OfUZyKinUwlShgn6zSVdZN0pS8pYYrHchd6Xpdvk ssXsCQu1FClvGGZUuDagEiL/yr58e6oj4PDv8LWAcE0ms2m+gp82bRApuSSYlzmp3tfg nTDgyymoZHAOSxN6LPq56X9dFIPAjbdfwCELQtLIRLeOGq8XF3RcOzH6+W2+9Ons7IML OrAHmn1XjOD3n1os6jbyaa1EHxBQhWHL/BsbllAZkss7ZCS/7CQOJgbt+fu1U3luAB0y KSGeOOE/f/Mxn9SYvQu6kHB/PoiFuuFqqm0UfyHNYovjVcx2JLWSlGuzu4rFG7rF30yK eSvw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@haasn.xyz header.s=mail header.b=OZSq0Uhb; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org X-Forwarded-Encrypted: i=1; AJvYcCWW2tUS5xM6enefhSA/34csTvSxSc7Xux6PZajjeilMfhsLkeKH+z/MVMNDaS3ZH/XjFTC6u5okJeCQhyulnK3quYHF0SNi6jvvv0yt0QOoQw5+j2yQiwjHO+55t65COS0tOlIVNY6xQEL800zpH9BwFI0LbjEUel4o6REqIOOSrpI3xdLW8Ntd7IDQb/Wbj0p9di+cBJWgyb70fm4+eLqoxmu+ttG4RoZxf49mYoBxTIZn4lDYVQK1o/1wQ6egcEAALUandP+t1cVTQlARDxVLdevdy5h6g74jh9xA+PkoJzo4sNFximrFVxwGHi837IlAEbUfTqpbrkncLcI37zryoXQ+LrpUhDxIjV3wEyGDklAH5yObLgiK/BbToYScuTwJcrBOp5L7rVg3xDY6hHtWdPbIEKUtpJ3nDZiLp+b0P8fDS3DnvgRin02H1EQ33z76n+0DQ//UH7jMfRuRXQRbXYeBXZ7hB5vSAVBY+wMoWNDHXSe3KE8ixrBcBWh4MLPM1OXE5B5Gg8srVTRARHAutrDSJZ+4yP48+RnhGwFFQmlAOZyOs08fY5dPYMKAZjDKfvbC+L+aP9CIEQwH6+A1SQ8Wet/L/5QWygsrSsJf2GZ7CF2S/L2JshAcTW9mwsJw/bvwBBbUGBmksudI6E6fdoJU0WSaNvpDs3laZ1iUQkGBpz4GiuRSP5o9wPaYotjiRZ/PaQGw9srbm7iDkaVggzcTQOT65+x3xx+bFGqD9wG9HJ9WZUgwq9Kxhc0LFaZX0RXWdCEZvGwgVXOZYpD27Dv4XUinrSq56loAiHiD2ZmocwlBrm5ediC2uyG3Ih/yDPUV9SbS9tNMe8TPZ1I9yockBRbkOM7Nqk6Dfc9Wz1XHH66R6UJBVUH2bzZQxGZThu/wvEIRqtD3qvPi34RZajV141mdBPb/YIdeQlkbo2NxGZwrGOJZJdK2s0nmqw+yt5 fhpGdwmE/Soe3mQ2pny5tiFT5RcGARq+I/5B0ITLcoac5iuGLQEDve0am5Bc+AazhjXlQH1jDwKrIYp6+V2ewJPnLGtfG/BDIwBBRrUp3pPf+nILt4vJ310K64pZI4ObXmRLJPu7iINSuX6c7t1sr5FaOxbj3/yjCR/C5pukARJ7CXG4Ytjc75xGYamiWW/WZMML1fUij58Y88nzzrfYw9Oho7yrVzGjSeI98G7of6OShHZGFT7Ki9LJp+tTl+XJaukW0+xnxf/rqRZNJ20Xnyi0MZSsslsDhlCWQp0TUbKkZqsNCrJiRoZMvI5iUL+KOMEXBUmZ14yyjGkBWJmu4WobdnSpZC1MsToLbK2uXj6eTwj8BEFO56AznBNpbJiQIlHz+8Ciy6tYYGFNy9Clvgnl4AJfTNzDc8a3OJ2q4grU6Q7uC2Eqd/Cz6XecPVqT37KkUQpKgan2yOLuaOIBnBX+JvqfLrkTA3fOk67f/u2uTwAANRfTLwBBR4RDTkvOBAXpiG0RorJTuIWauATdiGT3xU94TTT4EkY0fsR3znTyVWCVjlvAxV8rT2qGE3CSqzs30ILRzobHVPbR3IeQfS5NeUpX4Z7woEcXmwfNRanBsvuADBoO9lYEyK/H7V Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id y3-20020a50bb03000000b005601033ea51si928034ede.426.2024.02.09.06.54.41; Fri, 09 Feb 2024 06:54:41 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@haasn.xyz header.s=mail header.b=OZSq0Uhb; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4056768D137; Fri, 9 Feb 2024 16:54:06 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from haasn.dev (haasn.dev [78.46.187.166]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id AFE1968CD10 for ; Fri, 9 Feb 2024 16:53:55 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1707490435; bh=CtagyGptHiPnSFxnYkY2/MUsxw6U0L4TJJTaAwE/tuU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OZSq0UhbAoDyMWkptJ/zKdmBTsiL+um1wAUm1IebWyYU+gEiOCsuQOjDDLqxgmuqg npRuYUyU8dlxuiHW+Onb6JcMapTqN7p/jmYFekYRoM1B7K7554Yx0DA5nxYtHOxnHr XIJoRs6uNlBSSr70wymH6oaXC6mio+Oj1Pg9H1+Y= Received: from haasn.dev (unknown [10.30.0.2]) by haasn.dev (Postfix) with ESMTP id 6CBAD419F6; Fri, 9 Feb 2024 15:53:55 +0100 (CET) From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Fri, 9 Feb 2024 15:53:49 +0100 Message-ID: <20240209145349.104511-5-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240209145349.104511-1-ffmpeg@haasn.xyz> References: <20240209145349.104511-1-ffmpeg@haasn.xyz> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 5/5] avfilter/vsrc_ddagrab: move hwctx init to init() 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 Cc: Niklas Haas Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: z+lpWfQk0Js1 From: Niklas Haas Not as strongly motivated as the previous commits, but there's still no reason to do this from config_props if we can avoid it. --- libavfilter/vsrc_ddagrab.c | 99 ++++++++++++++++++-------------------- 1 file changed, 48 insertions(+), 51 deletions(-) diff --git a/libavfilter/vsrc_ddagrab.c b/libavfilter/vsrc_ddagrab.c index 51e928d785..c89eff6e5a 100644 --- a/libavfilter/vsrc_ddagrab.c +++ b/libavfilter/vsrc_ddagrab.c @@ -445,7 +445,54 @@ static av_cold int ddagrab_init(AVFilterContext *avctx) dda->mouse_x = -1; dda->mouse_y = -1; - return 0; + /* Init hardware context */ + if (avctx->hw_device_ctx) { + dda->device_ctx = (AVHWDeviceContext*)avctx->hw_device_ctx->data; + + if (dda->device_ctx->type != AV_HWDEVICE_TYPE_D3D11VA) { + av_log(avctx, AV_LOG_ERROR, "Non-D3D11VA input hw_device_ctx\n"); + return AVERROR(EINVAL); + } + + dda->device_ref = av_buffer_ref(avctx->hw_device_ctx); + if (!dda->device_ref) + return AVERROR(ENOMEM); + + av_log(avctx, AV_LOG_VERBOSE, "Using provided hw_device_ctx\n"); + } else { + ret = av_hwdevice_ctx_create(&dda->device_ref, AV_HWDEVICE_TYPE_D3D11VA, NULL, NULL, 0); + if (ret < 0) { + av_log(avctx, AV_LOG_ERROR, "Failed to create D3D11VA device.\n"); + return ret; + } + + dda->device_ctx = (AVHWDeviceContext*)dda->device_ref->data; + + av_log(avctx, AV_LOG_VERBOSE, "Created internal hw_device_ctx\n"); + } + + dda->device_hwctx = (AVD3D11VADeviceContext*)dda->device_ctx->hwctx; + + ret = init_dxgi_dda(avctx); + if (ret < 0) + return ret; + + ret = probe_output_format(avctx); + if (ret < 0) + return ret; + + if (dda->out_fmt && dda->raw_format != dda->out_fmt && (!dda->allow_fallback || dda->force_fmt)) { + av_log(avctx, AV_LOG_ERROR, "Requested output format unavailable.\n"); + return AVERROR(ENOTSUP); + } + + if (dda->draw_mouse) { + ret = init_render_resources(avctx); + if (ret < 0) + return ret; + } + + return init_hwframes_ctx(avctx); } static int create_d3d11_pointer_tex(AVFilterContext *avctx, @@ -814,46 +861,6 @@ static int ddagrab_config_props(AVFilterLink *outlink) DdagrabContext *dda = avctx->priv; int ret; - if (avctx->hw_device_ctx) { - dda->device_ctx = (AVHWDeviceContext*)avctx->hw_device_ctx->data; - - if (dda->device_ctx->type != AV_HWDEVICE_TYPE_D3D11VA) { - av_log(avctx, AV_LOG_ERROR, "Non-D3D11VA input hw_device_ctx\n"); - return AVERROR(EINVAL); - } - - dda->device_ref = av_buffer_ref(avctx->hw_device_ctx); - if (!dda->device_ref) - return AVERROR(ENOMEM); - - av_log(avctx, AV_LOG_VERBOSE, "Using provided hw_device_ctx\n"); - } else { - ret = av_hwdevice_ctx_create(&dda->device_ref, AV_HWDEVICE_TYPE_D3D11VA, NULL, NULL, 0); - if (ret < 0) { - av_log(avctx, AV_LOG_ERROR, "Failed to create D3D11VA device.\n"); - return ret; - } - - dda->device_ctx = (AVHWDeviceContext*)dda->device_ref->data; - - av_log(avctx, AV_LOG_VERBOSE, "Created internal hw_device_ctx\n"); - } - - dda->device_hwctx = (AVD3D11VADeviceContext*)dda->device_ctx->hwctx; - - ret = init_dxgi_dda(avctx); - if (ret < 0) - return ret; - - ret = probe_output_format(avctx); - if (ret < 0) - return ret; - - if (dda->out_fmt && dda->raw_format != dda->out_fmt && (!dda->allow_fallback || dda->force_fmt)) { - av_log(avctx, AV_LOG_ERROR, "Requested output format unavailable.\n"); - return AVERROR(ENOTSUP); - } - dda->width -= FFMAX(dda->width - dda->raw_width + dda->offset_x, 0); dda->height -= FFMAX(dda->height - dda->raw_height + dda->offset_y, 0); @@ -861,16 +868,6 @@ static int ddagrab_config_props(AVFilterLink *outlink) dda->time_frame = av_gettime_relative() / av_q2d(dda->time_base); dda->time_timeout = av_rescale_q(1, dda->time_base, (AVRational) { 1, 1000 }) / 2; - if (dda->draw_mouse) { - ret = init_render_resources(avctx); - if (ret < 0) - return ret; - } - - ret = init_hwframes_ctx(avctx); - if (ret < 0) - return ret; - outlink->hw_frames_ctx = av_buffer_ref(dda->frames_ref); if (!outlink->hw_frames_ctx) return AVERROR(ENOMEM);