[FFmpeg-cvslog] sws: share xyzgamma tables.

Michael Niedermayer git at videolan.org
Wed May 1 17:52:42 CEST 2013


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Wed May  1 17:45:33 2013 +0200| [2514b80045d56411343df80f07276817b5f0d1b0] | committer: Michael Niedermayer

sws: share xyzgamma tables.

They are currently always constant and thus theres no point to
store them in the context.
This makes the context 16kb smaller

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>

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

 libswscale/swscale_internal.h |    4 ++--
 libswscale/utils.c            |   13 ++++++++++---
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h
index 36ce1ea..c4ea26f 100644
--- a/libswscale/swscale_internal.h
+++ b/libswscale/swscale_internal.h
@@ -478,8 +478,8 @@ typedef struct SwsContext {
 /* pre defined color-spaces gamma */
 #define XYZ_GAMMA (2.6f)
 #define RGB_GAMMA (2.2f)
-    int16_t xyzgamma[4096];
-    int16_t rgbgamma[4096];
+    int16_t *xyzgamma;
+    int16_t *rgbgamma;
     int16_t xyz2rgb_matrix[3][4];
 
     /* function pointers for swScale() */
diff --git a/libswscale/utils.c b/libswscale/utils.c
index f13fec8..f013940 100644
--- a/libswscale/utils.c
+++ b/libswscale/utils.c
@@ -904,13 +904,20 @@ static void fill_xyztables(struct SwsContext *c)
         {13270, -6295, -2041},
         {-3969,  7682,   170},
         {  228,  -835,  4329} };
+    static int16_t xyzgamma_tab[4096], rgbgamma_tab[4096];
+
+    memcpy(c->xyz2rgb_matrix, xyz2rgb_matrix, sizeof(c->xyz2rgb_matrix));
+    c->xyzgamma = xyzgamma_tab;
+    c->rgbgamma = rgbgamma_tab;
+
+    if (rgbgamma_tab[4095])
+        return;
 
     /* set gamma vectors */
     for (i = 0; i < 4096; i++) {
-        c->xyzgamma[i] = lrint(pow(i / 4095.0, xyzgamma) * 4095.0);
-        c->rgbgamma[i] = lrint(pow(i / 4095.0, rgbgamma) * 4095.0);
+        xyzgamma_tab[i] = lrint(pow(i / 4095.0, xyzgamma) * 4095.0);
+        rgbgamma_tab[i] = lrint(pow(i / 4095.0, rgbgamma) * 4095.0);
     }
-    memcpy(c->xyz2rgb_matrix, xyz2rgb_matrix, sizeof(c->xyz2rgb_matrix));
 }
 
 int sws_setColorspaceDetails(struct SwsContext *c, const int inv_table[4],



More information about the ffmpeg-cvslog mailing list