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] avcodec/pthread_frame: Don't prematurily presume frame-threading Date: Mon, 7 Feb 2022 01:37:43 +0100 Message-ID: <AM7PR03MB6660F0B409023602042F3C1B8F2C9@AM7PR03MB6660.eurprd03.prod.outlook.com> (raw) Several of our decoders support both frame- as well as slice-threading; in case of the latter avctx->internal->thread_ctx points to a SliceThreadContext, not to a frame-thread PerThreadContext. So only treat avctx->internal->thread_ctx as the latter after having checked that frame-threading is active. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com> --- libavcodec/pthread_frame.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c index 85a6bc98c1..43e097ff06 100644 --- a/libavcodec/pthread_frame.c +++ b/libavcodec/pthread_frame.c @@ -949,7 +949,7 @@ FF_ENABLE_DEPRECATION_WARNINGS static int thread_get_buffer_internal(AVCodecContext *avctx, ThreadFrame *f, int flags) { - PerThreadContext *p = avctx->internal->thread_ctx; + PerThreadContext *p; int err; f->owner[0] = f->owner[1] = avctx; @@ -957,6 +957,7 @@ static int thread_get_buffer_internal(AVCodecContext *avctx, ThreadFrame *f, int if (!(avctx->active_thread_type & FF_THREAD_FRAME)) return ff_get_buffer(avctx, f->f, flags); + p = avctx->internal->thread_ctx; FF_DISABLE_DEPRECATION_WARNINGS if (atomic_load(&p->state) != STATE_SETTING_UP && (avctx->codec->update_thread_context @@ -1020,10 +1021,12 @@ FF_DISABLE_DEPRECATION_WARNINGS enum AVPixelFormat ff_thread_get_format(AVCodecContext *avctx, const enum AVPixelFormat *fmt) { enum AVPixelFormat res; - PerThreadContext *p = avctx->internal->thread_ctx; + PerThreadContext *p; if (!(avctx->active_thread_type & FF_THREAD_FRAME) || avctx->thread_safe_callbacks || avctx->get_format == avcodec_default_get_format) return ff_get_format(avctx, fmt); + + p = avctx->internal->thread_ctx; if (atomic_load(&p->state) != STATE_SETTING_UP) { av_log(avctx, AV_LOG_ERROR, "get_format() cannot be called after ff_thread_finish_setup()\n"); return -1; @@ -1057,7 +1060,7 @@ void ff_thread_release_buffer(AVCodecContext *avctx, ThreadFrame *f) { #if FF_API_THREAD_SAFE_CALLBACKS FF_DISABLE_DEPRECATION_WARNINGS - PerThreadContext *p = avctx->internal->thread_ctx; + PerThreadContext *p; FrameThreadContext *fctx; AVFrame *dst; int ret = 0; @@ -1084,6 +1087,7 @@ FF_ENABLE_DEPRECATION_WARNINGS return; } + p = avctx->internal->thread_ctx; fctx = p->parent; pthread_mutex_lock(&fctx->buffer_mutex); -- 2.32.0 _______________________________________________ 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-02-07 0:38 UTC|newest] Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-02-07 0:37 Andreas Rheinhardt [this message] 2022-02-07 0:58 ` [FFmpeg-devel] [PATCH 2/6] avcodec/hapdec: Remove always-false check Andreas Rheinhardt 2022-02-07 0:58 ` [FFmpeg-devel] [PATCH 3/6] avcodec/thread: Move ff_thread_(await|report)_progress to new header Andreas Rheinhardt 2022-02-07 0:58 ` [FFmpeg-devel] [PATCH 4/6] avcodec/threadframe: Add ff_thread_(get|release)_ext_buffer() Andreas Rheinhardt 2022-02-07 0:58 ` [FFmpeg-devel] [PATCH 5/6] avcodec/thread: Don't use ThreadFrame when unnecessary Andreas Rheinhardt 2022-02-07 0:58 ` [FFmpeg-devel] [PATCH 6/6] avcodec/pthread_frame: Properly unref frame in case of decoding failure Andreas Rheinhardt 2022-02-09 16:13 [FFmpeg-devel] [PATCH 1/6] avcodec/pthread_frame: Don't prematurily presume frame-threading Anton Khirnov
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=AM7PR03MB6660F0B409023602042F3C1B8F2C9@AM7PR03MB6660.eurprd03.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