swscale: add sws_test_hw_format()

Allows users to test if a given hardware pixel format is supported by swscale.
This is only a rough heuristic anyways, because the actual support may
depend on the specific *combination* of frame attributes, and ultimately
is better served by the `sws_test_frame` and `sws_frame_setup()` APIs anyways.

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Niklas Haas <git@haasn.dev>
This commit is contained in:
Niklas Haas
2026-02-26 12:40:33 +01:00
committed by Lynne
parent 43f1189af7
commit 26d6ac56c1
4 changed files with 22 additions and 2 deletions

View File

@@ -2,6 +2,9 @@ The last version increases of all libraries were on 2025-03-28
API changes, most recent first:
2026-02-xx - xxxxxxxxxx - lsws 9.4.100 - swscale.h
Add sws_test_hw_format().
2026-02-19 - xxxxxxxxxx - lavf 62.10.100 - avformat.h
Add demuxer command API consisting of:
- Add avformat_send_command().

View File

@@ -527,6 +527,14 @@ int sws_test_format(enum AVPixelFormat format, int output)
return output ? sws_isSupportedOutput(format) : sws_isSupportedInput(format);
}
int sws_test_hw_format(enum AVPixelFormat format)
{
switch (format) {
case AV_PIX_FMT_NONE: return 1;
default: return 0;
}
}
int sws_test_colorspace(enum AVColorSpace csp, int output)
{
switch (csp) {

View File

@@ -267,7 +267,7 @@ void sws_free_context(SwsContext **ctx);
***************************/
/**
* Test if a given pixel format is supported.
* Test if a given (software) pixel format is supported.
*
* @param output If 0, test if compatible with the source/input frame;
* otherwise, with the destination/output frame.
@@ -277,6 +277,15 @@ void sws_free_context(SwsContext **ctx);
*/
int sws_test_format(enum AVPixelFormat format, int output);
/**
* Test if a given hardware pixel format is supported.
*
* @param format The hardware format to check, or AV_PIX_FMT_NONE.
*
* @return A positive integer if supported or AV_PIX_FMT_NONE, 0 otherwise.
*/
int sws_test_hw_format(enum AVPixelFormat format);
/**
* Test if a given color space is supported.
*

View File

@@ -28,7 +28,7 @@
#include "version_major.h"
#define LIBSWSCALE_VERSION_MINOR 3
#define LIBSWSCALE_VERSION_MINOR 4
#define LIBSWSCALE_VERSION_MICRO 100
#define LIBSWSCALE_VERSION_INT AV_VERSION_INT(LIBSWSCALE_VERSION_MAJOR, \