[FFmpeg-devel,8/9] avcodec/gdv: Optimize 2x scaling loop a little in gdv_decode_frame()

Submitted by Michael Niedermayer on Aug. 5, 2018, 8:29 p.m.

Details

Message ID 20180805202937.7563-8-michael@niedermayer.cc
State New
Headers show

Commit Message

Michael Niedermayer Aug. 5, 2018, 8:29 p.m.
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavcodec/gdv.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/libavcodec/gdv.c b/libavcodec/gdv.c
index 1623febd1a..d497f76157 100644
--- a/libavcodec/gdv.c
+++ b/libavcodec/gdv.c
@@ -481,8 +481,12 @@  static int gdv_decode_frame(AVCodecContext *avctx, void *data,
             if (!gdv->scale_v) {
                 memcpy(dst + didx, gdv->frame + sidx, avctx->width);
             } else {
-                for (x = 0; x < avctx->width; x++) {
-                    dst[didx + x] = gdv->frame[sidx + x/2];
+                for (x = 0; x < avctx->width - 1; x+=2) {
+                    dst[didx + x    ] =
+                    dst[didx + x + 1] = gdv->frame[sidx + (x>>1)];
+                }
+                for (; x < avctx->width; x++) {
+                    dst[didx + x] = gdv->frame[sidx + (x>>1)];
                 }
             }
             if (!gdv->scale_h || ((y & 1) == 1)) {