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 16 8-bit pixels, stored in 4 32-bit words
23 * - 16 8-bit chunky pixels on input
24 * - permutated planar data (2 planes per 32-bit word) on output
27 static void c2p_16x8(u32 d
[4])
38 * Array containing the permutation indices of the planar data after c2p
41 static const int perm_c2p_16x8
[4] = { 1, 3, 0, 2 };
45 * Store a full block of iplan2 data after c2p conversion
48 static inline void store_iplan2(void *dst
, u32 bpp
, u32 d
[4])
52 for (i
= 0; i
< bpp
/2; i
++, dst
+= 4)
53 put_unaligned_be32(d
[perm_c2p_16x8
[i
]], dst
);
58 * Store a partial block of iplan2 data after c2p conversion
61 static inline void store_iplan2_masked(void *dst
, u32 bpp
, u32 d
[4], u32 mask
)
65 for (i
= 0; i
< bpp
/2; i
++, dst
+= 4)
66 put_unaligned_be32(comp(d
[perm_c2p_16x8
[i
]],
67 get_unaligned_be32(dst
), mask
),
73 * c2p_iplan2 - Copy 8-bit chunky image data to an interleaved planar
74 * frame buffer with 2 bytes of interleave
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 * @src_nextline: Image offset to the next line (in bytes)
82 * @bpp: Bits per pixel of the planar frame buffer (2, 4, or 8)
85 void c2p_iplan2(void *dst
, const void *src
, u32 dx
, u32 dy
, u32 width
,
86 u32 height
, u32 dst_nextline
, u32 src_nextline
, u32 bpp
)
92 u32 dst_idx
, first
, last
, w
;
96 dst
+= dy
*dst_nextline
+(dx
& ~15)*bpp
;
98 first
= 0xffffU
>> dst_idx
;
100 last
= 0xffffU
^ (0xffffU
>> ((dst_idx
+width
) % 16));
106 if (dst_idx
+width
<= 16) {
107 /* Single destination word */
109 memset(d
.pixels
, 0, sizeof(d
));
110 memcpy(d
.pixels
+dst_idx
, c
, width
);
113 store_iplan2_masked(p
, bpp
, d
.words
, first
);
116 /* Multiple destination words */
121 memset(d
.pixels
, 0, dst_idx
);
122 memcpy(d
.pixels
+dst_idx
, c
, w
);
125 store_iplan2_masked(p
, bpp
, d
.words
, first
);
131 memcpy(d
.pixels
, c
, 16);
134 store_iplan2(p
, bpp
, d
.words
);
141 memcpy(d
.pixels
, c
, w
);
142 memset(d
.pixels
+w
, 0, 16-w
);
144 store_iplan2_masked(p
, bpp
, d
.words
, last
);
151 EXPORT_SYMBOL_GPL(c2p_iplan2
);
153 MODULE_LICENSE("GPL");
This page took 0.033922 seconds and 5 git commands to generate.