[FFmpeg-devel] [libswscale PATCH] Invert logic for the single-pass in swScale() functions.

Diego 'Flameeyes' Pettenò flameeyes
Thu Oct 9 01:04:37 CEST 2008

Instead of having a firstTime variable defaulting to 1, have a
passedAlready defaulting to 0. While this should make no difference in
code speed at runtime, it allows to aggregate the four bytes of that
variable with clip_table in .bss section, rather than issuing a .data
section just for that.

As it is, libswscale require no .data section but .data.rel.ro (that
can be mitigated by prelinking), so the change might actually save one
page of memory at runtime (per process).

 swscale_template.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/swscale_template.c b/swscale_template.c
index 12b0546..7575da6 100644
--- a/swscale_template.c
+++ b/swscale_template.c
@@ -2964,12 +2964,12 @@ static int RENAME(swScale)(SwsContext *c, uint8_t* src[], int srcStride[], int s
     if (dstStride[0]%8 !=0 || dstStride[1]%8 !=0 || dstStride[2]%8 !=0)
-        static int firstTime=1; //FIXME move this into the context perhaps
-        if (flags & SWS_PRINT_INFO && firstTime)
+        static int passedAlready=0; //FIXME move this into the context perhaps
+        if (flags & SWS_PRINT_INFO && !passedAlready)
             av_log(c, AV_LOG_WARNING, "Warning: dstStride is not aligned!\n"
                    "         ->cannot do aligned memory accesses anymore\n");
-            firstTime=0;
+            passedAlready=1;

More information about the ffmpeg-devel mailing list