[FFmpeg-soc] [soc]: r821 - in dirac/libavcodec: dirac.c dirac_parser.c

marco subversion at mplayerhq.hu
Wed Aug 15 21:50:13 CEST 2007


Author: marco
Date: Wed Aug 15 21:50:13 2007
New Revision: 821

Log:
optimize loops

Modified:
   dirac/libavcodec/dirac.c
   dirac/libavcodec/dirac_parser.c

Modified: dirac/libavcodec/dirac.c
==============================================================================
--- dirac/libavcodec/dirac.c	(original)
+++ dirac/libavcodec/dirac.c	Wed Aug 15 21:50:13 2007
@@ -2016,10 +2016,11 @@ static int reference_frame_idx(DiracCont
  * @param pixels   buffer to write the interpolated pixels to
  * @param comp     component
  */
-static void interpolate_frame_halfpel(AVFrame *refframe,
+static inline void interpolate_frame_halfpel(AVFrame *refframe,
                                       int width, int height,
                                       uint8_t *pixels, int comp) {
     uint8_t *lineout;
+    uint8_t *lineoutodd;
     uint8_t *refdata;
     uint8_t *linein;
     int outwidth = width * 2;
@@ -2030,22 +2031,10 @@ START_TIMER
 
     refdata = refframe->data[comp];
 
-    /* Copy even lines.  */
     lineout = pixels;
+    lineoutodd = pixels + outwidth;
     linein = refdata;
     for (y = 0; y < height; y++) {
-        for (x = 0; x < width; x++)
-            lineout[x * 2] = linein[x];
-
-        /* Skip one line, we are copying to even lines.  */
-        lineout += outwidth * 2;
-
-        linein += refframe->linesize[comp];
-    }
-
-    /* Interpolate odd lines.  */
-    lineout = pixels + outwidth;
-    for (y = 0; y < height; y++) {
         for (x = 0; x < width; x++) {
             int i;
             int val = 0;
@@ -2066,42 +2055,45 @@ START_TIMER
 
             val += 128;
             val >>= 8;
-            lineout[x * 2] = av_clip_uint8(val);
+
+            lineout[x * 2] = linein[x];
+            lineoutodd[x * 2] = av_clip_uint8(val);
         }
 
+        linein += refframe->linesize[comp];
+
         /* Skip one line, we are interpolating to odd lines.  */
         lineout += outwidth * 2;
+        lineoutodd += outwidth * 2;
     }
 
     /* At this place the even rows of pixels are in place, no copying
        is required..  */
 
     /* Interpolate the odd rows of pixels.  */
-    lineout = pixels;
+    lineout = pixels + 1;
     linein  = pixels;
     for (y = 0; y < height * 2; y++) {
-        for (x = 0; x < width; x++) {
+        for (x = 0; x < outwidth; x += 2) {
             int i;
             int val = 0;
 
             for (i = 0; i <= 4; i++) {
                 int xpos;
-                xpos = x - i;
+                xpos = x - 2 * i;
                 /* The data that is called `ref2' in the specification
                    is stored in the even rows.  */
-                xpos *= 2;
                 val += t[i] * linein[FFMAX(xpos, 0)];
 
-                xpos = x + i + 1;
+                xpos = x + 2 * i + 2;
                 /* The data that is called `ref2' in the specification
                    is stored in the even rows.  */
-                xpos *= 2;
                 val += t[i] * linein[FFMIN(xpos, outwidth - 2)];
             }
 
             val += 128;
             val >>= 8;
-            lineout[x * 2 + 1] = av_clip_uint8(val);
+            lineout[x] = av_clip_uint8(val);
         }
         lineout += outwidth;
         linein  += outwidth;

Modified: dirac/libavcodec/dirac_parser.c
==============================================================================
--- dirac/libavcodec/dirac_parser.c	(original)
+++ dirac/libavcodec/dirac_parser.c	Wed Aug 15 21:50:13 2007
@@ -28,6 +28,8 @@
  */
 
 #include "parser.h"
+#undef printf
+#include <stdio.h>
 
 #define DEBUG 1
 
@@ -79,10 +81,10 @@ static int dirac_parse(AVCodecParserCont
 {
     ParseContext *pc = s->priv_data;
     int next;
-
-    if(s->flags & PARSER_FLAG_COMPLETE_FRAMES){
-        next = buf_size;
-    }else{
+    //        printf("XXXXXXXXX Foo\n");
+/*     if(s->flags & PARSER_FLAG_COMPLETE_FRAMES){ */
+/*         next = buf_size; */
+/*     }else */{
         next = find_frame_end(pc, buf, buf_size);
 
         if (ff_combine_frame(pc, next, &buf, &buf_size) < 0) {



More information about the FFmpeg-soc mailing list