From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 931E84B5DF for ; Sun, 9 Jun 2024 09:55:15 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5999168D7C3; Sun, 9 Jun 2024 12:55:10 +0300 (EEST) Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05olkn2100.outbound.protection.outlook.com [40.92.91.100]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D206868D7BE for ; Sun, 9 Jun 2024 12:55:03 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FuICC3zFUOCa6l+E67g2ij5e4s7qPC4eKoSyH6xi0fU2PVT86RtgFhnbcKyKYKp/DcMHpr0wGoBnRm7pvIB3fMHQeSF3ojR73n1Rlslhz5E8khpoOuwEAgOG+R4Qwh0M7PJ1yV6CNUXEL5MAO+JmISYklg6Zi2TKXSoVQ9cDhJqvM9KBEAYh+dOfk9slyjtGMhh4xodl3u5G8GHAi/mxGAn+RbGgqg8T5kin8LIOrvoNj9YP7KVA5LhHYQulCbnBiBnO9eK7VQaN7F6arFZ9UNY35P8Lmb+wRXQ+phoqSi2U4+BgQ6jByt/iibk+4Py0Eqmy8FKsqOEF4pMO9OICpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=sW6kYCyfxVZqCMOd7tS12yzHAn9NZy0qolpT5bNmlrA=; b=SYUHgzhreX9ebkCP4WPh9ZJC6qqeo75acgdwJUgrKWJMea+O0cSOOOpkKnvOZhvly3deiXKDrTpGJ6x7uF+DPaiygS9tBNJ+kEJQvNlnSD5bTzSOdweIMtevjA8gieK+fW+3oqce2vQ66i4mf8hr4tTJGfooNqFSPX2Q7CQQ36EaNWunKI0Ux8cJCDlQJ2SkXFs/rGq2g+oTmtMA5frFgDR66Lrk7bwOyMl3fMbth4OlicIJbIzlVf9dSrbu67qB1sXiJAOEExdirdttfuGLJW5S4cT991ytjtH438WL8msMmesRABLPhz84+k5AEDwSOracmRn3g05JOqs8Vgd35g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=sW6kYCyfxVZqCMOd7tS12yzHAn9NZy0qolpT5bNmlrA=; b=CSMCtBSgxxFlkXI3PEBnR61Yo0yGLnVjqF3dicKgjHurrhZTPykAs9IKhrowk7aqxwaYDrBe+KDYzup4IQcbJP2Rrnr3xrgW2DcwN7GVD+gUXpXLqt8GT5gSTg4rEVYjM32rwiNe78orNUwG+NPboqfaydPc+BeVFJbEDQj7FXx7f9qiCz0l15qh9TaNm6a7qaxStK01GEshUtjyMwhlpPCrwwXAOUFYICXqlW9xMAiB8MQdKeS5wHtpgAo4mtG1FWBAhw887xHBJ4hipUbtIMuQuNywKt6NZkDYpYkjDpWBBLr3CiOvrCVrBdOAMtdxMcN1cYFnCDni3f16YAN/TQ== Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) by AS1P250MB0553.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:4af::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7633.34; Sun, 9 Jun 2024 09:54:58 +0000 Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM ([fe80::384d:40d4:ecb7:1c9]) by AS8P250MB0744.EURP250.PROD.OUTLOOK.COM ([fe80::384d:40d4:ecb7:1c9%4]) with mapi id 15.20.7633.021; Sun, 9 Jun 2024 09:54:58 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 9 Jun 2024 11:54:35 +0200 Message-ID: X-Mailer: git-send-email 2.40.1 In-Reply-To: References: X-TMN: [SWqbAeBGPIG5v3X57uIkaerGOgCuqtedAgPoCVteTj8=] X-ClientProxiedBy: FR2P281CA0034.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:14::21) To AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) X-Microsoft-Original-Message-ID: <20240609095438.3250145-3-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8P250MB0744:EE_|AS1P250MB0553:EE_ X-MS-Office365-Filtering-Correlation-Id: 10ab1c11-e5a6-46c0-0015-08dc886a3931 X-Microsoft-Antispam: BCL:0; ARA:14566002|461199019|3412199016|440099019|1710799017; X-Microsoft-Antispam-Message-Info: eFanGYl5wwZxJfzNN5E2eMlRd0nfjmwr4rn+3qKM7nUblf1fi+kj26vS1DfN6cZ9097NYlzrq9dQXIbT1zkjdE/ByUYMD7b2jlHryVapLTMJ8lQAS4CAY/TXg7LS+fMisqWgq7aKK+5fKY0zASqd/rf2fNsrqSXUq3iSUvesO4qGAQeVJ3xkZXI3D3zWQzhz239M++fRiJHT0ZZHFm30kptBv3hTW4dWkeEamYizIROVHJ5GdK1hbrAeAMe1zpA43TW7aBd3uzMfiXC1qlHQDUzA+n9kkapkrsOMCvdkJ6pmnbcfMq3iCrfCdZvOqre7ASxHBSNyW4jVbWaZJsOfNSzEcjACUveLKDrzXBkitqTfRs5ibDaqZw7C3xrLerfd0Km+jwRboKlK8AkmU54VW4inTZcxbSRll1GNAIdJ527Qr1yc2y2UylhgFDF/FembGpEATEtolp4yFALwvCeqLPURd0VW8IOumWmrWsIrtqWkHyUe399RvT4SdZPzEEDnUi0sMKLGqj9ZYfd1+67ACxMXTQSqZ4Ryv+BZCU4mG1qXudrSeVmGV0J2m3beoyTwdmYVfLCKWOfLrvKfJdxl2NA13oy789Ki8GuaaNw8L3FegZBJHEoW4nWaMM29Wh17 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?fNKLoXmMzfKYdzWlX2iHn9zjCFeJs0naoGFssatpc/oj4sMZ82Klkf97OXqT?= =?us-ascii?Q?BdXUqSp1D2Vk9LHL7+rZTCLjK59+6wZZNbFYZimcBh3D5juwDlvazGO7iyAn?= =?us-ascii?Q?KR2pIrH8r0xIdUQQLbfcJ9eNc6beMGwJGwsX9rLvA6JMQSZqTSZUyxW2b2Lc?= =?us-ascii?Q?6XIU75YBlkO+kcPdutRXe7HIEmjQBAFqgikbxiLk9z5JYz7JY55LOTsyz9t+?= =?us-ascii?Q?eVD7S1rM3RMFX0ZqzWRoLikCe8h6F3525ObaVcldoFN6NQag6PsOtaEjBuIb?= =?us-ascii?Q?6m9o+YiElhDyHONNch7Hk/SQ3Xkta0sLRFdsQK+Hhe9AwBF7DFtE7/yBl8vr?= =?us-ascii?Q?7FrSDkhX/02FtIrMHu8QGz+TM3Q6MWExEsKyOsihVprIGGBGvAmT0s718ShU?= =?us-ascii?Q?oOos8tMINFwI74TXoHujRhOmWFvLXHQj4SHatLQGon0PVQZMhKBm2mgImof4?= =?us-ascii?Q?Qge7JTgu92X+lkkfmgRocRYNQgLRLYIKYcaUiXNz6+I1swCKWJXR3lcTv8MF?= =?us-ascii?Q?l6zqYwDMzMkYIy7l9sSHa8a7D7ruATDwj17qlARhkFvungtjG5qvJcQiRMmV?= =?us-ascii?Q?W/wOVKtL1KiK8cbr5R9SftofMQWMAo2gkDCMRE8OgIEu11ImQ/7zJgGsy4++?= =?us-ascii?Q?CDGL04Pypf5L3sRdavj6xpoQVQLA4HBKVGhAyNCjr/ncUvmzE8zSM/KElrt6?= =?us-ascii?Q?e9bACg0K/ZGSeftYgACuMxr5J3++R+NH26mrcbMZLgRw3cYwFyPrOOGefR+U?= =?us-ascii?Q?KwyF3gsP4Qo6XrWYwP5XOiM4ZsV0boxrWyCU9iebFdEDMitJ28o4x8D8EpCf?= =?us-ascii?Q?oGZYFMwcn6hvwPhobZxM03ugWODI5whoYImZ0dP2W59oBycdgJJS1AGea86q?= =?us-ascii?Q?O8Bn8xjAwM8iNt3NejEn0CRfp0pMMDacEnBPoc0nCT64cmm/cmULwUSItQb5?= =?us-ascii?Q?tdt4TNKp+cQsIV2GwYoLM5T/Mt8HIrBaEdsXU/nAQhVUeZftVGIY7+uC/ZnX?= =?us-ascii?Q?/Jrc2MVS4AsNQxA0vaHH5+oq0k5S13XUzk5O/CRydfa/aL+EgebqZmRbMuns?= =?us-ascii?Q?yk3keGwrQZFVkS365+hXni2VSXGh+Yqaf2QWZAhRAqCat+hgSZSthhZmAswl?= =?us-ascii?Q?5TICRbP+93JvZRkaKxvgRj0I6h6Hd2fLKE66WJ5cBlA4R/rEbvHelIGK4Aae?= =?us-ascii?Q?UDwqRJkwJge4i8mh9rQHFC2tk51cY2pt0afXucyoz9p3jsb9I7uStl4QcCIU?= =?us-ascii?Q?LM+mKBSOVqWnLmuGxYvRlGYVSWbmK20xuCARIsYhDQ=3D=3D?= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 10ab1c11-e5a6-46c0-0015-08dc886a3931 X-MS-Exchange-CrossTenant-AuthSource: AS8P250MB0744.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jun 2024 09:54:58.9103 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS1P250MB0553 Subject: [FFmpeg-devel] [PATCH 4/7] avcodec/mips/mpegvideo: Set denoise_dct only for encoder 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: Andreas Rheinhardt Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: The C version is set in ff_dct_encode_init(), yet the MIPS version is set in dct_init() (in ff_mpv_common_init() and therefore also for decoders). This commit fixes this inconsistency. Signed-off-by: Andreas Rheinhardt --- libavcodec/mips/Makefile | 4 +- libavcodec/mips/mpegvideo_init_mips.c | 2 - libavcodec/mips/mpegvideo_mmi.c | 72 ----------------- libavcodec/mips/mpegvideoenc_init_mips.c | 33 ++++++++ libavcodec/mips/mpegvideoenc_mmi.c | 98 ++++++++++++++++++++++++ libavcodec/mpegvideo_enc.c | 4 +- libavcodec/mpegvideoenc.h | 1 + 7 files changed, 138 insertions(+), 76 deletions(-) create mode 100644 libavcodec/mips/mpegvideoenc_init_mips.c create mode 100644 libavcodec/mips/mpegvideoenc_mmi.c diff --git a/libavcodec/mips/Makefile b/libavcodec/mips/Makefile index 0647c0142a..fc1bc6b03f 100644 --- a/libavcodec/mips/Makefile +++ b/libavcodec/mips/Makefile @@ -31,7 +31,8 @@ OBJS-$(CONFIG_BLOCKDSP) += mips/blockdsp_init_mips.o OBJS-$(CONFIG_PIXBLOCKDSP) += mips/pixblockdsp_init_mips.o OBJS-$(CONFIG_IDCTDSP) += mips/idctdsp_init_mips.o OBJS-$(CONFIG_MPEGVIDEO) += mips/mpegvideo_init_mips.o -OBJS-$(CONFIG_MPEGVIDEOENC) += mips/mpegvideoencdsp_init_mips.o +OBJS-$(CONFIG_MPEGVIDEOENC) += mips/mpegvideoenc_init_mips.o \ + mips/mpegvideoencdsp_init_mips.o OBJS-$(CONFIG_ME_CMP) += mips/me_cmp_init_mips.o OBJS-$(CONFIG_MPEG4_DECODER) += mips/xvididct_init_mips.o OBJS-$(CONFIG_VC1DSP) += mips/vc1dsp_init_mips.o @@ -76,6 +77,7 @@ MMI-OBJS-$(CONFIG_H264DSP) += mips/h264dsp_mmi.o MMI-OBJS-$(CONFIG_H264CHROMA) += mips/h264chroma_mmi.o MMI-OBJS-$(CONFIG_H264PRED) += mips/h264pred_mmi.o MMI-OBJS-$(CONFIG_MPEGVIDEO) += mips/mpegvideo_mmi.o +MMI-OBJS-$(CONFIG_MPEGVIDEOENC) += mips/mpegvideoenc_mmi.o MMI-OBJS-$(CONFIG_IDCTDSP) += mips/idctdsp_mmi.o \ mips/simple_idct_mmi.o MMI-OBJS-$(CONFIG_MPEG4_DECODER) += mips/xvid_idct_mmi.o diff --git a/libavcodec/mips/mpegvideo_init_mips.c b/libavcodec/mips/mpegvideo_init_mips.c index f687ad18f1..1d02b0c937 100644 --- a/libavcodec/mips/mpegvideo_init_mips.c +++ b/libavcodec/mips/mpegvideo_init_mips.c @@ -36,8 +36,6 @@ av_cold void ff_mpv_common_init_mips(MpegEncContext *s) if (!(s->avctx->flags & AV_CODEC_FLAG_BITEXACT)) if (!s->q_scale_type) s->dct_unquantize_mpeg2_intra = ff_dct_unquantize_mpeg2_intra_mmi; - - s->denoise_dct= ff_denoise_dct_mmi; } if (have_msa(cpu_flags)) { diff --git a/libavcodec/mips/mpegvideo_mmi.c b/libavcodec/mips/mpegvideo_mmi.c index 3d5b5e20ab..7af421db6b 100644 --- a/libavcodec/mips/mpegvideo_mmi.c +++ b/libavcodec/mips/mpegvideo_mmi.c @@ -434,75 +434,3 @@ void ff_dct_unquantize_mpeg2_intra_mmi(MpegEncContext *s, int16_t *block, block[0]= block0; } - -void ff_denoise_dct_mmi(MpegEncContext *s, int16_t *block) -{ - const int intra = s->mb_intra; - int *sum = s->dct_error_sum[intra]; - uint16_t *offset = s->dct_offset[intra]; - double ftmp[8]; - mips_reg addr[1]; - DECLARE_VAR_ALL64; - - s->dct_count[intra]++; - - __asm__ volatile( - "pxor %[ftmp0], %[ftmp0], %[ftmp0] \n\t" - "1: \n\t" - MMI_LDC1(%[ftmp1], %[block], 0x00) - "pxor %[ftmp2], %[ftmp2], %[ftmp2] \n\t" - MMI_LDC1(%[ftmp3], %[block], 0x08) - "pxor %[ftmp4], %[ftmp4], %[ftmp4] \n\t" - "pcmpgth %[ftmp2], %[ftmp2], %[ftmp1] \n\t" - "pcmpgth %[ftmp4], %[ftmp4], %[ftmp3] \n\t" - "pxor %[ftmp1], %[ftmp1], %[ftmp2] \n\t" - "pxor %[ftmp3], %[ftmp3], %[ftmp4] \n\t" - "psubh %[ftmp1], %[ftmp1], %[ftmp2] \n\t" - "psubh %[ftmp3], %[ftmp3], %[ftmp4] \n\t" - MMI_LDC1(%[ftmp6], %[offset], 0x00) - "mov.d %[ftmp5], %[ftmp1] \n\t" - "psubush %[ftmp1], %[ftmp1], %[ftmp6] \n\t" - MMI_LDC1(%[ftmp6], %[offset], 0x08) - "mov.d %[ftmp7], %[ftmp3] \n\t" - "psubush %[ftmp3], %[ftmp3], %[ftmp6] \n\t" - "pxor %[ftmp1], %[ftmp1], %[ftmp2] \n\t" - "pxor %[ftmp3], %[ftmp3], %[ftmp4] \n\t" - "psubh %[ftmp1], %[ftmp1], %[ftmp2] \n\t" - "psubh %[ftmp3], %[ftmp3], %[ftmp4] \n\t" - MMI_SDC1(%[ftmp1], %[block], 0x00) - MMI_SDC1(%[ftmp3], %[block], 0x08) - "mov.d %[ftmp1], %[ftmp5] \n\t" - "mov.d %[ftmp3], %[ftmp7] \n\t" - "punpcklhw %[ftmp5], %[ftmp5], %[ftmp0] \n\t" - "punpckhhw %[ftmp1], %[ftmp1], %[ftmp0] \n\t" - "punpcklhw %[ftmp7], %[ftmp7], %[ftmp0] \n\t" - "punpckhhw %[ftmp3], %[ftmp3], %[ftmp0] \n\t" - MMI_LDC1(%[ftmp2], %[sum], 0x00) - "paddw %[ftmp5], %[ftmp5], %[ftmp2] \n\t" - MMI_LDC1(%[ftmp2], %[sum], 0x08) - "paddw %[ftmp1], %[ftmp1], %[ftmp2] \n\t" - MMI_LDC1(%[ftmp2], %[sum], 0x10) - "paddw %[ftmp7], %[ftmp7], %[ftmp2] \n\t" - MMI_LDC1(%[ftmp2], %[sum], 0x18) - "paddw %[ftmp3], %[ftmp3], %[ftmp2] \n\t" - MMI_SDC1(%[ftmp5], %[sum], 0x00) - MMI_SDC1(%[ftmp1], %[sum], 0x08) - MMI_SDC1(%[ftmp7], %[sum], 0x10) - MMI_SDC1(%[ftmp3], %[sum], 0x18) - PTR_ADDIU "%[block], %[block], 0x10 \n\t" - PTR_ADDIU "%[sum], %[sum], 0x20 \n\t" - PTR_SUBU "%[addr0], %[block1], %[block] \n\t" - PTR_ADDIU "%[offset], %[offset], 0x10 \n\t" - "bgtz %[addr0], 1b \n\t" - : [ftmp0]"=&f"(ftmp[0]), [ftmp1]"=&f"(ftmp[1]), - [ftmp2]"=&f"(ftmp[2]), [ftmp3]"=&f"(ftmp[3]), - [ftmp4]"=&f"(ftmp[4]), [ftmp5]"=&f"(ftmp[5]), - [ftmp6]"=&f"(ftmp[6]), [ftmp7]"=&f"(ftmp[7]), - RESTRICT_ASM_ALL64 - [addr0]"=&r"(addr[0]), - [block]"+&r"(block), [sum]"+&r"(sum), - [offset]"+&r"(offset) - : [block1]"r"(block+64) - : "memory" - ); -} diff --git a/libavcodec/mips/mpegvideoenc_init_mips.c b/libavcodec/mips/mpegvideoenc_init_mips.c new file mode 100644 index 0000000000..5ef0664937 --- /dev/null +++ b/libavcodec/mips/mpegvideoenc_init_mips.c @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2015 Manojkumar Bhosale (Manojkumar.Bhosale@imgtec.com) + * + * 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/attributes.h" +#include "libavutil/mips/cpu.h" +#include "libavcodec/mpegvideoenc.h" +#include "mpegvideo_mips.h" + +av_cold void ff_mpvenc_dct_init_mips(MpegEncContext *s) +{ + int cpu_flags = av_get_cpu_flags(); + + if (have_mmi(cpu_flags)) { + s->denoise_dct = ff_denoise_dct_mmi; + } +} diff --git a/libavcodec/mips/mpegvideoenc_mmi.c b/libavcodec/mips/mpegvideoenc_mmi.c new file mode 100644 index 0000000000..65da155e9f --- /dev/null +++ b/libavcodec/mips/mpegvideoenc_mmi.c @@ -0,0 +1,98 @@ +/* + * Loongson SIMD optimized mpegvideo + * + * Copyright (c) 2015 Loongson Technology Corporation Limited + * Copyright (c) 2015 Zhou Xiaoyong + * Zhang Shuangshuang + * + * 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 "mpegvideo_mips.h" +#include "libavutil/mips/mmiutils.h" + +void ff_denoise_dct_mmi(MpegEncContext *s, int16_t *block) +{ + const int intra = s->mb_intra; + int *sum = s->dct_error_sum[intra]; + uint16_t *offset = s->dct_offset[intra]; + double ftmp[8]; + mips_reg addr[1]; + DECLARE_VAR_ALL64; + + s->dct_count[intra]++; + + __asm__ volatile( + "pxor %[ftmp0], %[ftmp0], %[ftmp0] \n\t" + "1: \n\t" + MMI_LDC1(%[ftmp1], %[block], 0x00) + "pxor %[ftmp2], %[ftmp2], %[ftmp2] \n\t" + MMI_LDC1(%[ftmp3], %[block], 0x08) + "pxor %[ftmp4], %[ftmp4], %[ftmp4] \n\t" + "pcmpgth %[ftmp2], %[ftmp2], %[ftmp1] \n\t" + "pcmpgth %[ftmp4], %[ftmp4], %[ftmp3] \n\t" + "pxor %[ftmp1], %[ftmp1], %[ftmp2] \n\t" + "pxor %[ftmp3], %[ftmp3], %[ftmp4] \n\t" + "psubh %[ftmp1], %[ftmp1], %[ftmp2] \n\t" + "psubh %[ftmp3], %[ftmp3], %[ftmp4] \n\t" + MMI_LDC1(%[ftmp6], %[offset], 0x00) + "mov.d %[ftmp5], %[ftmp1] \n\t" + "psubush %[ftmp1], %[ftmp1], %[ftmp6] \n\t" + MMI_LDC1(%[ftmp6], %[offset], 0x08) + "mov.d %[ftmp7], %[ftmp3] \n\t" + "psubush %[ftmp3], %[ftmp3], %[ftmp6] \n\t" + "pxor %[ftmp1], %[ftmp1], %[ftmp2] \n\t" + "pxor %[ftmp3], %[ftmp3], %[ftmp4] \n\t" + "psubh %[ftmp1], %[ftmp1], %[ftmp2] \n\t" + "psubh %[ftmp3], %[ftmp3], %[ftmp4] \n\t" + MMI_SDC1(%[ftmp1], %[block], 0x00) + MMI_SDC1(%[ftmp3], %[block], 0x08) + "mov.d %[ftmp1], %[ftmp5] \n\t" + "mov.d %[ftmp3], %[ftmp7] \n\t" + "punpcklhw %[ftmp5], %[ftmp5], %[ftmp0] \n\t" + "punpckhhw %[ftmp1], %[ftmp1], %[ftmp0] \n\t" + "punpcklhw %[ftmp7], %[ftmp7], %[ftmp0] \n\t" + "punpckhhw %[ftmp3], %[ftmp3], %[ftmp0] \n\t" + MMI_LDC1(%[ftmp2], %[sum], 0x00) + "paddw %[ftmp5], %[ftmp5], %[ftmp2] \n\t" + MMI_LDC1(%[ftmp2], %[sum], 0x08) + "paddw %[ftmp1], %[ftmp1], %[ftmp2] \n\t" + MMI_LDC1(%[ftmp2], %[sum], 0x10) + "paddw %[ftmp7], %[ftmp7], %[ftmp2] \n\t" + MMI_LDC1(%[ftmp2], %[sum], 0x18) + "paddw %[ftmp3], %[ftmp3], %[ftmp2] \n\t" + MMI_SDC1(%[ftmp5], %[sum], 0x00) + MMI_SDC1(%[ftmp1], %[sum], 0x08) + MMI_SDC1(%[ftmp7], %[sum], 0x10) + MMI_SDC1(%[ftmp3], %[sum], 0x18) + PTR_ADDIU "%[block], %[block], 0x10 \n\t" + PTR_ADDIU "%[sum], %[sum], 0x20 \n\t" + PTR_SUBU "%[addr0], %[block1], %[block] \n\t" + PTR_ADDIU "%[offset], %[offset], 0x10 \n\t" + "bgtz %[addr0], 1b \n\t" + : [ftmp0]"=&f"(ftmp[0]), [ftmp1]"=&f"(ftmp[1]), + [ftmp2]"=&f"(ftmp[2]), [ftmp3]"=&f"(ftmp[3]), + [ftmp4]"=&f"(ftmp[4]), [ftmp5]"=&f"(ftmp[5]), + [ftmp6]"=&f"(ftmp[6]), [ftmp7]"=&f"(ftmp[7]), + RESTRICT_ASM_ALL64 + [addr0]"=&r"(addr[0]), + [block]"+&r"(block), [sum]"+&r"(sum), + [offset]"+&r"(offset) + : [block1]"r"(block+64) + : "memory" + ); +} diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index c9cb4c2e64..bc36d4b5a6 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -292,7 +292,9 @@ static void mpv_encode_defaults(MpegEncContext *s) av_cold int ff_dct_encode_init(MpegEncContext *s) { -#if ARCH_X86 +#if ARCH_MIPS + ff_mpvenc_dct_init_mips(s); +#elif ARCH_X86 ff_dct_encode_init_x86(s); #endif diff --git a/libavcodec/mpegvideoenc.h b/libavcodec/mpegvideoenc.h index 169ed1dc3b..abbcdbc8fa 100644 --- a/libavcodec/mpegvideoenc.h +++ b/libavcodec/mpegvideoenc.h @@ -146,6 +146,7 @@ int ff_mpv_reallocate_putbitbuffer(MpegEncContext *s, size_t threshold, size_t s void ff_write_quant_matrix(PutBitContext *pb, uint16_t *matrix); int ff_dct_encode_init(MpegEncContext *s); +void ff_mpvenc_dct_init_mips(MpegEncContext *s); void ff_dct_encode_init_x86(MpegEncContext *s); void ff_convert_matrix(MpegEncContext *s, int (*qmat)[64], uint16_t (*qmat16)[2][64], -- 2.40.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".