[FFmpeg-cvslog] avcodec/gdv: Factor terms out of inner loops in rescale()

Michael Niedermayer git at videolan.org
Fri Sep 28 02:29:25 EEST 2018


ffmpeg | branch: master | Michael Niedermayer <michael at niedermayer.cc> | Sun Aug  5 16:29:13 2018 +0200| [a423970511bc3b271a1e4202f3bcf60773de657b] | committer: Michael Niedermayer

avcodec/gdv: Factor terms out of inner loops in rescale()

This also replaces some loops by memcpy()

Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a423970511bc3b271a1e4202f3bcf60773de657b
---

 libavcodec/gdv.c | 27 +++++++++++++++++----------
 1 file changed, 17 insertions(+), 10 deletions(-)

diff --git a/libavcodec/gdv.c b/libavcodec/gdv.c
index 79ca157dde..274552a7be 100644
--- a/libavcodec/gdv.c
+++ b/libavcodec/gdv.c
@@ -83,44 +83,51 @@ static void rescale(GDVContext *gdv, uint8_t *dst, int w, int h, int scale_v, in
     if (gdv->scale_h && gdv->scale_v) {
         for (j = 0; j < h; j++) {
             int y = h - j - 1;
+            uint8_t *dst1 = dst + PREAMBLE_SIZE + y * w;
+            uint8_t *src1 = dst + PREAMBLE_SIZE + (y>>1) * (w>>1);
             for (i = 0; i < w; i++) {
                 int x = w - i - 1;
-                dst[PREAMBLE_SIZE + x + y * w] = dst[PREAMBLE_SIZE + (x>>1) + (y>>1) * (w>>1)];
+                dst1[x] = src1[(x>>1)];
             }
         }
     } else if (gdv->scale_h) {
         for (j = 0; j < h; j++) {
             int y = h - j - 1;
-            for (x = 0; x < w; x++) {
-                dst[PREAMBLE_SIZE + x + y * w] = dst[PREAMBLE_SIZE + x + (y>>1) * w];
-            }
+            uint8_t *dst1 = dst + PREAMBLE_SIZE + y * w;
+            uint8_t *src1 = dst + PREAMBLE_SIZE + (y>>1) * w;
+            memcpy(dst1, src1, w);
         }
     } else if (gdv->scale_v) {
         for (j = 0; j < h; j++) {
             int y = h - j - 1;
+            uint8_t *dst1 = dst + PREAMBLE_SIZE + y * w;
+            uint8_t *src1 = dst + PREAMBLE_SIZE + y * (w>>1);
             for (i = 0; i < w; i++) {
                 int x = w - i - 1;
-                dst[PREAMBLE_SIZE + x + y * w] = dst[PREAMBLE_SIZE + (x>>1) + y * (w>>1)];
+                dst1[x] = src1[(x>>1)];
             }
         }
     }
 
     if (scale_h && scale_v) {
         for (y = 0; y < (h>>1); y++) {
+            uint8_t *dst1 = dst + PREAMBLE_SIZE + y * (w>>1);
+            uint8_t *src1 = dst + PREAMBLE_SIZE + y*2 * w;
             for (x = 0; x < (w>>1); x++) {
-                dst[PREAMBLE_SIZE + x + y * (w>>1)] = dst[PREAMBLE_SIZE + x*2 + y*2 * w];
+                dst1[x] = src1[x*2];
             }
         }
     } else if (scale_h) {
         for (y = 0; y < (h>>1); y++) {
-            for (x = 0; x < w; x++) {
-                dst[PREAMBLE_SIZE + x + y * w] = dst[PREAMBLE_SIZE + x + y*2 * w];
-            }
+            uint8_t *dst1 = dst + PREAMBLE_SIZE + y * w;
+            uint8_t *src1 = dst + PREAMBLE_SIZE + y*2 * w;
+            memcpy(dst1, src1, w);
         }
     } else if (scale_v) {
         for (y = 0; y < h; y++) {
+            uint8_t *dst1 = dst + PREAMBLE_SIZE + y * w;
             for (x = 0; x < (w>>1); x++) {
-                dst[PREAMBLE_SIZE + x + y * w] = dst[PREAMBLE_SIZE + x*2 + y * w];
+                dst1[x] = dst1[x*2];
             }
         }
     }



More information about the ffmpeg-cvslog mailing list