diff mbox series

[FFmpeg-devel,3/4] avfilter/vf_transpose: add support for packed rgb float formats

Message ID 20220929180841.614-4-mindmark@gmail.com
State New
Headers show
Series swscale rgbaf32 input/output support | expand

Commit Message

Mark Reid Sept. 29, 2022, 6:08 p.m. UTC
From: Mark Reid <mindmark@gmail.com>

---
 libavfilter/vf_transpose.c | 44 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)
diff mbox series

Patch

diff --git a/libavfilter/vf_transpose.c b/libavfilter/vf_transpose.c
index 469e66729f..1023d6fe82 100644
--- a/libavfilter/vf_transpose.c
+++ b/libavfilter/vf_transpose.c
@@ -174,6 +174,46 @@  static void transpose_8x8_64_c(uint8_t *src, ptrdiff_t src_linesize,
     transpose_block_64_c(src, src_linesize, dst, dst_linesize, 8, 8);
 }
 
+static inline void transpose_block_96_c(uint8_t *src, ptrdiff_t src_linesize,
+                                        uint8_t *dst, ptrdiff_t dst_linesize,
+                                        int w, int h)
+{
+    int x, y;
+    for (y = 0; y < h; y++, dst += dst_linesize, src += 12) {
+        for (x = 0; x < w; x++) {
+            *((uint32_t *)(dst+0 + 12*x)) = *((uint32_t *)(src+0 + x*src_linesize));
+            *((uint32_t *)(dst+4 + 12*x)) = *((uint32_t *)(src+4 + x*src_linesize));
+            *((uint32_t *)(dst+8 + 12*x)) = *((uint32_t *)(src+8 + x*src_linesize));
+        }
+    }
+}
+
+static void transpose_8x8_96_c(uint8_t *src, ptrdiff_t src_linesize,
+                               uint8_t *dst, ptrdiff_t dst_linesize)
+{
+    transpose_block_96_c(src, src_linesize, dst, dst_linesize, 8, 8);
+}
+
+
+static inline void transpose_block_128_c(uint8_t *src, ptrdiff_t src_linesize,
+                                         uint8_t *dst, ptrdiff_t dst_linesize,
+                                         int w, int h)
+{
+    int x, y;
+    for (y = 0; y < h; y++, dst += dst_linesize, src += 16) {
+        for (x = 0; x < w; x++) {
+            *((uint64_t *)(dst+0 + 16*x)) = *((uint64_t *)(src+0 + x*src_linesize));
+            *((uint64_t *)(dst+8 + 16*x)) = *((uint64_t *)(src+8 + x*src_linesize));
+        }
+    }
+}
+
+static void transpose_8x8_128_c(uint8_t *src, ptrdiff_t src_linesize,
+                                uint8_t *dst, ptrdiff_t dst_linesize)
+{
+    transpose_block_128_c(src, src_linesize, dst, dst_linesize, 8, 8);
+}
+
 static int config_props_output(AVFilterLink *outlink)
 {
     AVFilterContext *ctx = outlink->src;
@@ -232,6 +272,10 @@  static int config_props_output(AVFilterLink *outlink)
                 v->transpose_8x8   = transpose_8x8_48_c; break;
         case 8: v->transpose_block = transpose_block_64_c;
                 v->transpose_8x8   = transpose_8x8_64_c; break;
+        case 12: v->transpose_block = transpose_block_96_c;
+                 v->transpose_8x8   = transpose_8x8_96_c; break;
+        case 16: v->transpose_block = transpose_block_128_c;
+                 v->transpose_8x8   = transpose_8x8_128_c; break;
         }
     }