From patchwork Tue Jun 2 14:15:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaxun Yang X-Patchwork-Id: 20070 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 443B644A526 for ; Tue, 2 Jun 2020 17:16:45 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2D8EF68AA33; Tue, 2 Jun 2020 17:16:45 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from sender2-op-o12.zoho.com.cn (sender2-op-o12.zoho.com.cn [163.53.93.243]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D9D31680180 for ; Tue, 2 Jun 2020 17:16:37 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; t=1591107388; cv=none; d=zoho.com.cn; s=zohoarc; b=aTCNjIcitvvfvz7TLihTKs7eimtsJEM0O+6HLFU647H9/Eqxp/XHH8gijSOyq2xyeeK5NbE1+9s9xwZ2/O+bn/zwqHMFCKT72bYXeogLrn5jUtcNWl4+51bwfdTAX4YWAsd4Xr8DbfEUOiGUqJfiLI4JDFpW+RdJVHqE0cI1+e8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com.cn; s=zohoarc; t=1591107388; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=776ABoDI53Smb3q6iebMTjxBWz7lUS6GqHbxsewqaNc=; b=Ki6VMaV7aIzLVAlZWs5+jFJR6IyRoagNEZ3H+jOGDajk8KLa9rDrHf3mSGI1crc2M1Oagp6kqVToiy88Eeuc1Rd9islfeMmM4DwfUpNnYScltUlSt5Giy40SNZVUXDlPDM8AVl0LAMUZb1gwPEbsbb31vfEUb/QOw0uzlx8t+vw= ARC-Authentication-Results: i=1; mx.zoho.com.cn; dkim=pass header.i=flygoat.com; spf=pass smtp.mailfrom=jiaxun.yang@flygoat.com; dmarc=pass header.from= header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1591107388; s=mail; d=flygoat.com; i=jiaxun.yang@flygoat.com; h=From:To:Cc:Message-ID:Subject:Date:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Content-Type; bh=776ABoDI53Smb3q6iebMTjxBWz7lUS6GqHbxsewqaNc=; b=JO3iV2NeLOpX8w5ZaNqzI+N8qgpvaQ5c0AdP7e76MaCgeHtFjQRAOuIlzuTQ9cFb 4E/BiTBMraD2tMRnLPuZoGFznNb8s9upTyYaZfjfh0hGrHb4jPpjEbtdQ4M+qi8CvOq AoozIdeS7ZzvTS3JvmB9CDGlBdIQBAhLLlkHmEpU= Received: from halation.net.flygoat.com (60.177.188.90 [60.177.188.90]) by mx.zoho.com.cn with SMTPS id 1591107386205496.07892354021305; Tue, 2 Jun 2020 22:16:26 +0800 (CST) From: Jiaxun Yang To: ffmpeg-devel@ffmpeg.org Message-ID: <20200602141507.11151-2-jiaxun.yang@flygoat.com> Date: Tue, 2 Jun 2020 22:15:04 +0800 X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200602141507.11151-1-jiaxun.yang@flygoat.com> References: <20200602141507.11151-1-jiaxun.yang@flygoat.com> MIME-Version: 1.0 X-ZohoCNMailClient: External Subject: [FFmpeg-devel] [PATCH v2 1/4] ffbuild: Refine MIPS handling X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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: yinshiyou@loongson.cn, Jiaxun Yang Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" To enable runtime detection for MIPS, we need to refine ffbuild part to support buildding these feature together. Firstly, we fixed configure, let it probe native ability of toolchain to decide wether a feature can to be enabled, also clearly marked the conflictions between loongson2 & loongson3 and Release 6 & rest. Secondly, we compile MMI and MSA C sources with their own flags to ensure their flags won't pollute the whole program and generate illegal code. Signed-off-by: Jiaxun Yang --- configure | 179 +++++++++++++++++++++++---------------- ffbuild/common.mak | 10 ++- libavcodec/mips/Makefile | 3 +- 3 files changed, 117 insertions(+), 75 deletions(-) diff --git a/configure b/configure index f97cad0298..8dc3874642 100755 --- a/configure +++ b/configure @@ -1113,6 +1113,26 @@ void foo(void){ __asm__ volatile($code); } EOF } +check_extra_inline_asm_flags(){ + log check_extra_inline_asm_flags "$@" + name="$1" + extra=$2 + code="$3" + flags='' + shift 3 + while [ "$1" != "" ]; do + append flags $1 + shift + done; + disable $name + cat > $TMPC < X-Patchwork-Id: 20072 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id D575E44A526 for ; Tue, 2 Jun 2020 17:16:48 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id BDC6568AE72; Tue, 2 Jun 2020 17:16:48 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from sender2-op-o12.zoho.com.cn (sender2-op-o12.zoho.com.cn [163.53.93.243]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 73707680180 for ; Tue, 2 Jun 2020 17:16:39 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; t=1591107389; cv=none; d=zoho.com.cn; s=zohoarc; b=TSSry6QKnBo0e5thD0qglWFs997JHTbEGjx+falUP8TXp+2QY7fqJSn+QYuVUaUa8DcOWqNCoNhv3npa0++/CIbR46IePcPLAGoLDG5LD5mF3NRdd8E/LRX/axfzeBXcYhJrnNfjSWsZbpbWSLYbKsJNwLvWs6DXJ6L1IOUgXZI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com.cn; s=zohoarc; t=1591107389; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=emtOShO4X8s8ULQwg7s/0hORuQ0gOt8x0UC0xKdB3iE=; b=VNoZJ8B7jfdBwgSzWlP+y/VI5vPxrxGrbJyLxMf7x566RUiw50CErzehabYeTWtxDEw9DYET9ueF1RAXVjDU5BXnKvY4S5RPT5iRqq2FXDqzuOSxIebneT4Y5LolTmaKp5dVPqVHwzJ/NPdyElt9Hw54knYofPyK4/AiKNHSGC8= ARC-Authentication-Results: i=1; mx.zoho.com.cn; dkim=pass header.i=flygoat.com; spf=pass smtp.mailfrom=jiaxun.yang@flygoat.com; dmarc=pass header.from= header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1591107389; s=mail; d=flygoat.com; i=jiaxun.yang@flygoat.com; h=From:To:Cc:Message-ID:Subject:Date:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Content-Type; bh=emtOShO4X8s8ULQwg7s/0hORuQ0gOt8x0UC0xKdB3iE=; b=eXybcNDtPlfl4yn4Kka2fY9uehctSWylT80Cm2HaNpAHeUhBvcBP1ilMcdPiGvhG TYo43MP7TXqBmvCfxem3CkZtjVJ4xFMLHaNYXaHPBfmp9H2zNfjJFcLdXKdZ7pr657h 738ABvtsZ0N8J8UUPsEoc3PhEzMYAK5sXduEL1ZQ= Received: from halation.net.flygoat.com (60.177.188.90 [60.177.188.90]) by mx.zoho.com.cn with SMTPS id 159110738683110.073454320114479; Tue, 2 Jun 2020 22:16:26 +0800 (CST) From: Jiaxun Yang To: ffmpeg-devel@ffmpeg.org Message-ID: <20200602141507.11151-3-jiaxun.yang@flygoat.com> Date: Tue, 2 Jun 2020 22:15:05 +0800 X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200602141507.11151-1-jiaxun.yang@flygoat.com> References: <20200602141507.11151-1-jiaxun.yang@flygoat.com> MIME-Version: 1.0 X-ZohoCNMailClient: External Subject: [FFmpeg-devel] [PATCH v2 2/4] libavutils: Add parse_r helper for MIPS X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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: yinshiyou@loongson.cn, Jiaxun Yang Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" That helper grab from kernel code can allow us to inline newer instructions (not implemented by the assembler) in a elegant manner. Signed-off-by: Jiaxun Yang --- libavutil/mips/asmdefs.h | 42 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/libavutil/mips/asmdefs.h b/libavutil/mips/asmdefs.h index 748119918a..7e0e4cf575 100644 --- a/libavutil/mips/asmdefs.h +++ b/libavutil/mips/asmdefs.h @@ -55,4 +55,46 @@ # define PTR_SLL "sll " #endif +/* + * parse_r var, r - Helper assembler macro for parsing register names. + * + * This converts the register name in $n form provided in \r to the + * corresponding register number, which is assigned to the variable \var. It is + * needed to allow explicit encoding of instructions in inline assembly where + * registers are chosen by the compiler in $n form, allowing us to avoid using + * fixed register numbers. + * + * It also allows newer instructions (not implemented by the assembler) to be + * transparently implemented using assembler macros, instead of needing separate + * cases depending on toolchain support. + * + * Simple usage example: + * __asm__ __volatile__("parse_r __rt, %0\n\t" + * ".insn\n\t" + * "# di %0\n\t" + * ".word (0x41606000 | (__rt << 16))" + * : "=r" (status); + */ + +/* Match an individual register number and assign to \var */ +#define _IFC_REG(n) \ + ".ifc \\r, $" #n "\n\t" \ + "\\var = " #n "\n\t" \ + ".endif\n\t" + +__asm__(".macro parse_r var r\n\t" + "\\var = -1\n\t" + _IFC_REG(0) _IFC_REG(1) _IFC_REG(2) _IFC_REG(3) + _IFC_REG(4) _IFC_REG(5) _IFC_REG(6) _IFC_REG(7) + _IFC_REG(8) _IFC_REG(9) _IFC_REG(10) _IFC_REG(11) + _IFC_REG(12) _IFC_REG(13) _IFC_REG(14) _IFC_REG(15) + _IFC_REG(16) _IFC_REG(17) _IFC_REG(18) _IFC_REG(19) + _IFC_REG(20) _IFC_REG(21) _IFC_REG(22) _IFC_REG(23) + _IFC_REG(24) _IFC_REG(25) _IFC_REG(26) _IFC_REG(27) + _IFC_REG(28) _IFC_REG(29) _IFC_REG(30) _IFC_REG(31) + ".iflt \\var\n\t" + ".error \"Unable to parse register name \\r\"\n\t" + ".endif\n\t" + ".endm"); + #endif /* AVCODEC_MIPS_ASMDEFS_H */ From patchwork Tue Jun 2 14:15:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaxun Yang X-Patchwork-Id: 20073 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id CBC3244A526 for ; Tue, 2 Jun 2020 17:16:49 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B945068AED6; Tue, 2 Jun 2020 17:16:49 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from sender2-op-o12.zoho.com.cn (sender2-op-o12.zoho.com.cn [163.53.93.243]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 27F1868AE2D for ; Tue, 2 Jun 2020 17:16:40 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; t=1591107388; cv=none; d=zoho.com.cn; s=zohoarc; b=CD+GPX6aLE6BhSjp0sHmBVWlL3gLH0gcXvuUGNvIs7AGmG849eGGnci0xUcqE7zo+fGxkvF+2+lbTN5/U/cfGx6t9CC7eUBmMWrYaHWwUJ/8zsOk4g1l1uYK0lw2lO/jaeMPSYMTfOemIRu3JFLU9EHlXMyFQZb9C66OLTI6JW4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com.cn; s=zohoarc; t=1591107388; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=w9TyaFPr+W4bKN8v6weq3r+u3S+TDmEJLPq6J0gLq34=; b=lcg3m7z+nZ354dViS6b7TodtWRV2aghPFii7ILB367AEsOAfLUJMtM/SwtuF40zIf51uhPi+477IFLVECpvhFZbEnUeQ7Z3FO7pojrGqKoQRv9ycHnoj03aX+cVlioqqg8HmwZcnUoBtK/CjyWfFjhCoQBwQ0Ich+EJXTC7XmJE= ARC-Authentication-Results: i=1; mx.zoho.com.cn; dkim=pass header.i=flygoat.com; spf=pass smtp.mailfrom=jiaxun.yang@flygoat.com; dmarc=pass header.from= header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1591107388; s=mail; d=flygoat.com; i=jiaxun.yang@flygoat.com; h=From:To:Cc:Message-ID:Subject:Date:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Content-Type; bh=w9TyaFPr+W4bKN8v6weq3r+u3S+TDmEJLPq6J0gLq34=; b=PBsyuOVdCXYolEi+asJ0pJUNp3zDBVPjrLzOayIi+3Bhsz4cqDqn/ZH3PJ8Qocjk VryZif7zMlWJ2hDbkiLhWiW6OGPK3X/O5lPpbeyZhjP26WdsXDaCj7X/W40OB+qJW5P eJP2E4HkbDaUjefKd6MKYsyR8e4u6VKx17c3X6mU= Received: from halation.net.flygoat.com (60.177.188.90 [60.177.188.90]) by mx.zoho.com.cn with SMTPS id 1591107387215520.7218005735937; Tue, 2 Jun 2020 22:16:27 +0800 (CST) From: Jiaxun Yang To: ffmpeg-devel@ffmpeg.org Message-ID: <20200602141507.11151-4-jiaxun.yang@flygoat.com> Date: Tue, 2 Jun 2020 22:15:06 +0800 X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200602141507.11151-1-jiaxun.yang@flygoat.com> References: <20200602141507.11151-1-jiaxun.yang@flygoat.com> MIME-Version: 1.0 X-ZohoCNMailClient: External Subject: [FFmpeg-devel] [PATCH v2 3/4] libavutil: Detect MMI and MSA flags for MIPS X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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: yinshiyou@loongson.cn, Jiaxun Yang Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Add MMI & MSA runtime detection for MIPS. Basically there are two code pathes. For systems that natively support CPUCFG instruction or kernel emulated that instruction, we'll sense this feature from HWCAP and report the flags according to values grab from CPUCFG. For systems that have no CPUCFG (or not export it in HWCAP), we'll parse /proc/cpuinfo instead. Signed-off-by: Jiaxun Yang --- v2: Implement CPUCFG code path as CPUCFG emulation and HWCAP have accepted by Linux Kernel upstream. --- libavutil/cpu.c | 10 +++ libavutil/cpu.h | 3 + libavutil/cpu_internal.h | 2 + libavutil/mips/Makefile | 2 +- libavutil/mips/cpu.c | 134 ++++++++++++++++++++++++++++++++++++++ libavutil/mips/cpu.h | 28 ++++++++ libavutil/tests/cpu.c | 3 + tests/checkasm/checkasm.c | 3 + 8 files changed, 184 insertions(+), 1 deletion(-) create mode 100644 libavutil/mips/cpu.c create mode 100644 libavutil/mips/cpu.h diff --git a/libavutil/cpu.c b/libavutil/cpu.c index 6548cc3042..52f6b9a3bf 100644 --- a/libavutil/cpu.c +++ b/libavutil/cpu.c @@ -51,6 +51,8 @@ static atomic_int cpu_flags = ATOMIC_VAR_INIT(-1); static int get_cpu_flags(void) { + if (ARCH_MIPS) + return ff_get_cpu_flags_mips(); if (ARCH_AARCH64) return ff_get_cpu_flags_aarch64(); if (ARCH_ARM) @@ -169,6 +171,9 @@ int av_parse_cpu_flags(const char *s) { "armv8", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_ARMV8 }, .unit = "flags" }, { "neon", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_NEON }, .unit = "flags" }, { "vfp", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_VFP }, .unit = "flags" }, +#elif ARCH_MIPS + { "mmi", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_MMI }, .unit = "flags" }, + { "msa", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_MSA }, .unit = "flags" }, #endif { NULL }, }; @@ -250,6 +255,9 @@ int av_parse_cpu_caps(unsigned *flags, const char *s) { "armv8", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_ARMV8 }, .unit = "flags" }, { "neon", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_NEON }, .unit = "flags" }, { "vfp", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_VFP }, .unit = "flags" }, +#elif ARCH_MIPS + { "mmi", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_MMI }, .unit = "flags" }, + { "msa", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_MSA }, .unit = "flags" }, #endif { NULL }, }; @@ -308,6 +316,8 @@ int av_cpu_count(void) size_t av_cpu_max_align(void) { + if (ARCH_MIPS) + return ff_get_cpu_max_align_mips(); if (ARCH_AARCH64) return ff_get_cpu_max_align_aarch64(); if (ARCH_ARM) diff --git a/libavutil/cpu.h b/libavutil/cpu.h index 8bb9eb606b..83099dd969 100644 --- a/libavutil/cpu.h +++ b/libavutil/cpu.h @@ -71,6 +71,9 @@ #define AV_CPU_FLAG_VFP_VM (1 << 7) ///< VFPv2 vector mode, deprecated in ARMv7-A and unavailable in various CPUs implementations #define AV_CPU_FLAG_SETEND (1 <<16) +#define AV_CPU_FLAG_MMI (1 << 0) +#define AV_CPU_FLAG_MSA (1 << 1) + /** * Return the flags which specify extensions supported by the CPU. * The returned value is affected by av_force_cpu_flags() if that was used diff --git a/libavutil/cpu_internal.h b/libavutil/cpu_internal.h index 37122d1c5f..889764320b 100644 --- a/libavutil/cpu_internal.h +++ b/libavutil/cpu_internal.h @@ -41,11 +41,13 @@ #define CPUEXT_FAST(flags, cpuext) CPUEXT_SUFFIX_FAST(flags, , cpuext) #define CPUEXT_SLOW(flags, cpuext) CPUEXT_SUFFIX_SLOW(flags, , cpuext) +int ff_get_cpu_flags_mips(void); int ff_get_cpu_flags_aarch64(void); int ff_get_cpu_flags_arm(void); int ff_get_cpu_flags_ppc(void); int ff_get_cpu_flags_x86(void); +size_t ff_get_cpu_max_align_mips(void); size_t ff_get_cpu_max_align_aarch64(void); size_t ff_get_cpu_max_align_arm(void); size_t ff_get_cpu_max_align_ppc(void); diff --git a/libavutil/mips/Makefile b/libavutil/mips/Makefile index dbfa5aa341..5f8c9b64e9 100644 --- a/libavutil/mips/Makefile +++ b/libavutil/mips/Makefile @@ -1 +1 @@ -OBJS += mips/float_dsp_mips.o +OBJS += mips/float_dsp_mips.o mips/cpu.o diff --git a/libavutil/mips/cpu.c b/libavutil/mips/cpu.c new file mode 100644 index 0000000000..e9e291a45a --- /dev/null +++ b/libavutil/mips/cpu.c @@ -0,0 +1,134 @@ +/* + * 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 + */ + +#include "libavutil/cpu.h" +#include "libavutil/cpu_internal.h" +#include "config.h" +#if defined __linux__ || defined __ANDROID__ +#include +#include +#include +#include +#include "asmdefs.h" +#include "libavutil/avstring.h" +#endif + +#if defined __linux__ || defined __ANDROID__ + +#define HWCAP_LOONGSON_CPUCFG (1 << 14) + +static int cpucfg_available(void) +{ + return getauxval(AT_HWCAP) & HWCAP_LOONGSON_CPUCFG; +} + +/* Most toolchains have no CPUCFG support yet */ +static uint32_t read_cpucfg(uint32_t reg) +{ + uint32_t __res; + + __asm__ __volatile__( + "parse_r __res,%0\n\t" + "parse_r reg,%1\n\t" + ".insn \n\t" + ".word (0xc8080118 | (reg << 21) | (__res << 11))\n\t" + :"=r"(__res) + :"r"(reg) + : + ); + return __res; +} + +#define LOONGSON_CFG1 0x1 + +#define LOONGSON_CFG1_MMI (1 << 4) +#define LOONGSON_CFG1_MSA1 (1 << 5) + +static int cpu_flags_cpucfg(void) +{ + int flags = 0; + uint32_t cfg1 = read_cpucfg(LOONGSON_CFG1); + + if (cfg1 & LOONGSON_CFG1_MMI) + flags |= AV_CPU_FLAG_MMI; + + if (cfg1 & LOONGSON_CFG1_MMI) + flags |= AV_CPU_FLAG_MSA; + + return flags; +} + +static int cpu_flags_cpuinfo(void) +{ + FILE *f = fopen("/proc/cpuinfo", "r"); + char buf[200]; + int flags = 0; + + if (!f) + return -1; + + while (fgets(buf, sizeof(buf), f)) { + /* Legacy kernel may not export MMI in ASEs implemented */ + if (av_strstart(buf, "cpu model", NULL)) { + if (strstr(buf, "Loongson-3 ")) + flags |= AV_CPU_FLAG_MMI; + } + + if (av_strstart(buf, "ASEs implemented", NULL)) { + if (strstr(buf, " loongson-mmi")) + flags |= AV_CPU_FLAG_MMI; + if (strstr(buf, " msa")) + flags |= AV_CPU_FLAG_MSA; + + break; + } + } + fclose(f); + return flags; +} +#endif + +int ff_get_cpu_flags_mips(void) +{ +#if defined __linux__ || defined __ANDROID__ + if (cpucfg_available()) + return cpu_flags_cpucfg(); + else + return cpu_flags_cpuinfo(); +#else + /* Assume no SIMD ASE supported */ + return 0; +#endif +} + +size_t ff_get_cpu_max_align_mips(void) +{ + int flags = av_get_cpu_flags(); + + if (flags & AV_CPU_FLAG_MSA) + return 16; + + /* + * MMI itself is 64-bit but quad word load & store + * needs 128-bit align. + */ + if (flags & AV_CPU_FLAG_MMI) + return 16; + + return 8; +} diff --git a/libavutil/mips/cpu.h b/libavutil/mips/cpu.h new file mode 100644 index 0000000000..615dc49759 --- /dev/null +++ b/libavutil/mips/cpu.h @@ -0,0 +1,28 @@ +/* + * 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 AVUTIL_MIPS_CPU_H +#define AVUTIL_MIPS_CPU_H + +#include "libavutil/cpu.h" +#include "libavutil/cpu_internal.h" + +#define have_mmi(flags) CPUEXT(flags, MMI) +#define have_msa(flags) CPUEXT(flags, MSA) + +#endif /* AVUTIL_MIPS_CPU_H */ diff --git a/libavutil/tests/cpu.c b/libavutil/tests/cpu.c index ce45b715a0..c853371fb3 100644 --- a/libavutil/tests/cpu.c +++ b/libavutil/tests/cpu.c @@ -49,6 +49,9 @@ static const struct { { AV_CPU_FLAG_SETEND, "setend" }, #elif ARCH_PPC { AV_CPU_FLAG_ALTIVEC, "altivec" }, +#elif ARCH_MIPS + { AV_CPU_FLAG_MMI, "mmi" }, + { AV_CPU_FLAG_MSA, "msa" }, #elif ARCH_X86 { AV_CPU_FLAG_MMX, "mmx" }, { AV_CPU_FLAG_MMXEXT, "mmxext" }, diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c index 899f68bb32..b3ac76c325 100644 --- a/tests/checkasm/checkasm.c +++ b/tests/checkasm/checkasm.c @@ -213,6 +213,9 @@ static const struct { { "ALTIVEC", "altivec", AV_CPU_FLAG_ALTIVEC }, { "VSX", "vsx", AV_CPU_FLAG_VSX }, { "POWER8", "power8", AV_CPU_FLAG_POWER8 }, +#elif ARCH_MIPS + { "MMI", "mmi", AV_CPU_FLAG_MMI }, + { "MSA", "msa", AV_CPU_FLAG_MSA }, #elif ARCH_X86 { "MMX", "mmx", AV_CPU_FLAG_MMX|AV_CPU_FLAG_CMOV }, { "MMXEXT", "mmxext", AV_CPU_FLAG_MMXEXT }, From patchwork Tue Jun 2 14:15:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaxun Yang X-Patchwork-Id: 20071 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 1DFFE44A526 for ; Tue, 2 Jun 2020 17:16:46 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 0CF8E68AD33; Tue, 2 Jun 2020 17:16:46 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from sender2-op-o12.zoho.com.cn (sender2-op-o12.zoho.com.cn [163.53.93.243]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B732B68805B for ; Tue, 2 Jun 2020 17:16:38 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; t=1591107389; cv=none; d=zoho.com.cn; s=zohoarc; b=ScUrCR5wejiqYISpPzXRWAiCYEqP+RdnsUdzblBA24F3tTSEI7xBRHEPvJtmtkkXzGLZF5M4EFf999QBGIAWkKscEhaOOWbnk1QKztpphYYR8dHK+WUNXgx09KrPCUqq+IPFUh87iWrbuqZB5XxIZX4YDfAsS4rybR4bVV7q1zM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com.cn; s=zohoarc; t=1591107389; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=RfI5Ha/O6IPf/Z37z+qRYQASDfPbEo7vsUfJmWCa5DY=; b=pR2FyypkJJZBR3g/woTietVx7A5FpWl8LyBpBYlLZyTE3fnCHq3l8c6IX1+0kIBZp39Hjdou5pdiGrk3FjQvNamspv72gLTLvAdWjJD9TfMMGO4hD7B6/3OPi7L74EDEPrVGxkgdPZE5FIsvlhegox1C9jEjZuS6bUiswjAfAOY= ARC-Authentication-Results: i=1; mx.zoho.com.cn; dkim=pass header.i=flygoat.com; spf=pass smtp.mailfrom=jiaxun.yang@flygoat.com; dmarc=pass header.from= header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1591107389; s=mail; d=flygoat.com; i=jiaxun.yang@flygoat.com; h=From:To:Cc:Message-ID:Subject:Date:In-Reply-To:References:MIME-Version:Content-Transfer-Encoding:Content-Type; bh=RfI5Ha/O6IPf/Z37z+qRYQASDfPbEo7vsUfJmWCa5DY=; b=Dc00doEWJGDamKgaEmOpHd3RCsI7RQhAEAlTZUkmhqh54xbECRAVbadeETeBeZgJ Zpck85cmc8XzCwfYAfMuypwO8Ti6GvY04P0JVxhbW8LPiJyYYJ37mIL4WqBdWFktPWG EmjhRDrehKxpHb06QgcxUMb4htMfMZ6pvcEeGZaQ= Received: from halation.net.flygoat.com (60.177.188.90 [60.177.188.90]) by mx.zoho.com.cn with SMTPS id 1591107387661348.8481079570878; Tue, 2 Jun 2020 22:16:27 +0800 (CST) From: Jiaxun Yang To: ffmpeg-devel@ffmpeg.org Message-ID: <20200602141507.11151-5-jiaxun.yang@flygoat.com> Date: Tue, 2 Jun 2020 22:15:07 +0800 X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200602141507.11151-1-jiaxun.yang@flygoat.com> References: <20200602141507.11151-1-jiaxun.yang@flygoat.com> MIME-Version: 1.0 X-ZohoCNMailClient: External Subject: [FFmpeg-devel] [PATCH v2 4/4] libavcodec: Enable runtime detection for MIPS MMI & MSA X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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: yinshiyou@loongson.cn, Jiaxun Yang Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Apply optimized functions according to cpuflags. MSA is always put after MMI as it's usually faster than MMI. Signed-off-by: Jiaxun Yang --- libavcodec/mips/blockdsp_init_mips.c | 22 +++++++++++++----- libavcodec/mips/cabac.h | 2 +- libavcodec/mips/h263dsp_init_mips.c | 12 +++++++--- libavcodec/mips/h264chroma_init_mips.c | 22 +++++++++++++----- libavcodec/mips/h264dsp_init_mips.c | 25 ++++++++++++++++----- libavcodec/mips/h264pred_init_mips.c | 25 ++++++++++++++++----- libavcodec/mips/h264qpel_init_mips.c | 22 +++++++++++++----- libavcodec/mips/hevcdsp_init_mips.c | 24 +++++++++++++++----- libavcodec/mips/hevcpred_init_mips.c | 12 +++++++--- libavcodec/mips/hpeldsp_init_mips.c | 22 +++++++++++++----- libavcodec/mips/idctdsp_init_mips.c | 24 +++++++++++++++----- libavcodec/mips/me_cmp_init_mips.c | 12 +++++++--- libavcodec/mips/mpegvideo_init_mips.c | 22 +++++++++++++----- libavcodec/mips/mpegvideoencdsp_init_mips.c | 13 ++++++++--- libavcodec/mips/pixblockdsp_init_mips.c | 25 ++++++++++++++++----- libavcodec/mips/qpeldsp_init_mips.c | 12 +++++++--- libavcodec/mips/vc1dsp_init_mips.c | 22 +++++++++++++----- libavcodec/mips/videodsp_init.c | 12 +++++++--- libavcodec/mips/vp3dsp_init_mips.c | 22 +++++++++++++----- libavcodec/mips/vp8dsp_init_mips.c | 22 +++++++++++++----- libavcodec/mips/vp9dsp_init_mips.c | 22 +++++++++++++----- libavcodec/mips/wmv2dsp_init_mips.c | 12 +++++++--- libavcodec/mips/xvididct_init_mips.c | 13 ++++++++--- 23 files changed, 312 insertions(+), 109 deletions(-) diff --git a/libavcodec/mips/blockdsp_init_mips.c b/libavcodec/mips/blockdsp_init_mips.c index 55ac1c3e99..47170c17ef 100644 --- a/libavcodec/mips/blockdsp_init_mips.c +++ b/libavcodec/mips/blockdsp_init_mips.c @@ -19,6 +19,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "libavutil/mips/cpu.h" #include "blockdsp_mips.h" #if HAVE_MSA @@ -30,6 +31,10 @@ static av_cold void blockdsp_init_msa(BlockDSPContext *c) c->fill_block_tab[0] = ff_fill_block16_msa; c->fill_block_tab[1] = ff_fill_block8_msa; } +#else +static av_cold void blockdsp_init_msa(BlockDSPContext *c) +{ +} #endif // #if HAVE_MSA #if HAVE_MMI @@ -41,14 +46,19 @@ static av_cold void blockdsp_init_mmi(BlockDSPContext *c) c->fill_block_tab[0] = ff_fill_block16_mmi; c->fill_block_tab[1] = ff_fill_block8_mmi; } +#else +static av_cold void blockdsp_init_mmi(BlockDSPContext *c) +{ +} #endif /* HAVE_MMI */ void ff_blockdsp_init_mips(BlockDSPContext *c) { -#if HAVE_MMI - blockdsp_init_mmi(c); -#endif /* HAVE_MMI */ -#if HAVE_MSA - blockdsp_init_msa(c); -#endif // #if HAVE_MSA + int cpu_flags = av_get_cpu_flags(); + + if (have_mmi(cpu_flags)) + blockdsp_init_mmi(c); + + if (have_msa(cpu_flags)) + blockdsp_init_msa(c); } diff --git a/libavcodec/mips/cabac.h b/libavcodec/mips/cabac.h index 03b5010edc..c595915eda 100644 --- a/libavcodec/mips/cabac.h +++ b/libavcodec/mips/cabac.h @@ -25,7 +25,7 @@ #define AVCODEC_MIPS_CABAC_H #include "libavcodec/cabac.h" -#include "libavutil/mips/mmiutils.h" +#include "libavutil/mips/asmdefs.h" #include "config.h" #define get_cabac_inline get_cabac_inline_mips diff --git a/libavcodec/mips/h263dsp_init_mips.c b/libavcodec/mips/h263dsp_init_mips.c index 09bd93707d..b88b76368b 100644 --- a/libavcodec/mips/h263dsp_init_mips.c +++ b/libavcodec/mips/h263dsp_init_mips.c @@ -18,6 +18,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "libavutil/mips/cpu.h" #include "h263dsp_mips.h" #if HAVE_MSA @@ -26,11 +27,16 @@ static av_cold void h263dsp_init_msa(H263DSPContext *c) c->h263_h_loop_filter = ff_h263_h_loop_filter_msa; c->h263_v_loop_filter = ff_h263_v_loop_filter_msa; } +#else +static av_cold void h263dsp_init_msa(H263DSPContext *c) +{ +} #endif // #if HAVE_MSA av_cold void ff_h263dsp_init_mips(H263DSPContext *c) { -#if HAVE_MSA - h263dsp_init_msa(c); -#endif // #if HAVE_MSA + int cpu_flags = av_get_cpu_flags(); + + if (have_msa(cpu_flags)) + h263dsp_init_msa(c); } diff --git a/libavcodec/mips/h264chroma_init_mips.c b/libavcodec/mips/h264chroma_init_mips.c index ae817e47ae..84d335da59 100644 --- a/libavcodec/mips/h264chroma_init_mips.c +++ b/libavcodec/mips/h264chroma_init_mips.c @@ -19,6 +19,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "libavutil/mips/cpu.h" #include "h264chroma_mips.h" #if HAVE_MSA @@ -36,6 +37,10 @@ static av_cold void h264chroma_init_msa(H264ChromaContext *c, int bit_depth) c->avg_h264_chroma_pixels_tab[2] = ff_avg_h264_chroma_mc2_msa; } } +#else +static av_cold void h264chroma_init_msa(H264ChromaContext *c, int bit_depth) +{ +} #endif // #if HAVE_MSA #if HAVE_MMI @@ -50,14 +55,19 @@ static av_cold void h264chroma_init_mmi(H264ChromaContext *c, int bit_depth) c->avg_h264_chroma_pixels_tab[1] = ff_avg_h264_chroma_mc4_mmi; } } +#else +static av_cold void h264chroma_init_mmi(H264ChromaContext *c, int bit_depth) +{ +} #endif /* HAVE_MMI */ av_cold void ff_h264chroma_init_mips(H264ChromaContext *c, int bit_depth) { -#if HAVE_MMI - h264chroma_init_mmi(c, bit_depth); -#endif /* HAVE_MMI */ -#if HAVE_MSA - h264chroma_init_msa(c, bit_depth); -#endif // #if HAVE_MSA + int cpu_flags = av_get_cpu_flags(); + + if (have_mmi(cpu_flags)) + h264chroma_init_mmi(c, bit_depth); + + if (have_msa(cpu_flags)) + h264chroma_init_msa(c, bit_depth); } diff --git a/libavcodec/mips/h264dsp_init_mips.c b/libavcodec/mips/h264dsp_init_mips.c index dc08a25800..7b89cfc393 100644 --- a/libavcodec/mips/h264dsp_init_mips.c +++ b/libavcodec/mips/h264dsp_init_mips.c @@ -19,6 +19,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "libavutil/mips/cpu.h" #include "h264dsp_mips.h" #if HAVE_MSA @@ -79,6 +80,12 @@ static av_cold void h264dsp_init_msa(H264DSPContext *c, c->h264_luma_dc_dequant_idct = ff_h264_deq_idct_luma_dc_msa; } // if (8 == bit_depth) } +#else +static av_cold void h264dsp_init_msa(H264DSPContext *c, + const int bit_depth, + const int chroma_format_idc) +{ +} #endif // #if HAVE_MSA #if HAVE_MMI @@ -133,15 +140,21 @@ static av_cold void h264dsp_init_mmi(H264DSPContext * c, const int bit_depth, c->h264_h_loop_filter_luma_intra = ff_deblock_h_luma_intra_8_mmi; } } +#else +static av_cold void h264dsp_init_mmi(H264DSPContext * c, const int bit_depth, + const int chroma_format_idc) +{ +} #endif /* HAVE_MMI */ av_cold void ff_h264dsp_init_mips(H264DSPContext *c, const int bit_depth, const int chroma_format_idc) { -#if HAVE_MMI - h264dsp_init_mmi(c, bit_depth, chroma_format_idc); -#endif /* HAVE_MMI */ -#if HAVE_MSA - h264dsp_init_msa(c, bit_depth, chroma_format_idc); -#endif // #if HAVE_MSA + int cpu_flags = av_get_cpu_flags(); + + if (have_mmi(cpu_flags)) + h264dsp_init_mmi(c, bit_depth, chroma_format_idc); + + if (have_msa(cpu_flags)) + h264dsp_init_msa(c, bit_depth, chroma_format_idc); } diff --git a/libavcodec/mips/h264pred_init_mips.c b/libavcodec/mips/h264pred_init_mips.c index e537ad8bd4..633d157b50 100644 --- a/libavcodec/mips/h264pred_init_mips.c +++ b/libavcodec/mips/h264pred_init_mips.c @@ -19,6 +19,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "libavutil/mips/cpu.h" #include "config.h" #include "h264dsp_mips.h" #include "h264pred_mips.h" @@ -91,6 +92,12 @@ static av_cold void h264_pred_init_msa(H264PredContext *h, int codec_id, h->pred16x16[DC_128_PRED8x8] = ff_h264_intra_pred_dc_128_16x16_msa; } } +#else +static av_cold void h264_pred_init_msa(H264PredContext *h, int codec_id, + const int bit_depth, + const int chroma_format_idc) +{ +} #endif // #if HAVE_MSA #if HAVE_MMI @@ -137,16 +144,22 @@ static av_cold void h264_pred_init_mmi(H264PredContext *h, int codec_id, } } } +#else +static av_cold void h264_pred_init_mmi(H264PredContext *h, int codec_id, + const int bit_depth, const int chroma_format_idc) +{ +} #endif /* HAVE_MMI */ av_cold void ff_h264_pred_init_mips(H264PredContext *h, int codec_id, int bit_depth, const int chroma_format_idc) { -#if HAVE_MMI - h264_pred_init_mmi(h, codec_id, bit_depth, chroma_format_idc); -#endif /* HAVE_MMI */ -#if HAVE_MSA - h264_pred_init_msa(h, codec_id, bit_depth, chroma_format_idc); -#endif // #if HAVE_MSA + int cpu_flags = av_get_cpu_flags(); + + if (have_mmi(cpu_flags)) + h264_pred_init_mmi(h, codec_id, bit_depth, chroma_format_idc); + + if (have_msa(cpu_flags)) + h264_pred_init_msa(h, codec_id, bit_depth, chroma_format_idc); } diff --git a/libavcodec/mips/h264qpel_init_mips.c b/libavcodec/mips/h264qpel_init_mips.c index 33bae3093a..c1d584b14b 100644 --- a/libavcodec/mips/h264qpel_init_mips.c +++ b/libavcodec/mips/h264qpel_init_mips.c @@ -19,6 +19,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "libavutil/mips/cpu.h" #include "h264dsp_mips.h" #if HAVE_MSA @@ -127,6 +128,10 @@ static av_cold void h264qpel_init_msa(H264QpelContext *c, int bit_depth) c->avg_h264_qpel_pixels_tab[2][15] = ff_avg_h264_qpel4_mc33_msa; } } +#else +static av_cold void h264qpel_init_msa(H264QpelContext *c, int bit_depth) +{ +} #endif // #if HAVE_MSA #if HAVE_MMI @@ -236,14 +241,19 @@ static av_cold void h264qpel_init_mmi(H264QpelContext *c, int bit_depth) c->avg_h264_qpel_pixels_tab[2][15] = ff_avg_h264_qpel4_mc33_mmi; } } +#else +static av_cold void h264qpel_init_mmi(H264QpelContext *c, int bit_depth) +{ +} #endif /* HAVE_MMI */ av_cold void ff_h264qpel_init_mips(H264QpelContext *c, int bit_depth) { -#if HAVE_MMI - h264qpel_init_mmi(c, bit_depth); -#endif /* HAVE_MMI */ -#if HAVE_MSA - h264qpel_init_msa(c, bit_depth); -#endif // #if HAVE_MSA + int cpu_flags = av_get_cpu_flags(); + + if (have_mmi(cpu_flags)) + h264qpel_init_mmi(c, bit_depth); + + if (have_msa(cpu_flags)) + h264qpel_init_msa(c, bit_depth); } diff --git a/libavcodec/mips/hevcdsp_init_mips.c b/libavcodec/mips/hevcdsp_init_mips.c index 88337f462e..246d71b74e 100644 --- a/libavcodec/mips/hevcdsp_init_mips.c +++ b/libavcodec/mips/hevcdsp_init_mips.c @@ -18,6 +18,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "libavutil/mips/cpu.h" #include "libavcodec/mips/hevcdsp_mips.h" #if HAVE_MMI @@ -90,6 +91,11 @@ static av_cold void hevc_dsp_init_mmi(HEVCDSPContext *c, c->put_hevc_qpel_uni[9][1][1] = ff_hevc_put_hevc_qpel_uni_hv64_8_mmi; } } +#else +static av_cold void hevc_dsp_init_mmi(HEVCDSPContext *c, + const int bit_depth) +{ +} #endif // #if HAVE_MMI #if HAVE_MSA @@ -516,14 +522,20 @@ static av_cold void hevc_dsp_init_msa(HEVCDSPContext *c, c->transform_4x4_luma = ff_hevc_idct_luma_4x4_msa; } } +#else +static av_cold void hevc_dsp_init_msa(HEVCDSPContext *c, + const int bit_depth) +{ +} #endif // #if HAVE_MSA void ff_hevc_dsp_init_mips(HEVCDSPContext *c, const int bit_depth) { -#if HAVE_MMI - hevc_dsp_init_mmi(c, bit_depth); -#endif // #if HAVE_MMI -#if HAVE_MSA - hevc_dsp_init_msa(c, bit_depth); -#endif // #if HAVE_MSA + int cpu_flags = av_get_cpu_flags(); + + if (have_mmi(cpu_flags)) + hevc_dsp_init_mmi(c, bit_depth); + + if (have_msa(cpu_flags)) + hevc_dsp_init_msa(c, bit_depth); } diff --git a/libavcodec/mips/hevcpred_init_mips.c b/libavcodec/mips/hevcpred_init_mips.c index e987698d66..f829561ddf 100644 --- a/libavcodec/mips/hevcpred_init_mips.c +++ b/libavcodec/mips/hevcpred_init_mips.c @@ -18,6 +18,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "libavutil/mips/cpu.h" #include "config.h" #include "libavutil/attributes.h" #include "libavcodec/mips/hevcpred_mips.h" @@ -39,11 +40,16 @@ static av_cold void hevc_pred_init_msa(HEVCPredContext *c, const int bit_depth) c->pred_angular[3] = ff_pred_intra_pred_angular_3_msa; } } +#else +static av_cold void hevc_pred_init_msa(HEVCPredContext *c, const int bit_depth) +{ +} #endif // #if HAVE_MSA void ff_hevc_pred_init_mips(HEVCPredContext *c, const int bit_depth) { -#if HAVE_MSA - hevc_pred_init_msa(c, bit_depth); -#endif // #if HAVE_MSA + int cpu_flags = av_get_cpu_flags(); + + if (have_msa(cpu_flags)) + hevc_pred_init_msa(c, bit_depth); } diff --git a/libavcodec/mips/hpeldsp_init_mips.c b/libavcodec/mips/hpeldsp_init_mips.c index d6f7a9793d..9e12bde547 100644 --- a/libavcodec/mips/hpeldsp_init_mips.c +++ b/libavcodec/mips/hpeldsp_init_mips.c @@ -19,6 +19,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "libavutil/mips/cpu.h" #include "../hpeldsp.h" #include "libavcodec/mips/hpeldsp_mips.h" @@ -64,6 +65,10 @@ static void ff_hpeldsp_init_msa(HpelDSPContext *c, int flags) c->avg_pixels_tab[2][2] = ff_avg_pixels4_y2_msa; c->avg_pixels_tab[2][3] = ff_avg_pixels4_xy2_msa; } +#else +static void ff_hpeldsp_init_msa(HpelDSPContext *c, int flags) +{ +} #endif // #if HAVE_MSA #if HAVE_MMI @@ -109,14 +114,19 @@ static void ff_hpeldsp_init_mmi(HpelDSPContext *c, int flags) c->avg_pixels_tab[2][2] = ff_avg_pixels4_y2_8_mmi; c->avg_pixels_tab[2][3] = ff_avg_pixels4_xy2_8_mmi; } +#else +static void ff_hpeldsp_init_mmi(HpelDSPContext *c, int flags) +{ +} #endif // #if HAVE_MMI void ff_hpeldsp_init_mips(HpelDSPContext *c, int flags) { -#if HAVE_MMI - ff_hpeldsp_init_mmi(c, flags); -#endif // #if HAVE_MMI -#if HAVE_MSA - ff_hpeldsp_init_msa(c, flags); -#endif // #if HAVE_MSA + int cpu_flags = av_get_cpu_flags(); + + if (have_mmi(cpu_flags)) + ff_hpeldsp_init_mmi(c, flags); + + if (have_msa(cpu_flags)) + ff_hpeldsp_init_msa(c, flags); } diff --git a/libavcodec/mips/idctdsp_init_mips.c b/libavcodec/mips/idctdsp_init_mips.c index 85b76ca478..a1a5ad5449 100644 --- a/libavcodec/mips/idctdsp_init_mips.c +++ b/libavcodec/mips/idctdsp_init_mips.c @@ -19,6 +19,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "libavutil/mips/cpu.h" #include "idctdsp_mips.h" #include "xvididct_mips.h" @@ -40,6 +41,11 @@ static av_cold void idctdsp_init_msa(IDCTDSPContext *c, AVCodecContext *avctx, c->put_signed_pixels_clamped = ff_put_signed_pixels_clamped_msa; c->add_pixels_clamped = ff_add_pixels_clamped_msa; } +#else +static av_cold void idctdsp_init_msa(IDCTDSPContext *c, AVCodecContext *avctx, + unsigned high_bit_depth) +{ +} #endif // #if HAVE_MSA #if HAVE_MMI @@ -60,15 +66,21 @@ static av_cold void idctdsp_init_mmi(IDCTDSPContext *c, AVCodecContext *avctx, c->add_pixels_clamped = ff_add_pixels_clamped_mmi; c->put_signed_pixels_clamped = ff_put_signed_pixels_clamped_mmi; } +#else +static av_cold void idctdsp_init_mmi(IDCTDSPContext *c, AVCodecContext *avctx, + unsigned high_bit_depth) +{ +} #endif /* HAVE_MMI */ av_cold void ff_idctdsp_init_mips(IDCTDSPContext *c, AVCodecContext *avctx, unsigned high_bit_depth) { -#if HAVE_MMI - idctdsp_init_mmi(c, avctx, high_bit_depth); -#endif /* HAVE_MMI */ -#if HAVE_MSA - idctdsp_init_msa(c, avctx, high_bit_depth); -#endif // #if HAVE_MSA + int cpu_flags = av_get_cpu_flags(); + + if (have_mmi(cpu_flags)) + idctdsp_init_mmi(c, avctx, high_bit_depth); + + if (have_msa(cpu_flags)) + idctdsp_init_msa(c, avctx, high_bit_depth); } diff --git a/libavcodec/mips/me_cmp_init_mips.c b/libavcodec/mips/me_cmp_init_mips.c index 219a0dc00c..3b5c01ecd4 100644 --- a/libavcodec/mips/me_cmp_init_mips.c +++ b/libavcodec/mips/me_cmp_init_mips.c @@ -18,6 +18,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "libavutil/mips/cpu.h" #include "me_cmp_mips.h" #if HAVE_MSA @@ -46,11 +47,16 @@ static av_cold void me_cmp_msa(MECmpContext *c, AVCodecContext *avctx) c->sse[2] = ff_sse4_msa; #endif } +#else +static av_cold void me_cmp_msa(MECmpContext *c, AVCodecContext *avctx) +{ +} #endif // #if HAVE_MSA av_cold void ff_me_cmp_init_mips(MECmpContext *c, AVCodecContext *avctx) { -#if HAVE_MSA - me_cmp_msa(c, avctx); -#endif // #if HAVE_MSA + int cpu_flags = av_get_cpu_flags(); + + if (have_msa(cpu_flags)) + me_cmp_msa(c, avctx); } diff --git a/libavcodec/mips/mpegvideo_init_mips.c b/libavcodec/mips/mpegvideo_init_mips.c index be77308140..cc6d4b1785 100644 --- a/libavcodec/mips/mpegvideo_init_mips.c +++ b/libavcodec/mips/mpegvideo_init_mips.c @@ -18,6 +18,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "libavutil/mips/cpu.h" #include "h263dsp_mips.h" #include "mpegvideo_mips.h" @@ -29,6 +30,10 @@ static av_cold void dct_unquantize_init_msa(MpegEncContext *s) if (!s->q_scale_type) s->dct_unquantize_mpeg2_inter = ff_dct_unquantize_mpeg2_inter_msa; } +#else +static av_cold void dct_unquantize_init_msa(MpegEncContext *s) +{ +} #endif // #if HAVE_MSA #if HAVE_MMI @@ -45,14 +50,19 @@ static av_cold void dct_unquantize_init_mmi(MpegEncContext *s) s->denoise_dct= ff_denoise_dct_mmi; } +#else +static av_cold void dct_unquantize_init_mmi(MpegEncContext *s) +{ +} #endif /* HAVE_MMI */ av_cold void ff_mpv_common_init_mips(MpegEncContext *s) { -#if HAVE_MMI - dct_unquantize_init_mmi(s); -#endif /* HAVE_MMI */ -#if HAVE_MSA - dct_unquantize_init_msa(s); -#endif // #if HAVE_MSA + int cpu_flags = av_get_cpu_flags(); + + if (have_mmi(cpu_flags)) + dct_unquantize_init_mmi(s); + + if (have_msa(cpu_flags)) + dct_unquantize_init_msa(s); } diff --git a/libavcodec/mips/mpegvideoencdsp_init_mips.c b/libavcodec/mips/mpegvideoencdsp_init_mips.c index 9bfe94e4cd..543f429aa4 100644 --- a/libavcodec/mips/mpegvideoencdsp_init_mips.c +++ b/libavcodec/mips/mpegvideoencdsp_init_mips.c @@ -18,6 +18,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "libavutil/mips/cpu.h" #include "libavcodec/bit_depth_template.c" #include "h263dsp_mips.h" @@ -29,12 +30,18 @@ static av_cold void mpegvideoencdsp_init_msa(MpegvideoEncDSPContext *c, c->pix_sum = ff_pix_sum_msa; #endif } +#else +static av_cold void mpegvideoencdsp_init_msa(MpegvideoEncDSPContext *c, + AVCodecContext *avctx) +{ +} #endif // #if HAVE_MSA av_cold void ff_mpegvideoencdsp_init_mips(MpegvideoEncDSPContext *c, AVCodecContext *avctx) { -#if HAVE_MSA - mpegvideoencdsp_init_msa(c, avctx); -#endif // #if HAVE_MSA + int cpu_flags = av_get_cpu_flags(); + + if (have_msa(cpu_flags)) + mpegvideoencdsp_init_msa(c, avctx); } diff --git a/libavcodec/mips/pixblockdsp_init_mips.c b/libavcodec/mips/pixblockdsp_init_mips.c index fd0238d79b..cf4f986ba7 100644 --- a/libavcodec/mips/pixblockdsp_init_mips.c +++ b/libavcodec/mips/pixblockdsp_init_mips.c @@ -19,6 +19,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "libavutil/mips/cpu.h" #include "pixblockdsp_mips.h" #if HAVE_MSA @@ -43,6 +44,12 @@ static av_cold void pixblockdsp_init_msa(PixblockDSPContext *c, break; } } +#else +static av_cold void pixblockdsp_init_msa(PixblockDSPContext *c, + AVCodecContext *avctx, + unsigned high_bit_depth) +{ +} #endif // #if HAVE_MSA #if HAVE_MMI @@ -55,15 +62,21 @@ static av_cold void pixblockdsp_init_mmi(PixblockDSPContext *c, c->get_pixels = ff_get_pixels_8_mmi; } } +#else +static av_cold void pixblockdsp_init_mmi(PixblockDSPContext *c, + AVCodecContext *avctx, unsigned high_bit_depth) +{ +} #endif /* HAVE_MMI */ void ff_pixblockdsp_init_mips(PixblockDSPContext *c, AVCodecContext *avctx, unsigned high_bit_depth) { -#if HAVE_MMI - pixblockdsp_init_mmi(c, avctx, high_bit_depth); -#endif /* HAVE_MMI */ -#if HAVE_MSA - pixblockdsp_init_msa(c, avctx, high_bit_depth); -#endif // #if HAVE_MSA + int cpu_flags = av_get_cpu_flags(); + + if (have_mmi(cpu_flags)) + pixblockdsp_init_mmi(c, avctx, high_bit_depth); + + if (have_msa(cpu_flags)) + pixblockdsp_init_msa(c, avctx, high_bit_depth); } diff --git a/libavcodec/mips/qpeldsp_init_mips.c b/libavcodec/mips/qpeldsp_init_mips.c index 140e8f89c9..2d136f5d6f 100644 --- a/libavcodec/mips/qpeldsp_init_mips.c +++ b/libavcodec/mips/qpeldsp_init_mips.c @@ -18,6 +18,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "libavutil/mips/cpu.h" #include "qpeldsp_mips.h" #if HAVE_MSA @@ -157,11 +158,16 @@ static av_cold void qpeldsp_init_msa(QpelDSPContext *c) c->avg_qpel_pixels_tab[1][14] = ff_hv_mc_qpel_avg_dst_aver_v_src1_8x8_msa; c->avg_qpel_pixels_tab[1][15] = ff_hv_mc_qpel_avg_dst_aver_hv_src11_8x8_msa; } +#else +static av_cold void qpeldsp_init_msa(QpelDSPContext *c) +{ +} #endif // #if HAVE_MSA void ff_qpeldsp_init_mips(QpelDSPContext *c) { -#if HAVE_MSA - qpeldsp_init_msa(c); -#endif // #if HAVE_MSA + int cpu_flags = av_get_cpu_flags(); + + if (have_msa(cpu_flags)) + qpeldsp_init_msa(c); } diff --git a/libavcodec/mips/vc1dsp_init_mips.c b/libavcodec/mips/vc1dsp_init_mips.c index c0007ff650..09840c6b83 100644 --- a/libavcodec/mips/vc1dsp_init_mips.c +++ b/libavcodec/mips/vc1dsp_init_mips.c @@ -18,6 +18,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "libavutil/mips/cpu.h" #include "libavutil/attributes.h" #include "libavcodec/vc1dsp.h" #include "vc1dsp_mips.h" @@ -98,6 +99,10 @@ static av_cold void vc1dsp_init_mmi(VC1DSPContext *dsp) dsp->put_no_rnd_vc1_chroma_pixels_tab[1] = ff_put_no_rnd_vc1_chroma_mc4_mmi; dsp->avg_no_rnd_vc1_chroma_pixels_tab[1] = ff_avg_no_rnd_vc1_chroma_mc4_mmi; } +#else +static av_cold void vc1dsp_init_mmi(VC1DSPContext *dsp) +{ +} #endif /* HAVE_MMI */ #if HAVE_MSA @@ -117,14 +122,19 @@ static av_cold void vc1dsp_init_msa(VC1DSPContext *dsp) FN_ASSIGN(put_, 3, 2, _msa); FN_ASSIGN(put_, 3, 3, _msa); } +#else +static av_cold void vc1dsp_init_msa(VC1DSPContext *dsp) +{ +} #endif /* HAVE_MSA */ av_cold void ff_vc1dsp_init_mips(VC1DSPContext *dsp) { -#if HAVE_MMI - vc1dsp_init_mmi(dsp); -#endif /* HAVE_MMI */ -#if HAVE_MSA - vc1dsp_init_msa(dsp); -#endif /* HAVE_MSA */ + int cpu_flags = av_get_cpu_flags(); + + if (have_mmi(cpu_flags)) + vc1dsp_init_mmi(dsp); + + if (have_msa(cpu_flags)) + vc1dsp_init_msa(dsp); } diff --git a/libavcodec/mips/videodsp_init.c b/libavcodec/mips/videodsp_init.c index 817040420b..9d64d88a48 100644 --- a/libavcodec/mips/videodsp_init.c +++ b/libavcodec/mips/videodsp_init.c @@ -18,6 +18,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "libavutil/mips/cpu.h" #include "config.h" #include "libavutil/attributes.h" #include "libavutil/mips/asmdefs.h" @@ -41,11 +42,16 @@ static void prefetch_mips(uint8_t *mem, ptrdiff_t stride, int h) : [stride] "r" (stride) ); } +#else +static void prefetch_mips(uint8_t *mem, ptrdiff_t stride, int h) +{ +} #endif // #if HAVE_MSA av_cold void ff_videodsp_init_mips(VideoDSPContext *ctx, int bpc) { -#if HAVE_MSA - ctx->prefetch = prefetch_mips; -#endif // #if HAVE_MSA + int cpu_flags = av_get_cpu_flags(); + + if (have_msa(cpu_flags)) + ctx->prefetch = prefetch_mips; } diff --git a/libavcodec/mips/vp3dsp_init_mips.c b/libavcodec/mips/vp3dsp_init_mips.c index e183db35b6..fcbd7e8332 100644 --- a/libavcodec/mips/vp3dsp_init_mips.c +++ b/libavcodec/mips/vp3dsp_init_mips.c @@ -19,6 +19,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "libavutil/mips/cpu.h" #include "config.h" #include "libavutil/attributes.h" #include "libavcodec/avcodec.h" @@ -36,6 +37,10 @@ static av_cold void vp3dsp_init_msa(VP3DSPContext *c, int flags) c->v_loop_filter = ff_vp3_v_loop_filter_msa; c->h_loop_filter = ff_vp3_h_loop_filter_msa; } +#else +static av_cold void vp3dsp_init_msa(VP3DSPContext *c, int flags) +{ +} #endif /* HAVE_MSA */ #if HAVE_MMI @@ -47,14 +52,19 @@ static av_cold void vp3dsp_init_mmi(VP3DSPContext *c, int flags) c->idct_put = ff_vp3_idct_put_mmi; c->idct_dc_add = ff_vp3_idct_dc_add_mmi; } +#else +static av_cold void vp3dsp_init_mmi(VP3DSPContext *c, int flags) +{ +} #endif /* HAVE_MMI */ av_cold void ff_vp3dsp_init_mips(VP3DSPContext *c, int flags) { -#if HAVE_MMI - vp3dsp_init_mmi(c, flags); -#endif /* HAVE_MMI */ -#if HAVE_MSA - vp3dsp_init_msa(c, flags); -#endif /* HAVE_MSA */ + int cpu_flags = av_get_cpu_flags(); + + if (have_mmi(cpu_flags)) + vp3dsp_init_mmi(c, flags); + + if (have_msa(cpu_flags)) + vp3dsp_init_msa(c, flags); } diff --git a/libavcodec/mips/vp8dsp_init_mips.c b/libavcodec/mips/vp8dsp_init_mips.c index 7fd8fb0d32..73f172b64f 100644 --- a/libavcodec/mips/vp8dsp_init_mips.c +++ b/libavcodec/mips/vp8dsp_init_mips.c @@ -24,6 +24,7 @@ * VP8 compatible video decoder */ +#include "libavutil/mips/cpu.h" #include "config.h" #include "libavutil/attributes.h" #include "libavcodec/vp8dsp.h" @@ -104,6 +105,10 @@ static av_cold void vp8dsp_init_msa(VP8DSPContext *dsp) dsp->vp8_v_loop_filter_simple = ff_vp8_v_loop_filter_simple_msa; dsp->vp8_h_loop_filter_simple = ff_vp8_h_loop_filter_simple_msa; } +#else +static av_cold void vp8dsp_init_msa(VP8DSPContext *dsp) +{ +} #endif // #if HAVE_MSA #if HAVE_MMI @@ -189,14 +194,19 @@ static av_cold void vp8dsp_init_mmi(VP8DSPContext *dsp) dsp->vp8_v_loop_filter_simple = ff_vp8_v_loop_filter_simple_mmi; dsp->vp8_h_loop_filter_simple = ff_vp8_h_loop_filter_simple_mmi; } +#else +static av_cold void vp8dsp_init_mmi(VP8DSPContext *dsp) +{ +} #endif /* HAVE_MMI */ av_cold void ff_vp8dsp_init_mips(VP8DSPContext *dsp) { -#if HAVE_MMI - vp8dsp_init_mmi(dsp); -#endif /* HAVE_MMI */ -#if HAVE_MSA - vp8dsp_init_msa(dsp); -#endif // #if HAVE_MSA + int cpu_flags = av_get_cpu_flags(); + + if (have_mmi(cpu_flags)) + vp8dsp_init_mmi(dsp); + + if (have_msa(cpu_flags)) + vp8dsp_init_msa(dsp); } diff --git a/libavcodec/mips/vp9dsp_init_mips.c b/libavcodec/mips/vp9dsp_init_mips.c index 5990fa6952..ddbbd9f838 100644 --- a/libavcodec/mips/vp9dsp_init_mips.c +++ b/libavcodec/mips/vp9dsp_init_mips.c @@ -18,6 +18,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "libavutil/mips/cpu.h" #include "config.h" #include "libavutil/common.h" #include "libavcodec/vp9dsp.h" @@ -166,6 +167,10 @@ static av_cold void vp9dsp_init_msa(VP9DSPContext *dsp, int bpp) vp9dsp_mc_init_msa(dsp, bpp); vp9dsp_loopfilter_init_msa(dsp, bpp); } +#else +static av_cold void vp9dsp_init_msa(VP9DSPContext *dsp, int bpp) +{ +} #endif // #if HAVE_MSA #if HAVE_MMI @@ -205,14 +210,19 @@ static av_cold void vp9dsp_init_mmi(VP9DSPContext *dsp, int bpp) vp9dsp_mc_init_mmi(dsp); } } +#else +static av_cold void vp9dsp_init_mmi(VP9DSPContext *dsp, int bpp) +{ +} #endif // #if HAVE_MMI av_cold void ff_vp9dsp_init_mips(VP9DSPContext *dsp, int bpp) { -#if HAVE_MMI - vp9dsp_init_mmi(dsp, bpp); -#endif // #if HAVE_MMI -#if HAVE_MSA - vp9dsp_init_msa(dsp, bpp); -#endif // #if HAVE_MSA + int cpu_flags = av_get_cpu_flags(); + + if (have_mmi(cpu_flags)) + vp9dsp_init_mmi(dsp, bpp); + + if (have_msa(cpu_flags)) + vp9dsp_init_msa(dsp, bpp); } diff --git a/libavcodec/mips/wmv2dsp_init_mips.c b/libavcodec/mips/wmv2dsp_init_mips.c index 51dd2078d9..9dc3aeb29a 100644 --- a/libavcodec/mips/wmv2dsp_init_mips.c +++ b/libavcodec/mips/wmv2dsp_init_mips.c @@ -18,6 +18,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "libavutil/mips/cpu.h" #include "config.h" #include "libavutil/attributes.h" #include "wmv2dsp_mips.h" @@ -28,11 +29,16 @@ static av_cold void wmv2dsp_init_mmi(WMV2DSPContext *c) c->idct_add = ff_wmv2_idct_add_mmi; c->idct_put = ff_wmv2_idct_put_mmi; } +#else +static av_cold void wmv2dsp_init_mmi(WMV2DSPContext *c) +{ +} #endif /* HAVE_MMI */ av_cold void ff_wmv2dsp_init_mips(WMV2DSPContext *c) { -#if HAVE_MMI - wmv2dsp_init_mmi(c); -#endif /* HAVE_MMI */ + int cpu_flags = av_get_cpu_flags(); + + if (have_mmi(cpu_flags)) + wmv2dsp_init_mmi(c); } diff --git a/libavcodec/mips/xvididct_init_mips.c b/libavcodec/mips/xvididct_init_mips.c index c1d82cc30c..9193cbb401 100644 --- a/libavcodec/mips/xvididct_init_mips.c +++ b/libavcodec/mips/xvididct_init_mips.c @@ -18,6 +18,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "libavutil/mips/cpu.h" #include "xvididct_mips.h" #if HAVE_MMI @@ -34,12 +35,18 @@ static av_cold void xvid_idct_init_mmi(IDCTDSPContext *c, AVCodecContext *avctx, } } } +#else +static av_cold void xvid_idct_init_mmi(IDCTDSPContext *c, AVCodecContext *avctx, + unsigned high_bit_depth) +{ +} #endif /* HAVE_MMI */ av_cold void ff_xvid_idct_init_mips(IDCTDSPContext *c, AVCodecContext *avctx, unsigned high_bit_depth) { -#if HAVE_MMI - xvid_idct_init_mmi(c, avctx, high_bit_depth); -#endif /* HAVE_MMI */ + int cpu_flags = av_get_cpu_flags(); + + if (have_mmi(cpu_flags)) + xvid_idct_init_mmi(c, avctx, high_bit_depth); }