[FFmpeg-devel] [PATCH 1/5] avfilter: tighten semantics on hw_device_ctx

Niklas Haas ffmpeg at haasn.xyz
Fri Feb 9 16:53:45 EET 2024


From: Niklas Haas <git at haasn.dev>

Currently, such filters defer hardware device initialization to
query_formats(), which is not really the correct place to have it. It
would be far more logical for these filters to create the hardware
context at init time, and error out otherwise.

By contrast, filters which merely receive or process hardware frames
typically do this at link config time, because they do not need access
to the hwframe specifics in order to query supported formats.

The intention here is to specifically stop creating hardware devices in
query_formats.
---
 libavfilter/avfilter.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h
index 246d000251..b6adcf2473 100644
--- a/libavfilter/avfilter.h
+++ b/libavfilter/avfilter.h
@@ -464,7 +464,8 @@ struct AVFilterContext {
      *
      * May be set by the caller on filters flagged with AVFILTER_FLAG_HWDEVICE
      * before initializing the filter with avfilter_init_str() or
-     * avfilter_init_dict().
+     * avfilter_init_dict(). *Must* be set for filters which do not have another
+     * way of obtaining a hardware device context (e.g. from an input link).
      */
     AVBufferRef *hw_device_ctx;
 
-- 
2.43.0



More information about the ffmpeg-devel mailing list