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

Git pushed a commit to branch master
in repository ffmpeg.

commit 168dfcb557787aef72a010d98273143258b55dd5
Author:     Niklas Haas <[email protected]>
AuthorDate: Wed May 20 16:21:50 2026 +0200
Commit:     Niklas Haas <[email protected]>
CommitDate: Sat Jun 20 14:08:49 2026 +0000

    swscale/ops: add SWS_RW_PALETTE for PAL8 read type
    
    I decided to model this as a separate read/write type, rather than as a
    separate operation (e.g. SWS_OP_PALETTE), because it makes the semantics
    surrounding the read value range, plane pointer setup, etc. much cleaner.
    
    (This will become evident in the upcoming changes to the dispatch layer)
    
    Sponsored-by: Sovereign Tech Fund
    Signed-off-by: Niklas Haas <[email protected]>
---
 libswscale/ops.c  | 15 +++++++++------
 libswscale/ops.h  |  2 ++
 libswscale/uops.c |  2 ++
 3 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/libswscale/ops.c b/libswscale/ops.c
index 71f450fc6b..ec7f358005 100644
--- a/libswscale/ops.c
+++ b/libswscale/ops.c
@@ -171,8 +171,9 @@ int ff_sws_rw_op_planes(const SwsOp *op)
 {
     av_assert2(op->op == SWS_OP_READ || op->op == SWS_OP_WRITE);
     switch (op->rw.mode) {
-    case SWS_RW_PLANAR: return op->rw.elems;
-    case SWS_RW_PACKED: return 1;
+    case SWS_RW_PLANAR:  return op->rw.elems;
+    case SWS_RW_PACKED:  return 1;
+    case SWS_RW_PALETTE: return 2;
     }
 
     av_unreachable("Invalid read/write mode!");
@@ -384,8 +385,9 @@ void ff_sws_op_list_update_comps(SwsOpList *ops)
             for (int i = 0; i < op->rw.elems; i++) {
                 int idx = 0;
                 switch (op->rw.mode) {
-                case SWS_RW_PACKED: idx = i; break;
-                case SWS_RW_PLANAR: idx = ops->plane_src[i]; break;
+                case SWS_RW_PALETTE: idx = i; break;
+                case SWS_RW_PACKED:  idx = i; break;
+                case SWS_RW_PLANAR:  idx = ops->plane_src[i]; break;
                 }
 
                 av_assert0(!(ops->comps_src.flags[idx] & SWS_COMP_GARBAGE));
@@ -864,8 +866,9 @@ static void print_q4(AVBPrint *bp, const AVRational q4[4], 
SwsCompMask mask)
 }
 
 static const char *const rw_mode_names[] = {
-    [SWS_RW_PLANAR] = "planar",
-    [SWS_RW_PACKED] = "packed",
+    [SWS_RW_PLANAR]     = "planar",
+    [SWS_RW_PACKED]     = "packed",
+    [SWS_RW_PALETTE]    = "palette"
 };
 
 void ff_sws_op_desc(AVBPrint *bp, const SwsOp *op)
diff --git a/libswscale/ops.h b/libswscale/ops.h
index b5de7546d5..25ab7b752f 100644
--- a/libswscale/ops.h
+++ b/libswscale/ops.h
@@ -96,6 +96,7 @@ typedef enum SwsReadWriteMode {
      */
     SWS_RW_PLANAR,  /* one plane per component */
     SWS_RW_PACKED,  /* all components on a single plane */
+    SWS_RW_PALETTE, /* plane 0 is 8-bit index, plane 1 is packed palette */
 } SwsReadWriteMode;
 
 typedef struct SwsReadWriteOp {
@@ -106,6 +107,7 @@ typedef struct SwsReadWriteOp {
      *   rgb565    = 1x u16   <- use SWS_OP_UNPACK to unpack
      *   monow     = 1x u8 (frac 3)
      *   rgb4      = 1x u8 (frac 1)
+     *   pal8      = 4x u8 (palette)
      */
     SwsReadWriteMode mode; /* how data is laid out in memory */
     uint8_t elems; /* number of elements (of type `op.type`) to read/write */
diff --git a/libswscale/uops.c b/libswscale/uops.c
index a0bbf5ddbc..3c3edaf9d1 100644
--- a/libswscale/uops.c
+++ b/libswscale/uops.c
@@ -499,6 +499,8 @@ static int translate_rw_op(SwsContext *ctx, SwsUOpList 
*ops, SwsUOpFlags flags,
         if (op->rw.frac)
             return AVERROR(ENOTSUP);
         uop.uop = is_read ? SWS_UOP_READ_PACKED : SWS_UOP_WRITE_PACKED;
+    } else if (op->rw.mode == SWS_RW_PALETTE) {
+        return AVERROR(ENOTSUP);
     } else if (op->rw.frac == 3) {
         uop.uop = is_read ? SWS_UOP_READ_BIT : SWS_UOP_WRITE_BIT;
     } else if (op->rw.frac == 1) {

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

Reply via email to