2010-05-18 19:58:33 +04:00
|
|
|
/*
|
2010-09-09 16:16:39 +04:00
|
|
|
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
|
2010-05-18 19:58:33 +04:00
|
|
|
*
|
2010-06-18 20:39:21 +04:00
|
|
|
* Use of this source code is governed by a BSD-style license
|
2010-06-05 00:19:40 +04:00
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
2010-06-18 20:39:21 +04:00
|
|
|
* in the file PATENTS. All contributing project authors may
|
2010-06-05 00:19:40 +04:00
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
2010-05-18 19:58:33 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2011-02-17 04:54:49 +03:00
|
|
|
/*!\file
|
2010-05-18 19:58:33 +04:00
|
|
|
* \brief Describes the vpx image descriptor and associated operations
|
|
|
|
*
|
|
|
|
*/
|
2014-01-19 00:16:11 +04:00
|
|
|
#ifndef VPX_VPX_IMAGE_H_
|
|
|
|
#define VPX_VPX_IMAGE_H_
|
|
|
|
|
2010-05-18 19:58:33 +04:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2012-07-14 02:21:29 +04:00
|
|
|
/*!\brief Current ABI version number
|
|
|
|
*
|
|
|
|
* \internal
|
|
|
|
* If this file is altered in any way that changes the ABI, this value
|
|
|
|
* must be bumped. Examples include, but are not limited to, changing
|
|
|
|
* types, removing or reassigning enums, adding/removing/rearranging
|
|
|
|
* fields to structures
|
|
|
|
*/
|
2014-02-07 05:13:08 +04:00
|
|
|
#define VPX_IMAGE_ABI_VERSION (2) /**<\hideinitializer*/
|
2010-05-18 19:58:33 +04:00
|
|
|
|
|
|
|
|
2014-08-26 23:35:15 +04:00
|
|
|
#define VPX_IMG_FMT_PLANAR 0x100 /**< Image is a planar format. */
|
|
|
|
#define VPX_IMG_FMT_UV_FLIP 0x200 /**< V plane precedes U in memory. */
|
|
|
|
#define VPX_IMG_FMT_HAS_ALPHA 0x400 /**< Image has an alpha channel. */
|
|
|
|
#define VPX_IMG_FMT_HIGHBITDEPTH 0x800 /**< Image uses 16bit framebuffer. */
|
2010-05-18 19:58:33 +04:00
|
|
|
|
2012-07-14 02:21:29 +04:00
|
|
|
/*!\brief List of supported image formats */
|
|
|
|
typedef enum vpx_img_fmt {
|
|
|
|
VPX_IMG_FMT_NONE,
|
|
|
|
VPX_IMG_FMT_RGB24, /**< 24 bit per pixel packed RGB */
|
|
|
|
VPX_IMG_FMT_RGB32, /**< 32 bit per pixel packed 0RGB */
|
|
|
|
VPX_IMG_FMT_RGB565, /**< 16 bit per pixel, 565 */
|
|
|
|
VPX_IMG_FMT_RGB555, /**< 16 bit per pixel, 555 */
|
|
|
|
VPX_IMG_FMT_UYVY, /**< UYVY packed YUV */
|
|
|
|
VPX_IMG_FMT_YUY2, /**< YUYV packed YUV */
|
|
|
|
VPX_IMG_FMT_YVYU, /**< YVYU packed YUV */
|
|
|
|
VPX_IMG_FMT_BGR24, /**< 24 bit per pixel packed BGR */
|
|
|
|
VPX_IMG_FMT_RGB32_LE, /**< 32 bit packed BGR0 */
|
|
|
|
VPX_IMG_FMT_ARGB, /**< 32 bit packed ARGB, alpha=255 */
|
|
|
|
VPX_IMG_FMT_ARGB_LE, /**< 32 bit packed BGRA, alpha=255 */
|
|
|
|
VPX_IMG_FMT_RGB565_LE, /**< 16 bit per pixel, gggbbbbb rrrrrggg */
|
|
|
|
VPX_IMG_FMT_RGB555_LE, /**< 16 bit per pixel, gggbbbbb 0rrrrrgg */
|
|
|
|
VPX_IMG_FMT_YV12 = VPX_IMG_FMT_PLANAR | VPX_IMG_FMT_UV_FLIP | 1, /**< planar YVU */
|
|
|
|
VPX_IMG_FMT_I420 = VPX_IMG_FMT_PLANAR | 2,
|
|
|
|
VPX_IMG_FMT_VPXYV12 = VPX_IMG_FMT_PLANAR | VPX_IMG_FMT_UV_FLIP | 3, /** < planar 4:2:0 format with vpx color space */
|
2013-05-06 22:01:35 +04:00
|
|
|
VPX_IMG_FMT_VPXI420 = VPX_IMG_FMT_PLANAR | 4,
|
|
|
|
VPX_IMG_FMT_I422 = VPX_IMG_FMT_PLANAR | 5,
|
|
|
|
VPX_IMG_FMT_I444 = VPX_IMG_FMT_PLANAR | 6,
|
2014-04-30 19:14:11 +04:00
|
|
|
VPX_IMG_FMT_444A = VPX_IMG_FMT_PLANAR | VPX_IMG_FMT_HAS_ALPHA | 7,
|
2014-08-26 23:35:15 +04:00
|
|
|
VPX_IMG_FMT_I42016 = VPX_IMG_FMT_I420 | VPX_IMG_FMT_HIGHBITDEPTH,
|
|
|
|
VPX_IMG_FMT_I42216 = VPX_IMG_FMT_I422 | VPX_IMG_FMT_HIGHBITDEPTH,
|
|
|
|
VPX_IMG_FMT_I44416 = VPX_IMG_FMT_I444 | VPX_IMG_FMT_HIGHBITDEPTH
|
2013-05-06 22:01:35 +04:00
|
|
|
} vpx_img_fmt_t; /**< alias for enum vpx_img_fmt */
|
2010-05-18 19:58:33 +04:00
|
|
|
|
2012-07-14 02:21:29 +04:00
|
|
|
/**\brief Image Descriptor */
|
|
|
|
typedef struct vpx_image {
|
|
|
|
vpx_img_fmt_t fmt; /**< Image Format */
|
2010-05-18 19:58:33 +04:00
|
|
|
|
2012-07-14 02:21:29 +04:00
|
|
|
/* Image storage dimensions */
|
2014-06-13 03:53:13 +04:00
|
|
|
unsigned int w; /**< Stored image width */
|
|
|
|
unsigned int h; /**< Stored image height */
|
|
|
|
unsigned int bit_depth; /**< Stored image bit-depth */
|
2010-05-18 19:58:33 +04:00
|
|
|
|
2012-07-14 02:21:29 +04:00
|
|
|
/* Image display dimensions */
|
|
|
|
unsigned int d_w; /**< Displayed image width */
|
|
|
|
unsigned int d_h; /**< Displayed image height */
|
2010-05-18 19:58:33 +04:00
|
|
|
|
2012-07-14 02:21:29 +04:00
|
|
|
/* Chroma subsampling info */
|
|
|
|
unsigned int x_chroma_shift; /**< subsampling order, X */
|
|
|
|
unsigned int y_chroma_shift; /**< subsampling order, Y */
|
2010-05-18 19:58:33 +04:00
|
|
|
|
2012-07-14 02:21:29 +04:00
|
|
|
/* Image data pointers. */
|
2010-05-25 05:45:05 +04:00
|
|
|
#define VPX_PLANE_PACKED 0 /**< To be used for all packed formats */
|
|
|
|
#define VPX_PLANE_Y 0 /**< Y (Luminance) plane */
|
|
|
|
#define VPX_PLANE_U 1 /**< U (Chroma) plane */
|
|
|
|
#define VPX_PLANE_V 2 /**< V (Chroma) plane */
|
2011-02-17 04:54:49 +03:00
|
|
|
#define VPX_PLANE_ALPHA 3 /**< A (Transparency) plane */
|
2012-07-14 02:21:29 +04:00
|
|
|
unsigned char *planes[4]; /**< pointer to the top left pixel for each plane */
|
|
|
|
int stride[4]; /**< stride between rows for each plane */
|
2010-05-18 19:58:33 +04:00
|
|
|
|
2012-07-14 02:21:29 +04:00
|
|
|
int bps; /**< bits per sample (for packed formats) */
|
2010-05-18 19:58:33 +04:00
|
|
|
|
2012-07-14 02:21:29 +04:00
|
|
|
/* The following member may be set by the application to associate data
|
|
|
|
* with this image.
|
2010-05-18 19:58:33 +04:00
|
|
|
*/
|
2012-07-14 02:21:29 +04:00
|
|
|
void *user_priv; /**< may be set by the application to associate data
|
|
|
|
* with this image. */
|
2010-05-18 19:58:33 +04:00
|
|
|
|
2012-07-14 02:21:29 +04:00
|
|
|
/* The following members should be treated as private. */
|
|
|
|
unsigned char *img_data; /**< private */
|
|
|
|
int img_data_owner; /**< private */
|
|
|
|
int self_allocd; /**< private */
|
2014-02-07 05:13:08 +04:00
|
|
|
|
|
|
|
void *fb_priv; /**< Frame buffer data associated with the image. */
|
2012-07-14 02:21:29 +04:00
|
|
|
} vpx_image_t; /**< alias for struct vpx_image */
|
|
|
|
|
|
|
|
/**\brief Representation of a rectangle on a surface */
|
|
|
|
typedef struct vpx_image_rect {
|
|
|
|
unsigned int x; /**< leftmost column */
|
|
|
|
unsigned int y; /**< topmost row */
|
|
|
|
unsigned int w; /**< width */
|
|
|
|
unsigned int h; /**< height */
|
|
|
|
} vpx_image_rect_t; /**< alias for struct vpx_image_rect */
|
|
|
|
|
|
|
|
/*!\brief Open a descriptor, allocating storage for the underlying image
|
|
|
|
*
|
|
|
|
* Returns a descriptor for storing an image of the given format. The
|
|
|
|
* storage for the descriptor is allocated on the heap.
|
|
|
|
*
|
|
|
|
* \param[in] img Pointer to storage for descriptor. If this parameter
|
|
|
|
* is NULL, the storage for the descriptor will be
|
|
|
|
* allocated on the heap.
|
|
|
|
* \param[in] fmt Format for the image
|
|
|
|
* \param[in] d_w Width of the image
|
|
|
|
* \param[in] d_h Height of the image
|
2012-11-06 00:37:14 +04:00
|
|
|
* \param[in] align Alignment, in bytes, of the image buffer and
|
|
|
|
* each row in the image(stride).
|
2012-07-14 02:21:29 +04:00
|
|
|
*
|
|
|
|
* \return Returns a pointer to the initialized image descriptor. If the img
|
|
|
|
* parameter is non-null, the value of the img parameter will be
|
|
|
|
* returned.
|
|
|
|
*/
|
|
|
|
vpx_image_t *vpx_img_alloc(vpx_image_t *img,
|
|
|
|
vpx_img_fmt_t fmt,
|
|
|
|
unsigned int d_w,
|
|
|
|
unsigned int d_h,
|
|
|
|
unsigned int align);
|
|
|
|
|
|
|
|
/*!\brief Open a descriptor, using existing storage for the underlying image
|
|
|
|
*
|
|
|
|
* Returns a descriptor for storing an image of the given format. The
|
|
|
|
* storage for descriptor has been allocated elsewhere, and a descriptor is
|
|
|
|
* desired to "wrap" that storage.
|
|
|
|
*
|
|
|
|
* \param[in] img Pointer to storage for descriptor. If this parameter
|
|
|
|
* is NULL, the storage for the descriptor will be
|
|
|
|
* allocated on the heap.
|
|
|
|
* \param[in] fmt Format for the image
|
|
|
|
* \param[in] d_w Width of the image
|
|
|
|
* \param[in] d_h Height of the image
|
|
|
|
* \param[in] align Alignment, in bytes, of each row in the image.
|
|
|
|
* \param[in] img_data Storage to use for the image
|
|
|
|
*
|
|
|
|
* \return Returns a pointer to the initialized image descriptor. If the img
|
|
|
|
* parameter is non-null, the value of the img parameter will be
|
|
|
|
* returned.
|
|
|
|
*/
|
|
|
|
vpx_image_t *vpx_img_wrap(vpx_image_t *img,
|
|
|
|
vpx_img_fmt_t fmt,
|
|
|
|
unsigned int d_w,
|
|
|
|
unsigned int d_h,
|
|
|
|
unsigned int align,
|
|
|
|
unsigned char *img_data);
|
|
|
|
|
|
|
|
|
|
|
|
/*!\brief Set the rectangle identifying the displayed portion of the image
|
|
|
|
*
|
|
|
|
* Updates the displayed rectangle (aka viewport) on the image surface to
|
|
|
|
* match the specified coordinates and size.
|
|
|
|
*
|
|
|
|
* \param[in] img Image descriptor
|
|
|
|
* \param[in] x leftmost column
|
|
|
|
* \param[in] y topmost row
|
|
|
|
* \param[in] w width
|
|
|
|
* \param[in] h height
|
|
|
|
*
|
|
|
|
* \return 0 if the requested rectangle is valid, nonzero otherwise.
|
|
|
|
*/
|
|
|
|
int vpx_img_set_rect(vpx_image_t *img,
|
|
|
|
unsigned int x,
|
|
|
|
unsigned int y,
|
|
|
|
unsigned int w,
|
|
|
|
unsigned int h);
|
|
|
|
|
|
|
|
|
|
|
|
/*!\brief Flip the image vertically (top for bottom)
|
|
|
|
*
|
|
|
|
* Adjusts the image descriptor's pointers and strides to make the image
|
|
|
|
* be referenced upside-down.
|
|
|
|
*
|
|
|
|
* \param[in] img Image descriptor
|
|
|
|
*/
|
|
|
|
void vpx_img_flip(vpx_image_t *img);
|
|
|
|
|
|
|
|
/*!\brief Close an image descriptor
|
|
|
|
*
|
|
|
|
* Frees all allocated storage associated with an image descriptor.
|
|
|
|
*
|
|
|
|
* \param[in] img Image descriptor
|
|
|
|
*/
|
|
|
|
void vpx_img_free(vpx_image_t *img);
|
2010-05-18 19:58:33 +04:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
2014-01-19 00:16:11 +04:00
|
|
|
} // extern "C"
|
|
|
|
#endif
|
|
|
|
|
2013-12-16 06:26:15 +04:00
|
|
|
#endif // VPX_VPX_IMAGE_H_
|