This is an automated email from the git hooks/post-receive script.

Git pushed a commit to branch master
in repository ffmpeg.

commit 5bc08e259df5a1a56324cf36f007566ea667dcdc
Author:     Lynne <[email protected]>
AuthorDate: Mon Feb 23 19:22:18 2026 +0100
Commit:     Lynne <[email protected]>
CommitDate: Thu Feb 26 14:10:21 2026 +0100

    swscale: add SwsFormat.hw_format and populate it
    
    Sponsored-by: Sovereign Tech Fund
---
 libswscale/format.c | 35 +++++++++++++++++++++++++++--------
 libswscale/format.h |  1 +
 2 files changed, 28 insertions(+), 8 deletions(-)

diff --git a/libswscale/format.c b/libswscale/format.c
index ae2a701f43..1e7d491707 100644
--- a/libswscale/format.c
+++ b/libswscale/format.c
@@ -26,6 +26,11 @@
 #include "format.h"
 #include "csputils.h"
 #include "ops_internal.h"
+#include "config_components.h"
+
+#if CONFIG_UNSTABLE
+#include "libavutil/hwcontext.h"
+#endif
 
 #define Q(N) ((AVRational) { N, 1 })
 #define Q0   Q(0)
@@ -306,18 +311,31 @@ int sws_isSupportedEndiannessConversion(enum 
AVPixelFormat pix_fmt)
  */
 SwsFormat ff_fmt_from_frame(const AVFrame *frame, int field)
 {
-    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(frame->format);
     const AVColorPrimariesDesc *primaries;
     AVFrameSideData *sd;
 
+    enum AVPixelFormat format = frame->format;
+    enum AVPixelFormat hw_format = AV_PIX_FMT_NONE;
+
+#if CONFIG_UNSTABLE
+    if (frame->hw_frames_ctx) {
+        AVHWFramesContext *hwfc = (AVHWFramesContext 
*)frame->hw_frames_ctx->data;
+        hw_format = frame->format;
+        format = hwfc->sw_format;
+    }
+#endif
+
+    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(format);
+
     SwsFormat fmt = {
-        .width  = frame->width,
-        .height = frame->height,
-        .format = frame->format,
-        .range  = frame->color_range,
-        .csp    = frame->colorspace,
-        .loc    = frame->chroma_location,
-        .desc   = desc,
+        .width     = frame->width,
+        .height    = frame->height,
+        .format    = format,
+        .hw_format = hw_format,
+        .range     = frame->color_range,
+        .csp       = frame->colorspace,
+        .loc       = frame->chroma_location,
+        .desc      = desc,
         .color = {
             .prim = frame->color_primaries,
             .trc  = frame->color_trc,
@@ -583,6 +601,7 @@ int ff_test_fmt(const SwsFormat *fmt, int output)
            sws_test_colorspace(fmt->csp,        output) &&
            sws_test_primaries (fmt->color.prim, output) &&
            sws_test_transfer  (fmt->color.trc,  output) &&
+           sws_test_hw_format (fmt->hw_format)          &&
            test_range         (fmt->range)              &&
            test_loc           (fmt->loc);
 }
diff --git a/libswscale/format.h b/libswscale/format.h
index fbb65d6805..ee7a07e951 100644
--- a/libswscale/format.h
+++ b/libswscale/format.h
@@ -78,6 +78,7 @@ typedef struct SwsFormat {
     int width, height;
     int interlaced;
     enum AVPixelFormat format;
+    enum AVPixelFormat hw_format;
     enum AVColorRange range;
     enum AVColorSpace csp;
     enum AVChromaLocation loc;

_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to