From patchwork Fri May 5 09:07:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 41487 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:dca6:b0:f3:34fa:f187 with SMTP id ky38csp329934pzb; Fri, 5 May 2023 02:08:41 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7u0DuyFy+jRZVZPjvSHXXIA6KfsGhCZDIi3CaEE8fxbffMIstRXiZISgQ3r/6EkbQifj1y X-Received: by 2002:a05:6402:2145:b0:50b:f999:9dee with SMTP id bq5-20020a056402214500b0050bf9999deemr833431edb.8.1683277721675; Fri, 05 May 2023 02:08:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683277721; cv=none; d=google.com; s=arc-20160816; b=L0Xl1uZ11nGDAo1AXcW3ZI/p9e9J7hxcGNqncDu7JVHkQgU0AA3xhtoJGhtIEss1C8 q0x8st7IgKeASk+b5MrvJ9tFif2m1eufZEqqM7UvK7n1Qg1zXOSljedu9NizGZS7RbLy Pf8kSrGhtBPA661MxfE0KjbUP6Ffei2KNG6EEOhH5HyoEaA01Da5Sfyah7glUvCeqrjk F5hI3PLi2YZjMhfw9VPXON4slsa7Gv3rhDJgiiCMvftdXEdiO2jUvDQJgVfQe6ARk/hQ UnP2UWMoMMDn8l4I2ApMaNejEJ1kM5YGcNJbVHaHlHnjfaDbBkOJwt5rggGatUZ24AsJ 8juQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding: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:delivered-to; bh=4boRCkT42O4cjl1CI7KeebZfsmy72xWrmyTqOsKmuz4=; b=qOLc9iDmDxuTrLF/dBLSqpG12UP05ob6JuyAEEZpPXumMX7O/O1DIo8A0pgRBzycRH 0mWvcOMbf7jhx7sxVr+eaZZ0BwPj3jTlraFJVafRc0BXTtEBsQ6B/5B8YesSFRZPgR1P llbBECWmfVY7vn4T5fFmtf8jbwR+8jKzTJxYid6oJ4o1SKqP4Hwy1FM1dTog4beyRDKu qvdZbF5rV1q4nO3MRyYvFw7rBa/a4HO2z+IE8wJMx1pwctWPlCr8zT5G9ei6bt31yIFS fDxvwBReuiBfnLDTuLa4DJQcUMLX1BtjqpWiePpRDH94x7huyK8DiMW2JAQJe1f+PCPP Umbw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id i20-20020a50fc14000000b0050bfb60f440si3677594edr.444.2023.05.05.02.08.41; Fri, 05 May 2023 02:08:41 -0700 (PDT) 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; 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 01FE368C15C; Fri, 5 May 2023 12:07:45 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail0.khirnov.net (red.khirnov.net [176.97.15.12]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 70C9368C12A for ; Fri, 5 May 2023 12:07:36 +0300 (EEST) Received: from localhost (localhost [IPv6:::1]) by mail0.khirnov.net (Postfix) with ESMTP id 4779E240591 for ; Fri, 5 May 2023 11:07:33 +0200 (CEST) Received: from mail0.khirnov.net ([IPv6:::1]) by localhost (mail0.khirnov.net [IPv6:::1]) (amavisd-new, port 10024) with ESMTP id Rc_iMMugaF_m for ; Fri, 5 May 2023 11:07:31 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail0.khirnov.net (Postfix) with ESMTPS id 10A302405B5 for ; Fri, 5 May 2023 11:07:30 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 00EA13A048F for ; Fri, 5 May 2023 11:07:30 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Fri, 5 May 2023 11:07:20 +0200 Message-Id: <20230505090723.24872-8-anton@khirnov.net> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230505090723.24872-1-anton@khirnov.net> References: <20230505090723.24872-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 08/11] fftools/ffmpeg_filter: use av_buffer_replace() to improve code 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: KKnTciyGeaVq It is shorter and more efficient. --- fftools/ffmpeg_filter.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index 34c51c23d9..0165be8f77 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -1415,7 +1415,9 @@ static int ifilter_parameters_from_frame(InputFilter *ifilter, const AVFrame *fr AVFrameSideData *sd; int ret; - av_buffer_unref(&ifp->hw_frames_ctx); + ret = av_buffer_replace(&ifp->hw_frames_ctx, frame->hw_frames_ctx); + if (ret < 0) + return ret; ifilter->format = frame->format; @@ -1433,12 +1435,6 @@ static int ifilter_parameters_from_frame(InputFilter *ifilter, const AVFrame *fr if (sd) ifp->displaymatrix = av_memdup(sd->data, sizeof(int32_t) * 9); - if (frame->hw_frames_ctx) { - ifp->hw_frames_ctx = av_buffer_ref(frame->hw_frames_ctx); - if (!ifp->hw_frames_ctx) - return AVERROR(ENOMEM); - } - return 0; }