swscale: set thread count to auto

This enables multithreaded swscale conversion newly added to FFmpeg 5.
This commit is contained in:
Martin Pulec
2022-01-17 11:23:36 +01:00
parent 9cb6ffca48
commit cee4e8ff24

View File

@@ -2939,6 +2939,7 @@ struct SwsContext *getSwsContext(unsigned int SrcW, unsigned int SrcH, enum AVPi
int SrcRange = SrcFormatDesc != NULL && (SrcFormatDesc->flags & AV_PIX_FMT_FLAG_RGB) != 0 ? 1 : 0;
int DstRange = DstFormatDesc != NULL && (DstFormatDesc->flags & AV_PIX_FMT_FLAG_RGB) != 0 ? 1 : 0;
int rc = 0;
av_opt_set_int(Context, "sws_flags", Flags, 0);
av_opt_set_int(Context, "srcw", SrcW, 0);
av_opt_set_int(Context, "srch", SrcH, 0);
@@ -2948,6 +2949,9 @@ struct SwsContext *getSwsContext(unsigned int SrcW, unsigned int SrcH, enum AVPi
av_opt_set_int(Context, "dst_range", DstRange, 0);
av_opt_set_int(Context, "src_format", SrcFormat, 0);
av_opt_set_int(Context, "dst_format", DstFormat, 0);
if ((rc = av_opt_set(Context, "thread", "auto", 0)) != 0) {
print_libav_error(LOG_LEVEL_VERBOSE, "Swscale - cannot set thread mode", rc);
}
if (sws_init_context(Context, 0, 0) < 0) {
sws_freeContext(Context);