diff mbox

[FFmpeg-devel] avcodec/mips: Improve vp9 lpf msa functions

Message ID 70293ACCC3BA6A4E81FFCA024C7A86E1E058FEE1@PUMAIL01.pu.imgtec.org
State New
Headers show

Commit Message

Manojkumar Bhosale Sept. 7, 2017, 9 a.m. UTC
LGTM

-----Original Message-----
From: ffmpeg-devel [mailto:ffmpeg-devel-bounces@ffmpeg.org] On Behalf Of kaustubh.raste@imgtec.com

Sent: Monday, September 4, 2017 6:02 PM
To: ffmpeg-devel@ffmpeg.org
Cc: Kaustubh Raste
Subject: [FFmpeg-devel] [PATCH] avcodec/mips: Improve vp9 lpf msa functions

From: Kaustubh Raste <kaustubh.raste@imgtec.com>


Updated VP9_LPF_FILTER4_4W macro to process on 8 bit data.
Replaced VP9_LPF_FILTER4_8W with VP9_LPF_FILTER4_4W.

Signed-off-by: Kaustubh Raste <kaustubh.raste@imgtec.com>

---
 libavcodec/mips/vp9_lpf_msa.c |   94 ++++++-----------------------------------
 1 file changed, 14 insertions(+), 80 deletions(-)

 
     LPF_MASK_HEV(p3, p2, p1, p0, q0, q1, q2, q3, limit, b_limit, thresh,
                  hev, mask, flat);
-    VP9_LPF_FILTER4_8W(p1, p0, q0, q1, mask, hev, p1_out, p0_out, q0_out,
+    VP9_LPF_FILTER4_4W(p1, p0, q0, q1, mask, hev, p1_out, p0_out, 
+ q0_out,
                        q1_out);
 
     p1_d = __msa_copy_u_d((v2i64) p1_out, 0); @@ -342,7 +276,7 @@ void ff_loop_filter_v_8_8_msa(uint8_t *src, ptrdiff_t pitch,
     LPF_MASK_HEV(p3, p2, p1, p0, q0, q1, q2, q3, limit, b_limit, thresh,
                  hev, mask, flat);
     VP9_FLAT4(p3, p2, p0, q0, q2, q3, flat);
-    VP9_LPF_FILTER4_8W(p1, p0, q0, q1, mask, hev, p1_out, p0_out, q0_out,
+    VP9_LPF_FILTER4_4W(p1, p0, q0, q1, mask, hev, p1_out, p0_out, 
+ q0_out,
                        q1_out);
 
     flat = (v16u8) __msa_ilvr_d((v2i64) zero, (v2i64) flat); @@ -1065,7 +999,7 @@ void ff_loop_filter_v_16_8_msa(uint8_t *src, ptrdiff_t pitch,
     LPF_MASK_HEV(p3, p2, p1, p0, q0, q1, q2, q3, limit, b_limit, thresh,
                  hev, mask, flat);
     VP9_FLAT4(p3, p2, p0, q0, q2, q3, flat);
-    VP9_LPF_FILTER4_8W(p1, p0, q0, q1, mask, hev, p1_out, p0_out, q0_out,
+    VP9_LPF_FILTER4_4W(p1, p0, q0, q1, mask, hev, p1_out, p0_out, 
+ q0_out,
                        q1_out);
 
     flat = (v16u8) __msa_ilvr_d((v2i64) zero, (v2i64) flat); @@ -1280,7 +1214,7 @@ void ff_loop_filter_h_4_8_msa(uint8_t *src, ptrdiff_t pitch,
                        p3, p2, p1, p0, q0, q1, q2, q3);
     LPF_MASK_HEV(p3, p2, p1, p0, q0, q1, q2, q3, limit, b_limit, thresh,
                  hev, mask, flat);
-    VP9_LPF_FILTER4_8W(p1, p0, q0, q1, mask, hev, p1, p0, q0, q1);
+    VP9_LPF_FILTER4_4W(p1, p0, q0, q1, mask, hev, p1, p0, q0, q1);
     ILVR_B2_SH(p0, p1, q1, q0, vec0, vec1);
     ILVRL_H2_SH(vec1, vec0, vec2, vec3);
 
@@ -1367,7 +1301,7 @@ void ff_loop_filter_h_8_8_msa(uint8_t *src, ptrdiff_t pitch,
     /* flat4 */
     VP9_FLAT4(p3, p2, p0, q0, q2, q3, flat);
     /* filter4 */
-    VP9_LPF_FILTER4_8W(p1, p0, q0, q1, mask, hev, p1_out, p0_out, q0_out,
+    VP9_LPF_FILTER4_4W(p1, p0, q0, q1, mask, hev, p1_out, p0_out, 
+ q0_out,
                        q1_out);
 
     flat = (v16u8) __msa_ilvr_d((v2i64) zero, (v2i64) flat); @@ -1868,7 +1802,7 @@ static int32_t vp9_vt_lpf_t4_and_t8_8w(uint8_t *src, uint8_t *filter48,
     /* flat4 */
     VP9_FLAT4(p3, p2, p0, q0, q2, q3, flat);
     /* filter4 */
-    VP9_LPF_FILTER4_8W(p1, p0, q0, q1, mask, hev, p1_out, p0_out, q0_out,
+    VP9_LPF_FILTER4_4W(p1, p0, q0, q1, mask, hev, p1_out, p0_out, 
+ q0_out,
                        q1_out);
 
     flat = (v16u8) __msa_ilvr_d((v2i64) zero, (v2i64) flat);
--
1.7.9.5

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

Comments

Michael Niedermayer Sept. 8, 2017, 11:44 a.m. UTC | #1
On Thu, Sep 07, 2017 at 09:00:01AM +0000, Manojkumar Bhosale wrote:
> LGTM

applied

thanks

[...]
diff mbox

Patch

diff --git a/libavcodec/mips/vp9_lpf_msa.c b/libavcodec/mips/vp9_lpf_msa.c index eef8afc..c82a9e9 100644
--- a/libavcodec/mips/vp9_lpf_msa.c
+++ b/libavcodec/mips/vp9_lpf_msa.c
@@ -1,5 +1,5 @@ 
 /*
- * Copyright (c) 2015 Shivraj Patil (Shivraj.Patil@imgtec.com)
+ * Copyright (c) 2015 - 2017 Shivraj Patil (Shivraj.Patil@imgtec.com)
  *
  * This file is part of FFmpeg.
  *
@@ -22,63 +22,12 @@ 
 #include "libavutil/mips/generic_macros_msa.h"
 #include "vp9dsp_mips.h"
 
-#define VP9_LPF_FILTER4_8W(p1_in, p0_in, q0_in, q1_in, mask_in, hev_in,  \
-                           p1_out, p0_out, q0_out, q1_out)               \
-{                                                                        \
-    v16i8 p1_m, p0_m, q0_m, q1_m, q0_sub_p0, filt_sign;                  \
-    v16i8 filt, filt1, filt2, cnst4b, cnst3b;                            \
-    v8i16 q0_sub_p0_r, filt_r, cnst3h;                                   \
-                                                                         \
-    p1_m = (v16i8) __msa_xori_b(p1_in, 0x80);                            \
-    p0_m = (v16i8) __msa_xori_b(p0_in, 0x80);                            \
-    q0_m = (v16i8) __msa_xori_b(q0_in, 0x80);                            \
-    q1_m = (v16i8) __msa_xori_b(q1_in, 0x80);                            \
-                                                                         \
-    filt = __msa_subs_s_b(p1_m, q1_m);                                   \
-    filt = filt & (v16i8) hev_in;                                        \
-    q0_sub_p0 = q0_m - p0_m;                                             \
-    filt_sign = __msa_clti_s_b(filt, 0);                                 \
-                                                                         \
-    cnst3h = __msa_ldi_h(3);                                             \
-    q0_sub_p0_r = (v8i16) __msa_ilvr_b(q0_sub_p0, q0_sub_p0);            \
-    q0_sub_p0_r = __msa_dotp_s_h((v16i8) q0_sub_p0_r, (v16i8) cnst3h);   \
-    filt_r = (v8i16) __msa_ilvr_b(filt_sign, filt);                      \
-    filt_r += q0_sub_p0_r;                                               \
-    filt_r = __msa_sat_s_h(filt_r, 7);                                   \
-                                                                         \
-    /* combine left and right part */                                    \
-    filt = __msa_pckev_b((v16i8) filt_r, (v16i8) filt_r);                \
-                                                                         \
-    filt = filt & (v16i8) mask_in;                                       \
-    cnst4b = __msa_ldi_b(4);                                             \
-    filt1 = __msa_adds_s_b(filt, cnst4b);                                \
-    filt1 >>= 3;                                                         \
-                                                                         \
-    cnst3b = __msa_ldi_b(3);                                             \
-    filt2 = __msa_adds_s_b(filt, cnst3b);                                \
-    filt2 >>= 3;                                                         \
-                                                                         \
-    q0_m = __msa_subs_s_b(q0_m, filt1);                                  \
-    q0_out = __msa_xori_b((v16u8) q0_m, 0x80);                           \
-    p0_m = __msa_adds_s_b(p0_m, filt2);                                  \
-    p0_out = __msa_xori_b((v16u8) p0_m, 0x80);                           \
-                                                                         \
-    filt = __msa_srari_b(filt1, 1);                                      \
-    hev_in = __msa_xori_b((v16u8) hev_in, 0xff);                         \
-    filt = filt & (v16i8) hev_in;                                        \
-                                                                         \
-    q1_m = __msa_subs_s_b(q1_m, filt);                                   \
-    q1_out = __msa_xori_b((v16u8) q1_m, 0x80);                           \
-    p1_m = __msa_adds_s_b(p1_m, filt);                                   \
-    p1_out = __msa_xori_b((v16u8) p1_m, 0x80);                           \
-}
-
 #define VP9_LPF_FILTER4_4W(p1_in, p0_in, q0_in, q1_in, mask_in, hev_in,  \
                            p1_out, p0_out, q0_out, q1_out)               \
 {                                                                        \
-    v16i8 p1_m, p0_m, q0_m, q1_m, q0_sub_p0, filt_sign;                  \
-    v16i8 filt, filt1, filt2, cnst4b, cnst3b;                            \
-    v8i16 q0_sub_p0_r, q0_sub_p0_l, filt_l, filt_r, cnst3h;              \
+    v16i8 p1_m, p0_m, q0_m, q1_m, q0_sub_p0, filt, filt1, filt2;         \
+    const v16i8 cnst4b = __msa_ldi_b(4);                                 \
+    const v16i8 cnst3b = __msa_ldi_b(3);                                 \
                                                                          \
     p1_m = (v16i8) __msa_xori_b(p1_in, 0x80);                            \
     p0_m = (v16i8) __msa_xori_b(p0_in, 0x80);                            \
@@ -89,30 +38,15 @@ 
                                                                          \
     filt = filt & (v16i8) hev_in;                                        \
                                                                          \
-    q0_sub_p0 = q0_m - p0_m;                                             \
-    filt_sign = __msa_clti_s_b(filt, 0);                                 \
-                                                                         \
-    cnst3h = __msa_ldi_h(3);                                             \
-    q0_sub_p0_r = (v8i16) __msa_ilvr_b(q0_sub_p0, q0_sub_p0);            \
-    q0_sub_p0_r = __msa_dotp_s_h((v16i8) q0_sub_p0_r, (v16i8) cnst3h);   \
-    filt_r = (v8i16) __msa_ilvr_b(filt_sign, filt);                      \
-    filt_r += q0_sub_p0_r;                                               \
-    filt_r = __msa_sat_s_h(filt_r, 7);                                   \
-                                                                         \
-    q0_sub_p0_l = (v8i16) __msa_ilvl_b(q0_sub_p0, q0_sub_p0);            \
-    q0_sub_p0_l = __msa_dotp_s_h((v16i8) q0_sub_p0_l, (v16i8) cnst3h);   \
-    filt_l = (v8i16) __msa_ilvl_b(filt_sign, filt);                      \
-    filt_l += q0_sub_p0_l;                                               \
-    filt_l = __msa_sat_s_h(filt_l, 7);                                   \
-                                                                         \
-    filt = __msa_pckev_b((v16i8) filt_l, (v16i8) filt_r);                \
+    q0_sub_p0 = __msa_subs_s_b(q0_m, p0_m);                              \
+    filt = __msa_adds_s_b(filt, q0_sub_p0);                              \
+    filt = __msa_adds_s_b(filt, q0_sub_p0);                              \
+    filt = __msa_adds_s_b(filt, q0_sub_p0);                              \
     filt = filt & (v16i8) mask_in;                                       \
                                                                          \
-    cnst4b = __msa_ldi_b(4);                                             \
     filt1 = __msa_adds_s_b(filt, cnst4b);                                \
     filt1 >>= 3;                                                         \
                                                                          \
-    cnst3b = __msa_ldi_b(3);                                             \
     filt2 = __msa_adds_s_b(filt, cnst3b);                                \
     filt2 >>= 3;                                                         \
                                                                          \ @@ -277,7 +211,7 @@ void ff_loop_filter_v_4_8_msa(uint8_t *src, ptrdiff_t pitch,