/* * Pure Data Packet system implementation. Image packet interface * Copyright (c) by Tom Schouten * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ /** @file image.h @brief Image packet class This file contains the image/bitmap class data and code members. See pf_image for slot info. */ #ifndef PF_IMAGE_H #define PF_IMAGE_H #include #include /* * The image format is the internal format used for processing. * These have to obey certain constrains on image dimensions, so * they can be used by the tile processors, which use a 16x16 pixel * processing block. * * Data encoding is signed. For the 8bit formats, this means the * luma or rgb components have only 7 effective bits. */ /** \brief Image/Bitmap packet subheader * * Contains metadata for image/bitmap packets. * See image.h for method info. */ struct pf_image { pf_header_t super; /* standard images */ unsigned int encoding; ///< image encoding (data format) unsigned int width; ///< image width in pixels (see pf_image_cropdim) unsigned int height; ///< image height in pixels (see pf_image_cropdim) unsigned int depth; ///< number of colour planes unsigned int __chanmask; ///< backwards compat }; // encoding = bitdepth // currently, 8 = signed char, 16 = signed short #define PF_IMAGE_LAYOUT_PLANAR 0 ///< planar encoding, all equal sampling // old formats, for backward compat with pdp // not well supported in pf #define PF_IMAGE_LAYOUT_420 1 ///< backward compat 2x2 subsampled colour planes #define PF_IMAGE_LAYOUT_MONO 2 ///< backward compat greyscale image #define PF_IMAGE_MAKE_ENCODING(layout, bitdepth) ((layout << 8) | (bitdepth & 0xff)) ///< create encoding id #define PF_IMAGE_ENCODING_BITDEPTH(encoding) (encoding & 0xff) ///< obtain bit depth from encoding #define PF_IMAGE_ENCODING_LAYOUT(encoding) (encoding >> 8) ///< obtain layout from encoding #define PF_IMAGE_ENCODING_IS_FOURCC(encoding) (encoding & 0xff000000) ///< if this is true, it's not a PF_IMAGE but a PF_BITMAP #define PF_IMAGE_ENCODING_IS_FOURCC_LUMACHROMA(encoding) ((encoding && 0xff000000) != 0xff000000) ///< encoding is fourcc lumachroma? (rgb encodings have upper 8 bits set: nonstandard fourcc) /* bitmap types */ /* the yuv ones have standard fourcc codes the rgb/grey ones start with 0xff, with smallest nibble == the number of channels, and the second lowest nibble the byte/row order */ // rgb(a) & grey #define PF_FOURCC_GREY 0xff000001 ///< grey scale bitmap (unsigned char) #define PF_FOURCC_GREYA 0xff000002 ///< like grey, but including alpha (unsigned char) #define PF_FOURCC_RGB 0xff000003 ///< the standard rgb bitmap (unsigned char, r=0, g=1, b=2) #define PF_FOURCC_RGBA 0xff000004 ///< like rgb, including alpha // with swapped components #define PF_FOURCC_BGR 0xff000013 ///< like rgb, but components swapped (unsigned char, b=0, g=1, r=2) // opengl rgb(a) and grey // like above, only flipped along horiz axis #define PF_FOURCC_GL_GREY 0xff000021 ///< opengl style (top-bottom flipped) grey (unsigned char) #define PF_FOURCC_GL_GREYA 0xff000022 ///< opengl style (top-bottom flipped) grey (unsigned char) #define PF_FOURCC_GL_RGB 0xff000023 ///< opengl style (top-bottom flipped) rgb (unsigned char) #define PF_FOURCC_GL_RGBA 0xff000024 ///< opengl style (top-bottom flipped) rgba (unsigned char) // standard Y'CbCr fourcc packed #define PF_FOURCC_UYVY 0x59565955 ///< standard UYVY #define PF_FOURCC_YV12 0x32315659 ///< standard YV12 // standard Y'CbCr fourcc planar #define PF_FOURCC_I420 0x30323449 ///< standard I420 #define PF_FOURCC_YUY2 0x32595559 ///< standard YUY2 /* shortcut factory methods */ pf_packet_t pf_factory_newimage(char *type, unsigned int width, unsigned int height, unsigned int depth); ///< create an image pf_packet_t pf_factory_newbitmap(unsigned int fourcc, unsigned int width, unsigned int height); ///< create a bitmap /* image dimensions are multiples of 8x8 to simplify subdivision for vector processing */ static inline unsigned int pf_image_cropdim(unsigned int x) {return x & (~7);} ///< crop dimensions to legal dims: image dims are multiples of 8x8 tiles. #endif