This is an automated email from the git hooks/post-receive script. Git pushed a commit to branch master in repository ffmpeg.
commit 29333daae756042f373d8edc5d310219434797fb Author: Ramiro Polla <[email protected]> AuthorDate: Sun Jul 19 12:12:43 2026 +0200 Commit: Niklas Haas <[email protected]> CommitDate: Fri Oct 2 14:15:58 2026 +0200 swscale/uops: move some simple pixel functions to header file They are useful functions to be used elsewhere, and they are simple enough to make sense having them in a header file. Sponsored-by: Sovereign Tech Fund Signed-off-by: Ramiro Polla <[email protected]> --- libswscale/uops.c | 37 ++++--------------------------------- libswscale/uops.h | 25 +++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 33 deletions(-) diff --git a/libswscale/uops.c b/libswscale/uops.c index 316572d472..eb5b4e881c 100644 --- a/libswscale/uops.c +++ b/libswscale/uops.c @@ -47,36 +47,7 @@ static const struct { #undef UOP_NAME }; -static SwsPixel pixel_from_q64(SwsPixelType type, AVRational64 val) -{ - av_assert1(val.den != 0); - switch (type) { - case SWS_PIXEL_U8: return (SwsPixel) { .u8 = val.num / val.den }; - case SWS_PIXEL_U16: return (SwsPixel) { .u16 = val.num / val.den }; - case SWS_PIXEL_U32: return (SwsPixel) { .u32 = val.num / val.den }; - case SWS_PIXEL_F32: return (SwsPixel) { .f32 = (float) val.num / val.den }; - case SWS_PIXEL_NONE: - case SWS_PIXEL_TYPE_NB: break; - } - - av_unreachable("Invalid pixel type!"); - return (SwsPixel) {0}; -} - -#define Q2PIXEL(val) pixel_from_q64(op->type, val) - -static bool pixel_is_1s(SwsPixelType type, SwsPixel val) -{ - switch (ff_sws_pixel_type_size(type)) { - case 1: return val.u8 == UINT8_MAX; - case 2: return val.u16 == UINT16_MAX; - case 4: return val.u32 == UINT32_MAX; - default: break; - } - - av_unreachable("Invalid pixel type!"); - return false; -} +#define Q2PIXEL(val) ff_sws_pixel_from_q64(op->type, val) void ff_sws_uop_name(const SwsUOp *op, char buf[SWS_UOP_NAME_MAX]) { @@ -267,8 +238,8 @@ static bool exact_prod(SwsPixelType type, SwsPixel coef, else if (!minq.den || !maxq.den) return false; /* unknown bounds */ - const SwsPixel min = pixel_from_q64(type, minq); - const SwsPixel max = pixel_from_q64(type, maxq); + const SwsPixel min = ff_sws_pixel_from_q64(type, minq); + const SwsPixel max = ff_sws_pixel_from_q64(type, maxq); switch (type) { case SWS_PIXEL_F32: return exact_product_f32(coef.f32, min.f32) && @@ -610,7 +581,7 @@ static int translate_op(SwsContext *ctx, SwsUOpList *uops, SwsUOpFlags flags, uop.data.vec4[i] = px; if (v.num == 0) uop.par.clear.zero |= SWS_COMP(i); - else if (pixel_is_1s(op->type, px)) + else if (ff_sws_pixel_is_1s(op->type, px)) uop.par.clear.one |= SWS_COMP(i); } break; diff --git a/libswscale/uops.h b/libswscale/uops.h index f044da4547..a297070f76 100644 --- a/libswscale/uops.h +++ b/libswscale/uops.h @@ -30,6 +30,7 @@ ***************************************************************************/ #include "libavutil/attributes.h" +#include "rational64.h" typedef struct SwsContext SwsContext; typedef struct SwsFilterWeights SwsFilterWeights; @@ -87,6 +88,30 @@ typedef union SwsPixel { /* Ensures (SwsPixel) {0} is properly initialized to all zeros */ static_assert(sizeof(SwsPixel) == sizeof(char[4]), "SwsPixel size mismatch"); +static inline SwsPixel ff_sws_pixel_from_q64(SwsPixelType type, AVRational64 val) +{ + switch (type) { + case SWS_PIXEL_U8: return (SwsPixel) { .u8 = val.num / val.den }; + case SWS_PIXEL_U16: return (SwsPixel) { .u16 = val.num / val.den }; + case SWS_PIXEL_U32: return (SwsPixel) { .u32 = val.num / val.den }; + case SWS_PIXEL_F32: return (SwsPixel) { .f32 = (float) val.num / val.den }; + case SWS_PIXEL_NONE: + case SWS_PIXEL_TYPE_NB: break; + } + return (SwsPixel) {0}; +} + +static inline bool ff_sws_pixel_is_1s(SwsPixelType type, SwsPixel val) +{ + switch (ff_sws_pixel_type_size(type)) { + case 1: return val.u8 == UINT8_MAX; + case 2: return val.u16 == UINT16_MAX; + case 4: return val.u32 == UINT32_MAX; + default: break; + } + return false; +} + /** * Bit-mask of components. Exact meaning depends on the usage context. */ -- To stop receiving notification emails like this one, please contact [email protected]. _______________________________________________ ffmpeg-cvslog mailing list -- [email protected] To unsubscribe send an email to [email protected]
