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