Commit b57f9f57 authored by Michael Niedermayer's avatar 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: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent 2a7128f4
...@@ -369,7 +369,7 @@ static int swscale(SwsContext *c, const uint8_t *src[], ...@@ -369,7 +369,7 @@ static int swscale(SwsContext *c, const uint8_t *src[],
int chrBufIndex = c->chrBufIndex; int chrBufIndex = c->chrBufIndex;
int lastInLumBuf = c->lastInLumBuf; int lastInLumBuf = c->lastInLumBuf;
int lastInChrBuf = c->lastInChrBuf; int lastInChrBuf = c->lastInChrBuf;
int perform_gamma = c->flags & SWS_GAMMA_CORRECT; int perform_gamma = c->is_internal_gamma;
if (!usePal(c->srcFormat)) { if (!usePal(c->srcFormat)) {
......
...@@ -64,7 +64,6 @@ const char *swscale_license(void); ...@@ -64,7 +64,6 @@ const char *swscale_license(void);
#define SWS_SINC 0x100 #define SWS_SINC 0x100
#define SWS_LANCZOS 0x200 #define SWS_LANCZOS 0x200
#define SWS_SPLINE 0x400 #define SWS_SPLINE 0x400
#define SWS_GAMMA_CORRECT 0x800
#define SWS_SRC_V_CHR_DROP_MASK 0x30000 #define SWS_SRC_V_CHR_DROP_MASK 0x30000
#define SWS_SRC_V_CHR_DROP_SHIFT 16 #define SWS_SRC_V_CHR_DROP_SHIFT 16
......
...@@ -315,6 +315,7 @@ typedef struct SwsContext { ...@@ -315,6 +315,7 @@ typedef struct SwsContext {
double gamma_value; double gamma_value;
int gamma_flag; int gamma_flag;
int is_internal_gamma;
uint16_t *gamma; uint16_t *gamma;
uint16_t *inv_gamma; uint16_t *inv_gamma;
......
...@@ -1256,6 +1256,7 @@ av_cold int sws_init_context(SwsContext *c, SwsFilter *srcFilter, ...@@ -1256,6 +1256,7 @@ av_cold int sws_init_context(SwsContext *c, SwsFilter *srcFilter,
if (!unscaled && c->gamma_flag && (srcFormat != tmpFmt || dstFormat != tmpFmt)) { if (!unscaled && c->gamma_flag && (srcFormat != tmpFmt || dstFormat != tmpFmt)) {
SwsContext *c2;
c->cascaded_context[0] = NULL; c->cascaded_context[0] = NULL;
ret = av_image_alloc(c->cascaded_tmp, c->cascaded_tmpStride, ret = av_image_alloc(c->cascaded_tmp, c->cascaded_tmpStride,
...@@ -1272,11 +1273,18 @@ av_cold int sws_init_context(SwsContext *c, SwsFilter *srcFilter, ...@@ -1272,11 +1273,18 @@ av_cold int sws_init_context(SwsContext *c, SwsFilter *srcFilter,
c->cascaded_context[1] = sws_getContext(srcW, srcH, tmpFmt, c->cascaded_context[1] = sws_getContext(srcW, srcH, tmpFmt,
dstW, dstH, tmpFmt, dstW, dstH, tmpFmt,
flags | SWS_GAMMA_CORRECT, srcFilter, dstFilter, c->param); flags, srcFilter, dstFilter, c->param);
if (!c->cascaded_context[1]) if (!c->cascaded_context[1])
return -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; c->cascaded_context[2] = NULL;
if (dstFormat != tmpFmt) { if (dstFormat != tmpFmt) {
ret = av_image_alloc(c->cascaded1_tmp, c->cascaded1_tmpStride, ret = av_image_alloc(c->cascaded1_tmp, c->cascaded1_tmpStride,
...@@ -1293,18 +1301,6 @@ av_cold int sws_init_context(SwsContext *c, SwsFilter *srcFilter, ...@@ -1293,18 +1301,6 @@ av_cold int sws_init_context(SwsContext *c, SwsFilter *srcFilter,
return 0; 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 (isBayer(srcFormat)) {
if (!unscaled || if (!unscaled ||
(dstFormat != AV_PIX_FMT_RGB24 && dstFormat != AV_PIX_FMT_YUV420P)) { (dstFormat != AV_PIX_FMT_RGB24 && dstFormat != AV_PIX_FMT_YUV420P)) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment