Files
openloongarch-buildroot-202…/package/ffmpeg/0011-mips-refine-ff_h264_idct_add16_msa.patch
2024-06-17 20:39:36 +08:00

86 lines
3.3 KiB
Diff

From 6ce3d8fba8c93b1dcd738d2f09e3915db78f5fbc Mon Sep 17 00:00:00 2001
From: Shiyou Yin <yinshiyou-hf@loongson.cn>
Date: Wed, 1 Mar 2023 16:52:55 +0800
Subject: [PATCH 01/10] mips: refine ff_h264_idct_add16_msa.
speed up about 1.5% when decoding yuv444p H264 video.
Change-Id: Ie03b133a71b875c6c83c950d783ed83ae9be308f
---
libavcodec/mips/h264idct_msa.c | 36 +++++++++++++++-------------------
1 file changed, 16 insertions(+), 20 deletions(-)
diff --git a/libavcodec/mips/h264idct_msa.c b/libavcodec/mips/h264idct_msa.c
index fbf7795e27..9a1a757045 100644
--- a/libavcodec/mips/h264idct_msa.c
+++ b/libavcodec/mips/h264idct_msa.c
@@ -271,7 +271,7 @@ static void avc_idct8_dc_addblk_msa(uint8_t *dst, int16_t *src,
void ff_h264_idct_add_msa(uint8_t *dst, int16_t *src, int32_t dst_stride)
{
- uint32_t src0_m, src1_m, src2_m, src3_m, out0_m, out1_m, out2_m, out3_m;
+ uint32_t out0_m, out1_m, out2_m, out3_m;
v16i8 dst0_m = { 0 };
v16i8 dst1_m = { 0 };
v8i16 hres0, hres1, hres2, hres3, vres0, vres1, vres2, vres3;
@@ -279,23 +279,23 @@ void ff_h264_idct_add_msa(uint8_t *dst, int16_t *src, int32_t dst_stride)
const v8i16 src0 = LD_SH(src);
const v8i16 src2 = LD_SH(src + 8);
const v8i16 zero = { 0 };
- const uint8_t *dst1 = dst + dst_stride;
- const uint8_t *dst2 = dst + 2 * dst_stride;
- const uint8_t *dst3 = dst + 3 * dst_stride;
+ const uint8_t *dst1 = dst + dst_stride;
+ const uint8_t *dst2 = dst1 + dst_stride;
+ const uint8_t *dst3 = dst2 + dst_stride;
ILVL_D2_SH(src0, src0, src2, src2, src1, src3);
ST_SH2(zero, zero, src, 8);
AVC_ITRANS_H(src0, src1, src2, src3, hres0, hres1, hres2, hres3);
TRANSPOSE4x4_SH_SH(hres0, hres1, hres2, hres3, hres0, hres1, hres2, hres3);
AVC_ITRANS_H(hres0, hres1, hres2, hres3, vres0, vres1, vres2, vres3);
- src0_m = LW(dst);
- src1_m = LW(dst1);
- SRARI_H4_SH(vres0, vres1, vres2, vres3, 6);
- src2_m = LW(dst2);
- src3_m = LW(dst3);
+ out0_m = LW(dst);
+ out1_m = LW(dst1);
+ out2_m = LW(dst2);
+ out3_m = LW(dst3);
ILVR_D2_SH(vres1, vres0, vres3, vres2, inp0_m, inp1_m);
- INSERT_W2_SB(src0_m, src1_m, dst0_m);
- INSERT_W2_SB(src2_m, src3_m, dst1_m);
+ SRARI_H2_SH(inp0_m, inp1_m, 6);
+ INSERT_W2_SB(out0_m, out1_m, dst0_m);
+ INSERT_W2_SB(out2_m, out3_m, dst1_m);
ILVR_B2_SH(zero, dst0_m, zero, dst1_m, res0_m, res1_m);
ADD2(res0_m, inp0_m, res1_m, inp1_m, res0_m, res1_m);
CLIP_SH2_0_255(res0_m, res1_m);
@@ -352,17 +352,13 @@ void ff_h264_idct_add16_msa(uint8_t *dst,
int32_t i;
for (i = 0; i < 16; i++) {
- int32_t nnz = nzc[scan8[i]];
+ uint8_t *dst_l = dst + blk_offset[i];
+ uint8_t nnz = nzc[scan8[i]];
+ int32_t i_16p = i << 4;
if (nnz) {
- if (nnz == 1 && ((dctcoef *) block)[i * 16])
- ff_h264_idct4x4_addblk_dc_msa(dst + blk_offset[i],
- block + i * 16 * sizeof(pixel),
- dst_stride);
- else
- ff_h264_idct_add_msa(dst + blk_offset[i],
- block + i * 16 * sizeof(pixel),
- dst_stride);
+ i_16p *= sizeof(pixel);
+ ff_h264_idct_add_msa(dst_l, block + i_16p, dst_stride);
}
}
}
--
2.20.1