Or you can check the alternative patch: "avcodec/pthread_frame: rework assert"
On Thu, Nov 28, 2024, at 16:57, Thomas Guillem via ffmpeg-devel wrote: > usage example: > > AVBufferRef *hwframes_ref; > int ret = avcodec_get_hw_frames_parameters(ctx, hwdev_ref, hwfmt, > &hwframes_ref); > ... > ret = av_hwframe_ctx_init(hwframes_ref); > if (ret < 0) > { > av_buffer_unref(&hwframes_ref); > avcodec_reset_hw_frames_parameters(ctx); > return -1; > } > > If avcodec_reset_hw_frames_parameters() is not called, it can lead to the > following assert: > > Assertion p_dst->hwaccel_threadsafe || (!dst->hwaccel && > !dst->internal->hwaccel_priv_data) failed at > src/libavcodec/pthread_frame.c:426 > --- > libavcodec/avcodec.h | 15 +++++++++++++++ > libavcodec/decode.c | 5 +++++ > 2 files changed, 20 insertions(+) > > diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h > index 77ca8dee1f..dfea991db9 100644 > --- a/libavcodec/avcodec.h > +++ b/libavcodec/avcodec.h > @@ -2701,6 +2701,21 @@ int > avcodec_get_hw_frames_parameters(AVCodecContext *avctx, > enum AVPixelFormat hw_pix_fmt, > AVBufferRef **out_frames_ref); > > +/** > + * Reset AVCodecContext HW frames internals > + * > + * This function can be called after a successful call to > + * avcodec_get_hw_frames_parameters() in order to reset the HW > decoding state. > + * > + * It can be used from get_format, to fallback to software decoding > after a > + * failure, not necessarily linked to > avcodec_get_hw_frames_parameters() > + * > + * @param avctx The context which is currently calling get_format, and > which > + * implicitly contains all state needed for filling the > returned > + * AVHWFramesContext properly. > + */ > +void avcodec_reset_hw_frames_parameters(AVCodecContext *avctx); > + > enum AVCodecConfig { > AV_CODEC_CONFIG_PIX_FORMAT, ///< AVPixelFormat, terminated by > AV_PIX_FMT_NONE > AV_CODEC_CONFIG_FRAME_RATE, ///< AVRational, terminated by {0, > 0} > diff --git a/libavcodec/decode.c b/libavcodec/decode.c > index d1e10223f2..5e608076e5 100644 > --- a/libavcodec/decode.c > +++ b/libavcodec/decode.c > @@ -1227,6 +1227,11 @@ int > avcodec_get_hw_frames_parameters(AVCodecContext *avctx, > return ret; > } > > +void avcodec_reset_hw_frames_parameters(AVCodecContext *avctx) > +{ > + ff_hwaccel_uninit(avctx); > +} > + > static int hwaccel_init(AVCodecContext *avctx, > const FFHWAccel *hwaccel) > { > -- > 2.45.2 > > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe". _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".