[FFmpeg-devel] [PATCH 2/6] hevcdsp: simplified sao_edge_filter

James Almer jamrial at gmail.com
Wed Feb 4 04:55:49 CET 2015


From: Seppo Tomperi <seppo.tomperi at vtt.fi>

---
 libavcodec/hevc_filter.c      |  2 +-
 libavcodec/hevcdsp.h          |  2 +-
 libavcodec/hevcdsp_template.c | 36 ++++++++++++++++--------------------
 3 files changed, 18 insertions(+), 22 deletions(-)

diff --git a/libavcodec/hevc_filter.c b/libavcodec/hevc_filter.c
index bd00da5..b002d87 100644
--- a/libavcodec/hevc_filter.c
+++ b/libavcodec/hevc_filter.c
@@ -427,7 +427,7 @@ static void sao_filter_CTB(HEVCContext *s, int x, int y)
 
             copy_CTB_to_hv(s, src, stride_src, x0, y0, width, height, c_idx,
                            x_ctb, y_ctb);
-            s->hevcdsp.sao_edge_filter(src, dst, stride_src, stride_dst, sao, width, height, c_idx, 0, 0);
+            s->hevcdsp.sao_edge_filter(src, dst, stride_src, stride_dst, sao, width, height, c_idx);
             s->hevcdsp.sao_edge_restore[restore](src, dst,
                                                 stride_src, stride_dst,
                                                 sao,
diff --git a/libavcodec/hevcdsp.h b/libavcodec/hevcdsp.h
index c71b34f..53d7b1b 100644
--- a/libavcodec/hevcdsp.h
+++ b/libavcodec/hevcdsp.h
@@ -63,7 +63,7 @@ typedef struct HEVCDSPContext {
 
     void (*sao_edge_filter)(uint8_t *_dst, uint8_t *_src, ptrdiff_t stride_dst,
                             ptrdiff_t stride_src, SAOParams *sao, int width,
-                            int height, int c_idx, int init_x, int init_y);
+                            int height, int c_idx);
 
     void (*sao_edge_restore[2])(uint8_t *_dst, uint8_t *_src, ptrdiff_t _stride_dst, ptrdiff_t _stride_src,
                                 struct SAOParams *sao, int *borders, int _width, int _height, int c_idx,
diff --git a/libavcodec/hevcdsp_template.c b/libavcodec/hevcdsp_template.c
index 37c30b9..d372c9a 100644
--- a/libavcodec/hevcdsp_template.c
+++ b/libavcodec/hevcdsp_template.c
@@ -330,7 +330,7 @@ static void FUNC(sao_band_filter_0)(uint8_t *_dst, uint8_t *_src,
 static void FUNC(sao_edge_filter)(uint8_t *_dst, uint8_t *_src,
                                   ptrdiff_t stride_dst, ptrdiff_t stride_src, SAOParams *sao,
                                   int width, int height,
-                                  int c_idx, int init_x, int init_y) {
+                                  int c_idx) {
 
     static const uint8_t edge_idx[] = { 1, 2, 0, 3, 4 };
     static const int8_t pos[4][2][2] = {
@@ -340,31 +340,27 @@ static void FUNC(sao_edge_filter)(uint8_t *_dst, uint8_t *_src,
         { {  1, -1 }, { -1, 1 } }, // 135 degree
     };
     int16_t *sao_offset_val = sao->offset_val[c_idx];
-    int sao_eo_class    = sao->eo_class[c_idx];
+    int eo     = sao->eo_class[c_idx];
     pixel *dst = (pixel *)_dst;
     pixel *src = (pixel *)_src;
-
-    int y_stride_src = init_y * (stride_src /= sizeof(pixel));
-    int y_stride_dst = init_y * (stride_dst /= sizeof(pixel));
-    int pos_0_0  = pos[sao_eo_class][0][0];
-    int pos_0_1  = pos[sao_eo_class][0][1];
-    int pos_1_0  = pos[sao_eo_class][1][0];
-    int pos_1_1  = pos[sao_eo_class][1][1];
+    int a_stride, b_stride;
+    int src_offset = 0;
+    int dst_offset = 0;
     int x, y;
+    stride_src /= sizeof(pixel);
+    stride_dst /= sizeof(pixel);
 
-    int y_stride_0_1 = (init_y + pos_0_1) * stride_src;
-    int y_stride_1_1 = (init_y + pos_1_1) * stride_src;
-    for (y = init_y; y < height; y++) {
-        for (x = init_x; x < width; x++) {
-            int diff0             = CMP(src[x + y_stride_src], src[x + pos_0_0 + y_stride_0_1]);
-            int diff1             = CMP(src[x + y_stride_src], src[x + pos_1_0 + y_stride_1_1]);
+    a_stride = pos[eo][0][0] + pos[eo][0][1] * stride_src;
+    b_stride = pos[eo][1][0] + pos[eo][1][1] * stride_src;
+    for (y = 0; y < height; y++) {
+        for (x = 0; x < width; x++) {
+            int diff0 = CMP(src[x + src_offset], src[x + src_offset + a_stride]);
+            int diff1 = CMP(src[x + src_offset], src[x + src_offset + b_stride]);
             int offset_val        = edge_idx[2 + diff0 + diff1];
-            dst[x + y_stride_dst] = av_clip_pixel(src[x + y_stride_src] + sao_offset_val[offset_val]);
+            dst[x + dst_offset] = av_clip_pixel(src[x + src_offset] + sao_offset_val[offset_val]);
         }
-        y_stride_src += stride_src;
-        y_stride_dst += stride_dst;
-        y_stride_0_1 += stride_src;
-        y_stride_1_1 += stride_src;
+        src_offset += stride_src;
+        dst_offset += stride_dst;
     }
 }
 
-- 
2.2.2



More information about the ffmpeg-devel mailing list