2 * Fast C2P (Chunky-to-Planar) Conversion
4 * Copyright (C) 2003-2008 Geert Uytterhoeven
6 * This file is subject to the terms and conditions of the GNU General Public
7 * License. See the file COPYING in the main directory of this archive
11 #include <linux/module.h>
12 #include <linux/string.h>
14 #include <asm/unaligned.h>
21 * Perform a full C2P step on 32 8-bit pixels, stored in 8 32-bit words
23 * - 32 8-bit chunky pixels on input
24 * - permutated planar data (1 plane per 32-bit word) on output
27 static void c2p_32x8(u32 d
[8])
38 * Array containing the permutation indices of the planar data after c2p
41 static const int perm_c2p_32x8
[8] = { 7, 5, 3, 1, 6, 4, 2, 0 };
45 * Store a full block of planar data after c2p conversion
48 static inline void store_planar(void *dst
, u32 dst_inc
, u32 bpp
, u32 d
[8])
52 for (i
= 0; i
< bpp
; i
++, dst
+= dst_inc
)
53 put_unaligned_be32(d
[perm_c2p_32x8
[i
]], dst
);
58 * Store a partial block of planar data after c2p conversion
61 static inline void store_planar_masked(void *dst
, u32 dst_inc
, u32 bpp
,
66 for (i
= 0; i
< bpp
; i
++, dst
+= dst_inc
)
67 put_unaligned_be32(comp(d
[perm_c2p_32x8
[i
]],
68 get_unaligned_be32(dst
), mask
),
74 * c2p_planar - Copy 8-bit chunky image data to a planar frame buffer
75 * @dst: Starting address of the planar frame buffer
76 * @dx: Horizontal destination offset (in pixels)
77 * @dy: Vertical destination offset (in pixels)
78 * @width: Image width (in pixels)
79 * @height: Image height (in pixels)
80 * @dst_nextline: Frame buffer offset to the next line (in bytes)
81 * @dst_nextplane: Frame buffer offset to the next plane (in bytes)
82 * @src_nextline: Image offset to the next line (in bytes)
83 * @bpp: Bits per pixel of the planar frame buffer (1-8)
86 void c2p_planar(void *dst
, const void *src
, u32 dx
, u32 dy
, u32 width
,
87 u32 height
, u32 dst_nextline
, u32 dst_nextplane
,
88 u32 src_nextline
, u32 bpp
)
94 u32 dst_idx
, first
, last
, w
;
98 dst
+= dy
*dst_nextline
+(dx
& ~31);
100 first
= 0xffffffffU
>> dst_idx
;
101 last
= ~(0xffffffffU
>> ((dst_idx
+width
) % 32));
106 if (dst_idx
+width
<= 32) {
107 /* Single destination word */
109 memset(d
.pixels
, 0, sizeof(d
));
110 memcpy(d
.pixels
+dst_idx
, c
, width
);
113 store_planar_masked(p
, dst_nextplane
, bpp
, d
.words
,
117 /* Multiple destination words */
122 memset(d
.pixels
, 0, dst_idx
);
123 memcpy(d
.pixels
+dst_idx
, c
, w
);
126 store_planar_masked(p
, dst_nextplane
, bpp
,
133 memcpy(d
.pixels
, c
, 32);
136 store_planar(p
, dst_nextplane
, bpp
, d
.words
);
143 memcpy(d
.pixels
, c
, w
);
144 memset(d
.pixels
+w
, 0, 32-w
);
146 store_planar_masked(p
, dst_nextplane
, bpp
,
154 EXPORT_SYMBOL_GPL(c2p_planar
);
156 MODULE_LICENSE("GPL");
This page took 0.03278 seconds and 5 git commands to generate.