summaryrefslogtreecommitdiffstats
path: root/libswscale
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2015-04-23 20:13:58 +0200
committerMichael Niedermayer <michaelni@gmx.at>2015-04-23 20:34:51 +0200
commitb57f9f57240a8143b7c64b8f3e94454dc8895b34 (patch)
treeb0385ed07706898acc6c26c6c46df077eb3f653a /libswscale
parent2a7128f4ed00dbc9209d6f24501bb76a0c14b490 (diff)
downloadffmpeg-streaming-b57f9f57240a8143b7c64b8f3e94454dc8895b34.zip
ffmpeg-streaming-b57f9f57240a8143b7c64b8f3e94454dc8895b34.tar.gz
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@gmx.at>
Diffstat (limited to 'libswscale')
-rw-r--r--libswscale/swscale.c2
-rw-r--r--libswscale/swscale.h1
-rw-r--r--libswscale/swscale_internal.h1
-rw-r--r--libswscale/utils.c22
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)) {
OpenPOWER on IntegriCloud