ffmpeg | branch: master | James Almer <jamr...@gmail.com> | Wed Mar  5 12:55:26 
2025 -0300| [468577d1a52908519bb5af91cbe1430b5ae44d1e] | committer: James Almer

swscale/input: add support for YAF16 and YAF32

Signed-off-by: James Almer <jamr...@gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=468577d1a52908519bb5af91cbe1430b5ae44d1e
---

 libswscale/input.c   | 89 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 libswscale/utils.c   |  4 +++
 libswscale/version.h |  2 +-
 3 files changed, 94 insertions(+), 1 deletion(-)

diff --git a/libswscale/input.c b/libswscale/input.c
index d6b319f25f..9633df5d19 100644
--- a/libswscale/input.c
+++ b/libswscale/input.c
@@ -1283,6 +1283,28 @@ static av_always_inline void grayf32ToY16_c(uint8_t 
*_dst, const uint8_t *_src,
     }
 }
 
+static av_always_inline void read_yaf32_gray_c(uint8_t *_dst, const uint8_t 
*_src, const uint8_t *unused1,
+                                               const uint8_t *unused2, int 
width, int is_be, uint32_t *unused)
+{
+    int i;
+    const float *src = (const float *)_src;
+    uint16_t *dst    = (uint16_t *)_dst;
+
+    for (i = 0; i < width; ++i)
+        dst[i] = lrintf(av_clipf(65535.0f * rdpx(src + i*2), 0.0f,  65535.0f));
+}
+
+static av_always_inline void read_yaf32_alpha_c(uint8_t *_dst, const uint8_t 
*_src, const uint8_t *unused1,
+                                                const uint8_t *unused2, int 
width, int is_be, uint32_t *unused)
+{
+    int i;
+    const float *src = (const float *)_src;
+    uint16_t *dst    = (uint16_t *)_dst;
+
+    for (i = 0; i < width; ++i)
+        dst[i] = lrintf(av_clipf(65535.0f * rdpx(src + i*2 + 1), 0.0f,  
65535.0f));
+}
+
 #undef rdpx
 
 #define rgb9plus_planar_funcs_endian(nbits, endian_name, endian)               
                     \
@@ -1363,6 +1385,18 @@ static void grayf32##endian_name##ToY16_c(uint8_t *dst, 
const uint8_t *src,
                                           int width, uint32_t *unused, void 
*opq)                   \
 {                                                                              
                     \
     grayf32ToY16_c(dst, src, unused1, unused2, width, endian, unused);         
                     \
+}                                                                              
                     \
+static void read_yaf32##endian_name##_gray_c(uint8_t *dst, const uint8_t *src, 
                     \
+                                              const uint8_t *unused1, const 
uint8_t *unused2,       \
+                                              int width, uint32_t *unused, 
void *opq)               \
+{                                                                              
                     \
+    read_yaf32_gray_c(dst, src, unused1, unused2, width, endian, unused);      
                     \
+}                                                                              
                     \
+static void read_yaf32##endian_name##_alpha_c(uint8_t *dst, const uint8_t 
*src,                     \
+                                              const uint8_t *unused1, const 
uint8_t *unused2,       \
+                                              int width, uint32_t *unused, 
void *opq)               \
+{                                                                              
                     \
+    read_yaf32_alpha_c(dst, src, unused1, unused2, width, endian, unused);     
                     \
 }
 
 rgbf32_funcs_endian(le, 0)
@@ -1421,6 +1455,24 @@ static av_always_inline void grayf16ToY16_c(uint8_t 
*dst, const uint8_t *src, co
     }
 }
 
+static av_always_inline void read_yaf16_gray_c(uint8_t *_dst, const uint8_t 
*src, const uint8_t *unused1,
+                                               const uint8_t *unused2, int 
width, int is_be, uint32_t *unused, Half2FloatTables *h2f_tbl)
+{
+    uint16_t *dst = (uint16_t *)_dst;
+
+    for (int i = 0; i < width; i++)
+        dst[i] = lrintf(av_clipf(65535.0f * rdpx2(src + 4*i), 0.0f,  
65535.0f));
+}
+
+static av_always_inline void read_yaf16_alpha_c(uint8_t *_dst, const uint8_t 
*src, const uint8_t *unused1,
+                                               const uint8_t *unused2, int 
width, int is_be, uint32_t *unused, Half2FloatTables *h2f_tbl)
+{
+    uint16_t *dst = (uint16_t *)_dst;
+
+    for (int i = 0; i < width; i++)
+        dst[i] = lrintf(av_clipf(65535.0f * rdpx2(src + 4*i + 2), 0.0f,  
65535.0f));
+}
+
 static av_always_inline void rgbaf16ToUV_half_endian(uint16_t *dstU, uint16_t 
*dstV, int is_be,
                                                      const uint16_t *src, int 
width,
                                                      int32_t *rgb2yuv, 
Half2FloatTables *h2f_tbl)
@@ -1557,6 +1609,19 @@ static void grayf16##endian_name##ToY16_c(uint8_t *dst, 
const uint8_t *src,
 {                                                                              
                     \
     grayf16ToY16_c(dst, src, unused1, unused2, width, endian, unused, opq);    
                     \
 }                                                                              
                     \
+static void read_yaf16##endian_name##_gray_c(uint8_t *dst, const uint8_t *src, 
                     \
+                                            const uint8_t *unused1, const 
uint8_t *unused2,         \
+                                            int width, uint32_t *unused, void 
*opq)                 \
+{                                                                              
                     \
+    read_yaf16_gray_c(dst, src, unused1, unused2, width, endian, unused, opq); 
                     \
+}                                                                              
                     \
+static void read_yaf16##endian_name##_alpha_c(uint8_t *dst, const uint8_t 
*src,                     \
+                                              const uint8_t *unused1, const 
uint8_t *unused2,       \
+                                              int width, uint32_t *unused, 
void *opq)               \
+{                                                                              
                     \
+    read_yaf16_alpha_c(dst, src, unused1, unused2, width, endian, unused, 
opq);                     \
+}                                                                              
                     \
+                                                                               
                     \
 static void rgbaf16##endian_name##ToUV_half_c(uint8_t *_dstU, uint8_t *_dstV, 
const uint8_t *unused,      \
                                               const uint8_t *src1, const 
uint8_t *src2,                   \
                                               int width, uint32_t *_rgb2yuv, 
void *opq)                   \
@@ -2244,6 +2309,12 @@ av_cold void ff_sws_init_input_funcs(SwsInternal *c,
     case AV_PIX_FMT_YA16BE:
         *lumToYV12 = read_ya16be_gray_c;
         break;
+    case AV_PIX_FMT_YAF16LE:
+        *lumToYV12 = read_yaf16le_gray_c;
+        break;
+    case AV_PIX_FMT_YAF16BE:
+        *lumToYV12 = read_yaf16be_gray_c;
+        break;
     case AV_PIX_FMT_VUYA:
     case AV_PIX_FMT_VUYX:
         *lumToYV12 = read_vuyx_Y_c;
@@ -2400,6 +2471,12 @@ av_cold void ff_sws_init_input_funcs(SwsInternal *c,
     case AV_PIX_FMT_GRAYF32BE:
         *lumToYV12 = grayf32beToY16_c;
         break;
+    case AV_PIX_FMT_YAF32LE:
+        *lumToYV12 = read_yaf32le_gray_c;
+        break;
+    case AV_PIX_FMT_YAF32BE:
+        *lumToYV12 = read_yaf32be_gray_c;
+        break;
     case AV_PIX_FMT_GRAYF16LE:
         *lumToYV12 = grayf16leToY16_c;
         break;
@@ -2473,6 +2550,18 @@ av_cold void ff_sws_init_input_funcs(SwsInternal *c,
         case AV_PIX_FMT_YA16BE:
             *alpToYV12 = read_ya16be_alpha_c;
             break;
+        case AV_PIX_FMT_YAF16LE:
+            *alpToYV12 = read_yaf16le_alpha_c;
+            break;
+        case AV_PIX_FMT_YAF16BE:
+            *alpToYV12 = read_yaf16be_alpha_c;
+            break;
+        case AV_PIX_FMT_YAF32LE:
+            *alpToYV12 = read_yaf32le_alpha_c;
+            break;
+        case AV_PIX_FMT_YAF32BE:
+            *alpToYV12 = read_yaf32be_alpha_c;
+            break;
         case AV_PIX_FMT_VUYA:
         case AV_PIX_FMT_UYVA:
             *alpToYV12 = read_vuya_A_c;
diff --git a/libswscale/utils.c b/libswscale/utils.c
index c2fbaf5515..953bf015e4 100644
--- a/libswscale/utils.c
+++ b/libswscale/utils.c
@@ -252,6 +252,10 @@ static const FormatEntry format_entries[] = {
     [AV_PIX_FMT_GRAYF32BE]   = { 1, 1 },
     [AV_PIX_FMT_GRAYF16LE]   = { 1, 0 },
     [AV_PIX_FMT_GRAYF16BE]   = { 1, 0 },
+    [AV_PIX_FMT_YAF32LE]     = { 1, 0 },
+    [AV_PIX_FMT_YAF32BE]     = { 1, 0 },
+    [AV_PIX_FMT_YAF16LE]     = { 1, 0 },
+    [AV_PIX_FMT_YAF16BE]     = { 1, 0 },
     [AV_PIX_FMT_YUVA422P12BE] = { 1, 1 },
     [AV_PIX_FMT_YUVA422P12LE] = { 1, 1 },
     [AV_PIX_FMT_YUVA444P12BE] = { 1, 1 },
diff --git a/libswscale/version.h b/libswscale/version.h
index f84fcc160d..c0f1f0fadc 100644
--- a/libswscale/version.h
+++ b/libswscale/version.h
@@ -29,7 +29,7 @@
 #include "version_major.h"
 
 #define LIBSWSCALE_VERSION_MINOR  13
-#define LIBSWSCALE_VERSION_MICRO 100
+#define LIBSWSCALE_VERSION_MICRO 101
 
 #define LIBSWSCALE_VERSION_INT  AV_VERSION_INT(LIBSWSCALE_VERSION_MAJOR, \
                                                LIBSWSCALE_VERSION_MINOR, \

_______________________________________________
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to