* [FFmpeg-devel] [PATCH] lavc/pthread_frame: always transfer stashed hwaccel state
@ 2022-09-19 13:18 Anton Khirnov
2022-09-22 16:40 ` Wang Bin
0 siblings, 1 reply; 2+ messages in thread
From: Anton Khirnov @ 2022-09-19 13:18 UTC (permalink / raw)
To: ffmpeg-devel
Fixes assertion failures after avcodec_flush_buffers(), where
stashed hwaccel state is present, but prev_thread is NULL.
Found-by: Wang Bin <wbsecg1@gmail.com>
---
libavcodec/pthread_frame.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c
index 066269621d..f8fddc5e4d 100644
--- a/libavcodec/pthread_frame.c
+++ b/libavcodec/pthread_frame.c
@@ -459,14 +459,14 @@ static int submit_packet(PerThreadContext *p, AVCodecContext *user_avctx,
pthread_mutex_unlock(&p->mutex);
return err;
}
-
- /* transfer hwaccel state stashed from previous thread, if any */
- av_assert0(!p->avctx->hwaccel);
- FFSWAP(const AVHWAccel*, p->avctx->hwaccel, fctx->stash_hwaccel);
- FFSWAP(void*, p->avctx->hwaccel_context, fctx->stash_hwaccel_context);
- FFSWAP(void*, p->avctx->internal->hwaccel_priv_data, fctx->stash_hwaccel_priv);
}
+ /* transfer the stashed hwaccel state, if any */
+ av_assert0(!p->avctx->hwaccel);
+ FFSWAP(const AVHWAccel*, p->avctx->hwaccel, fctx->stash_hwaccel);
+ FFSWAP(void*, p->avctx->hwaccel_context, fctx->stash_hwaccel_context);
+ FFSWAP(void*, p->avctx->internal->hwaccel_priv_data, fctx->stash_hwaccel_priv);
+
av_packet_unref(p->avpkt);
ret = av_packet_ref(p->avpkt, avpkt);
if (ret < 0) {
--
2.35.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".
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [FFmpeg-devel] [PATCH] lavc/pthread_frame: always transfer stashed hwaccel state
2022-09-19 13:18 [FFmpeg-devel] [PATCH] lavc/pthread_frame: always transfer stashed hwaccel state Anton Khirnov
@ 2022-09-22 16:40 ` Wang Bin
0 siblings, 0 replies; 2+ messages in thread
From: Wang Bin @ 2022-09-22 16:40 UTC (permalink / raw)
To: FFmpeg development discussions and patches
Anton Khirnov <anton@khirnov.net> 于2022年9月19日周一 21:22写道:
> Fixes assertion failures after avcodec_flush_buffers(), where
> stashed hwaccel state is present, but prev_thread is NULL.
>
> Found-by: Wang Bin <wbsecg1@gmail.com>
> ---
> libavcodec/pthread_frame.c | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c
> index 066269621d..f8fddc5e4d 100644
> --- a/libavcodec/pthread_frame.c
> +++ b/libavcodec/pthread_frame.c
> @@ -459,14 +459,14 @@ static int submit_packet(PerThreadContext *p,
> AVCodecContext *user_avctx,
> pthread_mutex_unlock(&p->mutex);
> return err;
> }
> -
> - /* transfer hwaccel state stashed from previous thread, if any */
> - av_assert0(!p->avctx->hwaccel);
> - FFSWAP(const AVHWAccel*, p->avctx->hwaccel,
> fctx->stash_hwaccel);
> - FFSWAP(void*, p->avctx->hwaccel_context,
> fctx->stash_hwaccel_context);
> - FFSWAP(void*, p->avctx->internal->hwaccel_priv_data,
> fctx->stash_hwaccel_priv);
> }
>
> + /* transfer the stashed hwaccel state, if any */
> + av_assert0(!p->avctx->hwaccel);
> + FFSWAP(const AVHWAccel*, p->avctx->hwaccel,
> fctx->stash_hwaccel);
> + FFSWAP(void*, p->avctx->hwaccel_context,
> fctx->stash_hwaccel_context);
> + FFSWAP(void*, p->avctx->internal->hwaccel_priv_data,
> fctx->stash_hwaccel_priv);
> +
> av_packet_unref(p->avpkt);
> ret = av_packet_ref(p->avpkt, avpkt);
> if (ret < 0) {
> --
> 2.35.1
>
>
The patch works as expected. I've tested all hwaccels. Thanks.
Regards
_______________________________________________
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".
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-09-22 16:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-19 13:18 [FFmpeg-devel] [PATCH] lavc/pthread_frame: always transfer stashed hwaccel state Anton Khirnov
2022-09-22 16:40 ` Wang Bin
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