From patchwork Sat Nov 4 07:56:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 44504 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:3aa6:b0:181:818d:5e7f with SMTP id d38csp336088pzh; Sat, 4 Nov 2023 02:22:13 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG7BN+3sQAooBqTcJRgs7kkobVsuJeebl1LFL7jIWUaiGfYAg0S8jh5MwZD3SsKdc4pTIDm X-Received: by 2002:a17:907:934d:b0:9d3:ccd1:a911 with SMTP id bv13-20020a170907934d00b009d3ccd1a911mr9218175ejc.76.1699089732839; Sat, 04 Nov 2023 02:22:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1699089732; cv=none; d=google.com; s=arc-20160816; b=LZ7uzgluXkfctDlY9lx8rhKmUht7ExqPbqKzwe/YV+NoV+1KeyhQoLoOTXvE2Lzy6I BufjPmzxYUcUCKOwfFo59kEWPX2bSPgGZDqTsaEc9hxKBbFrgfmBSEqKOnKJUTcMu4Ob b4siBUcm892btFtrGsXsyvyyQ9h/BA24j23+wa5XGzV6LaI3TfKSP0nlZu08TAeWxM1F ReOOhT88LRZb9s4c/TstmR75SI5hPo3k7FwplrdE8CoB3CaUJLRbaI/b9n12LKphZVbW X4bi6P0HFHd20BP8ntGlwQeOsVcLeKXmrpAHZI+/hLh9h9+xu0em1acnDIm4iXpzWEQp A6ZQ== 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=Oz1rHoUcp7LAhyeWaemgvGp3MGUEbkd2wzWL4Rr6gbY=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=q2vxJ4hZCtoasJ4qIrq7O2UXi+wIgJKWRnhWDS8dqnykDeOv1/lgxm2C9mNBwMHOb0 jxg+z40tKj0RXg4MPxK9VgkwoaCrxGwwT3/BP0VUlnG0ij3cwQZShd9psSxRw33lf2cF CLpmzrb/8mAYEWWLXbzHhCXXPsGM8gTt4h8E5sWL5uL+hO5iMurRxjlNKdBoT+PooqFv oHmKo69gY9Nzw9EHl9GlYE909i1zCln/zRMwIX/53INUXSXr4BjRxtviumAHsJnZcJEe UFAd3RUNKMttIQxxuJ3a2ONt9fNIwkS4gq5/27c5Dlp7VYgQE0mbevEXlJfGLRGQrI8h YVng== 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 wz12-20020a170906fe4c00b009adec4bd971si2144890ejb.294.2023.11.04.02.22.12; Sat, 04 Nov 2023 02:22:12 -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 0631768CE50; Sat, 4 Nov 2023 11:21:57 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D213568CE3A for ; Sat, 4 Nov 2023 11:21:49 +0200 (EET) Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 2A3981006 for ; Sat, 4 Nov 2023 10:21:49 +0100 (CET) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id Vctmo95MHGel for ; Sat, 4 Nov 2023 10:21:48 +0100 (CET) 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 mail1.khirnov.net (Postfix) with ESMTPS id 696EE951 for ; Sat, 4 Nov 2023 10:21:47 +0100 (CET) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 3AE6A3A06E4 for ; Sat, 4 Nov 2023 10:21:40 +0100 (CET) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sat, 4 Nov 2023 08:56:13 +0100 Message-ID: <20231104092125.10213-5-anton@khirnov.net> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231104092125.10213-1-anton@khirnov.net> References: <20231104092125.10213-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 04/24] fftools/ffmpeg: move a few inline function into a new header 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: f34Lsf3dcdkT Will allow to use them in future commits without including the whole ffmpeg.h. --- fftools/ffmpeg.c | 1 + fftools/ffmpeg.h | 21 ------------------ fftools/ffmpeg_dec.c | 1 + fftools/ffmpeg_demux.c | 1 + fftools/ffmpeg_mux.c | 1 + fftools/ffmpeg_utils.h | 50 ++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 54 insertions(+), 21 deletions(-) create mode 100644 fftools/ffmpeg_utils.h diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 46a85b41a8..cdb16ef90b 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -99,6 +99,7 @@ #include "cmdutils.h" #include "ffmpeg.h" +#include "ffmpeg_utils.h" #include "sync_queue.h" const char program_name[] = "ffmpeg"; diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 0983d026cd..d52c954df5 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -880,17 +880,6 @@ int trigger_fix_sub_duration_heartbeat(OutputStream *ost, const AVPacket *pkt); int fix_sub_duration_heartbeat(InputStream *ist, int64_t signal_pts); void update_benchmark(const char *fmt, ...); -/** - * Merge two return codes - return one of the error codes if at least one of - * them was negative, 0 otherwise. - * Currently just picks the first one, eventually we might want to do something - * more sophisticated, like sorting them by priority. - */ -static inline int err_merge(int err0, int err1) -{ - return (err0 < 0) ? err0 : FFMIN(err1, 0); -} - #define SPECIFIER_OPT_FMT_str "%s" #define SPECIFIER_OPT_FMT_i "%i" #define SPECIFIER_OPT_FMT_i64 "%"PRId64 @@ -942,14 +931,4 @@ extern const char * const opt_name_frame_rates[]; extern const char * const opt_name_top_field_first[]; #endif -static inline void pkt_move(void *dst, void *src) -{ - av_packet_move_ref(dst, src); -} - -static inline void frame_move(void *dst, void *src) -{ - av_frame_move_ref(dst, src); -} - #endif /* FFTOOLS_FFMPEG_H */ diff --git a/fftools/ffmpeg_dec.c b/fftools/ffmpeg_dec.c index fcee8b65ac..8795a94c1a 100644 --- a/fftools/ffmpeg_dec.c +++ b/fftools/ffmpeg_dec.c @@ -30,6 +30,7 @@ #include "libavfilter/buffersrc.h" #include "ffmpeg.h" +#include "ffmpeg_utils.h" #include "thread_queue.h" struct Decoder { diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c index 350f233ab7..ec96daf26b 100644 --- a/fftools/ffmpeg_demux.c +++ b/fftools/ffmpeg_demux.c @@ -20,6 +20,7 @@ #include #include "ffmpeg.h" +#include "ffmpeg_utils.h" #include "libavutil/avassert.h" #include "libavutil/avstring.h" diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c index 7a924dba6c..30c033036d 100644 --- a/fftools/ffmpeg_mux.c +++ b/fftools/ffmpeg_mux.c @@ -22,6 +22,7 @@ #include "ffmpeg.h" #include "ffmpeg_mux.h" +#include "ffmpeg_utils.h" #include "objpool.h" #include "sync_queue.h" #include "thread_queue.h" diff --git a/fftools/ffmpeg_utils.h b/fftools/ffmpeg_utils.h new file mode 100644 index 0000000000..20cde94969 --- /dev/null +++ b/fftools/ffmpeg_utils.h @@ -0,0 +1,50 @@ +/* + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef FFTOOLS_FFMPEG_UTILS_H +#define FFTOOLS_FFMPEG_UTILS_H + +#include + +#include "libavutil/common.h" +#include "libavutil/frame.h" + +#include "libavcodec/packet.h" + +/** + * Merge two return codes - return one of the error codes if at least one of + * them was negative, 0 otherwise. + * Currently just picks the first one, eventually we might want to do something + * more sophisticated, like sorting them by priority. + */ +static inline int err_merge(int err0, int err1) +{ + return (err0 < 0) ? err0 : FFMIN(err1, 0); +} + +static inline void pkt_move(void *dst, void *src) +{ + av_packet_move_ref(dst, src); +} + +static inline void frame_move(void *dst, void *src) +{ + av_frame_move_ref(dst, src); +} + +#endif // FFTOOLS_FFMPEG_UTILS_H