loongarch: Improve the performance of deblock series functions.

Performance has improved from 4.76fps to 4.92fps.
Tested with following command:
./configure && make -j5
./x264 --threads 4 -o out.mkv yuv_1920x1080.yuv

functions           performance     performance
                        (c)            (asm)
deblock_luma[0]         79               39
deblock_luma[1]         91               18
deblock_luma_intra[0]   63               44
deblock_luma_intra[1]   71               18
deblock_strength        104              33

Signed-off-by: Hao Chen <chenhao@loongson.cn>
This commit is contained in:
Loongson Technology Corporation Limited 2023-10-02 22:54:39 +08:00 committed by Shiyou Yin
parent 25ffd616b1
commit d7d283f634
4 changed files with 1697 additions and 0 deletions

View File

@ -199,6 +199,9 @@ endif
# LOONGARCH optimization
ifeq ($(SYS_ARCH),LOONGARCH)
ifneq ($(findstring HAVE_LSX 1, $(CONFIG)),)
SRCASM_X += common/loongarch/deblock-a.S \
SRCS_X +=
OBJASM +=
@ -209,6 +212,7 @@ ifneq ($(findstring HAVE_BITDEPTH10 1, $(CONFIG)),)
OBJASM += $(SRCASM_X:%.S=%-10.o)
endif
endif
endif
endif

View File

@ -680,6 +680,9 @@ void x264_macroblock_deblock( x264_t *h )
#if HAVE_MSA
#include "mips/deblock.h"
#endif
#if HAVE_LSX
#include "loongarch/deblock.h"
#endif
void x264_deblock_init( uint32_t cpu, x264_deblock_function_t *pf, int b_mbaff )
{
@ -816,6 +819,24 @@ void x264_deblock_init( uint32_t cpu, x264_deblock_function_t *pf, int b_mbaff )
pf->deblock_strength = x264_deblock_strength_msa;
}
#endif
#if HAVE_LSX
if( cpu&X264_CPU_LSX )
{
pf->deblock_luma_intra[1] = x264_deblock_v_luma_intra_lsx;
pf->deblock_luma_intra[0] = x264_deblock_h_luma_intra_lsx;
pf->deblock_strength = x264_deblock_strength_lsx;
}
if( cpu&X264_CPU_LASX )
{
pf->deblock_luma[1] = x264_deblock_v_luma_lasx;
pf->deblock_luma[0] = x264_deblock_h_luma_lasx;
pf->deblock_luma_intra[1] = x264_deblock_v_luma_intra_lasx;
pf->deblock_luma_intra[0] = x264_deblock_h_luma_intra_lasx;
pf->deblock_strength = x264_deblock_strength_lasx;
}
#endif
#endif // !HIGH_BIT_DEPTH
/* These functions are equivalent, so don't duplicate them. */

1618
common/loongarch/deblock-a.S Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,54 @@
/*****************************************************************************
* deblock.h: loongarch deblock
*****************************************************************************
* Copyright (C) 2023 x264 project
*
* Authors: Hao Chen <chenhao@loongson.cn>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111, USA.
*
* This program is also available under a commercial proprietary license.
* For more information, contact us at licensing@x264.com.
*****************************************************************************/
#ifndef X264_LOONGARCH_DEBLOCK_H
#define X264_LOONGARCH_DEBLOCK_H
#if !HIGH_BIT_DEPTH
#define x264_deblock_v_luma_lasx x264_template(deblock_v_luma_lasx)
void x264_deblock_v_luma_lasx( uint8_t *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 );
#define x264_deblock_h_luma_lasx x264_template(deblock_h_luma_lasx)
void x264_deblock_h_luma_lasx( uint8_t *pix, intptr_t stride, int alpha, int beta, int8_t *tc0 );
#define x264_deblock_v_luma_intra_lsx x264_template(deblock_v_luma_intra_lsx)
void x264_deblock_v_luma_intra_lsx( uint8_t *pix, intptr_t stride, int alpha, int beta );
#define x264_deblock_h_luma_intra_lsx x264_template(deblock_h_luma_intra_lsx)
void x264_deblock_h_luma_intra_lsx( uint8_t *pix, intptr_t stride, int alpha, int beta );
#define x264_deblock_v_luma_intra_lasx x264_template(deblock_v_luma_intra_lasx)
void x264_deblock_v_luma_intra_lasx( uint8_t *pix, intptr_t stride, int alpha, int beta );
#define x264_deblock_h_luma_intra_lasx x264_template(deblock_h_luma_intra_lasx)
void x264_deblock_h_luma_intra_lasx( uint8_t *pix, intptr_t stride, int alpha, int beta );
#define x264_deblock_strength_lsx x264_template(deblock_strength_lsx)
void x264_deblock_strength_lsx( uint8_t nnz[X264_SCAN8_SIZE], int8_t ref[2][X264_SCAN8_LUMA_SIZE],
int16_t mv[2][X264_SCAN8_LUMA_SIZE][2], uint8_t bs[2][8][4],
int mvy_limit, int bframe );
#define x264_deblock_strength_lasx x264_template(deblock_strength_lasx)
void x264_deblock_strength_lasx( uint8_t nnz[X264_SCAN8_SIZE], int8_t ref[2][X264_SCAN8_LUMA_SIZE],
int16_t mv[2][X264_SCAN8_LUMA_SIZE][2], uint8_t bs[2][8][4],
int mvy_limit, int bframe );
#endif
#endif