media/libvpx/vpx/vpx_image.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/media/libvpx/vpx/vpx_image.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,243 @@
     1.4 +/*
     1.5 + *  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
     1.6 + *
     1.7 + *  Use of this source code is governed by a BSD-style license
     1.8 + *  that can be found in the LICENSE file in the root of the source
     1.9 + *  tree. An additional intellectual property rights grant can be found
    1.10 + *  in the file PATENTS.  All contributing project authors may
    1.11 + *  be found in the AUTHORS file in the root of the source tree.
    1.12 + */
    1.13 +
    1.14 +
    1.15 +/*!\file
    1.16 + * \brief Describes the vpx image descriptor and associated operations
    1.17 + *
    1.18 + */
    1.19 +#ifdef __cplusplus
    1.20 +extern "C" {
    1.21 +#endif
    1.22 +
    1.23 +#ifndef VPX_IMAGE_H
    1.24 +#define VPX_IMAGE_H
    1.25 +
    1.26 +  /*!\brief Current ABI version number
    1.27 +   *
    1.28 +   * \internal
    1.29 +   * If this file is altered in any way that changes the ABI, this value
    1.30 +   * must be bumped.  Examples include, but are not limited to, changing
    1.31 +   * types, removing or reassigning enums, adding/removing/rearranging
    1.32 +   * fields to structures
    1.33 +   */
    1.34 +#define VPX_IMAGE_ABI_VERSION (1) /**<\hideinitializer*/
    1.35 +
    1.36 +
    1.37 +#define VPX_IMG_FMT_PLANAR     0x100  /**< Image is a planar format */
    1.38 +#define VPX_IMG_FMT_UV_FLIP    0x200  /**< V plane precedes U plane in memory */
    1.39 +#define VPX_IMG_FMT_HAS_ALPHA  0x400  /**< Image has an alpha channel component */
    1.40 +
    1.41 +
    1.42 +  /*!\brief List of supported image formats */
    1.43 +  typedef enum vpx_img_fmt {
    1.44 +    VPX_IMG_FMT_NONE,
    1.45 +    VPX_IMG_FMT_RGB24,   /**< 24 bit per pixel packed RGB */
    1.46 +    VPX_IMG_FMT_RGB32,   /**< 32 bit per pixel packed 0RGB */
    1.47 +    VPX_IMG_FMT_RGB565,  /**< 16 bit per pixel, 565 */
    1.48 +    VPX_IMG_FMT_RGB555,  /**< 16 bit per pixel, 555 */
    1.49 +    VPX_IMG_FMT_UYVY,    /**< UYVY packed YUV */
    1.50 +    VPX_IMG_FMT_YUY2,    /**< YUYV packed YUV */
    1.51 +    VPX_IMG_FMT_YVYU,    /**< YVYU packed YUV */
    1.52 +    VPX_IMG_FMT_BGR24,   /**< 24 bit per pixel packed BGR */
    1.53 +    VPX_IMG_FMT_RGB32_LE, /**< 32 bit packed BGR0 */
    1.54 +    VPX_IMG_FMT_ARGB,     /**< 32 bit packed ARGB, alpha=255 */
    1.55 +    VPX_IMG_FMT_ARGB_LE,  /**< 32 bit packed BGRA, alpha=255 */
    1.56 +    VPX_IMG_FMT_RGB565_LE,  /**< 16 bit per pixel, gggbbbbb rrrrrggg */
    1.57 +    VPX_IMG_FMT_RGB555_LE,  /**< 16 bit per pixel, gggbbbbb 0rrrrrgg */
    1.58 +    VPX_IMG_FMT_YV12    = VPX_IMG_FMT_PLANAR | VPX_IMG_FMT_UV_FLIP | 1, /**< planar YVU */
    1.59 +    VPX_IMG_FMT_I420    = VPX_IMG_FMT_PLANAR | 2,
    1.60 +    VPX_IMG_FMT_VPXYV12 = VPX_IMG_FMT_PLANAR | VPX_IMG_FMT_UV_FLIP | 3, /** < planar 4:2:0 format with vpx color space */
    1.61 +    VPX_IMG_FMT_VPXI420 = VPX_IMG_FMT_PLANAR | 4,
    1.62 +    VPX_IMG_FMT_I422    = VPX_IMG_FMT_PLANAR | 5,
    1.63 +    VPX_IMG_FMT_I444    = VPX_IMG_FMT_PLANAR | 6,
    1.64 +    VPX_IMG_FMT_444A    = VPX_IMG_FMT_PLANAR | VPX_IMG_FMT_HAS_ALPHA | 7
    1.65 +  } vpx_img_fmt_t; /**< alias for enum vpx_img_fmt */
    1.66 +
    1.67 +#if !defined(VPX_CODEC_DISABLE_COMPAT) || !VPX_CODEC_DISABLE_COMPAT
    1.68 +#define IMG_FMT_PLANAR         VPX_IMG_FMT_PLANAR     /**< \deprecated Use #VPX_IMG_FMT_PLANAR */
    1.69 +#define IMG_FMT_UV_FLIP        VPX_IMG_FMT_UV_FLIP    /**< \deprecated Use #VPX_IMG_FMT_UV_FLIP */
    1.70 +#define IMG_FMT_HAS_ALPHA      VPX_IMG_FMT_HAS_ALPHA  /**< \deprecated Use #VPX_IMG_FMT_HAS_ALPHA */
    1.71 +
    1.72 +  /*!\brief Deprecated list of supported image formats
    1.73 +   * \deprecated New code should use #vpx_img_fmt
    1.74 +   */
    1.75 +#define img_fmt   vpx_img_fmt
    1.76 +  /*!\brief alias for enum img_fmt.
    1.77 +   * \deprecated New code should use #vpx_img_fmt_t
    1.78 +   */
    1.79 +#define img_fmt_t vpx_img_fmt_t
    1.80 +
    1.81 +#define IMG_FMT_NONE       VPX_IMG_FMT_NONE       /**< \deprecated Use #VPX_IMG_FMT_NONE */
    1.82 +#define IMG_FMT_RGB24      VPX_IMG_FMT_RGB24      /**< \deprecated Use #VPX_IMG_FMT_RGB24 */
    1.83 +#define IMG_FMT_RGB32      VPX_IMG_FMT_RGB32      /**< \deprecated Use #VPX_IMG_FMT_RGB32 */
    1.84 +#define IMG_FMT_RGB565     VPX_IMG_FMT_RGB565     /**< \deprecated Use #VPX_IMG_FMT_RGB565 */
    1.85 +#define IMG_FMT_RGB555     VPX_IMG_FMT_RGB555     /**< \deprecated Use #VPX_IMG_FMT_RGB555 */
    1.86 +#define IMG_FMT_UYVY       VPX_IMG_FMT_UYVY       /**< \deprecated Use #VPX_IMG_FMT_UYVY */
    1.87 +#define IMG_FMT_YUY2       VPX_IMG_FMT_YUY2       /**< \deprecated Use #VPX_IMG_FMT_YUY2 */
    1.88 +#define IMG_FMT_YVYU       VPX_IMG_FMT_YVYU       /**< \deprecated Use #VPX_IMG_FMT_YVYU */
    1.89 +#define IMG_FMT_BGR24      VPX_IMG_FMT_BGR24      /**< \deprecated Use #VPX_IMG_FMT_BGR24 */
    1.90 +#define IMG_FMT_RGB32_LE   VPX_IMG_FMT_RGB32_LE   /**< \deprecated Use #VPX_IMG_FMT_RGB32_LE */
    1.91 +#define IMG_FMT_ARGB       VPX_IMG_FMT_ARGB       /**< \deprecated Use #VPX_IMG_FMT_ARGB */
    1.92 +#define IMG_FMT_ARGB_LE    VPX_IMG_FMT_ARGB_LE    /**< \deprecated Use #VPX_IMG_FMT_ARGB_LE */
    1.93 +#define IMG_FMT_RGB565_LE  VPX_IMG_FMT_RGB565_LE  /**< \deprecated Use #VPX_IMG_FMT_RGB565_LE */
    1.94 +#define IMG_FMT_RGB555_LE  VPX_IMG_FMT_RGB555_LE  /**< \deprecated Use #VPX_IMG_FMT_RGB555_LE */
    1.95 +#define IMG_FMT_YV12       VPX_IMG_FMT_YV12       /**< \deprecated Use #VPX_IMG_FMT_YV12 */
    1.96 +#define IMG_FMT_I420       VPX_IMG_FMT_I420       /**< \deprecated Use #VPX_IMG_FMT_I420 */
    1.97 +#define IMG_FMT_VPXYV12    VPX_IMG_FMT_VPXYV12    /**< \deprecated Use #VPX_IMG_FMT_VPXYV12 */
    1.98 +#define IMG_FMT_VPXI420    VPX_IMG_FMT_VPXI420    /**< \deprecated Use #VPX_IMG_FMT_VPXI420 */
    1.99 +#endif /* VPX_CODEC_DISABLE_COMPAT */
   1.100 +
   1.101 +  /**\brief Image Descriptor */
   1.102 +  typedef struct vpx_image {
   1.103 +    vpx_img_fmt_t fmt; /**< Image Format */
   1.104 +
   1.105 +    /* Image storage dimensions */
   1.106 +    unsigned int  w;   /**< Stored image width */
   1.107 +    unsigned int  h;   /**< Stored image height */
   1.108 +
   1.109 +    /* Image display dimensions */
   1.110 +    unsigned int  d_w;   /**< Displayed image width */
   1.111 +    unsigned int  d_h;   /**< Displayed image height */
   1.112 +
   1.113 +    /* Chroma subsampling info */
   1.114 +    unsigned int  x_chroma_shift;   /**< subsampling order, X */
   1.115 +    unsigned int  y_chroma_shift;   /**< subsampling order, Y */
   1.116 +
   1.117 +    /* Image data pointers. */
   1.118 +#define VPX_PLANE_PACKED 0   /**< To be used for all packed formats */
   1.119 +#define VPX_PLANE_Y      0   /**< Y (Luminance) plane */
   1.120 +#define VPX_PLANE_U      1   /**< U (Chroma) plane */
   1.121 +#define VPX_PLANE_V      2   /**< V (Chroma) plane */
   1.122 +#define VPX_PLANE_ALPHA  3   /**< A (Transparency) plane */
   1.123 +#if !defined(VPX_CODEC_DISABLE_COMPAT) || !VPX_CODEC_DISABLE_COMPAT
   1.124 +#define PLANE_PACKED     VPX_PLANE_PACKED
   1.125 +#define PLANE_Y          VPX_PLANE_Y
   1.126 +#define PLANE_U          VPX_PLANE_U
   1.127 +#define PLANE_V          VPX_PLANE_V
   1.128 +#define PLANE_ALPHA      VPX_PLANE_ALPHA
   1.129 +#endif
   1.130 +    unsigned char *planes[4];  /**< pointer to the top left pixel for each plane */
   1.131 +    int      stride[4];  /**< stride between rows for each plane */
   1.132 +
   1.133 +    int     bps; /**< bits per sample (for packed formats) */
   1.134 +
   1.135 +    /* The following member may be set by the application to associate data
   1.136 +     * with this image.
   1.137 +     */
   1.138 +    void    *user_priv; /**< may be set by the application to associate data
   1.139 +                         *   with this image. */
   1.140 +
   1.141 +    /* The following members should be treated as private. */
   1.142 +    unsigned char *img_data;       /**< private */
   1.143 +    int      img_data_owner; /**< private */
   1.144 +    int      self_allocd;    /**< private */
   1.145 +  } vpx_image_t; /**< alias for struct vpx_image */
   1.146 +
   1.147 +  /**\brief Representation of a rectangle on a surface */
   1.148 +  typedef struct vpx_image_rect {
   1.149 +    unsigned int x; /**< leftmost column */
   1.150 +    unsigned int y; /**< topmost row */
   1.151 +    unsigned int w; /**< width */
   1.152 +    unsigned int h; /**< height */
   1.153 +  } vpx_image_rect_t; /**< alias for struct vpx_image_rect */
   1.154 +
   1.155 +  /*!\brief Open a descriptor, allocating storage for the underlying image
   1.156 +   *
   1.157 +   * Returns a descriptor for storing an image of the given format. The
   1.158 +   * storage for the descriptor is allocated on the heap.
   1.159 +   *
   1.160 +   * \param[in]    img       Pointer to storage for descriptor. If this parameter
   1.161 +   *                         is NULL, the storage for the descriptor will be
   1.162 +   *                         allocated on the heap.
   1.163 +   * \param[in]    fmt       Format for the image
   1.164 +   * \param[in]    d_w       Width of the image
   1.165 +   * \param[in]    d_h       Height of the image
   1.166 +   * \param[in]    align     Alignment, in bytes, of the image buffer and
   1.167 +   *                         each row in the image(stride).
   1.168 +   *
   1.169 +   * \return Returns a pointer to the initialized image descriptor. If the img
   1.170 +   *         parameter is non-null, the value of the img parameter will be
   1.171 +   *         returned.
   1.172 +   */
   1.173 +  vpx_image_t *vpx_img_alloc(vpx_image_t  *img,
   1.174 +                             vpx_img_fmt_t fmt,
   1.175 +                             unsigned int d_w,
   1.176 +                             unsigned int d_h,
   1.177 +                             unsigned int align);
   1.178 +
   1.179 +  /*!\brief Open a descriptor, using existing storage for the underlying image
   1.180 +   *
   1.181 +   * Returns a descriptor for storing an image of the given format. The
   1.182 +   * storage for descriptor has been allocated elsewhere, and a descriptor is
   1.183 +   * desired to "wrap" that storage.
   1.184 +   *
   1.185 +   * \param[in]    img       Pointer to storage for descriptor. If this parameter
   1.186 +   *                         is NULL, the storage for the descriptor will be
   1.187 +   *                         allocated on the heap.
   1.188 +   * \param[in]    fmt       Format for the image
   1.189 +   * \param[in]    d_w       Width of the image
   1.190 +   * \param[in]    d_h       Height of the image
   1.191 +   * \param[in]    align     Alignment, in bytes, of each row in the image.
   1.192 +   * \param[in]    img_data  Storage to use for the image
   1.193 +   *
   1.194 +   * \return Returns a pointer to the initialized image descriptor. If the img
   1.195 +   *         parameter is non-null, the value of the img parameter will be
   1.196 +   *         returned.
   1.197 +   */
   1.198 +  vpx_image_t *vpx_img_wrap(vpx_image_t  *img,
   1.199 +                            vpx_img_fmt_t fmt,
   1.200 +                            unsigned int d_w,
   1.201 +                            unsigned int d_h,
   1.202 +                            unsigned int align,
   1.203 +                            unsigned char      *img_data);
   1.204 +
   1.205 +
   1.206 +  /*!\brief Set the rectangle identifying the displayed portion of the image
   1.207 +   *
   1.208 +   * Updates the displayed rectangle (aka viewport) on the image surface to
   1.209 +   * match the specified coordinates and size.
   1.210 +   *
   1.211 +   * \param[in]    img       Image descriptor
   1.212 +   * \param[in]    x         leftmost column
   1.213 +   * \param[in]    y         topmost row
   1.214 +   * \param[in]    w         width
   1.215 +   * \param[in]    h         height
   1.216 +   *
   1.217 +   * \return 0 if the requested rectangle is valid, nonzero otherwise.
   1.218 +   */
   1.219 +  int vpx_img_set_rect(vpx_image_t  *img,
   1.220 +                       unsigned int  x,
   1.221 +                       unsigned int  y,
   1.222 +                       unsigned int  w,
   1.223 +                       unsigned int  h);
   1.224 +
   1.225 +
   1.226 +  /*!\brief Flip the image vertically (top for bottom)
   1.227 +   *
   1.228 +   * Adjusts the image descriptor's pointers and strides to make the image
   1.229 +   * be referenced upside-down.
   1.230 +   *
   1.231 +   * \param[in]    img       Image descriptor
   1.232 +   */
   1.233 +  void vpx_img_flip(vpx_image_t *img);
   1.234 +
   1.235 +  /*!\brief Close an image descriptor
   1.236 +   *
   1.237 +   * Frees all allocated storage associated with an image descriptor.
   1.238 +   *
   1.239 +   * \param[in]    img       Image descriptor
   1.240 +   */
   1.241 +  void vpx_img_free(vpx_image_t *img);
   1.242 +
   1.243 +#endif
   1.244 +#ifdef __cplusplus
   1.245 +}
   1.246 +#endif

mercurial