| @@ -1026,12 +1026,13 @@ static int handle_xyz(enum AVPixelFormat *format) · 1025 unmodified lines |
| 1026 | 1026 | } |
| 1027 | 1027 | } |
| 1028 | 1028 | |
| 1029 | | −static void handle_formats(SwsInternal *c) |
| 1029 | +static void handle_formats(SwsContext *sws) |
| 1030 | 1030 | { |
| 1031 | | − c->src0Alpha |= handle_0alpha(&c->opts.src_format); |
| 1032 | | − c->dst0Alpha |= handle_0alpha(&c->opts.dst_format); |
| 1033 | | − c->srcXYZ |= handle_xyz(&c->opts.src_format); |
| 1034 | | − c->dstXYZ |= handle_xyz(&c->opts.dst_format); |
| 1031 | + SwsInternal *c = sws_internal(sws); |
| 1032 | + c->src0Alpha |= handle_0alpha(&sws->src_format); |
| 1033 | + c->dst0Alpha |= handle_0alpha(&sws->dst_format); |
| 1034 | + c->srcXYZ |= handle_xyz(&sws->src_format); |
| 1035 | + c->dstXYZ |= handle_xyz(&sws->dst_format); |
| 1035 | 1036 | if (c->srcXYZ || c->dstXYZ) |
| 1036 | 1037 | fill_xyztables(c); |
| 1037 | 1038 | } |
| @@ -1063,17 +1064,17 @@ int sws_setColorspaceDetails(SwsContext *sws, const int inv_table[4], · 25 unmodified lines |
| 1063 | 1064 | return parent_ret; |
| 1064 | 1065 | } |
| 1065 | 1066 | |
| 1066 | | − handle_formats(c); |
| 1067 | | − desc_dst = av_pix_fmt_desc_get(c->opts.dst_format); |
| 1068 | | − desc_src = av_pix_fmt_desc_get(c->opts.src_format); |
| 1067 | + handle_formats(sws); |
| 1068 | + desc_dst = av_pix_fmt_desc_get(sws->dst_format); |
| 1069 | + desc_src = av_pix_fmt_desc_get(sws->src_format); |
| 1069 | 1070 | |
| 1070 | | − if(range_override_needed(c->opts.dst_format)) |
| 1071 | + if(range_override_needed(sws->dst_format)) |
| 1071 | 1072 | dstRange = 0; |
| 1072 | | − if(range_override_needed(c->opts.src_format)) |
| 1073 | + if(range_override_needed(sws->src_format)) |
| 1073 | 1074 | srcRange = 0; |
| 1074 | 1075 | |
| 1075 | | − if (c->opts.src_range != srcRange || |
| 1076 | | − c->opts.dst_range != dstRange || |
| 1076 | + if (sws->src_range != srcRange || |
| 1077 | + sws->dst_range != dstRange || |
| 1077 | 1078 | c->brightness != brightness || |
| 1078 | 1079 | c->contrast != contrast || |
| 1079 | 1080 | c->saturation != saturation || |
| @@ -1090,8 +1091,8 @@ int sws_setColorspaceDetails(SwsContext *sws, const int inv_table[4], · 10 unmodified lines |
| 1090 | 1091 | c->brightness = brightness; |
| 1091 | 1092 | c->contrast = contrast; |
| 1092 | 1093 | c->saturation = saturation; |
| 1093 | | − c->opts.src_range = srcRange; |
| 1094 | | − c->opts.dst_range = dstRange; |
| 1094 | + sws->src_range = srcRange; |
| 1095 | + sws->dst_range = dstRange; |
| 1095 | 1096 | |
| 1096 | 1097 | if (need_reinit) |
| 1097 | 1098 | ff_sws_init_range_convert(c); |
| @@ -1105,27 +1106,27 @@ int sws_setColorspaceDetails(SwsContext *sws, const int inv_table[4], · 7 unmodified lines |
| 1105 | 1106 | if (!need_reinit) |
| 1106 | 1107 | return 0; |
| 1107 | 1108 | |
| 1108 | | − if ((isYUV(c->opts.dst_format) || isGray(c->opts.dst_format)) && (isYUV(c->opts.src_format) || isGray(c->opts.src_format))) { |
| 1109 | + if ((isYUV(sws->dst_format) || isGray(sws->dst_format)) && (isYUV(sws->src_format) || isGray(sws->src_format))) { |
| 1109 | 1110 | if (!c->cascaded_context[0] && |
| 1110 | 1111 | memcmp(c->dstColorspaceTable, c->srcColorspaceTable, sizeof(int) * 4) && |
| 1111 | | − c->opts.src_w && c->opts.src_h && c->opts.dst_w && c->opts.dst_h) { |
| 1112 | + sws->src_w && sws->src_h && sws->dst_w && sws->dst_h) { |
| 1112 | 1113 | enum AVPixelFormat tmp_format; |
| 1113 | 1114 | int tmp_width, tmp_height; |
| 1114 | | − int srcW = c->opts.src_w; |
| 1115 | | − int srcH = c->opts.src_h; |
| 1116 | | − int dstW = c->opts.dst_w; |
| 1117 | | − int dstH = c->opts.dst_h; |
| 1115 | + int srcW = sws->src_w; |
| 1116 | + int srcH = sws->src_h; |
| 1117 | + int dstW = sws->dst_w; |
| 1118 | + int dstH = sws->dst_h; |
| 1118 | 1119 | int ret; |
| 1119 | 1120 | av_log(c, AV_LOG_VERBOSE, "YUV color matrix differs for YUV->YUV, using intermediate RGB to convert\n"); |
| 1120 | 1121 | |
| 1121 | | − if (isNBPS(c->opts.dst_format) || is16BPS(c->opts.dst_format)) { |
| 1122 | | − if (isALPHA(c->opts.src_format) && isALPHA(c->opts.dst_format)) { |
| 1122 | + if (isNBPS(sws->dst_format) || is16BPS(sws->dst_format)) { |
| 1123 | + if (isALPHA(sws->src_format) && isALPHA(sws->dst_format)) { |
| 1123 | 1124 | tmp_format = AV_PIX_FMT_BGRA64; |
| 1124 | 1125 | } else { |
| 1125 | 1126 | tmp_format = AV_PIX_FMT_BGR48; |
| 1126 | 1127 | } |
| 1127 | 1128 | } else { |
| 1128 | | − if (isALPHA(c->opts.src_format) && isALPHA(c->opts.dst_format)) { |
| 1129 | + if (isALPHA(sws->src_format) && isALPHA(sws->dst_format)) { |
| 1129 | 1130 | tmp_format = AV_PIX_FMT_BGRA; |
| 1130 | 1131 | } else { |
| 1131 | 1132 | tmp_format = AV_PIX_FMT_BGR24; |
| @@ -1145,14 +1146,13 @@ int sws_setColorspaceDetails(SwsContext *sws, const int inv_table[4], · 13 unmodified lines |
| 1145 | 1146 | if (ret < 0) |
| 1146 | 1147 | return ret; |
| 1147 | 1148 | |
| 1148 | | − c->cascaded_context[0] = alloc_set_opts(srcW, srcH, c->opts.src_format, |
| 1149 | + c->cascaded_context[0] = alloc_set_opts(srcW, srcH, sws->src_format, |
| 1149 | 1150 | tmp_width, tmp_height, tmp_format, |
| 1150 | | − c->opts.flags, |
| 1151 | | − c->opts.scaler_params); |
| 1151 | + sws->flags, sws->scaler_params); |
| 1152 | 1152 | if (!c->cascaded_context[0]) |
| 1153 | 1153 | return -1; |
| 1154 | 1154 | |
| 1155 | | − sws_internal(c->cascaded_context[0])->opts.alpha_blend = c->opts.alpha_blend; |
| 1155 | + c->cascaded_context[0]->alpha_blend = sws->alpha_blend; |
| 1156 | 1156 | ret = sws_init_context(c->cascaded_context[0], NULL , NULL); |
| 1157 | 1157 | if (ret < 0) |
| 1158 | 1158 | return ret; |
| @@ -1162,13 +1162,12 @@ int sws_setColorspaceDetails(SwsContext *sws, const int inv_table[4], · 3 unmodified lines |
| 1162 | 1162 | brightness, contrast, saturation); |
| 1163 | 1163 | |
| 1164 | 1164 | c->cascaded_context[1] = alloc_set_opts(tmp_width, tmp_height, tmp_format, |
| 1165 | | − dstW, dstH, c->opts.dst_format, |
| 1166 | | − c->opts.flags, |
| 1167 | | − c->opts.scaler_params); |
| 1165 | + dstW, dstH, sws->dst_format, |
| 1166 | + sws->flags, sws->scaler_params); |
| 1168 | 1167 | if (!c->cascaded_context[1]) |
| 1169 | 1168 | return -1; |
| 1170 | | − sws_internal(c->cascaded_context[1])->opts.src_range = srcRange; |
| 1171 | | − sws_internal(c->cascaded_context[1])->opts.dst_range = dstRange; |
| 1169 | + c->cascaded_context[1]->src_range = srcRange; |
| 1170 | + c->cascaded_context[1]->dst_range = dstRange; |
| 1172 | 1171 | ret = sws_init_context(c->cascaded_context[1], NULL , NULL); |
| 1173 | 1172 | if (ret < 0) |
| 1174 | 1173 | return ret; |
| @@ -1183,7 +1182,7 @@ int sws_setColorspaceDetails(SwsContext *sws, const int inv_table[4], · 8 unmodified lines |
| 1183 | 1182 | return 0; |
| 1184 | 1183 | } |
| 1185 | 1184 | |
| 1186 | | − if (!isYUV(c->opts.dst_format) && !isGray(c->opts.dst_format)) { |
| 1185 | + if (!isYUV(sws->dst_format) && !isGray(sws->dst_format)) { |
| 1187 | 1186 | ff_yuv2rgb_c_init_tables(c, inv_table, srcRange, brightness, |
| 1188 | 1187 | contrast, saturation); |
| 1189 | 1188 | // FIXME factorize |
| @@ -1215,8 +1214,8 @@ int sws_getColorspaceDetails(SwsContext *sws, int **inv_table, · 25 unmodified lines |
| 1215 | 1214 | |
| 1216 | 1215 | *inv_table = c->srcColorspaceTable; |
| 1217 | 1216 | *table = c->dstColorspaceTable; |
| 1218 | | − *srcRange = range_override_needed(c->opts.src_format) ? 1 : c->opts.src_range; |
| 1219 | | − *dstRange = range_override_needed(c->opts.dst_format) ? 1 : c->opts.dst_range; |
| 1217 | + *srcRange = range_override_needed(sws->src_format) ? 1 : sws->src_range; |
| 1218 | + *dstRange = range_override_needed(sws->dst_format) ? 1 : sws->dst_range; |
| 1220 | 1219 | *brightness = c->brightness; |
| 1221 | 1220 | *contrast = c->contrast; |
| 1222 | 1221 | *saturation = c->saturation; |
| @@ -1321,10 +1320,10 @@ static av_cold int sws_init_single_context(SwsContext *sws, SwsFilter *srcFilter · 98 unmodified lines |
| 1321 | 1320 | int unscaled; |
| 1322 | 1321 | SwsInternal *c = sws_internal(sws); |
| 1323 | 1322 | SwsFilter dummyFilter = { NULL, NULL, NULL, NULL }; |
| 1324 | | − int srcW = c->opts.src_w; |
| 1325 | | − int srcH = c->opts.src_h; |
| 1326 | | − int dstW = c->opts.dst_w; |
| 1327 | | − int dstH = c->opts.dst_h; |
| 1323 | + int srcW = sws->src_w; |
| 1324 | + int srcH = sws->src_h; |
| 1325 | + int dstW = sws->dst_w; |
| 1326 | + int dstH = sws->dst_h; |
| 1328 | 1327 | int dst_stride = FFALIGN(dstW * sizeof(int16_t) + 66, 16); |
| 1329 | 1328 | int flags, cpu_flags; |
| 1330 | 1329 | enum AVPixelFormat srcFormat, dstFormat; |
| @@ -1335,25 +1334,25 @@ static av_cold int sws_init_single_context(SwsContext *sws, SwsFilter *srcFilter · 4 unmodified lines |
| 1335 | 1334 | static const float float_mult = 1.0f / 255.0f; |
| 1336 | 1335 | |
| 1337 | 1336 | cpu_flags = av_get_cpu_flags(); |
| 1338 | | − flags = c->opts.flags; |
| 1337 | + flags = sws->flags; |
| 1339 | 1338 | emms_c(); |
| 1340 | 1339 | |
| 1341 | 1340 | unscaled = (srcW == dstW && srcH == dstH); |
| 1342 | 1341 | |
| 1343 | 1342 | if (!c->contrast && !c->saturation && !c->dstFormatBpp) |
| 1344 | | − sws_setColorspaceDetails(sws, ff_yuv2rgb_coeffs[SWS_CS_DEFAULT], c->opts.src_range, |
| 1343 | + sws_setColorspaceDetails(sws, ff_yuv2rgb_coeffs[SWS_CS_DEFAULT], sws->src_range, |
| 1345 | 1344 | ff_yuv2rgb_coeffs[SWS_CS_DEFAULT], |
| 1346 | | − c->opts.dst_range, 0, 1 << 16, 1 << 16); |
| 1345 | + sws->dst_range, 0, 1 << 16, 1 << 16); |
| 1347 | 1346 | |
| 1348 | | − handle_formats(c); |
| 1349 | | − srcFormat = c->opts.src_format; |
| 1350 | | − dstFormat = c->opts.dst_format; |
| 1347 | + handle_formats(sws); |
| 1348 | + srcFormat = sws->src_format; |
| 1349 | + dstFormat = sws->dst_format; |
| 1351 | 1350 | desc_src = av_pix_fmt_desc_get(srcFormat); |
| 1352 | 1351 | desc_dst = av_pix_fmt_desc_get(dstFormat); |
| 1353 | 1352 | |
| 1354 | 1353 | // If the source has no alpha then disable alpha blendaway |
| 1355 | 1354 | if (c->src0Alpha) |
| 1356 | | − c->opts.alpha_blend = SWS_ALPHA_BLEND_NONE; |
| 1355 | + sws->alpha_blend = SWS_ALPHA_BLEND_NONE; |
| 1357 | 1356 | |
| 1358 | 1357 | if (!(unscaled && sws_isSupportedEndiannessConversion(srcFormat) && |
| 1359 | 1358 | av_pix_fmt_swap_endianness(srcFormat) == dstFormat)) { |
| @@ -1390,7 +1389,7 @@ static av_cold int sws_init_single_context(SwsContext *sws, SwsFilter *srcFilter · 30 unmodified lines |
| 1390 | 1389 | flags |= SWS_BICUBIC; |
| 1391 | 1390 | else |
| 1392 | 1391 | flags |= SWS_BICUBIC; |
| 1393 | | − c->opts.flags = flags; |
| 1392 | + sws->flags = flags; |
| 1394 | 1393 | } else if (i & (i - 1)) { |
| 1395 | 1394 | av_log(c, AV_LOG_ERROR, |
| 1396 | 1395 | "Exactly one scaler algorithm must be chosen, got %X\n", i); |
| @@ -1407,7 +1406,7 @@ static av_cold int sws_init_single_context(SwsContext *sws, SwsFilter *srcFilter · 10 unmodified lines |
| 1407 | 1406 | if (flags & SWS_FAST_BILINEAR) { |
| 1408 | 1407 | if (srcW < 8 || dstW < 8) { |
| 1409 | 1408 | flags ^= SWS_FAST_BILINEAR | SWS_BILINEAR; |
| 1410 | | − c->opts.flags = flags; |
| 1409 | + sws->flags = flags; |
| 1411 | 1410 | } |
| 1412 | 1411 | } |
| 1413 | 1412 | |
| @@ -1440,46 +1439,46 @@ static av_cold int sws_init_single_context(SwsContext *sws, SwsFilter *srcFilter · 26 unmodified lines |
| 1440 | 1439 | if (dstW&1) { |
| 1441 | 1440 | av_log(c, AV_LOG_DEBUG, "Forcing full internal H chroma due to odd output size\n"); |
| 1442 | 1441 | flags |= SWS_FULL_CHR_H_INT; |
| 1443 | | − c->opts.flags = flags; |
| 1442 | + sws->flags = flags; |
| 1444 | 1443 | } |
| 1445 | 1444 | |
| 1446 | 1445 | if ( c->chrSrcHSubSample == 0 |
| 1447 | 1446 | && c->chrSrcVSubSample == 0 |
| 1448 | | − && c->opts.dither != SWS_DITHER_BAYER //SWS_FULL_CHR_H_INT is currently not supported with SWS_DITHER_BAYER |
| 1449 | | − && !(c->opts.flags & SWS_FAST_BILINEAR) |
| 1447 | + && sws->dither != SWS_DITHER_BAYER //SWS_FULL_CHR_H_INT is currently not supported with SWS_DITHER_BAYER |
| 1448 | + && !(sws->flags & SWS_FAST_BILINEAR) |
| 1450 | 1449 | ) { |
| 1451 | 1450 | av_log(c, AV_LOG_DEBUG, "Forcing full internal H chroma due to input having non subsampled chroma\n"); |
| 1452 | 1451 | flags |= SWS_FULL_CHR_H_INT; |
| 1453 | | − c->opts.flags = flags; |
| 1452 | + sws->flags = flags; |
| 1454 | 1453 | } |
| 1455 | 1454 | } |
| 1456 | 1455 | |
| 1457 | | − if (c->opts.dither == SWS_DITHER_AUTO) { |
| 1456 | + if (sws->dither == SWS_DITHER_AUTO) { |
| 1458 | 1457 | if (flags & SWS_ERROR_DIFFUSION) |
| 1459 | | − c->opts.dither = SWS_DITHER_ED; |
| 1458 | + sws->dither = SWS_DITHER_ED; |
| 1460 | 1459 | } |
| 1461 | 1460 | |
| 1462 | 1461 | if(dstFormat == AV_PIX_FMT_BGR4_BYTE || |
| 1463 | 1462 | dstFormat == AV_PIX_FMT_RGB4_BYTE || |
| 1464 | 1463 | dstFormat == AV_PIX_FMT_BGR8 || |
| 1465 | 1464 | dstFormat == AV_PIX_FMT_RGB8) { |
| 1466 | | − if (c->opts.dither == SWS_DITHER_AUTO) |
| 1467 | | − c->opts.dither = (flags & SWS_FULL_CHR_H_INT) ? SWS_DITHER_ED : SWS_DITHER_BAYER; |
| 1465 | + if (sws->dither == SWS_DITHER_AUTO) |
| 1466 | + sws->dither = (flags & SWS_FULL_CHR_H_INT) ? SWS_DITHER_ED : SWS_DITHER_BAYER; |
| 1468 | 1467 | if (!(flags & SWS_FULL_CHR_H_INT)) { |
| 1469 | | − if (c->opts.dither == SWS_DITHER_ED || c->opts.dither == SWS_DITHER_A_DITHER || c->opts.dither == SWS_DITHER_X_DITHER || c->opts.dither == SWS_DITHER_NONE) { |
| 1468 | + if (sws->dither == SWS_DITHER_ED || sws->dither == SWS_DITHER_A_DITHER || sws->dither == SWS_DITHER_X_DITHER || sws->dither == SWS_DITHER_NONE) { |
| 1470 | 1469 | av_log(c, AV_LOG_DEBUG, |
| 1471 | 1470 | "Desired dithering only supported in full chroma interpolation for destination format '%s'\n", |
| 1472 | 1471 | av_get_pix_fmt_name(dstFormat)); |
| 1473 | 1472 | flags |= SWS_FULL_CHR_H_INT; |
| 1474 | | − c->opts.flags = flags; |
| 1473 | + sws->flags = flags; |
| 1475 | 1474 | } |
| 1476 | 1475 | } |
| 1477 | 1476 | if (flags & SWS_FULL_CHR_H_INT) { |
| 1478 | | − if (c->opts.dither == SWS_DITHER_BAYER) { |
| 1477 | + if (sws->dither == SWS_DITHER_BAYER) { |
| 1479 | 1478 | av_log(c, AV_LOG_DEBUG, |
| 1480 | 1479 | "Ordered dither is not supported in full chroma interpolation for destination format '%s'\n", |
| 1481 | 1480 | av_get_pix_fmt_name(dstFormat)); |
| 1482 | | − c->opts.dither = SWS_DITHER_ED; |
| 1481 | + sws->dither = SWS_DITHER_ED; |
| 1483 | 1482 | } |
| 1484 | 1483 | } |
| 1485 | 1484 | } |
| @@ -1489,7 +1488,7 @@ static av_cold int sws_init_single_context(SwsContext *sws, SwsFilter *srcFilter · 3 unmodified lines |
| 1489 | 1488 | "%s output is not supported with half chroma resolution, switching to full\n", |
| 1490 | 1489 | av_get_pix_fmt_name(dstFormat)); |
| 1491 | 1490 | flags |= SWS_FULL_CHR_H_INT; |
| 1492 | | − c->opts.flags = flags; |
| 1491 | + sws->flags = flags; |
| 1493 | 1492 | } |
| 1494 | 1493 | } |
| 1495 | 1494 | |
| @@ -1523,7 +1522,7 @@ static av_cold int sws_init_single_context(SwsContext *sws, SwsFilter *srcFilter · 27 unmodified lines |
| 1523 | 1522 | "full chroma interpolation for destination format '%s' not yet implemented\n", |
| 1524 | 1523 | av_get_pix_fmt_name(dstFormat)); |
| 1525 | 1524 | flags &= ~SWS_FULL_CHR_H_INT; |
| 1526 | | − c->opts.flags = flags; |
| 1525 | + sws->flags = flags; |
| 1527 | 1526 | } |
| 1528 | 1527 | if (isAnyRGB(dstFormat) && !(flags & SWS_FULL_CHR_H_INT)) |
| 1529 | 1528 | c->chrDstHSubSample = 1; |
| @@ -1585,7 +1584,7 @@ static av_cold int sws_init_single_context(SwsContext *sws, SwsFilter *srcFilter · 55 unmodified lines |
| 1585 | 1584 | av_log(c, AV_LOG_INFO, |
| 1586 | 1585 | "output width is not a multiple of 32 -> no MMXEXT scaler\n"); |
| 1587 | 1586 | } |
| 1588 | | − if (usesHFilter || isNBPS(c->opts.src_format) || is16BPS(c->opts.src_format) || isAnyRGB(c->opts.src_format)) |
| 1587 | + if (usesHFilter || isNBPS(sws->src_format) || is16BPS(sws->src_format) || isAnyRGB(sws->src_format)) |
| 1589 | 1588 | c->canMMXEXTBeUsed = 0; |
| 1590 | 1589 | } else |
| 1591 | 1590 | c->canMMXEXTBeUsed = 0; |
| @@ -1616,8 +1615,7 @@ static av_cold int sws_init_single_context(SwsContext *sws, SwsFilter *srcFilter · 24 unmodified lines |
| 1616 | 1615 | c->gamma_value = 2.2; |
| 1617 | 1616 | tmpFmt = AV_PIX_FMT_RGBA64LE; |
| 1618 | 1617 | |
| 1619 | | − |
| 1620 | | − if (!unscaled && c->opts.gamma_flag && (srcFormat != tmpFmt || dstFormat != tmpFmt)) { |
| 1618 | + if (!unscaled && sws->gamma_flag && (srcFormat != tmpFmt || dstFormat != tmpFmt)) { |
| 1621 | 1619 | SwsInternal *c2; |
| 1622 | 1620 | c->cascaded_context[0] = NULL; |
| 1623 | 1621 | |
| @@ -1629,7 +1627,7 @@ static av_cold int sws_init_single_context(SwsContext *sws, SwsFilter *srcFilter · 5 unmodified lines |
| 1629 | 1627 | c->cascaded_context[0] = sws_getContext(srcW, srcH, srcFormat, |
| 1630 | 1628 | srcW, srcH, tmpFmt, |
| 1631 | 1629 | flags, NULL, NULL, |
| 1632 | | − c->opts.scaler_params); |
| 1630 | + sws->scaler_params); |
| 1633 | 1631 | if (!c->cascaded_context[0]) { |
| 1634 | 1632 | return AVERROR(ENOMEM); |
| 1635 | 1633 | } |
| @@ -1637,7 +1635,7 @@ static av_cold int sws_init_single_context(SwsContext *sws, SwsFilter *srcFilter · 1 unmodified line |
| 1637 | 1635 | c->cascaded_context[1] = sws_getContext(srcW, srcH, tmpFmt, |
| 1638 | 1636 | dstW, dstH, tmpFmt, |
| 1639 | 1637 | flags, srcFilter, dstFilter, |
| 1640 | | − c->opts.scaler_params); |
| 1638 | + sws->scaler_params); |
| 1641 | 1639 | |
| 1642 | 1640 | if (!c->cascaded_context[1]) |
| 1643 | 1641 | return AVERROR(ENOMEM); |
| @@ -1669,7 +1667,7 @@ static av_cold int sws_init_single_context(SwsContext *sws, SwsFilter *srcFilter · 25 unmodified lines |
| 1669 | 1667 | c->cascaded_context[2] = sws_getContext(dstW, dstH, tmpFmt, |
| 1670 | 1668 | dstW, dstH, dstFormat, |
| 1671 | 1669 | flags, NULL, NULL, |
| 1672 | | − c->opts.scaler_params); |
| 1670 | + sws->scaler_params); |
| 1673 | 1671 | if (!c->cascaded_context[2]) |
| 1674 | 1672 | return AVERROR(ENOMEM); |
| 1675 | 1673 | } |
| @@ -1690,14 +1688,14 @@ static av_cold int sws_init_single_context(SwsContext *sws, SwsFilter *srcFilter · 14 unmodified lines |
| 1690 | 1688 | c->cascaded_context[0] = sws_getContext(srcW, srcH, srcFormat, |
| 1691 | 1689 | srcW, srcH, tmpFormat, |
| 1692 | 1690 | flags, srcFilter, NULL, |
| 1693 | | − c->opts.scaler_params); |
| 1691 | + sws->scaler_params); |
| 1694 | 1692 | if (!c->cascaded_context[0]) |
| 1695 | 1693 | return AVERROR(ENOMEM); |
| 1696 | 1694 | |
| 1697 | 1695 | c->cascaded_context[1] = sws_getContext(srcW, srcH, tmpFormat, |
| 1698 | 1696 | dstW, dstH, dstFormat, |
| 1699 | 1697 | flags, NULL, dstFilter, |
| 1700 | | − c->opts.scaler_params); |
| 1698 | + sws->scaler_params); |
| 1701 | 1699 | if (!c->cascaded_context[1]) |
| 1702 | 1700 | return AVERROR(ENOMEM); |
| 1703 | 1701 | return 0; |
| @@ -1720,11 +1718,11 @@ static av_cold int sws_init_single_context(SwsContext *sws, SwsFilter *srcFilter · 16 unmodified lines |
| 1720 | 1718 | if (CONFIG_SWSCALE_ALPHA && isALPHA(srcFormat) && !isALPHA(dstFormat)) { |
| 1721 | 1719 | enum AVPixelFormat tmpFormat = alphaless_fmt(srcFormat); |
| 1722 | 1720 | |
| 1723 | | − if (tmpFormat != AV_PIX_FMT_NONE && c->opts.alpha_blend != SWS_ALPHA_BLEND_NONE) { |
| 1721 | + if (tmpFormat != AV_PIX_FMT_NONE && sws->alpha_blend != SWS_ALPHA_BLEND_NONE) { |
| 1724 | 1722 | if (!unscaled || |
| 1725 | 1723 | dstFormat != tmpFormat || |
| 1726 | 1724 | usesHFilter || usesVFilter || |
| 1727 | | − c->opts.src_range != c->opts.dst_range |
| 1725 | + sws->src_range != sws->dst_range |
| 1728 | 1726 | ) { |
| 1729 | 1727 | c->cascaded_mainindex = 1; |
| 1730 | 1728 | ret = av_image_alloc(c->cascaded_tmp[0], c->cascaded_tmpStride[0], |
| @@ -1734,22 +1732,22 @@ static av_cold int sws_init_single_context(SwsContext *sws, SwsFilter *srcFilter · 3 unmodified lines |
| 1734 | 1732 | |
| 1735 | 1733 | c->cascaded_context[0] = alloc_set_opts(srcW, srcH, srcFormat, |
| 1736 | 1734 | srcW, srcH, tmpFormat, |
| 1737 | | − flags, c->opts.scaler_params); |
| 1735 | + flags, sws->scaler_params); |
| 1738 | 1736 | if (!c->cascaded_context[0]) |
| 1739 | 1737 | return AVERROR(EINVAL); |
| 1740 | | − sws_internal(c->cascaded_context[0])->opts.alpha_blend = c->opts.alpha_blend; |
| 1738 | + c->cascaded_context[0]->alpha_blend = sws->alpha_blend; |
| 1741 | 1739 | ret = sws_init_context(c->cascaded_context[0], NULL , NULL); |
| 1742 | 1740 | if (ret < 0) |
| 1743 | 1741 | return ret; |
| 1744 | 1742 | |
| 1745 | 1743 | c->cascaded_context[1] = alloc_set_opts(srcW, srcH, tmpFormat, |
| 1746 | 1744 | dstW, dstH, dstFormat, |
| 1747 | | − flags, c->opts.scaler_params); |
| 1745 | + flags, sws->scaler_params); |
| 1748 | 1746 | if (!c->cascaded_context[1]) |
| 1749 | 1747 | return AVERROR(EINVAL); |
| 1750 | 1748 | |
| 1751 | | − sws_internal(c->cascaded_context[1])->opts.src_range = c->opts.src_range; |
| 1752 | | − sws_internal(c->cascaded_context[1])->opts.dst_range = c->opts.dst_range; |
| 1749 | + c->cascaded_context[1]->src_range = sws->src_range; |
| 1750 | + c->cascaded_context[1]->dst_range = sws->dst_range; |
| 1753 | 1751 | ret = sws_init_context(c->cascaded_context[1], srcFilter , dstFilter); |
| 1754 | 1752 | if (ret < 0) |
| 1755 | 1753 | return ret; |
| @@ -1761,9 +1759,9 @@ static av_cold int sws_init_single_context(SwsContext *sws, SwsFilter *srcFilter · 5 unmodified lines |
| 1761 | 1759 | |
| 1762 | 1760 | /* alpha blend special case, note this has been split via cascaded contexts if its scaled */ |
| 1763 | 1761 | if (unscaled && !usesHFilter && !usesVFilter && |
| 1764 | | − c->opts.alpha_blend != SWS_ALPHA_BLEND_NONE && |
| 1762 | + sws->alpha_blend != SWS_ALPHA_BLEND_NONE && |
| 1765 | 1763 | isALPHA(srcFormat) && |
| 1766 | | − (c->opts.src_range == c->opts.dst_range || isAnyRGB(dstFormat)) && |
| 1764 | + (sws->src_range == sws->dst_range || isAnyRGB(dstFormat)) && |
| 1767 | 1765 | alphaless_fmt(srcFormat) == dstFormat |
| 1768 | 1766 | ) { |
| 1769 | 1767 | c->convert_unscaled = ff_sws_alphablendaway; |
| @@ -1777,7 +1775,7 @@ static av_cold int sws_init_single_context(SwsContext *sws, SwsFilter *srcFilter · 7 unmodified lines |
| 1777 | 1775 | |
| 1778 | 1776 | /* unscaled special cases */ |
| 1779 | 1777 | if (unscaled && !usesHFilter && !usesVFilter && |
| 1780 | | − (c->opts.src_range == c->opts.dst_range || isAnyRGB(dstFormat) || |
| 1778 | + (sws->src_range == sws->dst_range || isAnyRGB(dstFormat) || |
| 1781 | 1779 | isFloat(srcFormat) || isFloat(dstFormat) || isBayer(srcFormat))){ |
| 1782 | 1780 | |
| 1783 | 1781 | ff_get_unscaled_swscale(c); |
| @@ -1873,7 +1871,7 @@ static av_cold int sws_init_single_context(SwsContext *sws, SwsFilter *srcFilter · 89 unmodified lines |
| 1873 | 1871 | srcW, dstW, filterAlign, 1 << 14, |
| 1874 | 1872 | (flags & SWS_BICUBLIN) ? (flags | SWS_BICUBIC) : flags, |
| 1875 | 1873 | cpu_flags, srcFilter->lumH, dstFilter->lumH, |
| 1876 | | − c->opts.scaler_params, |
| 1874 | + sws->scaler_params, |
| 1877 | 1875 | get_local_pos(c, 0, 0, 0), |
| 1878 | 1876 | get_local_pos(c, 0, 0, 0))) < 0) |
| 1879 | 1877 | goto fail; |
| @@ -1884,9 +1882,9 @@ static av_cold int sws_init_single_context(SwsContext *sws, SwsFilter *srcFilter · 4 unmodified lines |
| 1884 | 1882 | c->chrSrcW, c->chrDstW, filterAlign, 1 << 14, |
| 1885 | 1883 | (flags & SWS_BICUBLIN) ? (flags | SWS_BILINEAR) : flags, |
| 1886 | 1884 | cpu_flags, srcFilter->chrH, dstFilter->chrH, |
| 1887 | | − c->opts.scaler_params, |
| 1888 | | − get_local_pos(c, c->chrSrcHSubSample, c->opts.src_h_chr_pos, 0), |
| 1889 | | − get_local_pos(c, c->chrDstHSubSample, c->opts.dst_h_chr_pos, 0))) < 0) |
| 1885 | + sws->scaler_params, |
| 1886 | + get_local_pos(c, c->chrSrcHSubSample, sws->src_h_chr_pos, 0), |
| 1887 | + get_local_pos(c, c->chrDstHSubSample, sws->dst_h_chr_pos, 0))) < 0) |
| 1890 | 1888 | goto fail; |
| 1891 | 1889 | if (ff_shuffle_filter_coefficients(c, c->hChrFilterPos, c->hChrFilterSize, c->hChrFilter, c->chrDstW) < 0) |
| 1892 | 1890 | goto nomem; |
| @@ -1903,7 +1901,7 @@ static av_cold int sws_init_single_context(SwsContext *sws, SwsFilter *srcFilter · 10 unmodified lines |
| 1903 | 1901 | c->lumYInc, srcH, dstH, filterAlign, (1 << 12), |
| 1904 | 1902 | (flags & SWS_BICUBLIN) ? (flags | SWS_BICUBIC) : flags, |
| 1905 | 1903 | cpu_flags, srcFilter->lumV, dstFilter->lumV, |
| 1906 | | − c->opts.scaler_params, |
| 1904 | + sws->scaler_params, |
| 1907 | 1905 | get_local_pos(c, 0, 0, 1), |
| 1908 | 1906 | get_local_pos(c, 0, 0, 1))) < 0) |
| 1909 | 1907 | goto fail; |
| @@ -1912,18 +1910,18 @@ static av_cold int sws_init_single_context(SwsContext *sws, SwsFilter *srcFilter · 2 unmodified lines |
| 1912 | 1910 | filterAlign, (1 << 12), |
| 1913 | 1911 | (flags & SWS_BICUBLIN) ? (flags | SWS_BILINEAR) : flags, |
| 1914 | 1912 | cpu_flags, srcFilter->chrV, dstFilter->chrV, |
| 1915 | | − c->opts.scaler_params, |
| 1916 | | − get_local_pos(c, c->chrSrcVSubSample, c->opts.src_v_chr_pos, 1), |
| 1917 | | − get_local_pos(c, c->chrDstVSubSample, c->opts.dst_v_chr_pos, 1))) < 0) |
| 1913 | + sws->scaler_params, |
| 1914 | + get_local_pos(c, c->chrSrcVSubSample, sws->src_v_chr_pos, 1), |
| 1915 | + get_local_pos(c, c->chrDstVSubSample, sws->dst_v_chr_pos, 1))) < 0) |
| 1918 | 1916 | |
| 1919 | 1917 | goto fail; |
| 1920 | 1918 | |
| 1921 | 1919 | #if HAVE_ALTIVEC |
| 1922 | | − if (!FF_ALLOC_TYPED_ARRAY(c->vYCoeffsBank, c->vLumFilterSize * c->opts.dst_h) || |
| 1920 | + if (!FF_ALLOC_TYPED_ARRAY(c->vYCoeffsBank, c->vLumFilterSize * sws->dst_h) || |
| 1923 | 1921 | !FF_ALLOC_TYPED_ARRAY(c->vCCoeffsBank, c->vChrFilterSize * c->chrDstH)) |
| 1924 | 1922 | goto nomem; |
| 1925 | 1923 | |
| 1926 | | − for (i = 0; i < c->vLumFilterSize * c->opts.dst_h; i++) { |
| 1924 | + for (i = 0; i < c->vLumFilterSize * sws->dst_h; i++) { |
| 1927 | 1925 | int j; |
| 1928 | 1926 | short *p = (short *)&c->vYCoeffsBank[i]; |
| 1929 | 1927 | for (j = 0; j < 8; j++) |
| @@ -1940,10 +1938,10 @@ static av_cold int sws_init_single_context(SwsContext *sws, SwsFilter *srcFilter · 10 unmodified lines |
| 1940 | 1938 | } |
| 1941 | 1939 | |
| 1942 | 1940 | for (i = 0; i < 4; i++) |
| 1943 | | − if (!FF_ALLOCZ_TYPED_ARRAY(c->dither_error[i], c->opts.dst_w + 3)) |
| 1941 | + if (!FF_ALLOCZ_TYPED_ARRAY(c->dither_error[i], sws->dst_w + 3)) |
| 1944 | 1942 | goto nomem; |
| 1945 | 1943 | |
| 1946 | | − c->needAlpha = (CONFIG_SWSCALE_ALPHA && isALPHA(c->opts.src_format) && isALPHA(c->opts.dst_format)) ? 1 : 0; |
| 1944 | + c->needAlpha = (CONFIG_SWSCALE_ALPHA && isALPHA(sws->src_format) && isALPHA(sws->dst_format)) ? 1 : 0; |
| 1947 | 1945 | |
| 1948 | 1946 | // 64 / c->scalingBpp is the same as 16 / sizeof(scaling_intermediate) |
| 1949 | 1947 | c->uv_off = (dst_stride>>1) + 64 / (c->dstBpc &~ 7); |
| @@ -1985,7 +1983,7 @@ static av_cold int sws_init_single_context(SwsContext *sws, SwsFilter *srcFilter · 35 unmodified lines |
| 1985 | 1983 | av_log(c, AV_LOG_VERBOSE, "%dx%d -> %dx%d\n", srcW, srcH, dstW, dstH); |
| 1986 | 1984 | av_log(c, AV_LOG_DEBUG, |
| 1987 | 1985 | "lum srcW=%d srcH=%d dstW=%d dstH=%d xInc=%d yInc=%d\n", |
| 1988 | | − c->opts.src_w, c->opts.src_h, c->opts.dst_w, c->opts.dst_h, c->lumXInc, c->lumYInc); |
| 1986 | + sws->src_w, sws->src_h, sws->dst_w, sws->dst_h, c->lumXInc, c->lumYInc); |
| 1989 | 1987 | av_log(c, AV_LOG_DEBUG, |
| 1990 | 1988 | "chr srcW=%d srcH=%d dstW=%d dstH=%d xInc=%d yInc=%d\n", |
| 1991 | 1989 | c->chrSrcW, c->chrSrcH, c->chrDstW, c->chrDstH, |
| @@ -2017,14 +2015,14 @@ fail: // FIXME replace things by appropriate error codes · 25 unmodified lines |
| 2017 | 2015 | c->cascaded_context[0] = sws_getContext(srcW, srcH, srcFormat, |
| 2018 | 2016 | tmpW, tmpH, tmpFormat, |
| 2019 | 2017 | flags, srcFilter, NULL, |
| 2020 | | − c->opts.scaler_params); |
| 2018 | + sws->scaler_params); |
| 2021 | 2019 | if (!c->cascaded_context[0]) |
| 2022 | 2020 | return AVERROR(ENOMEM); |
| 2023 | 2021 | |
| 2024 | 2022 | c->cascaded_context[1] = sws_getContext(tmpW, tmpH, tmpFormat, |
| 2025 | 2023 | dstW, dstH, dstFormat, |
| 2026 | 2024 | flags, NULL, dstFilter, |
| 2027 | | − c->opts.scaler_params); |
| 2025 | + sws->scaler_params); |
| 2028 | 2026 | if (!c->cascaded_context[1]) |
| 2029 | 2027 | return AVERROR(ENOMEM); |
| 2030 | 2028 | return 0; |
| @@ -2039,41 +2037,38 @@ static int context_init_threaded(SwsContext *sws, · 8 unmodified lines |
| 2039 | 2037 | int ret; |
| 2040 | 2038 | |
| 2041 | 2039 | ret = avpriv_slicethread_create(&c->slicethread, (void*) sws, |
| 2042 | | − ff_sws_slice_worker, NULL, c->opts.threads); |
| 2040 | + ff_sws_slice_worker, NULL, sws->threads); |
| 2043 | 2041 | if (ret == AVERROR(ENOSYS)) { |
| 2044 | | − c->opts.threads = 1; |
| 2042 | + sws->threads = 1; |
| 2045 | 2043 | return 0; |
| 2046 | 2044 | } else if (ret < 0) |
| 2047 | 2045 | return ret; |
| 2048 | 2046 | |
| 2049 | | − c->opts.threads = ret; |
| 2047 | + sws->threads = ret; |
| 2050 | 2048 | |
| 2051 | | − c->slice_ctx = av_calloc(c->opts.threads, sizeof(*c->slice_ctx)); |
| 2052 | | − c->slice_err = av_calloc(c->opts.threads, sizeof(*c->slice_err)); |
| 2049 | + c->slice_ctx = av_calloc(sws->threads, sizeof(*c->slice_ctx)); |
| 2050 | + c->slice_err = av_calloc(sws->threads, sizeof(*c->slice_err)); |
| 2053 | 2051 | if (!c->slice_ctx || !c->slice_err) |
| 2054 | 2052 | return AVERROR(ENOMEM); |
| 2055 | 2053 | |
| 2056 | | − for (int i = 0; i < c->opts.threads; i++) { |
| 2057 | | − SwsInternal *c2; |
| 2058 | | − c->slice_ctx[i] = sws_alloc_context(); |
| 2059 | | − if (!c->slice_ctx[i]) |
| 2054 | + for (int i = 0; i < sws->threads; i++) { |
| 2055 | + SwsContext *slice; |
| 2056 | + slice = c->slice_ctx[i] = sws_alloc_context(); |
| 2057 | + if (!slice) |
| 2060 | 2058 | return AVERROR(ENOMEM); |
| 2061 | | − c2 = sws_internal(c->slice_ctx[i]); |
| 2062 | | − |
| 2059 | + sws_internal(slice)->parent = sws; |
| 2063 | 2060 | c->nb_slice_ctx++; |
| 2064 | | − c2->parent = sws; |
| 2065 | 2061 | |
| 2066 | | − ret = av_opt_copy((void*)c->slice_ctx[i], (void*)c); |
| 2062 | + ret = av_opt_copy(slice, sws); |
| 2067 | 2063 | if (ret < 0) |
| 2068 | 2064 | return ret; |
| 2065 | + slice->threads = 1; |
| 2069 | 2066 | |
| 2070 | | − c2->opts.threads = 1; |
| 2071 | | − |
| 2072 | | − ret = sws_init_single_context(c->slice_ctx[i], src_filter, dst_filter); |
| 2067 | + ret = sws_init_single_context(slice, src_filter, dst_filter); |
| 2073 | 2068 | if (ret < 0) |
| 2074 | 2069 | return ret; |
| 2075 | 2070 | |
| 2076 | | − if (c2->opts.dither == SWS_DITHER_ED) { |
| 2071 | + if (slice->dither == SWS_DITHER_ED) { |
| 2077 | 2072 | av_log(c, AV_LOG_VERBOSE, |
| 2078 | 2073 | "Error-diffusion dither is in use, scaling will be single-threaded."); |
| 2079 | 2074 | break; |
| @@ -2099,17 +2094,17 @@ av_cold int sws_init_context(SwsContext *sws, SwsFilter *srcFilter, · 19 unmodified lines |
| 2099 | 2094 | if (ff_thread_once(&rgb2rgb_once, ff_sws_rgb2rgb_init) != 0) |
| 2100 | 2095 | return AVERROR_UNKNOWN; |
| 2101 | 2096 | |
| 2102 | | − src_format = c->opts.src_format; |
| 2103 | | − dst_format = c->opts.dst_format; |
| 2104 | | − c->opts.src_range |= handle_jpeg(&c->opts.src_format); |
| 2105 | | − c->opts.dst_range |= handle_jpeg(&c->opts.dst_format); |
| 2097 | + src_format = sws->src_format; |
| 2098 | + dst_format = sws->dst_format; |
| 2099 | + sws->src_range |= handle_jpeg(&sws->src_format); |
| 2100 | + sws->dst_range |= handle_jpeg(&sws->dst_format); |
| 2106 | 2101 | |
| 2107 | | − if (src_format != c->opts.src_format || dst_format != c->opts.dst_format) |
| 2102 | + if (src_format != sws->src_format || dst_format != sws->dst_format) |
| 2108 | 2103 | av_log(c, AV_LOG_WARNING, "deprecated pixel format used, make sure you did set range correctly\n"); |
| 2109 | 2104 | |
| 2110 | | − if (c->opts.threads != 1) { |
| 2105 | + if (sws->threads != 1) { |
| 2111 | 2106 | ret = context_init_threaded(sws, srcFilter, dstFilter); |
| 2112 | | − if (ret < 0 || c->opts.threads > 1) |
| 2107 | + if (ret < 0 || sws->threads > 1) |
| 2113 | 2108 | return ret; |
| 2114 | 2109 | // threading disabled in this build, init as single-threaded |
| 2115 | 2110 | } |