[FFmpeg-cvslog] fraps: optimize pseudo-YUV to RGB conversion.

Reimar Döffinger git at videolan.org
Sun Jan 29 17:35:03 CET 2012


ffmpeg | branch: master | Reimar Döffinger <Reimar.Doeffinger at gmx.de> | Sun Jan 29 15:40:48 2012 +0100| [7fabef1f014eea1c7b4a0eed789b7a4e8c76ad5f] | committer: Reimar Döffinger

fraps: optimize pseudo-YUV to RGB conversion.

With gcc 4.6 this part of the code is ca. 4x faster, resulting
in an overall speedup of around 5% for fate-fraps-v5 sample.

Signed-off-by: Reimar Döffinger <Reimar.Doeffinger at gmx.de>

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

 libavcodec/fraps.c |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/libavcodec/fraps.c b/libavcodec/fraps.c
index 99387b5..27df547 100644
--- a/libavcodec/fraps.c
+++ b/libavcodec/fraps.c
@@ -140,6 +140,7 @@ static int decode_frame(AVCodecContext *avctx,
     uint32_t offs[4];
     int i, j, is_chroma;
     const int planes = 3;
+    uint8_t *out;
 
 
     header = AV_RL32(buf);
@@ -281,12 +282,16 @@ static int decode_frame(AVCodecContext *avctx,
                 return -1;
             }
         }
+        out = f->data[0];
         // convert pseudo-YUV into real RGB
         for(j = 0; j < avctx->height; j++){
-            for(i = 0; i < avctx->width; i++){
-                f->data[0][0 + i*3 + j*f->linesize[0]] += f->data[0][1 + i*3 + j*f->linesize[0]];
-                f->data[0][2 + i*3 + j*f->linesize[0]] += f->data[0][1 + i*3 + j*f->linesize[0]];
+            uint8_t *line_end = out + 3*avctx->width;
+            while (out < line_end) {
+                out[0]  += out[1];
+                out[2]  += out[1];
+                out += 3;
             }
+            out += f->linesize[0] - 3*avctx->width;
         }
         break;
     }



More information about the ffmpeg-cvslog mailing list