From patchwork Mon Jun 8 03:30:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaxun Yang X-Patchwork-Id: 20195 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 A8EB644ADA2 for ; Mon, 8 Jun 2020 06:30:58 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 926D868B03C; Mon, 8 Jun 2020 06:30:58 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from relay4.mymailcheap.com (relay4.mymailcheap.com [137.74.80.154]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9C973689C71 for ; Mon, 8 Jun 2020 06:30:51 +0300 (EEST) Received: from filter1.mymailcheap.com (filter1.mymailcheap.com [149.56.130.247]) by relay4.mymailcheap.com (Postfix) with ESMTPS id 0B9153F1CF; Mon, 8 Jun 2020 05:30:51 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by filter1.mymailcheap.com (Postfix) with ESMTP id 23F032A39E; Sun, 7 Jun 2020 23:30:50 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mymailcheap.com; s=default; t=1591587050; bh=kpkPxDALa2wqAY43z40CrB63MQYO1nc6Esz2UwDKD44=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aaz9g7YJ4LrdUX/8fMDgKF2asISsShal4s+f8+ubi43EITyU71QuG4V/+MvKk+pcd yY/nNlpLLffYMCj9k8Ie/mWYxTUWvqfg+sJLwFlntv8RE/vIRl/WSNw1RuvLPYwAzM gTNdb/F+tVQbGFZ2FMzU3Mz4rnwvD33WWZLLFGyA= X-Virus-Scanned: Debian amavisd-new at filter1.mymailcheap.com Received: from filter1.mymailcheap.com ([127.0.0.1]) by localhost (filter1.mymailcheap.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id rjepQmlASBO4; Sun, 7 Jun 2020 23:30:47 -0400 (EDT) Received: from mail20.mymailcheap.com (mail20.mymailcheap.com [51.83.111.147]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by filter1.mymailcheap.com (Postfix) with ESMTPS; Sun, 7 Jun 2020 23:30:47 -0400 (EDT) Received: from [148.251.23.173] (ml.mymailcheap.com [148.251.23.173]) by mail20.mymailcheap.com (Postfix) with ESMTP id 773DD41DF2; Mon, 8 Jun 2020 03:30:45 +0000 (UTC) Authentication-Results: mail20.mymailcheap.com; dkim=pass (1024-bit key; unprotected) header.d=flygoat.com header.i=@flygoat.com header.b="mAiye9YO"; dkim-atps=neutral AI-Spam-Status: Not processed Received: from rush.localdomain (unknown [60.177.191.23]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail20.mymailcheap.com (Postfix) with ESMTPSA id 96C3C414D1; Mon, 8 Jun 2020 03:30:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=flygoat.com; s=default; t=1591587013; bh=kpkPxDALa2wqAY43z40CrB63MQYO1nc6Esz2UwDKD44=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mAiye9YOoojWq1cPj/K1fjwr8tyD3m7giTi/n95qO1TVTysVDYAzmji+JA6zX7RHT tY5tOSkdaKcdc61kyCGWOZcxMnGFkC+ygLbNlAdlqjOy8tHJdVEqpohPkXxDOCBmXm fff0j1iqWZQ829FL0JBwywHccx1VW+j5OufI7rGU= From: Jiaxun Yang To: ffmpeg-devel@ffmpeg.org Date: Mon, 8 Jun 2020 11:30:01 +0800 Message-Id: <20200608033004.2635-2-jiaxun.yang@flygoat.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200608033004.2635-1-jiaxun.yang@flygoat.com> References: <20200608033004.2635-1-jiaxun.yang@flygoat.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 773DD41DF2 X-Spamd-Result: default: False [4.90 / 10.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; R_DKIM_ALLOW(0.00)[flygoat.com:s=default]; RECEIVED_SPAMHAUS_PBL(0.00)[60.177.191.23:received]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; R_MISSING_CHARSET(2.50)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; BROKEN_CONTENT_TYPE(1.50)[]; TO_DN_SOME(0.00)[]; R_SPF_SOFTFAIL(0.00)[~all]; ML_SERVERS(-3.10)[148.251.23.173]; DKIM_TRACE(0.00)[flygoat.com:+]; DMARC_POLICY_ALLOW(0.00)[flygoat.com,none]; MID_CONTAINS_FROM(1.00)[]; DMARC_POLICY_ALLOW_WITH_FAILURES(0.00)[]; RCVD_NO_TLS_LAST(0.10)[]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:24940, ipnet:148.251.0.0/16, country:DE]; RCVD_COUNT_TWO(0.00)[2]; HFILTER_HELO_BAREIP(3.00)[148.251.23.173,1] X-Rspamd-Server: mail20.mymailcheap.com X-Spam: Yes Subject: [FFmpeg-devel] [PATCH v4 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 --- v3: Address Shiyou's review suggestions, Fix GCC version detection method. v4: Disable DSP* defaultly. --- configure | 183 +++++++++++++++++++++++---------------- ffbuild/common.mak | 10 ++- libavcodec/mips/Makefile | 3 +- 3 files changed, 120 insertions(+), 76 deletions(-) diff --git a/configure b/configure index f97cad0298..03516effe1 100755 --- a/configure +++ b/configure @@ -2542,7 +2542,7 @@ vsx_deps="altivec" power8_deps="vsx" loongson2_deps="mips" -loongson3_deps="mips" +loongson3_deps="mips64r2" mips32r2_deps="mips" mips32r5_deps="mips" mips32r6_deps="mips" @@ -2551,7 +2551,7 @@ mips64r6_deps="mips" mipsfpu_deps="mips" mipsdsp_deps="mips" mipsdspr2_deps="mips" -mmi_deps="mips" +mmi_deps_any="loongson2 loongson3" msa_deps="mipsfpu" msa2_deps="msa" @@ -4999,8 +4999,6 @@ elif enabled bfin; then elif enabled mips; then - cpuflags="-march=$cpu" - if [ "$cpu" != "generic" ]; then disable mips32r2 disable mips32r5 @@ -5009,19 +5007,63 @@ elif enabled mips; then disable mips64r6 disable loongson2 disable loongson3 + disable mipsdsp + disable mipsdspr2 + disable msa + disable mmi + + cpuflags="-march=$cpu" case $cpu in - 24kc|24kf*|24kec|34kc|1004kc|24kef*|34kf*|1004kf*|74kc|74kf) + # General ISA levels + mips1|mips3) + ;; + mips32r2) + enable msa enable mips32r2 - disable msa ;; - p5600|i6400|p6600) - disable mipsdsp - disable mipsdspr2 + mips32r5) + enable msa + enable mips32r2 + enable mips32r5 ;; - loongson*) - enable loongson2 + mips64r2|mips64r5) + enable msa + enable mmi + enable mips64r2 enable loongson3 + ;; + # Cores from MIPS(MTI) + 24kc) + disable mipsfpu + enable mips32r2 + ;; + 24kf*|24kec|34kc|74Kc|1004kc) + enable mips32r2 + ;; + 24kef*|34kf*|1004kf*) + enable mipsdsp + enable mips32r2 + ;; + p5600) + enable msa + enable mips32r2 + enable mips32r5 + check_cflags "-mtune=p5600" && check_cflags "-msched-weight -mload-store-pairs -funroll-loops" + ;; + i6400) + enable mips64r6 + check_cflags "-mtune=i6400 -mabi=64" && check_cflags "-msched-weight -mload-store-pairs -funroll-loops" && check_ldflags "-mabi=64" + ;; + p6600) + enable mips64r6 + check_cflags "-mtune=p6600 -mabi=64" && check_cflags "-msched-weight -mload-store-pairs -funroll-loops" && check_ldflags "-mabi=64" + ;; + # Cores from Loongson + loongson2e|loongson2f|loongson3*) + disable mipsdsp + disable mipsdspr2 + enable mmi enable local_aligned enable simd_align_16 enable fast_64bit @@ -5029,75 +5071,45 @@ elif enabled mips; then enable fast_cmov enable fast_unaligned disable aligned_stack - disable mipsdsp - disable mipsdspr2 # When gcc version less than 5.3.0, add -fno-expensive-optimizations flag. - if [ $cc == gcc ]; then - gcc_version=$(gcc -dumpversion) - if [ "$(echo "$gcc_version 5.3.0" | tr " " "\n" | sort -rV | head -n 1)" == "$gcc_version" ]; then - expensive_optimization_flag="" - else + if test "$cc_type" = "gcc"; then + case $gcc_basever in + 2|2.*|3.*|4.*|5.0|5.1|5.2) expensive_optimization_flag="-fno-expensive-optimizations" - fi + ;; + *) + expensive_optimization_flag="" + ;; + esac fi + case $cpu in loongson3*) + enable loongson3 + enable mips64r2 cpuflags="-march=loongson3a -mhard-float $expensive_optimization_flag" ;; loongson2e) + disable msa + enable loongson2 cpuflags="-march=loongson2e -mhard-float $expensive_optimization_flag" ;; loongson2f) + disable msa + enable loongson2 cpuflags="-march=loongson2f -mhard-float $expensive_optimization_flag" ;; esac ;; *) - # Unknown CPU. Disable everything. - warn "unknown CPU. Disabling all MIPS optimizations." - disable mipsfpu - disable mipsdsp - disable mipsdspr2 - disable msa - disable mmi + warn "unknown MIPS CPU" ;; esac - case $cpu in - 24kc) - disable mipsfpu - disable mipsdsp - disable mipsdspr2 - ;; - 24kf*) - disable mipsdsp - disable mipsdspr2 - ;; - 24kec|34kc|1004kc) - disable mipsfpu - disable mipsdspr2 - ;; - 24kef*|34kf*|1004kf*) - disable mipsdspr2 - ;; - 74kc) - disable mipsfpu - ;; - p5600) - enable mips32r5 - check_cflags "-mtune=p5600" && check_cflags "-msched-weight -mload-store-pairs -funroll-loops" - ;; - i6400) - enable mips64r6 - check_cflags "-mtune=i6400 -mabi=64" && check_cflags "-msched-weight -mload-store-pairs -funroll-loops" && check_ldflags "-mabi=64" - ;; - p6600) - enable mips64r6 - check_cflags "-mtune=p6600 -mabi=64" && check_cflags "-msched-weight -mload-store-pairs -funroll-loops" && check_ldflags "-mabi=64" - ;; - esac else - # We do not disable anything. Is up to the user to disable the unwanted features. + disable mipsdsp + disable mipsdspr2 + # Disable DSP stuff for generic CPU, it can't be detected at runtime. warn 'generic cpu selected' fi @@ -5844,28 +5856,49 @@ EOF elif enabled mips; then - enabled loongson2 && check_inline_asm loongson2 '"dmult.g $8, $9, $10"' - enabled loongson3 && check_inline_asm loongson3 '"gsldxc1 $f0, 0($2, $3)"' - enabled mmi && check_inline_asm mmi '"punpcklhw $f0, $f0, $f0"' - # Enable minimum ISA based on selected options + # Check toolchain ISA level if enabled mips64; then - enabled mips64r6 && check_inline_asm_flags mips64r6 '"dlsa $0, $0, $0, 1"' '-mips64r6' - enabled mips64r2 && check_inline_asm_flags mips64r2 '"dext $0, $0, 0, 1"' '-mips64r2' - disabled mips64r6 && disabled mips64r2 && check_inline_asm_flags mips64r1 '"daddi $0, $0, 0"' '-mips64' + enabled mips64r6 && check_inline_asm mips64r6 '"dlsa $0, $0, $0, 1"' && + disable mips64r2 + enabled mips64r2 && check_inline_asm mips64r2 '"dext $0, $0, 0, 1"' + + disable mips32r6 && disable mips32r5 && disable mips32r2 else - enabled mips32r6 && check_inline_asm_flags mips32r6 '"aui $0, $0, 0"' '-mips32r6' - enabled mips32r5 && check_inline_asm_flags mips32r5 '"eretnc"' '-mips32r5' - enabled mips32r2 && check_inline_asm_flags mips32r2 '"ext $0, $0, 0, 1"' '-mips32r2' - disabled mips32r6 && disabled mips32r5 && disabled mips32r2 && check_inline_asm_flags mips32r1 '"addi $0, $0, 0"' '-mips32' + enabled mips32r6 && check_inline_asm mips32r6 '"aui $0, $0, 0"' && + disable mips32r5 && disable mips32r2 + enabled mips32r5 && check_inline_asm mips32r5 '"eretnc"' + enabled mips32r2 && check_inline_asm mips32r2 '"ext $0, $0, 0, 1"' + + disable mips64r6 && disable mips64r5 && disable mips64r2 fi - enabled mipsfpu && check_inline_asm_flags mipsfpu '"cvt.d.l $f0, $f2"' '-mhard-float' + enabled mipsfpu && check_inline_asm mipsfpu '"cvt.d.l $f0, $f2"' enabled mipsfpu && (enabled mips32r5 || enabled mips32r6 || enabled mips64r6) && check_inline_asm_flags mipsfpu '"cvt.d.l $f0, $f1"' '-mfp64' - enabled mipsfpu && enabled msa && check_inline_asm_flags msa '"addvi.b $w0, $w1, 1"' '-mmsa' && check_headers msa.h || disable msa + enabled mipsdsp && check_inline_asm_flags mipsdsp '"addu.qb $t0, $t1, $t2"' '-mdsp' enabled mipsdspr2 && check_inline_asm_flags mipsdspr2 '"absq_s.qb $t0, $t1"' '-mdspr2' - enabled msa && enabled msa2 && check_inline_asm_flags msa2 '"nxbits.any.b $w0, $w0"' '-mmsa2' && check_headers msa2.h || disable msa2 + + # MSA and MSA2 can be detected at runtime so we supply extra flags here + enabled mipsfpu && enabled msa && check_inline_asm msa '"addvi.b $w0, $w1, 1"' '-mmsa' && append MSAFLAGS '-mmsa' + enabled msa && enabled msa2 && check_inline_asm msa2 '"nxbits.any.b $w0, $w0"' '-mmsa2' && append MSAFLAGS '-mmsa2' + + # loongson2 have no switch cflag so we can only probe toolchain ability + enabled loongson2 && check_inline_asm loongson2 '"dmult.g $8, $9, $10"' + if enabled loongson2 ; then + disable loongson3 + fi + + # loongson3 can be treated as a part of MMI + enabled mips64r2 && enabled loongson3 && check_inline_asm loongson3 '"gsldxc1 $f0, 0($2, $3)"' '-mloongson-ext' && append MMIFLAGS '-mloongson-ext' + + # MMI must come together with loongson2 or loongson3 + if disabled loongson2 && disabled loongson3; then + disable mmi + fi + + # MMI can be detected at runtime too + enabled mmi && check_inline_asm mmi '"punpcklhw $f0, $f0, $f0"' '-mloongson-mmi' && append MMIFLAGS '-mloongson-mmi' if enabled bigendian && enabled msa; then disable msa @@ -7439,6 +7472,8 @@ LDSOFLAGS=$LDSOFLAGS SHFLAGS=$(echo $($ldflags_filter $SHFLAGS)) ASMSTRIPFLAGS=$ASMSTRIPFLAGS X86ASMFLAGS=$X86ASMFLAGS +MSAFLAGS=$MSAFLAGS +MMIFLAGS=$MMIFLAGS BUILDSUF=$build_suffix PROGSSUF=$progs_suffix FULLNAME=$FULLNAME diff --git a/ffbuild/common.mak b/ffbuild/common.mak index a60d27c9bd..6b95a17fbb 100644 --- a/ffbuild/common.mak +++ b/ffbuild/common.mak @@ -44,7 +44,7 @@ LDFLAGS := $(ALLFFLIBS:%=$(LD_PATH)lib%) $(LDFLAGS) define COMPILE $(call $(1)DEP,$(1)) - $($(1)) $($(1)FLAGS) $($(1)_DEPFLAGS) $($(1)_C) $($(1)_O) $(patsubst $(SRC_PATH)/%,$(SRC_LINK)/%,$<) + $($(1)) $($(1)FLAGS) $($(1)_DEPFLAGS) $($(1)_C) $($(1)_O) $($(2)) $(patsubst $(SRC_PATH)/%,$(SRC_LINK)/%,$<) endef COMPILE_C = $(call COMPILE,CC) @@ -54,6 +54,14 @@ COMPILE_M = $(call COMPILE,OBJCC) COMPILE_X86ASM = $(call COMPILE,X86ASM) COMPILE_HOSTC = $(call COMPILE,HOSTCC) COMPILE_NVCC = $(call COMPILE,NVCC) +COMPILE_MMI = $(call COMPILE,CC,MMIFLAGS) +COMPILE_MSA = $(call COMPILE,CC,MSAFLAGS) + +%_mmi.o: %_mmi.c + $(COMPILE_MMI) + +%_msa.o: %_msa.c + $(COMPILE_MSA) %.o: %.c $(COMPILE_C) diff --git a/libavcodec/mips/Makefile b/libavcodec/mips/Makefile index b4993f6e76..2be4d9b8a2 100644 --- a/libavcodec/mips/Makefile +++ b/libavcodec/mips/Makefile @@ -71,6 +71,8 @@ MSA-OBJS-$(CONFIG_IDCTDSP) += mips/idctdsp_msa.o \ MSA-OBJS-$(CONFIG_MPEGVIDEO) += mips/mpegvideo_msa.o MSA-OBJS-$(CONFIG_MPEGVIDEOENC) += mips/mpegvideoencdsp_msa.o MSA-OBJS-$(CONFIG_ME_CMP) += mips/me_cmp_msa.o +MSA-OBJS-$(CONFIG_VC1_DECODER) += mips/vc1dsp_msa.o + MMI-OBJS += mips/constants.o MMI-OBJS-$(CONFIG_H264DSP) += mips/h264dsp_mmi.o MMI-OBJS-$(CONFIG_H264CHROMA) += mips/h264chroma_mmi.o @@ -89,4 +91,3 @@ MMI-OBJS-$(CONFIG_WMV2DSP) += mips/wmv2dsp_mmi.o MMI-OBJS-$(CONFIG_HEVC_DECODER) += mips/hevcdsp_mmi.o MMI-OBJS-$(CONFIG_VP3DSP) += mips/vp3dsp_idct_mmi.o MMI-OBJS-$(CONFIG_VP9_DECODER) += mips/vp9_mc_mmi.o -MSA-OBJS-$(CONFIG_VC1_DECODER) += mips/vc1dsp_msa.o From patchwork Mon Jun 8 03:30:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaxun Yang X-Patchwork-Id: 20208 Delivered-To: andriy.gelman@gmail.com Received: by 2002:a25:bac9:0:0:0:0:0 with SMTP id a9csp4198292ybk; Sun, 7 Jun 2020 20:31:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxaYPjIPboO3Rvs7YitMEYqlczG96blPIIaxg+kWHn4EPQAyOymtPXSIknb4A47mCZ+/KLH X-Received: by 2002:a1c:3987:: with SMTP id g129mr14502319wma.139.1591587084979; Sun, 07 Jun 2020 20:31:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591587084; cv=none; d=google.com; s=arc-20160816; b=XnAbL1E7hkee2ikuQwTIFK90O9POacaomvaNKI/LEm+iWfyQ99NXSa3CVpx/nMOjt5 cb/m1CW5T7JVyWvIEXWcNnhFdqBczeyrqAAaE2YvheUUHFaj++J4sa4LH69dpVVNngjI gPQwnbt2IetjCR4GIklwDBpQe3xEYNAo0w6wb6KXhfG3d4Z3fmKfSuyNvGkZSyEHfKhm Qp2jQ+jdxiMPkvhx/5qyZYtGP0JMFc4WAvjjhB8E4UV5eUJPU5htm3bWQV/wv8Js0bg4 9C2ffrZQQfTlmqrOb5ntjpGIVrxa7jyTrZo+Cfq0PinN29+O1HnRG7ieDXdZEeXmSQPN iEIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:ai-spam-status :dkim-signature:delivered-to; bh=YCC/QnxqpUcmqlZsIm+5BmFiJw8y5+VIoCKA/wItOrA=; b=EUhigcJPPjsCOSg5RuubnyHEA49T7gjGlizduyvqkjGnHL5H56E+Ba4t6pUeQXpZb2 Cm7rm7XINJsBMXMFcJ75SDILGYul5U1zRUi1xk+9qgkVIeNC3bC9Bu3WgFq1fruzIlBp XJYfM9Sphx+5fqSnTgxdLde/4dH2HH//n2iZa7O86qkecWkY7YWrcZFuTFzpjeGnkFrT 1It1Ufc1T7swcHbzuJqm+Im0CCVEmy343sk7w8FmkMbf2oapA8fcIXr0G9XbJgSxMKzj Ic1AqtEl9B1ATxfPf+wkNpRD3soOusKlpRwqgZjTQeyfYXWQSEmiJdPoxCRz/G9FgzQC etdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@mymailcheap.com header.s=default header.b=elMoAPsC; dkim=neutral (body hash did not verify) header.i=@flygoat.com header.s=default header.b=c3ekmsiH; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=flygoat.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id j7si16609689wmj.113.2020.06.07.20.31.24; Sun, 07 Jun 2020 20:31:24 -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=@mymailcheap.com header.s=default header.b=elMoAPsC; dkim=neutral (body hash did not verify) header.i=@flygoat.com header.s=default header.b=c3ekmsiH; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=flygoat.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E796E68B14F; Mon, 8 Jun 2020 06:31:08 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from relay2.mymailcheap.com (relay2.mymailcheap.com [151.80.165.199]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 473DE68B0E6 for ; Mon, 8 Jun 2020 06:31:02 +0300 (EEST) Received: from filter2.mymailcheap.com (filter2.mymailcheap.com [91.134.140.82]) by relay2.mymailcheap.com (Postfix) with ESMTPS id 587F73E90B; Mon, 8 Jun 2020 05:31:01 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by filter2.mymailcheap.com (Postfix) with ESMTP id 38BCA2A8BA; Mon, 8 Jun 2020 05:31:01 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mymailcheap.com; s=default; t=1591587061; bh=4WvzDHPKPy32fR3JYC+X6T8j43jVMvoreuBSinzPMaA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=elMoAPsCXooRN61wnSvVWgf93cmMNpGyI6tk8Z3j4wZM5nfIO6Nt/n7AM0G7Wj50f N8R9Xs/H5D6BHyXxxc4J1rdxqxIrblr4Ty8KBhrORNPQqCvkufC9jtrhcwc9drrjG/ O1BGiaElPfLLA7xT8o16YITeYjrZMg4Wgf/yP6EU= X-Virus-Scanned: Debian amavisd-new at filter2.mymailcheap.com Received: from filter2.mymailcheap.com ([127.0.0.1]) by localhost (filter2.mymailcheap.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id nHxWAcwhbde9; Mon, 8 Jun 2020 05:31:00 +0200 (CEST) Received: from mail20.mymailcheap.com (mail20.mymailcheap.com [51.83.111.147]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by filter2.mymailcheap.com (Postfix) with ESMTPS; Mon, 8 Jun 2020 05:31:00 +0200 (CEST) Received: from [213.133.102.83] (ml.mymailcheap.com [213.133.102.83]) by mail20.mymailcheap.com (Postfix) with ESMTP id C693B414D1; Mon, 8 Jun 2020 03:30:59 +0000 (UTC) Authentication-Results: mail20.mymailcheap.com; dkim=pass (1024-bit key; unprotected) header.d=flygoat.com header.i=@flygoat.com header.b="c3ekmsiH"; dkim-atps=neutral AI-Spam-Status: Not processed Received: from rush.localdomain (unknown [60.177.191.23]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail20.mymailcheap.com (Postfix) with ESMTPSA id 5CE47414D1; Mon, 8 Jun 2020 03:30:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=flygoat.com; s=default; t=1591587015; bh=4WvzDHPKPy32fR3JYC+X6T8j43jVMvoreuBSinzPMaA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=c3ekmsiHwgU8K/lXM936gclKGrpHaALP9g7PlU0pEdNSLpG4fI7ixGBbopnarbj8K TcnfhLNyX2TO3/4en+/OZnw2pmrFK5RwEgLYIlqWdbUvSG4O1oVkeN4IhmwQ/kVdiU fx8/NgHRdZJB1m4jdwPUfZGX6W0Mu12CbOFrKyXU= From: Jiaxun Yang To: ffmpeg-devel@ffmpeg.org Date: Mon, 8 Jun 2020 11:30:02 +0800 Message-Id: <20200608033004.2635-3-jiaxun.yang@flygoat.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200608033004.2635-1-jiaxun.yang@flygoat.com> References: <20200608033004.2635-1-jiaxun.yang@flygoat.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: C693B414D1 X-Spamd-Result: default: False [4.90 / 10.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; R_DKIM_ALLOW(0.00)[flygoat.com:s=default]; RECEIVED_SPAMHAUS_PBL(0.00)[60.177.191.23:received]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; R_MISSING_CHARSET(2.50)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; BROKEN_CONTENT_TYPE(1.50)[]; R_SPF_SOFTFAIL(0.00)[~all:c]; TO_DN_SOME(0.00)[]; ML_SERVERS(-3.10)[213.133.102.83]; DKIM_TRACE(0.00)[flygoat.com:+]; DMARC_POLICY_ALLOW(0.00)[flygoat.com,none]; MID_CONTAINS_FROM(1.00)[]; RCVD_IN_DNSWL_NONE(0.00)[213.133.102.83:from]; DMARC_POLICY_ALLOW_WITH_FAILURES(0.00)[]; RCVD_NO_TLS_LAST(0.10)[]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:24940, ipnet:213.133.96.0/19, country:DE]; RCVD_COUNT_TWO(0.00)[2]; HFILTER_HELO_BAREIP(3.00)[213.133.102.83,1] X-Rspamd-Server: mail20.mymailcheap.com X-Spam: Yes Subject: [FFmpeg-devel] [PATCH v4 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" X-TUID: fxG3uYnzeznB Content-Length: 3222 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 Mon Jun 8 03:32:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaxun Yang X-Patchwork-Id: 20196 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 85D1444BA78 for ; Mon, 8 Jun 2020 06:32:46 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 640C868B010; Mon, 8 Jun 2020 06:32:46 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from relay3.mymailcheap.com (relay3.mymailcheap.com [217.182.119.155]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 59238680A7C for ; Mon, 8 Jun 2020 06:32:40 +0300 (EEST) Received: from filter1.mymailcheap.com (filter1.mymailcheap.com [149.56.130.247]) by relay3.mymailcheap.com (Postfix) with ESMTPS id BD7C93ECDF; Mon, 8 Jun 2020 05:32:39 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by filter1.mymailcheap.com (Postfix) with ESMTP id ED7632A39E; Sun, 7 Jun 2020 23:32:38 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mymailcheap.com; s=default; t=1591587159; bh=+Eei7640ZMGmJOegVFdL1tFVvygXv/BLkbP++Q7T/1Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=L0/NQxtARDVias0plkVgNG8EPaLY0FIwn14AqumE1CuJ3dgfIoR14Rd0IqeRKovWC YI0HqDaKNwQ9FTRMWQvUuhVORuRuQsLExuejNVJzh+t3Il2XwzUaHWuJkUscJhJkcm sK8GD6nne/2iSw3O/7Ua34K2d0dtQ/P4pItQAq94= X-Virus-Scanned: Debian amavisd-new at filter1.mymailcheap.com Received: from filter1.mymailcheap.com ([127.0.0.1]) by localhost (filter1.mymailcheap.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id LJREIEkExn1f; Sun, 7 Jun 2020 23:32:37 -0400 (EDT) Received: from mail20.mymailcheap.com (mail20.mymailcheap.com [51.83.111.147]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by filter1.mymailcheap.com (Postfix) with ESMTPS; Sun, 7 Jun 2020 23:32:37 -0400 (EDT) Received: from [213.133.102.83] (ml.mymailcheap.com [213.133.102.83]) by mail20.mymailcheap.com (Postfix) with ESMTP id 89400414D1; Mon, 8 Jun 2020 03:32:36 +0000 (UTC) Authentication-Results: mail20.mymailcheap.com; dkim=pass (1024-bit key; unprotected) header.d=flygoat.com header.i=@flygoat.com header.b="kA54vWIR"; dkim-atps=neutral AI-Spam-Status: Not processed Received: from rush.localdomain (unknown [60.177.191.23]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail20.mymailcheap.com (Postfix) with ESMTPSA id 230C940141; Mon, 8 Jun 2020 03:32:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=flygoat.com; s=default; t=1591587137; bh=+Eei7640ZMGmJOegVFdL1tFVvygXv/BLkbP++Q7T/1Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kA54vWIRtUbrUifJSZPc1NWgNCM7QaauDDvm3qG6Neeg2y0NhW/C5hirzPyCIQn5U EolatuFzo/XjHW3PumhtSJ4kSOKqeV9+rfpRfGU9Lm5WMYizlxL7XlwUo4ehGIn1tU H393OHsxSqh1fX+QyZEsRMMbqfaINNHvhSlJa7nA= From: Jiaxun Yang To: ffmpeg-devel@ffmpeg.org Date: Mon, 8 Jun 2020 11:32:10 +0800 Message-Id: <20200608033210.2765-1-jiaxun.yang@flygoat.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200608033004.2635-1-jiaxun.yang@flygoat.com> References: <20200608033004.2635-1-jiaxun.yang@flygoat.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 89400414D1 X-Spamd-Result: default: False [4.90 / 10.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; R_DKIM_ALLOW(0.00)[flygoat.com:s=default]; RECEIVED_SPAMHAUS_PBL(0.00)[60.177.191.23:received]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; R_MISSING_CHARSET(2.50)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; BROKEN_CONTENT_TYPE(1.50)[]; R_SPF_SOFTFAIL(0.00)[~all:c]; TO_DN_SOME(0.00)[]; ML_SERVERS(-3.10)[213.133.102.83]; DKIM_TRACE(0.00)[flygoat.com:+]; DMARC_POLICY_ALLOW(0.00)[flygoat.com,none]; MID_CONTAINS_FROM(1.00)[]; RCVD_IN_DNSWL_NONE(0.00)[213.133.102.83:from]; DMARC_POLICY_ALLOW_WITH_FAILURES(0.00)[]; RCVD_NO_TLS_LAST(0.10)[]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:24940, ipnet:213.133.96.0/19, country:DE]; RCVD_COUNT_TWO(0.00)[2]; HFILTER_HELO_BAREIP(3.00)[213.133.102.83,1] X-Rspamd-Server: mail20.mymailcheap.com X-Spam: Yes Subject: [FFmpeg-devel] [PATCH v4 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 Mon Jun 8 03:32:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaxun Yang X-Patchwork-Id: 20197 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 10A1344BA78 for ; Mon, 8 Jun 2020 06:32:51 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id E405A68B1AE; Mon, 8 Jun 2020 06:32:50 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from relay4.mymailcheap.com (relay4.mymailcheap.com [137.74.80.154]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id BE4F868B199 for ; Mon, 8 Jun 2020 06:32:44 +0300 (EEST) Received: from filter2.mymailcheap.com (filter2.mymailcheap.com [91.134.140.82]) by relay4.mymailcheap.com (Postfix) with ESMTPS id 598523F163; Mon, 8 Jun 2020 05:32:44 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by filter2.mymailcheap.com (Postfix) with ESMTP id 294362A8BA; Mon, 8 Jun 2020 05:32:44 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mymailcheap.com; s=default; t=1591587164; bh=41XXgqO20ptI4+LABEQ5knYNMelONDLe4Tq6kkfbRhI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zTFoLu1cF8z5n8n4313E9zgf+qVWhgBQCux70yYG+fJulS1zPh8xOkg08o2JW8/LE P7MdJbAC9z2gPZzx8gbvA/25Xxi6FOPqA8Fi8S8tJ4hsZcAOBrPdTkK6eT8/762zX4 UCjs7BDclRlYsfWiugbZmiVBiLsUJklTtH5mrWJM= X-Virus-Scanned: Debian amavisd-new at filter2.mymailcheap.com Received: from filter2.mymailcheap.com ([127.0.0.1]) by localhost (filter2.mymailcheap.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id P1LLyJgyJ1GF; Mon, 8 Jun 2020 05:32:42 +0200 (CEST) Received: from mail20.mymailcheap.com (mail20.mymailcheap.com [51.83.111.147]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by filter2.mymailcheap.com (Postfix) with ESMTPS; Mon, 8 Jun 2020 05:32:41 +0200 (CEST) Received: from [213.133.102.83] (ml.mymailcheap.com [213.133.102.83]) by mail20.mymailcheap.com (Postfix) with ESMTP id 6260741DFF; Mon, 8 Jun 2020 03:32:41 +0000 (UTC) Authentication-Results: mail20.mymailcheap.com; dkim=pass (1024-bit key; unprotected) header.d=flygoat.com header.i=@flygoat.com header.b="ci7bTJIX"; dkim-atps=neutral AI-Spam-Status: Not processed Received: from rush.localdomain (unknown [60.177.191.23]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail20.mymailcheap.com (Postfix) with ESMTPSA id 288A440141; Mon, 8 Jun 2020 03:32:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=flygoat.com; s=default; t=1591587154; bh=41XXgqO20ptI4+LABEQ5knYNMelONDLe4Tq6kkfbRhI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ci7bTJIXhrnEsswmCb4Q3rwRFY9t6AMD6FLSLfwAualxGBfA0psr+6/qKZ4jpbn+K fqPWoS1GdvjsaKILp1zGHq8M+xGDU4A1qJskU4CbKp0owIWG9pFOvvCKGuyuGeWqB5 c4wMGFlqHvKn/Bkk+ZREZMi2UVu4zxTzdLcGRpAs= From: Jiaxun Yang To: ffmpeg-devel@ffmpeg.org Date: Mon, 8 Jun 2020 11:32:26 +0800 Message-Id: <20200608033226.2844-1-jiaxun.yang@flygoat.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200608033004.2635-1-jiaxun.yang@flygoat.com> References: <20200608033004.2635-1-jiaxun.yang@flygoat.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 6260741DFF X-Spamd-Result: default: False [4.90 / 10.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; R_DKIM_ALLOW(0.00)[flygoat.com:s=default]; RECEIVED_SPAMHAUS_PBL(0.00)[60.177.191.23:received]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; R_MISSING_CHARSET(2.50)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; BROKEN_CONTENT_TYPE(1.50)[]; R_SPF_SOFTFAIL(0.00)[~all:c]; TO_DN_SOME(0.00)[]; ML_SERVERS(-3.10)[213.133.102.83]; DKIM_TRACE(0.00)[flygoat.com:+]; DMARC_POLICY_ALLOW(0.00)[flygoat.com,none]; MID_CONTAINS_FROM(1.00)[]; RCVD_IN_DNSWL_NONE(0.00)[213.133.102.83:from]; DMARC_POLICY_ALLOW_WITH_FAILURES(0.00)[]; RCVD_NO_TLS_LAST(0.10)[]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:24940, ipnet:213.133.96.0/19, country:DE]; RCVD_COUNT_TWO(0.00)[2]; HFILTER_HELO_BAREIP(3.00)[213.133.102.83,1] X-Rspamd-Server: mail20.mymailcheap.com X-Spam: Yes Subject: [FFmpeg-devel] [PATCH v4 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); }