swscale/swscale: Get rid of the SWS_GAMMA_CORRECT flag
authorMichael Niedermayer <michaelni@gmx.at>
Thu, 23 Apr 2015 18:13:58 +0000 (20:13 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Thu, 23 Apr 2015 18:34:51 +0000 (20:34 +0200)
This avoids using up a bit of the public flags

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
libswscale/swscale.c
libswscale/swscale.h
libswscale/swscale_internal.h
libswscale/utils.c

index 8b244ef..5312016 100644 (file)
@@ -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)) {
index 6e88323..903e120 100644 (file)
@@ -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
index fad33b2..2299aa5 100644 (file)
@@ -315,6 +315,7 @@ typedef struct SwsContext {
 
     double gamma_value;
     int gamma_flag;
+    int is_internal_gamma;
     uint16_t *gamma;
     uint16_t *inv_gamma;
 
index d1cdf00..45e4b7c 100644 (file)
@@ -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)) {