From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
To: ffmpeg-devel@ffmpeg.org
Cc: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Subject: [FFmpeg-devel] [PATCH 1/6] swscale/utils: Factor initializing single slice context out
Date: Mon, 21 Nov 2022 01:24:46 +0100
Message-ID: <AS8P250MB074468613CBDF4C527764D468F0A9@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM> (raw)
Initializing slice threads currently uses the function
(sws_init_context()) that is also used for initializing
user-facing contexts with the only difference being that
nb_threads is set to one before initializing the slice contexts.
Yet sws_init_context() also initializes lots of stuff
that is not slice-dependent, i.e. (src|dst)Range. This
currently only works because the code sets these fields
to the same values for all slice contexts. This is not
nice; even worse, it entails that log messages are printed
once per slice context (and therefore fill the screen).
This commit lays the groundwork to fix this.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libswscale/utils.c | 31 +++++++++++++++++++++----------
1 file changed, 21 insertions(+), 10 deletions(-)
diff --git a/libswscale/utils.c b/libswscale/utils.c
index 85640a143f..c6fa07f752 100644
--- a/libswscale/utils.c
+++ b/libswscale/utils.c
@@ -1268,6 +1268,9 @@ static enum AVPixelFormat alphaless_fmt(enum AVPixelFormat fmt)
}
}
+static int sws_init_single_context(SwsContext *c, SwsFilter *srcFilter,
+ SwsFilter *dstFilter);
+
static int context_init_threaded(SwsContext *c,
SwsFilter *src_filter, SwsFilter *dst_filter)
{
@@ -1301,7 +1304,7 @@ static int context_init_threaded(SwsContext *c,
c->slice_ctx[i]->nb_threads = 1;
- ret = sws_init_context(c->slice_ctx[i], src_filter, dst_filter);
+ ret = sws_init_single_context(c->slice_ctx[i], src_filter, dst_filter);
if (ret < 0)
return ret;
@@ -1322,8 +1325,8 @@ static int context_init_threaded(SwsContext *c,
return 0;
}
-av_cold int sws_init_context(SwsContext *c, SwsFilter *srcFilter,
- SwsFilter *dstFilter)
+static av_cold int sws_init_single_context(SwsContext *c, SwsFilter *srcFilter,
+ SwsFilter *dstFilter)
{
int i;
int usesVFilter, usesHFilter;
@@ -1344,13 +1347,6 @@ av_cold int sws_init_context(SwsContext *c, SwsFilter *srcFilter,
static const float float_mult = 1.0f / 255.0f;
static AVOnce rgb2rgb_once = AV_ONCE_INIT;
- if (c->nb_threads != 1) {
- ret = context_init_threaded(c, srcFilter, dstFilter);
- if (ret < 0 || c->nb_threads > 1)
- return ret;
- // threading disabled in this build, init as single-threaded
- }
-
cpu_flags = av_get_cpu_flags();
flags = c->flags;
emms_c();
@@ -2054,6 +2050,21 @@ fail: // FIXME replace things by appropriate error codes
return ret;
}
+av_cold int sws_init_context(SwsContext *c, SwsFilter *srcFilter,
+ SwsFilter *dstFilter)
+{
+ int ret;
+
+ if (c->nb_threads != 1) {
+ ret = context_init_threaded(c, srcFilter, dstFilter);
+ if (ret < 0 || c->nb_threads > 1)
+ return ret;
+ // threading disabled in this build, init as single-threaded
+ }
+
+ return sws_init_single_context(c, srcFilter, dstFilter);
+}
+
SwsContext *sws_alloc_set_opts(int srcW, int srcH, enum AVPixelFormat srcFormat,
int dstW, int dstH, enum AVPixelFormat dstFormat,
int flags, const double *param)
--
2.34.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
next reply other threads:[~2022-11-21 0:24 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-21 0:24 Andreas Rheinhardt [this message]
2022-11-21 0:26 ` [FFmpeg-devel] [PATCH 2/6] swscale/utils: Don't allocate AVFrames for slice contexts Andreas Rheinhardt
2022-11-21 0:26 ` [FFmpeg-devel] [PATCH 3/6] swscale/utils: Avoid calling ff_thread_once() unnecessarily Andreas Rheinhardt
2022-11-21 0:26 ` [FFmpeg-devel] [PATCH 4/6] swscale/utils: Move functions to avoid forward declarations Andreas Rheinhardt
2022-11-21 0:27 ` [FFmpeg-devel] [PATCH 5/6] swscale/utils: Derive range from YUVJ-pix-fmt only once Andreas Rheinhardt
2022-11-21 0:27 ` [FFmpeg-devel] [PATCH 6/6] swscale/utils: Fix indentation Andreas Rheinhardt
2022-11-23 21:43 ` [FFmpeg-devel] [PATCH 1/6] swscale/utils: Factor initializing single slice context out Andreas Rheinhardt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=AS8P250MB074468613CBDF4C527764D468F0A9@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM \
--to=andreas.rheinhardt@outlook.com \
--cc=ffmpeg-devel@ffmpeg.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git