From patchwork Thu Sep 21 12:01:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manojkumar Bhosale X-Patchwork-Id: 5218 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.2.36.26 with SMTP id f26csp1859793jaa; Thu, 21 Sep 2017 05:01:57 -0700 (PDT) X-Google-Smtp-Source: AOwi7QDqtqxlYueKUj4hMROMGMeK+4tuo0VZdnnWfYJhmn7qQxr9gdCU/bT2XBF0Gh00DzX6w9w1 X-Received: by 10.223.171.21 with SMTP id q21mr1709729wrc.125.1505995317771; Thu, 21 Sep 2017 05:01:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505995317; cv=none; d=google.com; s=arc-20160816; b=VS1T1JMU/hNoiCAjmF5iP1YCVyxwT2MF6dxfSwSzPhHgoPUr21ctUbaz5Cjutc0d11 WoNQW/6rUqZ2h0uWt0sMcBR8Rj8Dqb/YJ4rJbAHJmnF3cEdMLyrQK8uDnzwB7pAb8oWo F75Y/rBvc8Yu5FomhXRpVPTYFWO1tbMynwwTypRnKbLFIvFNCxr6Q6l8dPGmbbGwvX6m mSn1chH8oekUD0gDYEbbxQ0paCiubRYg3QsMSNDgvJ2FObaxaNDaSyJSX+ZzWJX3jX2t S9YI1axkYmHUOiTB9szLPonKcQOl5kLA/+wOiRb3MTy9T2rzcPRYMDJy9IhiS1LeOdao PiMA== 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:mime-version:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:to:from:delivered-to:arc-authentication-results; bh=juXy52k4rr3kzLWLfAim3nyLgPqxFo3cA2GbB1KCfaU=; b=qYKcaB/qmszsGOQLyiRolLkJvpSlltvcEp3AgLkBvTaaOBiNiKYU5FmtDm5B/7HY00 OgcE/G3xzKG4jE3k8EVXYHL9662E6ftWxhxai/3qe5pn2ByyvTw850SYyQMDXfKI1tZ1 rykp5u13qM8ydFPi54F8Je2H6q2E0l1+2NgNehvuYloNYFRrlLsj72SOSG9MvwZ9IFCV Ua/JuFfMxcWttMH86wu1exAenUUCj34xzAbBdL7FJCjnmvJY55gP6oEsIqRdflTvbKqN 8zuIb0uRqD2EaG67WMNTQ53klSIfl0L1w7AdApDU14PsSAh3FR5TVMUNnJWJTsQBTCud zVLA== ARC-Authentication-Results: i=1; mx.google.com; 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 132si1163116wmr.65.2017.09.21.05.01.57; Thu, 21 Sep 2017 05:01:57 -0700 (PDT) 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; 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 AF32A68838F; Thu, 21 Sep 2017 15:01:46 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mailapp01.imgtec.com (mailapp01.imgtec.com [195.59.15.196]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 07EB268036E for ; Thu, 21 Sep 2017 15:01:41 +0300 (EEST) Received: from hhmail02.hh.imgtec.org (unknown [10.100.10.20]) by Forcepoint Email with ESMTPS id A4DAA8AFA6057 for ; Thu, 21 Sep 2017 13:01:45 +0100 (IST) Received: from PUMAIL01.pu.imgtec.org (192.168.91.250) by hhmail02.hh.imgtec.org (10.100.10.20) with Microsoft SMTP Server (TLS) id 14.3.361.1; Thu, 21 Sep 2017 13:01:48 +0100 Received: from PUMAIL01.pu.imgtec.org ([::1]) by PUMAIL01.pu.imgtec.org ([::1]) with mapi id 14.03.0266.001; Thu, 21 Sep 2017 17:31:46 +0530 From: Manojkumar Bhosale To: FFmpeg development discussions and patches Thread-Topic: [FFmpeg-devel] [PATCH] avcodec/mips: preload data in hevc sao edge 90 degree filter msa functions Thread-Index: AQHTMqVnah3JDBkj0k+hGA4BEvoFcaK/PW/A Date: Thu, 21 Sep 2017 12:01:45 +0000 Message-ID: <70293ACCC3BA6A4E81FFCA024C7A86E1E0592310@PUMAIL01.pu.imgtec.org> References: <1505976460-32246-1-git-send-email-kaustubh.raste@imgtec.com> In-Reply-To: <1505976460-32246-1-git-send-email-kaustubh.raste@imgtec.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [192.168.91.86] MIME-Version: 1.0 Subject: Re: [FFmpeg-devel] [PATCH] avcodec/mips: preload data in hevc sao edge 90 degree filter msa functions X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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: Kaustubh Raste Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" LGTM -----Original Message----- From: ffmpeg-devel [mailto:ffmpeg-devel-bounces@ffmpeg.org] On Behalf Of kaustubh.raste@imgtec.com Sent: Thursday, September 21, 2017 12:18 PM To: ffmpeg-devel@ffmpeg.org Cc: Kaustubh Raste Subject: [FFmpeg-devel] [PATCH] avcodec/mips: preload data in hevc sao edge 90 degree filter msa functions From: Kaustubh Raste Signed-off-by: Kaustubh Raste --- libavcodec/mips/hevc_lpf_sao_msa.c | 181 ++++++++++++++++++++++++------------ 1 file changed, 122 insertions(+), 59 deletions(-) offset_mask1 = (v8i16) (__msa_hadd_u_h(diff_minus11, diff_minus11) + 2); - VSHF_H2_SH(edge_idx, edge_idx, sao_offset, sao_offset, offset_mask0, - offset_mask0, offset_mask0, offset_mask0); - VSHF_H2_SH(edge_idx, edge_idx, sao_offset, sao_offset, offset_mask1, - offset_mask1, offset_mask1, offset_mask1); - ILVEV_B2_SH(src_zero0, zero, src_zero1, zero, src00, src01); - ADD2(offset_mask0, src00, offset_mask1, src01, offset_mask0, - offset_mask1); - CLIP_SH2_0_255(offset_mask0, offset_mask1); - dst0 = __msa_pckev_b((v16i8) offset_mask1, (v16i8) offset_mask0); + offset = __msa_pckev_b((v16i8) offset_mask1, (v16i8) offset_mask0); + dst0 = __msa_pckev_b((v16i8) src_zero1, (v16i8) src_zero0); + + VSHF_B2_SB(edge_idx, edge_idx, sao_offset, sao_offset, offset, offset, + offset, offset); + + dst0 = (v16i8) __msa_xori_b((v16u8) dst0, 128); + dst0 = __msa_adds_s_b(dst0, offset); + dst0 = (v16i8) __msa_xori_b((v16u8) dst0, 128); src_minus10 = src10; src_minus11 = src11; + /* load in advance */ + LD_UB2(src + src_stride, src_stride, src10, src11); + dst_val0 = __msa_copy_u_w((v4i32) dst0, 0); dst_val1 = __msa_copy_u_w((v4i32) dst0, 2); SW(dst_val0, dst); @@ -1624,8 +1629,41 @@ static void hevc_sao_edge_filter_90degree_4width_msa(uint8_t *dst, SW(dst_val1, dst); dst += dst_stride; - src += (src_stride << 1); } + + src_minus10 = (v16u8) __msa_ilvr_b((v16i8) src10, (v16i8) src_minus10); + src_zero0 = __msa_ilvr_b((v16i8) src_minus11, (v16i8) src_minus11); + src_minus11 = (v16u8) __msa_ilvr_b((v16i8) src11, (v16i8) src_minus11); + src_zero1 = __msa_ilvr_b((v16i8) src10, (v16i8) src10); + + cmp_minus10 = ((v16u8) src_zero0 == src_minus10); + diff_minus10 = __msa_nor_v(cmp_minus10, cmp_minus10); + cmp_minus10 = (src_minus10 < (v16u8) src_zero0); + diff_minus10 = __msa_bmnz_v(diff_minus10, const1, cmp_minus10); + + cmp_minus11 = ((v16u8) src_zero1 == src_minus11); + diff_minus11 = __msa_nor_v(cmp_minus11, cmp_minus11); + cmp_minus11 = (src_minus11 < (v16u8) src_zero1); + diff_minus11 = __msa_bmnz_v(diff_minus11, const1, cmp_minus11); + + offset_mask0 = (v8i16) (__msa_hadd_u_h(diff_minus10, diff_minus10) + 2); + offset_mask1 = (v8i16) (__msa_hadd_u_h(diff_minus11, diff_minus11) + + 2); + + offset = __msa_pckev_b((v16i8) offset_mask1, (v16i8) offset_mask0); + dst0 = __msa_pckev_b((v16i8) src_zero1, (v16i8) src_zero0); + + VSHF_B2_SB(edge_idx, edge_idx, sao_offset, sao_offset, offset, + offset, offset, offset); + + dst0 = (v16i8) __msa_xori_b((v16u8) dst0, 128); + dst0 = __msa_adds_s_b(dst0, offset); + dst0 = (v16i8) __msa_xori_b((v16u8) dst0, 128); + + dst_val0 = __msa_copy_u_w((v4i32) dst0, 0); + dst_val1 = __msa_copy_u_w((v4i32) dst0, 2); + SW(dst_val0, dst); + dst += dst_stride; + SW(dst_val1, dst); } static void hevc_sao_edge_filter_90degree_8width_msa(uint8_t *dst, @@ -1635,22 +1673,23 @@ static void hevc_sao_edge_filter_90degree_8width_msa(uint8_t *dst, int16_t *sao_offset_val, int32_t height) { - int32_t h_cnt; uint64_t dst_val0, dst_val1; - v8i16 edge_idx = { 1, 2, 0, 3, 4, 0, 0, 0 }; + v16i8 edge_idx = { 1, 2, 0, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + }; v16u8 const1 = (v16u8) __msa_ldi_b(1); - v16i8 zero = { 0 }; - v16i8 src_zero0, src_zero1, dst0, dst1; + v16i8 offset, sao_offset = LD_SB(sao_offset_val); + v16i8 src_zero0, src_zero1, dst0; v16u8 cmp_minus10, diff_minus10, cmp_minus11, diff_minus11; v16u8 src_minus10, src_minus11, src10, src11; - v8i16 sao_offset, src00, offset_mask0, src01, offset_mask1; + v8i16 offset_mask0, offset_mask1; - sao_offset = LD_SH(sao_offset_val); + sao_offset = __msa_pckev_b(sao_offset, sao_offset); + /* load in advance */ LD_UB2(src - src_stride, src_stride, src_minus10, src_minus11); + LD_UB2(src + src_stride, src_stride, src10, src11); - for (h_cnt = (height >> 1); h_cnt--;) { - LD_UB2(src + src_stride, src_stride, src10, src11); + for (height -= 2; height; height -= 2) { + src += (src_stride << 1); src_minus10 = (v16u8) __msa_ilvr_b((v16i8) src10, (v16i8) src_minus10); src_zero0 = __msa_ilvr_b((v16i8) src_minus11, (v16i8) src_minus11); @@ -1670,28 +1709,63 @@ static void hevc_sao_edge_filter_90degree_8width_msa(uint8_t *dst, offset_mask0 = (v8i16) (__msa_hadd_u_h(diff_minus10, diff_minus10) + 2); offset_mask1 = (v8i16) (__msa_hadd_u_h(diff_minus11, diff_minus11) + 2); - VSHF_H2_SH(edge_idx, edge_idx, sao_offset, sao_offset, offset_mask0, - offset_mask0, offset_mask0, offset_mask0); - VSHF_H2_SH(edge_idx, edge_idx, sao_offset, sao_offset, offset_mask1, - offset_mask1, offset_mask1, offset_mask1); - ILVEV_B2_SH(src_zero0, zero, src_zero1, zero, src00, src01); - ADD2(offset_mask0, src00, offset_mask1, src01, offset_mask0, - offset_mask1); - CLIP_SH2_0_255(offset_mask0, offset_mask1); - PCKEV_B2_SB(offset_mask0, offset_mask0, offset_mask1, offset_mask1, - dst0, dst1); + offset = __msa_pckev_b((v16i8) offset_mask1, (v16i8) offset_mask0); + dst0 = __msa_pckev_b((v16i8) src_zero1, (v16i8) src_zero0); + + VSHF_B2_SB(edge_idx, edge_idx, sao_offset, sao_offset, offset, + offset, offset, offset); + + dst0 = (v16i8) __msa_xori_b((v16u8) dst0, 128); + dst0 = __msa_adds_s_b(dst0, offset); + dst0 = (v16i8) __msa_xori_b((v16u8) dst0, 128); src_minus10 = src10; src_minus11 = src11; + /* load in advance */ + LD_UB2(src + src_stride, src_stride, src10, src11); + dst_val0 = __msa_copy_u_d((v2i64) dst0, 0); - dst_val1 = __msa_copy_u_d((v2i64) dst1, 0); + dst_val1 = __msa_copy_u_d((v2i64) dst0, 1); SD(dst_val0, dst); dst += dst_stride; SD(dst_val1, dst); dst += dst_stride; - src += (src_stride << 1); } + + src_minus10 = (v16u8) __msa_ilvr_b((v16i8) src10, (v16i8) src_minus10); + src_zero0 = __msa_ilvr_b((v16i8) src_minus11, (v16i8) src_minus11); + src_minus11 = (v16u8) __msa_ilvr_b((v16i8) src11, (v16i8) src_minus11); + src_zero1 = __msa_ilvr_b((v16i8) src10, (v16i8) src10); + + cmp_minus10 = ((v16u8) src_zero0 == src_minus10); + diff_minus10 = __msa_nor_v(cmp_minus10, cmp_minus10); + cmp_minus10 = (src_minus10 < (v16u8) src_zero0); + diff_minus10 = __msa_bmnz_v(diff_minus10, const1, cmp_minus10); + + cmp_minus11 = ((v16u8) src_zero1 == src_minus11); + diff_minus11 = __msa_nor_v(cmp_minus11, cmp_minus11); + cmp_minus11 = (src_minus11 < (v16u8) src_zero1); + diff_minus11 = __msa_bmnz_v(diff_minus11, const1, cmp_minus11); + + offset_mask0 = (v8i16) (__msa_hadd_u_h(diff_minus10, diff_minus10) + 2); + offset_mask1 = (v8i16) (__msa_hadd_u_h(diff_minus11, diff_minus11) + + 2); + + offset = __msa_pckev_b((v16i8) offset_mask1, (v16i8) offset_mask0); + dst0 = __msa_pckev_b((v16i8) src_zero1, (v16i8) src_zero0); + + VSHF_B2_SB(edge_idx, edge_idx, sao_offset, sao_offset, offset, offset, + offset, offset); + + dst0 = (v16i8) __msa_xori_b((v16u8) dst0, 128); + dst0 = __msa_adds_s_b(dst0, offset); + dst0 = (v16i8) __msa_xori_b((v16u8) dst0, 128); + + dst_val0 = __msa_copy_u_d((v2i64) dst0, 0); + dst_val1 = __msa_copy_u_d((v2i64) dst0, 1); + SD(dst_val0, dst); + dst += dst_stride; + SD(dst_val1, dst); } static void hevc_sao_edge_filter_90degree_16multiple_msa(uint8_t *dst, @@ -1715,15 +1789,13 @@ static void hevc_sao_edge_filter_90degree_16multiple_msa(uint8_t *dst, v16u8 src10, src_minus10, dst0, src11, src_minus11, dst1; v16u8 src12, dst2, src13, dst3; v16i8 offset_mask0, offset_mask1, offset_mask2, offset_mask3, sao_offset; - v8i16 src0, src1, src2, src3, src4, src5, src6, src7; - v8i16 temp0, temp1, temp2, temp3, temp4, temp5, temp6, temp7; sao_offset = LD_SB(sao_offset_val); sao_offset = __msa_pckev_b(sao_offset, sao_offset); - for (v_cnt = 0; v_cnt < (width >> 4); v_cnt++) { - src = src_orig + (v_cnt << 4); - dst = dst_orig + (v_cnt << 4); + for (v_cnt = 0; v_cnt < width; v_cnt += 16) { + src = src_orig + v_cnt; + dst = dst_orig + v_cnt; LD_UB2(src - src_stride, src_stride, src_minus10, src_minus11); @@ -1779,24 +1851,15 @@ static void hevc_sao_edge_filter_90degree_16multiple_msa(uint8_t *dst, VSHF_B2_SB(edge_idx, edge_idx, sao_offset, sao_offset, offset_mask3, offset_mask3, offset_mask3, offset_mask3); - UNPCK_UB_SH(src_minus11, src0, src1); - UNPCK_SB_SH(offset_mask0, temp0, temp1); - UNPCK_UB_SH(src10, src2, src3); - UNPCK_SB_SH(offset_mask1, temp2, temp3); - UNPCK_UB_SH(src11, src4, src5); - UNPCK_SB_SH(offset_mask2, temp4, temp5); - UNPCK_UB_SH(src12, src6, src7); - UNPCK_SB_SH(offset_mask3, temp6, temp7); - ADD4(temp0, src0, temp1, src1, temp2, src2, temp3, src3, temp0, - temp1, temp2, temp3); - ADD4(temp4, src4, temp5, src5, temp6, src6, temp7, src7, temp4, - temp5, temp6, temp7); - CLIP_SH4_0_255(temp0, temp1, temp2, temp3); - CLIP_SH4_0_255(temp4, temp5, temp6, temp7); - PCKEV_B4_UB(temp1, temp0, temp3, temp2, temp5, temp4, temp7, temp6, - dst0, dst1, dst2, dst3); - src_minus10 = src12; + XORI_B4_128_UB(src_minus11, src10, src11, src12); + + dst0 = (v16u8) __msa_adds_s_b((v16i8) src_minus11, offset_mask0); + dst1 = (v16u8) __msa_adds_s_b((v16i8) src10, offset_mask1); + dst2 = (v16u8) __msa_adds_s_b((v16i8) src11, offset_mask2); + dst3 = (v16u8) __msa_adds_s_b((v16i8) src12, offset_mask3); + + XORI_B4_128_UB(dst0, dst1, dst2, dst3); src_minus11 = src13; ST_UB4(dst0, dst1, dst2, dst3, dst, dst_stride); -- 1.7.9.5 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel diff --git a/libavcodec/mips/hevc_lpf_sao_msa.c b/libavcodec/mips/hevc_lpf_sao_msa.c index 3472d32..39c647e 100644 --- a/libavcodec/mips/hevc_lpf_sao_msa.c +++ b/libavcodec/mips/hevc_lpf_sao_msa.c @@ -1568,23 +1568,25 @@ static void hevc_sao_edge_filter_90degree_4width_msa(uint8_t *dst, int16_t *sao_offset_val, int32_t height) { - int32_t h_cnt; uint32_t dst_val0, dst_val1; - v8i16 edge_idx = { 1, 2, 0, 3, 4, 0, 0, 0 }; + v16i8 edge_idx = { 1, 2, 0, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + }; v16u8 const1 = (v16u8) __msa_ldi_b(1); v16i8 dst0; - v16i8 zero = { 0 }; + v16i8 sao_offset = LD_SB(sao_offset_val); v16u8 cmp_minus10, diff_minus10, cmp_minus11, diff_minus11; v16u8 src_minus10, src_minus11, src10, src11; v16i8 src_zero0, src_zero1; - v8i16 sao_offset, src00, src01, offset_mask0, offset_mask1; + v16i8 offset; + v8i16 offset_mask0, offset_mask1; - sao_offset = LD_SH(sao_offset_val); + sao_offset = __msa_pckev_b(sao_offset, sao_offset); + /* load in advance */ LD_UB2(src - src_stride, src_stride, src_minus10, src_minus11); + LD_UB2(src + src_stride, src_stride, src10, src11); - for (h_cnt = (height >> 1); h_cnt--;) { - LD_UB2(src + src_stride, src_stride, src10, src11); + for (height -= 2; height; height -= 2) { + src += (src_stride << 1); src_minus10 = (v16u8) __msa_ilvr_b((v16i8) src10, (v16i8) src_minus10); src_zero0 = __msa_ilvr_b((v16i8) src_minus11, (v16i8) src_minus11); @@ -1604,19 +1606,22 @@ static void hevc_sao_edge_filter_90degree_4width_msa(uint8_t *dst, offset_mask0 = (v8i16) (__msa_hadd_u_h(diff_minus10, diff_minus10) + 2);