This avoids using up a bit of the public flags
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
... | ... |
@@ -369,7 +369,7 @@ static int swscale(SwsContext *c, const uint8_t *src[], |
369 | 369 |
int chrBufIndex = c->chrBufIndex; |
370 | 370 |
int lastInLumBuf = c->lastInLumBuf; |
371 | 371 |
int lastInChrBuf = c->lastInChrBuf; |
372 |
- int perform_gamma = c->flags & SWS_GAMMA_CORRECT; |
|
372 |
+ int perform_gamma = c->is_internal_gamma; |
|
373 | 373 |
|
374 | 374 |
|
375 | 375 |
if (!usePal(c->srcFormat)) { |
... | ... |
@@ -1256,6 +1256,7 @@ av_cold int sws_init_context(SwsContext *c, SwsFilter *srcFilter, |
1256 | 1256 |
|
1257 | 1257 |
|
1258 | 1258 |
if (!unscaled && c->gamma_flag && (srcFormat != tmpFmt || dstFormat != tmpFmt)) { |
1259 |
+ SwsContext *c2; |
|
1259 | 1260 |
c->cascaded_context[0] = NULL; |
1260 | 1261 |
|
1261 | 1262 |
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 | 1272 |
|
1273 | 1273 |
c->cascaded_context[1] = sws_getContext(srcW, srcH, tmpFmt, |
1274 | 1274 |
dstW, dstH, tmpFmt, |
1275 |
- flags | SWS_GAMMA_CORRECT, srcFilter, dstFilter, c->param); |
|
1275 |
+ flags, srcFilter, dstFilter, c->param); |
|
1276 | 1276 |
|
1277 | 1277 |
if (!c->cascaded_context[1]) |
1278 | 1278 |
return -1; |
1279 | 1279 |
|
1280 |
+ c2 = c->cascaded_context[1]; |
|
1281 |
+ c2->is_internal_gamma = 1; |
|
1282 |
+ c2->gamma = alloc_gamma_tbl( c->gamma_value); |
|
1283 |
+ c2->inv_gamma = alloc_gamma_tbl(1.f/c->gamma_value); |
|
1284 |
+ if (!c2->gamma || !c2->inv_gamma) |
|
1285 |
+ return AVERROR(ENOMEM); |
|
1286 |
+ |
|
1280 | 1287 |
c->cascaded_context[2] = NULL; |
1281 | 1288 |
if (dstFormat != tmpFmt) { |
1282 | 1289 |
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 | 1293 |
return 0; |
1294 | 1294 |
} |
1295 | 1295 |
|
1296 |
- c->gamma = NULL; |
|
1297 |
- c->inv_gamma = NULL; |
|
1298 |
- if (c->flags & SWS_GAMMA_CORRECT) { |
|
1299 |
- c->gamma = alloc_gamma_tbl(c->gamma_value); |
|
1300 |
- if (!c->gamma) |
|
1301 |
- return AVERROR(ENOMEM); |
|
1302 |
- c->inv_gamma = alloc_gamma_tbl(1.f/c->gamma_value); |
|
1303 |
- if (!c->inv_gamma) { |
|
1304 |
- return AVERROR(ENOMEM); |
|
1305 |
- } |
|
1306 |
- } |
|
1307 |
- |
|
1308 | 1296 |
if (isBayer(srcFormat)) { |
1309 | 1297 |
if (!unscaled || |
1310 | 1298 |
(dstFormat != AV_PIX_FMT_RGB24 && dstFormat != AV_PIX_FMT_YUV420P)) { |