]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/rv40dsp.c
Merge remote-tracking branch 'qatar/master'
[ffmpeg] / libavcodec / rv40dsp.c
index 913ced046d4347dc0139db2c65bbff3c4ee203b1..8ba10beac8e6d67e6ab22e2789bab4134bd311f6 100644 (file)
@@ -278,7 +278,7 @@ RV40_CHROMA_MC(put_, op_put)
 RV40_CHROMA_MC(avg_, op_avg)
 
 #define RV40_WEIGHT_FUNC(size) \
-static void rv40_weight_func_ ## size (uint8_t *dst, uint8_t *src1, uint8_t *src2, int w1, int w2, int stride)\
+static void rv40_weight_func_rnd_ ## size (uint8_t *dst, uint8_t *src1, uint8_t *src2, int w1, int w2, ptrdiff_t stride)\
 {\
     int i, j;\
 \
@@ -289,6 +289,18 @@ static void rv40_weight_func_ ## size (uint8_t *dst, uint8_t *src1, uint8_t *src
         src2 += stride;\
         dst  += stride;\
     }\
+}\
+static void rv40_weight_func_nornd_ ## size (uint8_t *dst, uint8_t *src1, uint8_t *src2, int w1, int w2, ptrdiff_t stride)\
+{\
+    int i, j;\
+\
+    for (j = 0; j < size; j++) {\
+        for (i = 0; i < size; i++)\
+            dst[i] = (w2 * src1[i] + w1 * src2[i] + 0x10) >> 5;\
+        src1 += stride;\
+        src2 += stride;\
+        dst  += stride;\
+    }\
 }
 
 RV40_WEIGHT_FUNC(16)
@@ -316,7 +328,7 @@ static const uint8_t rv40_dither_r[16] = {
  */
 static av_always_inline void rv40_weak_loop_filter(uint8_t *src,
                                                    const int step,
-                                                   const int stride,
+                                                   const ptrdiff_t stride,
                                                    const int filter_p1,
                                                    const int filter_q1,
                                                    const int alpha,
@@ -362,7 +374,7 @@ static av_always_inline void rv40_weak_loop_filter(uint8_t *src,
     }
 }
 
-static void rv40_h_weak_loop_filter(uint8_t *src, const int stride,
+static void rv40_h_weak_loop_filter(uint8_t *src, const ptrdiff_t stride,
                                     const int filter_p1, const int filter_q1,
                                     const int alpha, const int beta,
                                     const int lim_p0q0, const int lim_q1,
@@ -372,7 +384,7 @@ static void rv40_h_weak_loop_filter(uint8_t *src, const int stride,
                           alpha, beta, lim_p0q0, lim_q1, lim_p1);
 }
 
-static void rv40_v_weak_loop_filter(uint8_t *src, const int stride,
+static void rv40_v_weak_loop_filter(uint8_t *src, const ptrdiff_t stride,
                                     const int filter_p1, const int filter_q1,
                                     const int alpha, const int beta,
                                     const int lim_p0q0, const int lim_q1,
@@ -384,7 +396,7 @@ static void rv40_v_weak_loop_filter(uint8_t *src, const int stride,
 
 static av_always_inline void rv40_strong_loop_filter(uint8_t *src,
                                                      const int step,
-                                                     const int stride,
+                                                     const ptrdiff_t stride,
                                                      const int alpha,
                                                      const int lims,
                                                      const int dmode,
@@ -440,14 +452,14 @@ static av_always_inline void rv40_strong_loop_filter(uint8_t *src,
     }
 }
 
-static void rv40_h_strong_loop_filter(uint8_t *src, const int stride,
+static void rv40_h_strong_loop_filter(uint8_t *src, const ptrdiff_t stride,
                                       const int alpha, const int lims,
                                       const int dmode, const int chroma)
 {
     rv40_strong_loop_filter(src, stride, 1, alpha, lims, dmode, chroma);
 }
 
-static void rv40_v_strong_loop_filter(uint8_t *src, const int stride,
+static void rv40_v_strong_loop_filter(uint8_t *src, const ptrdiff_t stride,
                                       const int alpha, const int lims,
                                       const int dmode, const int chroma)
 {
@@ -455,7 +467,7 @@ static void rv40_v_strong_loop_filter(uint8_t *src, const int stride,
 }
 
 static av_always_inline int rv40_loop_filter_strength(uint8_t *src,
-                                                      int step, int stride,
+                                                      int step, ptrdiff_t stride,
                                                       int beta, int beta2,
                                                       int edge,
                                                       int *p1, int *q1)
@@ -490,14 +502,14 @@ static av_always_inline int rv40_loop_filter_strength(uint8_t *src,
     return strong0 && strong1;
 }
 
-static int rv40_h_loop_filter_strength(uint8_t *src, int stride,
+static int rv40_h_loop_filter_strength(uint8_t *src, ptrdiff_t stride,
                                        int beta, int beta2, int edge,
                                        int *p1, int *q1)
 {
     return rv40_loop_filter_strength(src, stride, 1, beta, beta2, edge, p1, q1);
 }
 
-static int rv40_v_loop_filter_strength(uint8_t *src, int stride,
+static int rv40_v_loop_filter_strength(uint8_t *src, ptrdiff_t stride,
                                        int beta, int beta2, int edge,
                                        int *p1, int *q1)
 {
@@ -578,8 +590,10 @@ av_cold void ff_rv40dsp_init(RV34DSPContext *c, DSPContext* dsp) {
     c->avg_chroma_pixels_tab[0] = avg_rv40_chroma_mc8_c;
     c->avg_chroma_pixels_tab[1] = avg_rv40_chroma_mc4_c;
 
-    c->rv40_weight_pixels_tab[0] = rv40_weight_func_16;
-    c->rv40_weight_pixels_tab[1] = rv40_weight_func_8;
+    c->rv40_weight_pixels_tab[0][0] = rv40_weight_func_rnd_16;
+    c->rv40_weight_pixels_tab[0][1] = rv40_weight_func_rnd_8;
+    c->rv40_weight_pixels_tab[1][0] = rv40_weight_func_nornd_16;
+    c->rv40_weight_pixels_tab[1][1] = rv40_weight_func_nornd_8;
 
     c->rv40_weak_loop_filter[0]     = rv40_h_weak_loop_filter;
     c->rv40_weak_loop_filter[1]     = rv40_v_weak_loop_filter;