[FFmpeg-cvslog] swscale/swscale: Get rid of the SWS_GAMMA_CORRECT flag

Michael Niedermayer git at videolan.org
Thu Apr 23 20:35:29 CEST 2015


ffmpeg | branch: master | Michael Niedermayer <michaelni at gmx.at> | Thu Apr 23 20:13:58 2015 +0200| [b57f9f57240a8143b7c64b8f3e94454dc8895b34] | committer: Michael Niedermayer

swscale/swscale: Get rid of the SWS_GAMMA_CORRECT flag

This avoids using up a bit of the public flags

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

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

 libswscale/swscale.c          |    2 +-
 libswscale/swscale.h          |    1 -
 libswscale/swscale_internal.h |    1 +
 libswscale/utils.c            |   22 +++++++++-------------
 4 files changed, 11 insertions(+), 15 deletions(-)

diff --git a/libswscale/swscale.c b/libswscale/swscale.c
index 8b244ef..5312016 100644
--- a/libswscale/swscale.c
+++ b/libswscale/swscale.c
@@ -369,7 +369,7 @@ static int swscale(SwsContext *c, const uint8_t *src[],
     int chrBufIndex  = c->chrBufIndex;
     int lastInLumBuf = c->lastInLumBuf;
     int lastInChrBuf = c->lastInChrBuf;
-    int perform_gamma = c->flags & SWS_GAMMA_CORRECT;
+    int perform_gamma = c->is_internal_gamma;
 
 
     if (!usePal(c->srcFormat)) {
diff --git a/libswscale/swscale.h b/libswscale/swscale.h
index 6e88323..903e120 100644
--- a/libswscale/swscale.h
+++ b/libswscale/swscale.h
@@ -64,7 +64,6 @@ const char *swscale_license(void);
 #define SWS_SINC          0x100
 #define SWS_LANCZOS       0x200
 #define SWS_SPLINE        0x400
-#define SWS_GAMMA_CORRECT 0x800
 
 #define SWS_SRC_V_CHR_DROP_MASK     0x30000
 #define SWS_SRC_V_CHR_DROP_SHIFT    16
diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h
index fad33b2..2299aa5 100644
--- a/libswscale/swscale_internal.h
+++ b/libswscale/swscale_internal.h
@@ -315,6 +315,7 @@ typedef struct SwsContext {
 
     double gamma_value;
     int gamma_flag;
+    int is_internal_gamma;
     uint16_t *gamma;
     uint16_t *inv_gamma;
 
diff --git a/libswscale/utils.c b/libswscale/utils.c
index d1cdf00..45e4b7c 100644
--- a/libswscale/utils.c
+++ b/libswscale/utils.c
@@ -1256,6 +1256,7 @@ av_cold int sws_init_context(SwsContext *c, SwsFilter *srcFilter,
 
 
     if (!unscaled && c->gamma_flag && (srcFormat != tmpFmt || dstFormat != tmpFmt)) {
+        SwsContext *c2;
         c->cascaded_context[0] = NULL;
 
         ret = av_image_alloc(c->cascaded_tmp, c->cascaded_tmpStride,
@@ -1272,11 +1273,18 @@ av_cold int sws_init_context(SwsContext *c, SwsFilter *srcFilter,
 
         c->cascaded_context[1] = sws_getContext(srcW, srcH, tmpFmt,
                                                 dstW, dstH, tmpFmt,
-                                                flags | SWS_GAMMA_CORRECT, srcFilter, dstFilter, c->param);
+                                                flags, srcFilter, dstFilter, c->param);
 
         if (!c->cascaded_context[1])
             return -1;
 
+        c2 = c->cascaded_context[1];
+        c2->is_internal_gamma = 1;
+        c2->gamma     = alloc_gamma_tbl(    c->gamma_value);
+        c2->inv_gamma = alloc_gamma_tbl(1.f/c->gamma_value);
+        if (!c2->gamma || !c2->inv_gamma)
+            return AVERROR(ENOMEM);
+
         c->cascaded_context[2] = NULL;
         if (dstFormat != tmpFmt) {
             ret = av_image_alloc(c->cascaded1_tmp, c->cascaded1_tmpStride,
@@ -1293,18 +1301,6 @@ av_cold int sws_init_context(SwsContext *c, SwsFilter *srcFilter,
         return 0;
     }
 
-    c->gamma = NULL;
-    c->inv_gamma = NULL;
-    if (c->flags & SWS_GAMMA_CORRECT) {
-        c->gamma = alloc_gamma_tbl(c->gamma_value);
-        if (!c->gamma)
-            return AVERROR(ENOMEM);
-        c->inv_gamma = alloc_gamma_tbl(1.f/c->gamma_value);
-        if (!c->inv_gamma) {
-            return AVERROR(ENOMEM);
-        }
-    }
-
     if (isBayer(srcFormat)) {
         if (!unscaled ||
             (dstFormat != AV_PIX_FMT_RGB24 && dstFormat != AV_PIX_FMT_YUV420P)) {



More information about the ffmpeg-cvslog mailing list