Message ID | 20220919131829.14950-1-anton@khirnov.net |
---|---|
State | Accepted |
Commit | c504fb869264fbd8fba6e81c186b2f2848b62e26 |
Headers | show |
Series | [FFmpeg-devel] lavc/pthread_frame: always transfer stashed hwaccel state | expand |
Context | Check | Description |
---|---|---|
yinshiyou/make_loongarch64 | success | Make finished |
yinshiyou/make_fate_loongarch64 | success | Make fate finished |
andriy/make_x86 | success | Make finished |
andriy/make_fate_x86 | success | Make fate finished |
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
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) {