2 * Implimentation of the planar buffer files.
\r
7 /* creates a planar buffer from the bitmap data.
\r
8 The planar buffer is dynamically allocated, and should
\r
9 be destroyed with the planar_buf_free function when no longer
\r
13 planar_buf_from_bitmap(bitmap_t *b) {
\r
15 int plane, bi, pi, x, y;
\r
17 /* allocate the buffer */
\r
18 p = planar_buf_alloc(b->width, b->height);
\r
20 /* copy the bitmap data into the planar format */
\r
23 for(y=0; y < b->height; y++) {
\r
24 /* start on the first plane */
\r
26 for(x=0; x < b->width; x++) {
\r
27 /* copy to each plane */
\r
28 p->plane[plane++][pi]=b->data[bi++];
\r
30 /* handle the completion of 4 planes. */
\r
37 /* correct for images not divisible by 4 */
\r
45 /* allocates a planar buffer with specified dimensions */
\r
47 planar_buf_alloc(word width, word height) {
\r
51 /* allocate the structure and populate sizes */
\r
52 p=malloc(sizeof(planar_buf_t));
\r
55 p->pwidth = width / 4 + (width%4 ? 1 : 0);
\r
57 /* allocate the planes */
\r
58 for(i=0; i<4; i++) {
\r
59 p->plane[i] = malloc(p->height * p->pwidth);
\r
66 /* deallocates a planar buffer */
\r
68 planar_buf_free(planar_buf_t *p) {
\r
71 /* free the planes */
\r
72 for(i=0; i<4; i++) {
\r
76 /* free the structure */
\r