From patchwork Fri May 20 21:12:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Martin_Storsj=C3=B6?= X-Patchwork-Id: 35856 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a17:906:4548:b0:6fe:2728:7bda with SMTP id s8csp1436391ejq; Fri, 20 May 2022 14:13:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzhnTG/Y5DZDUpNY2TTM/w3Pz2mkLnGc/mWpFF5jaHkLHF/Xb58Jxb4QFUcCZXuE6eO04H9 X-Received: by 2002:aa7:db10:0:b0:42a:a983:a5d6 with SMTP id t16-20020aa7db10000000b0042aa983a5d6mr13023491eds.312.1653081192633; Fri, 20 May 2022 14:13:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653081192; cv=none; d=google.com; s=arc-20160816; b=RWg2tdUQui7wqgKJVKt1uX1hbGz3FUJA9xz3IqM2B3hnf9XiNhWNd6Fv2uK3HQSQHU 9c7dx0tr0kuZEierrVv30lUynmdi5Qs+8tb2rc+X4TqvFTNdpfRo+c3i4koUtGo4daCw nH5pdaZ3Z3yr6uG5gDtq6xeVc3BXQdqasZIX2vxUb1JcFBwxt0wU5Rp5PDb0GZpzWiQh bbKfNuvEN9o06ChNevBVHpfMZCFSczjmYZVcLFnFYQ4aowolfq/mPBCWzsUKQLsIZ3Hb Wpfa3FJbvD2K/KCESEpl4QRRZS+I7kwzkSuELK+URcLeDZsadd6XSpPj3Yv1SI+0VP5+ lQ0w== 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:message-id:date:to:from :dkim-signature:delivered-to; bh=wYWhLZzLVbXZw5crtYEUO9gntdhr0wO0sJgZShk3jy4=; b=UwvmH/ddM7YfCnqnYbHCUrh5DXS3BX2Sqyyixuv0/G4UlAb692IJmpb8fxY4rIRX9H C4q2Hq0/5kVNWvbmCkmHtIiLc/osrF8Wbc10QQ1rhCIlcMVAIUxkQTNm5+eTOaGgGegj kDcOHCLxV3ytWuTQ9IQQqLjvZUDU8HbeguvHaWLMHS1J9uUqIVXHKQ+f6mEVVZ7gV099 MEZBW5SH5BfJxKf0mivfRacoH8H4jmNcY79LUosG6HgppHsf0HPqlznysxvAdqyjfMFv Qn+wKkumoNvH9lX4IB+dbP1ql6BmcRdHVLRDLKO4n6YTcGe0HYkDFUuOKZuhqjitnsQC BSXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@martin-st.20210112.gappssmtp.com header.s=20210112 header.b=yd06ns6e; 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 cw19-20020a170906479300b006fe1c07f388si3773950ejc.827.2022.05.20.14.13.06; Fri, 20 May 2022 14:13: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; dkim=neutral (body hash did not verify) header.i=@martin-st.20210112.gappssmtp.com header.s=20210112 header.b=yd06ns6e; 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 5DF9368B48F; Sat, 21 May 2022 00:13:03 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id DF7FD68B2A8 for ; Sat, 21 May 2022 00:12:56 +0300 (EEST) Received: by mail-wm1-f54.google.com with SMTP id ay35so3551928wmb.5 for ; Fri, 20 May 2022 14:12:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=martin-st.20210112.gappssmtp.com; s=20210112; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=h+mTlvg8h49b+TJB7PBBfv5/KyYrOJmAZIyOkWNR1A8=; b=yd06ns6ehSWlIXqVkJykGyMv4e60gcMuw8tmIQ+LL9pg0mkimtSQn/Mzn2862/uygv OUFzEBfn4TXw1xE9Nvz36rykyr2Lbb8Dc3tDhwbNVwWUWqUZVboFydLUYO21VprccPGR hQx0KZ7bk5aOgzGR+/xt4SQEDHOUR/7ICx34+nYvCGofMjTjEClGpvpwMxkEut8JmJ26 20ZWmU03ba7xMEuLOrI5AdrDR6BFoTrf6xUb3LnYg0+xbRn0xI06/HRprUUTuAgGYYUV iFgaz30EEXahj/oLRiTMN9uVpr9QHO2Mu9bQW4P+iSUBjdArIDXkLqSfzx/SiDn3NpSV I2LA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=h+mTlvg8h49b+TJB7PBBfv5/KyYrOJmAZIyOkWNR1A8=; b=WyU/i9FZh+uIE+XUuC9UgT2NI/InWIxK6Bq4PU2bkJMOf1Qf/1BMqllO6xKFTQel4m ync4Ua8JETVeTw80Ya7ofePMJKcqfC1I9Ql6fZsPoRoH52W1ahrfhhXZD7/zQ+g4C7r0 +YM1kWv5NP8m42DNHZoxaMAhDaEJllTccG5yAA83k/0EDEEXVPjwdvTWtQT/iMtWuRE7 d9htQT+R5YPj1N6q8JJf8t96rZDWx6ObuLgaZ8S95mVCC1oLbZjyf6Yw2JU2VqscQhJu tLnBQPZTGbFLGnkRHc9uAmb/mAnraKtpgTt935z1KMP0J8G4869q6V+a1uB+a1nl5hGi QLfA== X-Gm-Message-State: AOAM530yjQ+KmhA4Ft6xXnGAtNjWoGTXZgV5GP4UfZsmmYENppteCA04 lQH3RyZT6adZ+VtnP4mVBR330vWgKpTVXsi7 X-Received: by 2002:a7b:cd97:0:b0:38f:f785:ff8 with SMTP id y23-20020a7bcd97000000b0038ff7850ff8mr10059605wmj.44.1653081176267; Fri, 20 May 2022 14:12:56 -0700 (PDT) Received: from localhost (host-97-187.parnet.fi. [77.234.97.187]) by smtp.gmail.com with ESMTPSA id n19-20020a05600c3b9300b003942a244ecbsm2952090wms.16.2022.05.20.14.12.55 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 20 May 2022 14:12:55 -0700 (PDT) From: =?utf-8?q?Martin_Storsj=C3=B6?= To: ffmpeg-devel@ffmpeg.org Date: Sat, 21 May 2022 00:12:52 +0300 Message-Id: <20220520211254.47116-1-martin@martin.st> X-Mailer: git-send-email 2.32.0 (Apple Git-132) MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/3] fftools: Stop using av_fopen_utf8 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: zrITePTJ6L5n Provide a header based inline reimplementation of it. Using av_fopen_utf8 doesn't work outside of the libraries when built with MSVC as shared libraries (in the default configuration, where each DLL gets a separate statically linked CRT). --- fftools/ffmpeg_opt.c | 3 +- fftools/fopen_utf8.h | 71 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 fftools/fopen_utf8.h diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index 47e8b9b7bd..a5cd989d35 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -28,6 +28,7 @@ #endif #include "ffmpeg.h" +#include "fopen_utf8.h" #include "cmdutils.h" #include "opt_common.h" @@ -1882,7 +1883,7 @@ static OutputStream *new_video_stream(OptionsContext *o, AVFormatContext *oc, in video_enc->stats_in = logbuffer; } if (video_enc->flags & AV_CODEC_FLAG_PASS1) { - f = av_fopen_utf8(logfilename, "wb"); + f = fopen_utf8(logfilename, "wb"); if (!f) { av_log(NULL, AV_LOG_FATAL, "Cannot write log file '%s' for pass-1 encoding: %s\n", diff --git a/fftools/fopen_utf8.h b/fftools/fopen_utf8.h new file mode 100644 index 0000000000..db57fcaec4 --- /dev/null +++ b/fftools/fopen_utf8.h @@ -0,0 +1,71 @@ +/* + * 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_FOPEN_UTF8_H +#define FFTOOLS_FOPEN_UTF8_H + +#include + +/* The fopen_utf8 function here is essentially equivalent to av_fopen_utf8, + * except that it doesn't set O_CLOEXEC, and that it isn't exported + * from a different library. (On Windows, each DLL might use a different + * CRT, and FILE* handles can't be shared across them.) */ + +#ifdef _WIN32 +#include "libavutil/wchar_filename.h" + +static inline FILE *fopen_utf8(const char *path_utf8, const char *mode) +{ + wchar_t *path_w, *mode_w; + FILE *f; + + /* convert UTF-8 to wide chars */ + if (utf8towchar(path_utf8, &path_w)) /* This sets errno on error. */ + return NULL; + if (!path_w) + goto fallback; + + if (utf8towchar(mode, &mode_w)) + return NULL; + if (!mode_w) { + /* If failing to interpret the mode string as utf8, it is an invalid + * parameter. */ + av_freep(&path_w); + errno = EINVAL; + return NULL; + } + + f = _wfopen(path_w, mode_w); + av_freep(&path_w); + av_freep(&mode_w); + + return f; +fallback: + /* path may be in CP_ACP */ + return fopen(path_utf8, mode); +} + +#else + +static inline FILE *fopen_utf8(const char *path, const char *mode) +{ + return fopen(path, mode); +} +#endif + +#endif /* FFTOOLS_FOPEN_UTF8_H */ From patchwork Fri May 20 21:12:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Martin_Storsj=C3=B6?= X-Patchwork-Id: 35857 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a17:906:4548:b0:6fe:2728:7bda with SMTP id s8csp1436432ejq; Fri, 20 May 2022 14:13:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwR/fpaH3TiPGf3Uzf+5j5DWtqXRoDlUbddUqLrhYYuxhiURWu5i+axrDYfjGtbYEH4G/zE X-Received: by 2002:a17:907:3f29:b0:6f4:cb04:a6f5 with SMTP id hq41-20020a1709073f2900b006f4cb04a6f5mr10320798ejc.115.1653081200545; Fri, 20 May 2022 14:13:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653081200; cv=none; d=google.com; s=arc-20160816; b=jxoxjArKKSULgxSawOt9j3FrLahvELEuMaGQURH6TYDkIoTd4j5D7mAlZyB1X8uLz4 bpTOBzWXwXZ6XD3PVIMocl3u+Zfi9029KCb1Vq2vrI7eDlahgIVcQLsEJQ1K9LS/LLQC N52XiZZ5ndGkicfBePWf7wnv1vrQb87mQvrDAnA5jXb7hBE7QlXjWQRDYj2o3velcbkz OimGxVHjWha/KhDk9i2OTZTIF7pJkVDkldDwkt/qaZoxCnORmtwrtLb2SwLpxpq8JYDX XGKpmIJDvBg44eXTAsvmZ4/Z46XYtWZkiEcP2LbB3i2XS2JlaxUsL/Mjui1mqEbkPBcr oN5Q== 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:dkim-signature:delivered-to; bh=a1mP3xPYzOO3Lj9hzlRCmpCAaHh9pcH8jU2EGwmGdas=; b=rCXf8cAAeOpxQMWxHaSyB3X0ukFz4rV6dSqce/NIEnd0bPz5KSbaNd20iajvZApNlT JHDCCruFonWLc5dRmHzZom34ZjNoW7ptYojz7B7hoA62NS17V3a1Dg1M3D/spQh0BqL1 wtJCksQwyToBEXsPncf0oOv118Z56divNHRmZ0Ot/FuM4nCYCNuBQJXDU8EgoY1/JXBZ yBhB8XFGeBoelVrfDwV2Hpu134Psx/WCjJTYgJJmL6tE2JMKEizG7HK0MM3B+O6zZkv7 Qhsar2j30RZtK9L6JFrOWv4y7PQBSvEK9Esy8NvaygzX9MYzjWAfsI8vxUkhHUmSB2QJ /iYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@martin-st.20210112.gappssmtp.com header.s=20210112 header.b=JMKMPsrY; 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 ht19-20020a170907609300b006ee402acc45si9580388ejc.166.2022.05.20.14.13.15; Fri, 20 May 2022 14:13:20 -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; dkim=neutral (body hash did not verify) header.i=@martin-st.20210112.gappssmtp.com header.s=20210112 header.b=JMKMPsrY; 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 7143E68B480; Sat, 21 May 2022 00:13:05 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 715CA68B493 for ; Sat, 21 May 2022 00:12:58 +0300 (EEST) Received: by mail-wr1-f47.google.com with SMTP id r23so13063134wrr.2 for ; Fri, 20 May 2022 14:12:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=martin-st.20210112.gappssmtp.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=ey6NSpiyRkwlcBY1q5cHaf63o5NxUsIeQerbDkCyX0o=; b=JMKMPsrYaXcvEltW2xgtFXpxpmlFYmJN6fmc3XXa2vW3yyYoij9+lEXOxLlgSgwnL7 nEKICIxUJudC/YA4XUkqv3GWF3x8X6Px4pPBcLRAPVQ6tBRC/SsaAnYz3wPfSbwhknLx 5zuyfvOTBfuSmE6/7H0jbpj0L0OBQzErcmdSaE1fAOgPmeWq7DlUTnqg9Y2G5BnwPpVq ji683q4fOGb0e75q3Zs8/OKYgs82vtsI+gdysvphuhq7ERPUL1ZCpjx/Nns9W562lCqa cJY3nwiL745bRsxt1n11heevtti6H1/BnBHwBXQHD/UC0YBkVCnuyYpiy+bilsYvIsFG I8Pw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ey6NSpiyRkwlcBY1q5cHaf63o5NxUsIeQerbDkCyX0o=; b=o7O59dHUWJl1jYzNqYcKfMSsyiiq8aNqoTPPMmUfXnbUT3J9BPGsoFLAAz5c/qr59n ojvSKgtawKW2EbDAoN1/e46xcQRqVA/GpCSlxQebGdRsCbxdLKSjrcjA0UwaL15oELcW Ks6zJYRxTok+QhvJrOi2i6F1qm02q2+bnPIpZBFTVzlGU/0iEEZ4FN0Z6eluJydGuJ1L pekORk0oKw31xzm3qGfvcI74AzH9/eXETOpMJNve4qi6NQiPeBpWtmhQkPD3vev5V5Yt q289CSRDcrr0PLGfX6pCdXFLmgGb6hb9aKwOybR8ywBBykCvr/TELIxJC0hcBTrXyn25 dE1A== X-Gm-Message-State: AOAM531MOKOzDFW4HgKMGWXQkTn4nCqtxO7mZV0e13sjSji5tvNLr8hN RufWiyFScbsgAhQq9gAyHPtxVZuKoY76jyDj X-Received: by 2002:adf:f807:0:b0:20d:4c77:3567 with SMTP id s7-20020adff807000000b0020d4c773567mr9780951wrp.118.1653081177677; Fri, 20 May 2022 14:12:57 -0700 (PDT) Received: from localhost (host-97-187.parnet.fi. [77.234.97.187]) by smtp.gmail.com with ESMTPSA id g22-20020adfa496000000b0020c5253d907sm3294278wrb.83.2022.05.20.14.12.56 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 20 May 2022 14:12:57 -0700 (PDT) From: =?utf-8?q?Martin_Storsj=C3=B6?= To: ffmpeg-devel@ffmpeg.org Date: Sat, 21 May 2022 00:12:53 +0300 Message-Id: <20220520211254.47116-2-martin@martin.st> X-Mailer: git-send-email 2.32.0 (Apple Git-132) In-Reply-To: <20220520211254.47116-1-martin@martin.st> References: <20220520211254.47116-1-martin@martin.st> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/3] libavutil: Deprecate av_fopen_utf8, provide an avpriv version 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: CIlGYlKR/pxj Since every DLL can use an individual CRT on Windows, having an exported function that opens a FILE* won't work if that FILE* is going to be used from a different DLL (or from user application code). Internally within the libraries, the issue can be worked around by duplicating the function in all libraries (this already happened implicitly because the function resided in file_open.c) and renaming the function to ff_fopen_utf8 (so that it doesn't end up exported from the DLLs) and duplicating it in all libraries that use it. That mechanism doesn't work for external users, thus deprecate the existing function. --- doc/APIchanges | 3 +++ fftools/fopen_utf8.h | 2 +- libavfilter/Makefile | 1 + libavfilter/file_open.c | 1 + libavutil/avutil.h | 6 ++++++ libavutil/file_open.c | 9 ++++++++- libavutil/internal.h | 8 ++++++++ libavutil/version.h | 1 + tests/ref/fate/source | 1 + 9 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 libavfilter/file_open.c diff --git a/doc/APIchanges b/doc/APIchanges index 1a9f0a303e..c3a1649079 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -14,6 +14,9 @@ libavutil: 2021-04-27 API changes, most recent first: +2022-xx-xx - xxxxxxxxx - lavu 57.xx.xxx - avutil.h + Deprecate av_fopen_utf8() without replacement. + 2022-03-16 - xxxxxxxxxx - all libraries - version_major.h Add lib/version_major.h as new installed headers, which only contain the major version number (and corresponding API deprecation diff --git a/fftools/fopen_utf8.h b/fftools/fopen_utf8.h index db57fcaec4..cd18fe8ce1 100644 --- a/fftools/fopen_utf8.h +++ b/fftools/fopen_utf8.h @@ -21,7 +21,7 @@ #include -/* The fopen_utf8 function here is essentially equivalent to av_fopen_utf8, +/* The fopen_utf8 function here is essentially equivalent to avpriv_fopen_utf8, * except that it doesn't set O_CLOEXEC, and that it isn't exported * from a different library. (On Windows, each DLL might use a different * CRT, and FILE* handles can't be shared across them.) */ diff --git a/libavfilter/Makefile b/libavfilter/Makefile index ee2ea51e69..78ccfa37d3 100644 --- a/libavfilter/Makefile +++ b/libavfilter/Makefile @@ -23,6 +23,7 @@ OBJS = allfilters.o \ version.o \ video.o \ +OBJS-$(HAVE_LIBC_MSVCRT) += file_open.o OBJS-$(HAVE_THREADS) += pthread.o # subsystems diff --git a/libavfilter/file_open.c b/libavfilter/file_open.c new file mode 100644 index 0000000000..494a5d37a4 --- /dev/null +++ b/libavfilter/file_open.c @@ -0,0 +1 @@ +#include "libavutil/file_open.c" diff --git a/libavutil/avutil.h b/libavutil/avutil.h index 4d633156d1..64b68bdbd3 100644 --- a/libavutil/avutil.h +++ b/libavutil/avutil.h @@ -331,12 +331,18 @@ unsigned av_int_list_length_for_size(unsigned elsize, #define av_int_list_length(list, term) \ av_int_list_length_for_size(sizeof(*(list)), list, term) +#if FF_API_AV_FOPEN_UTF8 /** * Open a file using a UTF-8 filename. * The API of this function matches POSIX fopen(), errors are returned through * errno. + * @deprecated Avoid using it, as on Windows, the FILE* allocated by this + * function may be allocated with a different CRT than the caller + * who uses the FILE*. No replacement provided in public API. */ +attribute_deprecated FILE *av_fopen_utf8(const char *path, const char *mode); +#endif /** * Return the fractional representation of the internal time base. diff --git a/libavutil/file_open.c b/libavutil/file_open.c index cc302f2f76..fb64c2e4ee 100644 --- a/libavutil/file_open.c +++ b/libavutil/file_open.c @@ -155,7 +155,7 @@ int avpriv_tempfile(const char *prefix, char **filename, int log_offset, void *l return fd; /* success */ } -FILE *av_fopen_utf8(const char *path, const char *mode) +FILE *avpriv_fopen_utf8(const char *path, const char *mode) { int fd; int access; @@ -188,3 +188,10 @@ FILE *av_fopen_utf8(const char *path, const char *mode) return NULL; return fdopen(fd, mode); } + +#if FF_API_AV_FOPEN_UTF8 +FILE *av_fopen_utf8(const char *path, const char *mode) +{ + return avpriv_fopen_utf8(path, mode); +} +#endif diff --git a/libavutil/internal.h b/libavutil/internal.h index 79c2130be0..b44cbaaa7b 100644 --- a/libavutil/internal.h +++ b/libavutil/internal.h @@ -37,6 +37,7 @@ #include #include #include +#include #include "config.h" #include "attributes.h" #include "timer.h" @@ -183,8 +184,10 @@ void avpriv_request_sample(void *avc, #pragma comment(linker, "/include:" EXTERN_PREFIX "avpriv_snprintf") #endif +#define avpriv_fopen_utf8 ff_fopen_utf8 #define avpriv_open ff_open #define avpriv_tempfile ff_tempfile + #define PTRDIFF_SPECIFIER "Id" #define SIZE_SPECIFIER "Iu" #else @@ -256,6 +259,11 @@ static av_always_inline av_const int64_t ff_rint64_clip(double a, int64_t amin, av_warn_unused_result int avpriv_open(const char *filename, int flags, ...); +/** + * Open a file using a UTF-8 filename. + */ +FILE *avpriv_fopen_utf8(const char *path, const char *mode); + /** * Wrapper to work around the lack of mkstemp() on mingw. * Also, tries to create file in /tmp first, if possible. diff --git a/libavutil/version.h b/libavutil/version.h index 6735c20090..8532051c00 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -113,6 +113,7 @@ #define FF_API_FIFO_OLD_API (LIBAVUTIL_VERSION_MAJOR < 58) #define FF_API_XVMC (LIBAVUTIL_VERSION_MAJOR < 58) #define FF_API_OLD_CHANNEL_LAYOUT (LIBAVUTIL_VERSION_MAJOR < 58) +#define FF_API_AV_FOPEN_UTF8 (LIBAVUTIL_VERSION_MAJOR < 58) /** * @} diff --git a/tests/ref/fate/source b/tests/ref/fate/source index 69dcdc4f27..16ea7ef9c1 100644 --- a/tests/ref/fate/source +++ b/tests/ref/fate/source @@ -8,6 +8,7 @@ libavcodec/reverse.c libavdevice/file_open.c libavdevice/reverse.c libavfilter/af_arnndn.c +libavfilter/file_open.c libavfilter/log2_tab.c libavformat/file_open.c libavformat/golomb_tab.c From patchwork Fri May 20 21:12:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Martin_Storsj=C3=B6?= X-Patchwork-Id: 35858 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a17:906:4548:b0:6fe:2728:7bda with SMTP id s8csp1436493ejq; Fri, 20 May 2022 14:13:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwUyixWNSiilsJ0208W9IscrTUYEc7lTvGV/wbbCNT2sk7Ll1fd2w2e4k0u6mM7uCZKAB7V X-Received: by 2002:a05:6402:6d0:b0:42a:9597:9e4a with SMTP id n16-20020a05640206d000b0042a95979e4amr12566876edy.147.1653081209709; Fri, 20 May 2022 14:13:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653081209; cv=none; d=google.com; s=arc-20160816; b=iRKwq91cf+miYyO93v1mBWEfTAYaf/SAVORJyzF4osTEciXY9AWSbbmNDbsD5zEudP gzJfBzPlhLA5vfacS0gz8ZvPHw65PpMpiKcymX75o4XZvgl/AVOfz02Ft07jngf/m91k zS6Yee7Ql24zbDffKyVAS2pg+Cd6mglKKyY53fsFLRzLjj9xJ7/Th9cKanB91vgh+TG/ zzVSX4CQkxpG1U0MGNtsLB3xEDUcXUieW56RF2A6xZbUxaybcIbuUJ7S8bg4mQ9JLYsI v7C9+6vPnTlpFWTdAxA5Zba97meTvYQhRUOMDk4BsMUMpPbFB8cApIrpevyebrGKO4hf 0gRw== 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:dkim-signature:delivered-to; bh=OHurGlEATusc7bGxrz/LAhI0St7kywTxFyefQ7DIsNc=; b=v0VJIQSVAqjr4Uwd/Kci4REpNJrbAqYHmmHZxSz6OT4CKYcv7aZUZEyF1zIcSDz2mf g7D5S7MdRz7zMJoPz+UFMAxC3eLqqNZNBz20LH/xAuPMQtXGsPhVtnWggTTD3TK29lsF /w7iI1LV+FPD1IGYsWTEZHMTVGQVV9b2jo9nsLw3czVYCbVHNNIwWncxq/G/yiAxuMCM iO2XyuCjE1WHvjw4RgvjdAWLLKDTcCkbVN8JFs28YaueIrJ8hZwGjJ1xxfZn7nlqHGKY 2l2MI+C7I/nzDZZ7xGC+2e463JqTSvowO587Kvmt5NlgE1DasVwFXYS6Ii9o4J7rZ8lr hl0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@martin-st.20210112.gappssmtp.com header.s=20210112 header.b=y10mSOo9; 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 bc12-20020a056402204c00b0042aa68f763asi8577066edb.595.2022.05.20.14.13.24; Fri, 20 May 2022 14:13:29 -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; dkim=neutral (body hash did not verify) header.i=@martin-st.20210112.gappssmtp.com header.s=20210112 header.b=y10mSOo9; 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 6909568B4BF; Sat, 21 May 2022 00:13:06 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id AFF4568AF9F for ; Sat, 21 May 2022 00:12:59 +0300 (EEST) Received: by mail-wm1-f54.google.com with SMTP id p189so5150527wmp.3 for ; Fri, 20 May 2022 14:12:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=martin-st.20210112.gappssmtp.com; s=20210112; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=inOeI2Vhzrj2wXDQoXJjSGnxkwFt0t1xZgBufqo0XSs=; b=y10mSOo9pUCS6+HJv94W1r+Mu6TfAEhNK5T0KkSqTwO2BxvpjLuJhCUZJmbYcHk1ge 0wAyF8A8e1XqyubO268Ms8IjqC7QbkawMK5ysQYNuAXptiKMrLjkiRwxDfctSYm4DLCZ 2h6Wyr9xCrs3KtqKVvQDlapT73u1Zxgz60X11yvSXsbEkeRgyms7zhgXW8rk/6Nqjy4Y 3mZFg5guGfFpgMjeZUV5OrRNsKA4QU2jeAnSzp8W3tmy5T+dop3ivzCnf0jg8Npfu3VN 3NfLYPB0cAy+H6ZJDMXtorq+KRMeI6mHp+T/JRD/NT7Ikae+K3wWLJcUZGavN84xgqQF 8dJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=inOeI2Vhzrj2wXDQoXJjSGnxkwFt0t1xZgBufqo0XSs=; b=0nHHEyXXHS729vZRp5WK2Ll4CqRxqgCu2eltzz3TCqOcwVaH9GuU+EY2kNh2GOdOn+ UxMvBsRxhobDVOTzW4z/wTbyNz0zNNfIKZCPkbjrMWCOP0QI6L5DDShdt+Or1Z9j1wZ9 0dc6escw7cPuC/hOS1EIJoDOGIlTzt6EMebT4stJaM5p+6frIAGLTSE1dQZv7iBCqqB+ 966HqJzGMBDUCQ94x/m5RfRhnNVPRb/1+3i9EheWY+go0Hm1INcs8/inY9xr0OyfQbZp X2wgHWvaP9bjEZEh6CLmlYqVM1yugFbY8iNdq6vJ2mQIZ+a2777IZY0HwXKiaR4cLG7N S6cg== X-Gm-Message-State: AOAM532wHgnLpsa+JugowSlbHiqkaOl5KKJIayPP65CQ/65hMLikOmNz d1x1nisGNiPNFlc00UomG1DXgW0zVm1uw/HE X-Received: by 2002:a05:600c:2055:b0:397:2b06:57c7 with SMTP id p21-20020a05600c205500b003972b0657c7mr10378960wmg.97.1653081179127; Fri, 20 May 2022 14:12:59 -0700 (PDT) Received: from localhost (host-97-187.parnet.fi. [77.234.97.187]) by smtp.gmail.com with ESMTPSA id h3-20020adfa4c3000000b0020e609dd274sm3359707wrb.76.2022.05.20.14.12.58 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 20 May 2022 14:12:58 -0700 (PDT) From: =?utf-8?q?Martin_Storsj=C3=B6?= To: ffmpeg-devel@ffmpeg.org Date: Sat, 21 May 2022 00:12:54 +0300 Message-Id: <20220520211254.47116-3-martin@martin.st> X-Mailer: git-send-email 2.32.0 (Apple Git-132) In-Reply-To: <20220520211254.47116-1-martin@martin.st> References: <20220520211254.47116-1-martin@martin.st> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/3] Switch uses of av_fopen_utf8 to avpriv_fopen_utf8 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: av7+DlLq/60w --- libavfilter/af_arnndn.c | 2 +- libavfilter/opencl.c | 2 +- libavfilter/vf_curves.c | 2 +- libavfilter/vf_dnn_classify.c | 2 +- libavfilter/vf_dnn_detect.c | 2 +- libavfilter/vf_fieldhint.c | 2 +- libavfilter/vf_lut3d.c | 4 ++-- libavfilter/vf_nnedi.c | 2 +- libavfilter/vf_paletteuse.c | 2 +- libavformat/ipfsgateway.c | 2 +- 10 files changed, 11 insertions(+), 11 deletions(-) diff --git a/libavfilter/af_arnndn.c b/libavfilter/af_arnndn.c index fe562e81a1..5e3403ca6a 100644 --- a/libavfilter/af_arnndn.c +++ b/libavfilter/af_arnndn.c @@ -1478,7 +1478,7 @@ static int open_model(AVFilterContext *ctx, RNNModel **model) if (!s->model_name) return AVERROR(EINVAL); - f = av_fopen_utf8(s->model_name, "r"); + f = avpriv_fopen_utf8(s->model_name, "r"); if (!f) { av_log(ctx, AV_LOG_ERROR, "Failed to open model file: %s\n", s->model_name); return AVERROR(EINVAL); diff --git a/libavfilter/opencl.c b/libavfilter/opencl.c index 70d5edb78c..c8e7e6e1a5 100644 --- a/libavfilter/opencl.c +++ b/libavfilter/opencl.c @@ -210,7 +210,7 @@ int ff_opencl_filter_load_program_from_file(AVFilterContext *avctx, const char *src_const; int err; - file = av_fopen_utf8(filename, "r"); + file = avpriv_fopen_utf8(filename, "r"); if (!file) { av_log(avctx, AV_LOG_ERROR, "Unable to open program " "source file \"%s\".\n", filename); diff --git a/libavfilter/vf_curves.c b/libavfilter/vf_curves.c index 22a1f8aa70..82e2753f01 100644 --- a/libavfilter/vf_curves.c +++ b/libavfilter/vf_curves.c @@ -416,7 +416,7 @@ static int dump_curves(const char *fname, uint16_t *graph[NB_COMP + 1], AVBPrint buf; const double scale = 1. / (lut_size - 1); static const char * const colors[] = { "red", "green", "blue", "#404040", }; - FILE *f = av_fopen_utf8(fname, "w"); + FILE *f = avpriv_fopen_utf8(fname, "w"); av_assert0(FF_ARRAY_ELEMS(colors) == NB_COMP + 1); diff --git a/libavfilter/vf_dnn_classify.c b/libavfilter/vf_dnn_classify.c index c612ba8e80..852f5ddcee 100644 --- a/libavfilter/vf_dnn_classify.c +++ b/libavfilter/vf_dnn_classify.c @@ -131,7 +131,7 @@ static int read_classify_label_file(AVFilterContext *context) FILE *file; DnnClassifyContext *ctx = context->priv; - file = av_fopen_utf8(ctx->labels_filename, "r"); + file = avpriv_fopen_utf8(ctx->labels_filename, "r"); if (!file){ av_log(context, AV_LOG_ERROR, "failed to open file %s\n", ctx->labels_filename); return AVERROR(EINVAL); diff --git a/libavfilter/vf_dnn_detect.c b/libavfilter/vf_dnn_detect.c index dd4507250f..68bd2cd0c3 100644 --- a/libavfilter/vf_dnn_detect.c +++ b/libavfilter/vf_dnn_detect.c @@ -244,7 +244,7 @@ static int read_detect_label_file(AVFilterContext *context) FILE *file; DnnDetectContext *ctx = context->priv; - file = av_fopen_utf8(ctx->labels_filename, "r"); + file = avpriv_fopen_utf8(ctx->labels_filename, "r"); if (!file){ av_log(context, AV_LOG_ERROR, "failed to open file %s\n", ctx->labels_filename); return AVERROR(EINVAL); diff --git a/libavfilter/vf_fieldhint.c b/libavfilter/vf_fieldhint.c index e7afac1116..e6061c6d3c 100644 --- a/libavfilter/vf_fieldhint.c +++ b/libavfilter/vf_fieldhint.c @@ -73,7 +73,7 @@ static av_cold int init(AVFilterContext *ctx) av_log(ctx, AV_LOG_ERROR, "Hint file must be set.\n"); return AVERROR(EINVAL); } - s->hint = av_fopen_utf8(s->hint_file_str, "r"); + s->hint = avpriv_fopen_utf8(s->hint_file_str, "r"); if (!s->hint) { ret = AVERROR(errno); av_log(ctx, AV_LOG_ERROR, "%s: %s\n", s->hint_file_str, av_err2str(ret)); diff --git a/libavfilter/vf_lut3d.c b/libavfilter/vf_lut3d.c index a5190b6688..c7ecb7018e 100644 --- a/libavfilter/vf_lut3d.c +++ b/libavfilter/vf_lut3d.c @@ -1243,7 +1243,7 @@ static av_cold int lut3d_init(AVFilterContext *ctx) return set_identity_matrix(ctx, 32); } - f = av_fopen_utf8(lut3d->file, "r"); + f = avpriv_fopen_utf8(lut3d->file, "r"); if (!f) { ret = AVERROR(errno); av_log(ctx, AV_LOG_ERROR, "%s: %s\n", lut3d->file, av_err2str(ret)); @@ -2134,7 +2134,7 @@ static av_cold int lut1d_init(AVFilterContext *ctx) return 0; } - f = av_fopen_utf8(lut1d->file, "r"); + f = avpriv_fopen_utf8(lut1d->file, "r"); if (!f) { ret = AVERROR(errno); av_log(ctx, AV_LOG_ERROR, "%s: %s\n", lut1d->file, av_err2str(ret)); diff --git a/libavfilter/vf_nnedi.c b/libavfilter/vf_nnedi.c index 370f643678..e5a16918bd 100644 --- a/libavfilter/vf_nnedi.c +++ b/libavfilter/vf_nnedi.c @@ -957,7 +957,7 @@ static av_cold int init(AVFilterContext *ctx) size_t bytes_read; int ret = 0; - weights_file = av_fopen_utf8(s->weights_file, "rb"); + weights_file = avpriv_fopen_utf8(s->weights_file, "rb"); if (!weights_file) { av_log(ctx, AV_LOG_ERROR, "No weights file provided, aborting!\n"); return AVERROR(EINVAL); diff --git a/libavfilter/vf_paletteuse.c b/libavfilter/vf_paletteuse.c index e57882a64c..5c491a290c 100644 --- a/libavfilter/vf_paletteuse.c +++ b/libavfilter/vf_paletteuse.c @@ -538,7 +538,7 @@ static void disp_node(AVBPrint *buf, static int disp_tree(const struct color_node *node, const char *fname) { AVBPrint buf; - FILE *f = av_fopen_utf8(fname, "w"); + FILE *f = avpriv_fopen_utf8(fname, "w"); if (!f) { int ret = AVERROR(errno); diff --git a/libavformat/ipfsgateway.c b/libavformat/ipfsgateway.c index 9b0d3dea59..83d52293b4 100644 --- a/libavformat/ipfsgateway.c +++ b/libavformat/ipfsgateway.c @@ -139,7 +139,7 @@ static int populate_ipfs_gateway(URLContext *h) } // Get the contents of the gateway file. - gateway_file = av_fopen_utf8(ipfs_gateway_file, "r"); + gateway_file = avpriv_fopen_utf8(ipfs_gateway_file, "r"); if (!gateway_file) { av_log(h, AV_LOG_WARNING, "The IPFS gateway file (full uri: %s) doesn't exist. "