From patchwork Thu Dec 1 06:42:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Junxian Zhu X-Patchwork-Id: 39547 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:999a:b0:a4:2148:650a with SMTP id ve26csp147086pzb; Wed, 30 Nov 2022 22:42:53 -0800 (PST) X-Google-Smtp-Source: AA0mqf6KEvo7cJheR/pMaiyNiQZBbxVbUHbQ9X/JKfKCE4W9xrTCTcRaAjihRYa1q/4h8gxomLpr X-Received: by 2002:a17:906:924b:b0:7c0:9d37:ec95 with SMTP id c11-20020a170906924b00b007c09d37ec95mr5627210ejx.401.1669876972778; Wed, 30 Nov 2022 22:42:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669876972; cv=none; d=google.com; s=arc-20160816; b=EzebjtiUN0Esg6HGimdrtxQ/9Q51r0ukgjkh+7zBrOCI0/YRuuktQovlzJSOO8x2M4 dJOZretj6MLx6fn/Qo3/0NTD93+eETguVDTUnEm+ZgTG5UP4wTNYrtlchBHP+wA25MKV YxqgsVyL5DaPEOuwAxKx9yIrS91c/QBHE8kHaFBWWIBXyfzsLnh+qsZcBmPzkiynm9sH Zp66o5x+BaHQAnVDOmfRXF9TV4Cp0m1mi8aes/k2SUfEVmOBAUDcCvYL4mTFOTs9MjTk jSeWHy8jkAwLkANme37Kq+cPpJCsjWHGZAeyOeKZE/sBRnf29P0oH0nfOr0mhccKIFhc 8f6g== 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:to:mime-version:date:message-id:from :dkim-signature:delivered-to; bh=YTU+ksHFg6TR3S9kREQXyQCq+937QkZe8pK02IzFfJU=; b=ssSXP5ZZ8XPqrClCj4tGLqEoI5NrdB0bjPHG0CM+cw1Gznn1muuCfcX2mZ6EwSQvqW fW4zhvp4Z7Lod21nbRWMif9ALdW48J04PeOSp4pWvST+jr38+k3uGr9x9cdcDLWVc7l1 KR1IZd5k9wfylNV5f0H+YTC9BQPNx62C3qhTGdvWjHxJ22Dixw3vkO88zaz78XfzqJFi n/YvuGhGU7jrs19QYnzS0MsjmWbfYKvADUAnZqiGvZ95QSkX75KMwcjPpDhCPKj5yxeg WXfGISOaDilgCTd/DlzfJV0QsONZ69pt/vitssCggNyRsBOT9Ehl6u+fClzsM2ozcEWG 3YMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@oss-cipunited-com.20200927.dkim.feishu.cn header.s=s1 header.b="BJO4xo/B"; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id sc10-20020a1709078a0a00b007ae199ea55asi3147844ejc.817.2022.11.30.22.42.49; Wed, 30 Nov 2022 22:42:52 -0800 (PST) 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=@oss-cipunited-com.20200927.dkim.feishu.cn header.s=s1 header.b="BJO4xo/B"; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id BC53D68B30F; Thu, 1 Dec 2022 08:42:45 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from lf01132.bc.feishu.cn (lf01132.bc.feishu.cn [103.149.242.132]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D6DCD68B155 for ; Thu, 1 Dec 2022 08:42:38 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; s=s1; d=oss-cipunited-com.20200927.dkim.feishu.cn; t=1669876950; h=from:subject:mime-version:from:date:message-id:subject:to:cc: reply-to:content-type:mime-version:in-reply-to:message-id; bh=lTw77M+nv2nfNNglWdHNp0CR3KnFcFM8jeBQjJVVefQ=; b=BJO4xo/Bqy3NdN+rAba4G+k6b224SLoaQ9Vra8R88+o2Y+OYe3wRJY+WprnoMWolTGndg3 7hwVEeycA9lao82/G5h7UYfvdGEeXDwC2lHn0uZbf0K6qpdHX4Us636FYyhOAijwH6AVkU ZgSzEMsG2+LymT+1Ekwk7C4XjYvxfhyv9ZvM+aIUD9g2vhPn2zYdWHWIjQHczyV+ncMwtP KZmnObKgAyPzs68dNxHgziWKL4CyKykpJbOy08tRgJVAPIoavNOh6Uk1YRDaLpPYxXC4Ei 0jNo21QKwJx2tVP9BiagrnOicG7kavti3oLIZyK2ZfiJ0pudLzFNTHUb2RqhUA== From: "Junxian Zhu" Message-Id: <20221201064137.1406-1-zhujunxian@oss.cipunited.com> X-Lms-Return-Path: Date: Thu, 01 Dec 2022 14:42:20 +0800 X-Mailer: git-send-email 2.38.1.windows.1 Mime-Version: 1.0 X-Original-From: "Junxian Zhu" To: X-Content-Filtered-By: Mailman/MimeDel 2.1.29 Subject: [FFmpeg-devel] [PATCH] avcodec/mathops: Optimize generic mid_pred function X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Junxian Zhu , jiaxun.yang@flygoat.com Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: RtprbRW4Vf/K From: Junxian Zhu Rewrite mid_pred function in generic mathops.h, reduce branch jump to improve performance. And because nowadays new version compiler can compile enough short asmbbely code as handwritting in these function, so remove specified optimized mips inline asmbbely mathops.h. Signed-off-by: Junxian Zhu --- libavcodec/mathops.h | 20 ++++-------- libavcodec/mips/mathops.h | 67 --------------------------------------- 2 files changed, 6 insertions(+), 81 deletions(-) delete mode 100644 libavcodec/mips/mathops.h diff --git a/libavcodec/mathops.h b/libavcodec/mathops.h index c89054d6ed..526ffe0eec 100644 --- a/libavcodec/mathops.h +++ b/libavcodec/mathops.h @@ -41,8 +41,6 @@ extern const uint8_t ff_zigzag_scan[16+1]; # include "arm/mathops.h" #elif ARCH_AVR32 # include "avr32/mathops.h" -#elif ARCH_MIPS -# include "mips/mathops.h" #elif ARCH_PPC # include "ppc/mathops.h" #elif ARCH_X86 @@ -98,18 +96,12 @@ static av_always_inline unsigned UMULH(unsigned a, unsigned b){ #define mid_pred mid_pred static inline av_const int mid_pred(int a, int b, int c) { - if(a>b){ - if(c>b){ - if(c>a) b=a; - else b=c; - } - }else{ - if(b>c){ - if(c>a) b=c; - else b=a; - } - } - return b; + int t0,t1,t2,t3; + t0 = (a > b) ? b : a ; + t1 = (a > b) ? a : b ; + t2 = (t0 > c) ? t0 : c; + t3 = (t1 > t2) ? t2 : t1; + return t3; } #endif diff --git a/libavcodec/mips/mathops.h b/libavcodec/mips/mathops.h deleted file mode 100644 index bb9dc8375a..0000000000 --- a/libavcodec/mips/mathops.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2009 Mans Rullgard - * Copyright (c) 2015 Zhou Xiaoyong - * - * 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 AVCODEC_MIPS_MATHOPS_H -#define AVCODEC_MIPS_MATHOPS_H - -#include -#include "config.h" -#include "libavutil/common.h" - -#if HAVE_INLINE_ASM - -#if HAVE_LOONGSON3 - -#define MULH MULH -static inline av_const int MULH(int a, int b) -{ - int c; - __asm__ ("dmult %1, %2 \n\t" - "mflo %0 \n\t" - "dsrl %0, %0, 32 \n\t" - : "=r"(c) - : "r"(a),"r"(b) - : "hi", "lo"); - return c; -} - -#define mid_pred mid_pred -static inline av_const int mid_pred(int a, int b, int c) -{ - int t = b; - __asm__ ("sgt $8, %1, %2 \n\t" - "movn %0, %1, $8 \n\t" - "movn %1, %2, $8 \n\t" - "sgt $8, %1, %3 \n\t" - "movz %1, %3, $8 \n\t" - "sgt $8, %0, %1 \n\t" - "movn %0, %1, $8 \n\t" - : "+&r"(t),"+&r"(a) - : "r"(b),"r"(c) - : "$8"); - return t; -} - -#endif /* HAVE_LOONGSON3 */ - -#endif /* HAVE_INLINE_ASM */ - -#endif /* AVCODEC_MIPS_MATHOPS_H */