avcodec/la: Add LSX optimization for loop filter.

Replaced function(LSX is sufficient for these functions):
ff_h264_v_lpf_chroma_8_lasx
ff_h264_h_lpf_chroma_8_lasx
ff_h264_v_lpf_chroma_intra_8_lasx
ff_h264_h_lpf_chroma_intra_8_lasx
ff_weight_h264_pixels4_8_lasx
ff_biweight_h264_pixels4_8_lasx

./configure --disable-lasx
ffmpeg -i 1_h264_1080p_30fps_3Mbps.mp4 -f rawvideo -y /dev/null -an
before: 161fps
after:  199fps

Reviewed-by: Shiyou Yin <yinshiyou-hf@loongson.cn>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
pull/389/head
Hao Chen 2 years ago committed by Michael Niedermayer
parent e1b6ecd20a
commit 7845b5ecd6
No known key found for this signature in database
GPG Key ID: B18E8928B3948D64
  1. 3
      libavcodec/loongarch/Makefile
  2. 1977
      libavcodec/loongarch/h264dsp.S
  3. 37
      libavcodec/loongarch/h264dsp_init_loongarch.c
  4. 1354
      libavcodec/loongarch/h264dsp_lasx.c
  5. 67
      libavcodec/loongarch/h264dsp_loongarch.h

@ -31,4 +31,5 @@ LSX-OBJS-$(CONFIG_HEVC_DECODER) += loongarch/hevcdsp_lsx.o \
loongarch/hevc_mc_uni_lsx.o \
loongarch/hevc_mc_uniw_lsx.o
LSX-OBJS-$(CONFIG_H264DSP) += loongarch/h264idct.o \
loongarch/h264idct_loongarch.o
loongarch/h264idct_loongarch.o \
loongarch/h264dsp.o

File diff suppressed because it is too large Load Diff

@ -29,21 +29,44 @@ av_cold void ff_h264dsp_init_loongarch(H264DSPContext *c, const int bit_depth,
int cpu_flags = av_get_cpu_flags();
if (have_lsx(cpu_flags)) {
if (chroma_format_idc <= 1)
c->h264_loop_filter_strength = ff_h264_loop_filter_strength_lsx;
if (bit_depth == 8) {
c->h264_idct_add = ff_h264_idct_add_8_lsx;
c->h264_idct8_add = ff_h264_idct8_add_8_lsx;
c->h264_idct_dc_add = ff_h264_idct_dc_add_8_lsx;
c->h264_idct8_dc_add = ff_h264_idct8_dc_add_8_lsx;
if (chroma_format_idc <= 1)
if (chroma_format_idc <= 1) {
c->h264_idct_add8 = ff_h264_idct_add8_8_lsx;
else
c->h264_h_loop_filter_chroma = ff_h264_h_lpf_chroma_8_lsx;
c->h264_h_loop_filter_chroma_intra = ff_h264_h_lpf_chroma_intra_8_lsx;
} else
c->h264_idct_add8 = ff_h264_idct_add8_422_8_lsx;
c->h264_idct_add16 = ff_h264_idct_add16_8_lsx;
c->h264_idct8_add4 = ff_h264_idct8_add4_8_lsx;
c->h264_luma_dc_dequant_idct = ff_h264_luma_dc_dequant_idct_8_lsx;
c->h264_idct_add16intra = ff_h264_idct_add16_intra_8_lsx;
c->h264_add_pixels4_clear = ff_h264_add_pixels4_8_lsx;
c->h264_add_pixels8_clear = ff_h264_add_pixels8_8_lsx;
c->h264_v_loop_filter_luma = ff_h264_v_lpf_luma_8_lsx;
c->h264_h_loop_filter_luma = ff_h264_h_lpf_luma_8_lsx;
c->h264_v_loop_filter_luma_intra = ff_h264_v_lpf_luma_intra_8_lsx;
c->h264_h_loop_filter_luma_intra = ff_h264_h_lpf_luma_intra_8_lsx;
c->h264_v_loop_filter_chroma = ff_h264_v_lpf_chroma_8_lsx;
c->h264_v_loop_filter_chroma_intra = ff_h264_v_lpf_chroma_intra_8_lsx;
c->biweight_h264_pixels_tab[0] = ff_biweight_h264_pixels16_8_lsx;
c->biweight_h264_pixels_tab[1] = ff_biweight_h264_pixels8_8_lsx;
c->biweight_h264_pixels_tab[2] = ff_biweight_h264_pixels4_8_lsx;
c->weight_h264_pixels_tab[0] = ff_weight_h264_pixels16_8_lsx;
c->weight_h264_pixels_tab[1] = ff_weight_h264_pixels8_8_lsx;
c->weight_h264_pixels_tab[2] = ff_weight_h264_pixels4_8_lsx;
c->h264_idct8_add = ff_h264_idct8_add_8_lsx;
c->h264_idct8_dc_add = ff_h264_idct8_dc_add_8_lsx;
}
}
#if HAVE_LASX
@ -57,23 +80,13 @@ av_cold void ff_h264dsp_init_loongarch(H264DSPContext *c, const int bit_depth,
c->h264_h_loop_filter_luma = ff_h264_h_lpf_luma_8_lasx;
c->h264_v_loop_filter_luma_intra = ff_h264_v_lpf_luma_intra_8_lasx;
c->h264_h_loop_filter_luma_intra = ff_h264_h_lpf_luma_intra_8_lasx;
c->h264_v_loop_filter_chroma = ff_h264_v_lpf_chroma_8_lasx;
if (chroma_format_idc <= 1)
c->h264_h_loop_filter_chroma = ff_h264_h_lpf_chroma_8_lasx;
c->h264_v_loop_filter_chroma_intra = ff_h264_v_lpf_chroma_intra_8_lasx;
if (chroma_format_idc <= 1)
c->h264_h_loop_filter_chroma_intra = ff_h264_h_lpf_chroma_intra_8_lasx;
/* Weighted MC */
c->weight_h264_pixels_tab[0] = ff_weight_h264_pixels16_8_lasx;
c->weight_h264_pixels_tab[1] = ff_weight_h264_pixels8_8_lasx;
c->weight_h264_pixels_tab[2] = ff_weight_h264_pixels4_8_lasx;
c->biweight_h264_pixels_tab[0] = ff_biweight_h264_pixels16_8_lasx;
c->biweight_h264_pixels_tab[1] = ff_biweight_h264_pixels8_8_lasx;
c->biweight_h264_pixels_tab[2] = ff_biweight_h264_pixels4_8_lasx;
c->h264_idct8_add = ff_h264_idct8_add_8_lasx;
c->h264_idct8_dc_add = ff_h264_idct8_dc_add_8_lasx;

File diff suppressed because it is too large Load Diff

@ -47,6 +47,50 @@ void ff_h264_idct_add16_intra_8_lsx(uint8_t *dst, const int32_t *blk_offset,
int16_t *block, int32_t dst_stride,
const uint8_t nzc[15 * 8]);
void ff_h264_h_lpf_luma_8_lsx(uint8_t *src, ptrdiff_t stride,
int alpha, int beta, int8_t *tc0);
void ff_h264_v_lpf_luma_8_lsx(uint8_t *src, ptrdiff_t stride,
int alpha, int beta, int8_t *tc0);
void ff_h264_h_lpf_luma_intra_8_lsx(uint8_t *src, ptrdiff_t stride,
int alpha, int beta);
void ff_h264_v_lpf_luma_intra_8_lsx(uint8_t *src, ptrdiff_t stride,
int alpha, int beta);
void ff_h264_h_lpf_chroma_8_lsx(uint8_t *src, ptrdiff_t stride,
int alpha, int beta, int8_t *tc0);
void ff_h264_v_lpf_chroma_8_lsx(uint8_t *src, ptrdiff_t stride,
int alpha, int beta, int8_t *tc0);
void ff_h264_h_lpf_chroma_intra_8_lsx(uint8_t *src, ptrdiff_t stride,
int alpha, int beta);
void ff_h264_v_lpf_chroma_intra_8_lsx(uint8_t *src, ptrdiff_t stride,
int alpha, int beta);
void ff_biweight_h264_pixels16_8_lsx(uint8_t *dst, uint8_t *src,
ptrdiff_t stride, int height,
int log2_denom, int weight_dst,
int weight_src, int offset_in);
void ff_biweight_h264_pixels8_8_lsx(uint8_t *dst, uint8_t *src,
ptrdiff_t stride, int height,
int log2_denom, int weight_dst,
int weight_src, int offset);
void ff_biweight_h264_pixels4_8_lsx(uint8_t *dst, uint8_t *src,
ptrdiff_t stride, int height,
int log2_denom, int weight_dst,
int weight_src, int offset);
void ff_weight_h264_pixels16_8_lsx(uint8_t *src, ptrdiff_t stride,
int height, int log2_denom,
int weight_src, int offset_in);
void ff_weight_h264_pixels8_8_lsx(uint8_t *src, ptrdiff_t stride,
int height, int log2_denom,
int weight_src, int offset);
void ff_weight_h264_pixels4_8_lsx(uint8_t *src, ptrdiff_t stride,
int height, int log2_denom,
int weight_src, int offset);
void ff_h264_add_pixels4_8_lsx(uint8_t *_dst, int16_t *_src, int stride);
void ff_h264_add_pixels8_8_lsx(uint8_t *_dst, int16_t *_src, int stride);
void ff_h264_loop_filter_strength_lsx(int16_t bS[2][4][4], uint8_t nnz[40],
int8_t ref[2][40], int16_t mv[2][40][2],
int bidir, int edges, int step,
int mask_mv0, int mask_mv1, int field);
#if HAVE_LASX
void ff_h264_h_lpf_luma_8_lasx(uint8_t *src, ptrdiff_t stride,
int alpha, int beta, int8_t *tc0);
@ -56,24 +100,12 @@ void ff_h264_h_lpf_luma_intra_8_lasx(uint8_t *src, ptrdiff_t stride,
int alpha, int beta);
void ff_h264_v_lpf_luma_intra_8_lasx(uint8_t *src, ptrdiff_t stride,
int alpha, int beta);
void ff_h264_h_lpf_chroma_8_lasx(uint8_t *src, ptrdiff_t stride,
int alpha, int beta, int8_t *tc0);
void ff_h264_v_lpf_chroma_8_lasx(uint8_t *src, ptrdiff_t stride,
int alpha, int beta, int8_t *tc0);
void ff_h264_h_lpf_chroma_intra_8_lasx(uint8_t *src, ptrdiff_t stride,
int alpha, int beta);
void ff_h264_v_lpf_chroma_intra_8_lasx(uint8_t *src, ptrdiff_t stride,
int alpha, int beta);
void ff_biweight_h264_pixels16_8_lasx(uint8_t *dst, uint8_t *src,
ptrdiff_t stride, int height,
void ff_biweight_h264_pixels16_8_lasx(unsigned char *dst, unsigned char *src,
long int stride, int height,
int log2_denom, int weight_dst,
int weight_src, int offset_in);
void ff_biweight_h264_pixels8_8_lasx(uint8_t *dst, uint8_t *src,
ptrdiff_t stride, int height,
int log2_denom, int weight_dst,
int weight_src, int offset);
void ff_biweight_h264_pixels4_8_lasx(uint8_t *dst, uint8_t *src,
ptrdiff_t stride, int height,
void ff_biweight_h264_pixels8_8_lasx(unsigned char *dst, unsigned char *src,
long int stride, int height,
int log2_denom, int weight_dst,
int weight_src, int offset);
void ff_weight_h264_pixels16_8_lasx(uint8_t *src, ptrdiff_t stride,
@ -82,9 +114,6 @@ void ff_weight_h264_pixels16_8_lasx(uint8_t *src, ptrdiff_t stride,
void ff_weight_h264_pixels8_8_lasx(uint8_t *src, ptrdiff_t stride,
int height, int log2_denom,
int weight_src, int offset);
void ff_weight_h264_pixels4_8_lasx(uint8_t *src, ptrdiff_t stride,
int height, int log2_denom,
int weight_src, int offset);
void ff_h264_add_pixels4_8_lasx(uint8_t *_dst, int16_t *_src, int stride);
void ff_h264_add_pixels8_8_lasx(uint8_t *_dst, int16_t *_src, int stride);

Loading…
Cancel
Save