Skip to content

Commit cee4e8f

Browse files
committed
swscale: set thread count to auto
This enables multithreaded swscale conversion newly added to FFmpeg 5.
1 parent 9cb6ffc commit cee4e8f

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/libavcodec_common.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2939,6 +2939,7 @@ struct SwsContext *getSwsContext(unsigned int SrcW, unsigned int SrcH, enum AVPi
29392939
int SrcRange = SrcFormatDesc != NULL && (SrcFormatDesc->flags & AV_PIX_FMT_FLAG_RGB) != 0 ? 1 : 0;
29402940
int DstRange = DstFormatDesc != NULL && (DstFormatDesc->flags & AV_PIX_FMT_FLAG_RGB) != 0 ? 1 : 0;
29412941

2942+
int rc = 0;
29422943
av_opt_set_int(Context, "sws_flags", Flags, 0);
29432944
av_opt_set_int(Context, "srcw", SrcW, 0);
29442945
av_opt_set_int(Context, "srch", SrcH, 0);
@@ -2948,6 +2949,9 @@ struct SwsContext *getSwsContext(unsigned int SrcW, unsigned int SrcH, enum AVPi
29482949
av_opt_set_int(Context, "dst_range", DstRange, 0);
29492950
av_opt_set_int(Context, "src_format", SrcFormat, 0);
29502951
av_opt_set_int(Context, "dst_format", DstFormat, 0);
2952+
if ((rc = av_opt_set(Context, "thread", "auto", 0)) != 0) {
2953+
print_libav_error(LOG_LEVEL_VERBOSE, "Swscale - cannot set thread mode", rc);
2954+
}
29512955

29522956
if (sws_init_context(Context, 0, 0) < 0) {
29532957
sws_freeContext(Context);

0 commit comments

Comments
 (0)