[FFmpeg-devel] [PATCH] avcodec/pthread_frame: rework assert

Thomas Guillem thomas at gllm.fr
Fri Nov 29 10:37:03 EET 2024


This patch is an alternative to the patch "avcodec: add avcodec_reset_hw_frames_parameters():

On Fri, Nov 29, 2024, at 09:34, Thomas Guillem via ffmpeg-devel wrote:
> avcodec_get_hw_frames_parameters(), called by the user from get_format,
> is allocating ctx->internal->hwaccel_priv_data. But the hardware
> decoding setup may fail on the user side and it may fallback to software
> decoding. In that case, ctx->internal->hwaccel_priv_data is still
> allocated but not used anymore.
> ---
>  libavcodec/pthread_frame.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/libavcodec/pthread_frame.c b/libavcodec/pthread_frame.c
> index 1b1b96623f..a4474e4216 100644
> --- a/libavcodec/pthread_frame.c
> +++ b/libavcodec/pthread_frame.c
> @@ -49,6 +49,7 @@
>  #include "libavutil/mem.h"
>  #include "libavutil/opt.h"
>  #include "libavutil/thread.h"
> +#include "libavutil/pixdesc.h"
> 
>  enum {
>      /// Set when the thread is awaiting a packet.
> @@ -413,6 +414,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
>          if (codec->update_thread_context_for_user)
>              err = codec->update_thread_context_for_user(dst, src);
>      } else {
> +        const AVPixFmtDescriptor *desc;
>          const PerThreadContext *p_src = src->internal->thread_ctx;
>          PerThreadContext       *p_dst = dst->internal->thread_ctx;
> 
> @@ -423,8 +425,9 @@ FF_ENABLE_DEPRECATION_WARNINGS
>          }
> 
>          // reset dst hwaccel state if needed
> -        av_assert0(p_dst->hwaccel_threadsafe ||
> -                   (!dst->hwaccel && 
> !dst->internal->hwaccel_priv_data));
> +        desc = av_pix_fmt_desc_get(dst->pix_fmt);
> +        av_assert0(p_dst->hwaccel_threadsafe || desc == NULL ||
> +                   (!dst->hwaccel && (desc->flags & 
> AV_PIX_FMT_FLAG_HWACCEL) == 0));
>          if (p_dst->hwaccel_threadsafe &&
>              (!p_src->hwaccel_threadsafe || dst->hwaccel != 
> src->hwaccel)) {
>              ff_hwaccel_uninit(dst);
> -- 
> 2.45.2
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".


More information about the ffmpeg-devel mailing list