WebM VP8 Codec SDK
vpx/vpx_image.h
Go to the documentation of this file.
00001 /*
00002  *  Copyright (c) 2010 The WebM project authors. All Rights Reserved.
00003  *
00004  *  Use of this source code is governed by a BSD-style license
00005  *  that can be found in the LICENSE file in the root of the source
00006  *  tree. An additional intellectual property rights grant can be found
00007  *  in the file PATENTS.  All contributing project authors may
00008  *  be found in the AUTHORS file in the root of the source tree.
00009  */
00010 
00011 
00016 #ifdef __cplusplus
00017 extern "C" {
00018 #endif
00019 
00020 #ifndef VPX_IMAGE_H
00021 #define VPX_IMAGE_H
00022 
00031 #define VPX_IMAGE_ABI_VERSION (1) 
00034 #define VPX_IMG_FMT_PLANAR     0x100  
00035 #define VPX_IMG_FMT_UV_FLIP    0x200  
00036 #define VPX_IMG_FMT_HAS_ALPHA  0x400  
00040     typedef enum vpx_img_fmt {
00041         VPX_IMG_FMT_NONE,
00042         VPX_IMG_FMT_RGB24,   
00043         VPX_IMG_FMT_RGB32,   
00044         VPX_IMG_FMT_RGB565,  
00045         VPX_IMG_FMT_RGB555,  
00046         VPX_IMG_FMT_UYVY,    
00047         VPX_IMG_FMT_YUY2,    
00048         VPX_IMG_FMT_YVYU,    
00049         VPX_IMG_FMT_BGR24,   
00050         VPX_IMG_FMT_RGB32_LE, 
00051         VPX_IMG_FMT_ARGB,     
00052         VPX_IMG_FMT_ARGB_LE,  
00053         VPX_IMG_FMT_RGB565_LE,  
00054         VPX_IMG_FMT_RGB555_LE,  
00055         VPX_IMG_FMT_YV12    = VPX_IMG_FMT_PLANAR | VPX_IMG_FMT_UV_FLIP | 1, 
00056         VPX_IMG_FMT_I420    = VPX_IMG_FMT_PLANAR | 2,
00057         VPX_IMG_FMT_VPXYV12 = VPX_IMG_FMT_PLANAR | VPX_IMG_FMT_UV_FLIP | 3, 
00058         VPX_IMG_FMT_VPXI420 = VPX_IMG_FMT_PLANAR | 4   
00059     }
00060     vpx_img_fmt_t; 
00062 #if !defined(VPX_CODEC_DISABLE_COMPAT) || !VPX_CODEC_DISABLE_COMPAT
00063 #define IMG_FMT_PLANAR         VPX_IMG_FMT_PLANAR     
00064 #define IMG_FMT_UV_FLIP        VPX_IMG_FMT_UV_FLIP    
00065 #define IMG_FMT_HAS_ALPHA      VPX_IMG_FMT_HAS_ALPHA  
00070 #define img_fmt   vpx_img_fmt
00071 
00074 #define img_fmt_t vpx_img_fmt_t
00075 
00076 #define IMG_FMT_NONE       VPX_IMG_FMT_NONE       
00077 #define IMG_FMT_RGB24      VPX_IMG_FMT_RGB24      
00078 #define IMG_FMT_RGB32      VPX_IMG_FMT_RGB32      
00079 #define IMG_FMT_RGB565     VPX_IMG_FMT_RGB565     
00080 #define IMG_FMT_RGB555     VPX_IMG_FMT_RGB555     
00081 #define IMG_FMT_UYVY       VPX_IMG_FMT_UYVY       
00082 #define IMG_FMT_YUY2       VPX_IMG_FMT_YUY2       
00083 #define IMG_FMT_YVYU       VPX_IMG_FMT_YVYU       
00084 #define IMG_FMT_BGR24      VPX_IMG_FMT_BGR24      
00085 #define IMG_FMT_RGB32_LE   VPX_IMG_FMT_RGB32_LE   
00086 #define IMG_FMT_ARGB       VPX_IMG_FMT_ARGB       
00087 #define IMG_FMT_ARGB_LE    VPX_IMG_FMT_ARGB_LE    
00088 #define IMG_FMT_RGB565_LE  VPX_IMG_FMT_RGB565_LE  
00089 #define IMG_FMT_RGB555_LE  VPX_IMG_FMT_RGB555_LE  
00090 #define IMG_FMT_YV12       VPX_IMG_FMT_YV12       
00091 #define IMG_FMT_I420       VPX_IMG_FMT_I420       
00092 #define IMG_FMT_VPXYV12    VPX_IMG_FMT_VPXYV12    
00093 #define IMG_FMT_VPXI420    VPX_IMG_FMT_VPXI420    
00094 #endif /* VPX_CODEC_DISABLE_COMPAT */
00095 
00097     typedef struct vpx_image
00098     {
00099         vpx_img_fmt_t fmt; 
00101         /* Image storage dimensions */
00102         unsigned int  w;   
00103         unsigned int  h;   
00105         /* Image display dimensions */
00106         unsigned int  d_w;   
00107         unsigned int  d_h;   
00109         /* Chroma subsampling info */
00110         unsigned int  x_chroma_shift;   
00111         unsigned int  y_chroma_shift;   
00113         /* Image data pointers. */
00114 #define VPX_PLANE_PACKED 0   
00115 #define VPX_PLANE_Y      0   
00116 #define VPX_PLANE_U      1   
00117 #define VPX_PLANE_V      2   
00118 #define VPX_PLANE_ALPHA  3   
00119 #if !defined(VPX_CODEC_DISABLE_COMPAT) || !VPX_CODEC_DISABLE_COMPAT
00120 #define PLANE_PACKED     VPX_PLANE_PACKED
00121 #define PLANE_Y          VPX_PLANE_Y
00122 #define PLANE_U          VPX_PLANE_U
00123 #define PLANE_V          VPX_PLANE_V
00124 #define PLANE_ALPHA      VPX_PLANE_ALPHA
00125 #endif
00126         unsigned char *planes[4];  
00127         int      stride[4];  
00129         int     bps; 
00131         /* The following member may be set by the application to associate data
00132          * with this image.
00133          */
00134         void    *user_priv; 
00137         /* The following members should be treated as private. */
00138         unsigned char *img_data;       
00139         int      img_data_owner; 
00140         int      self_allocd;    
00141     } vpx_image_t; 
00144     typedef struct vpx_image_rect
00145     {
00146         unsigned int x; 
00147         unsigned int y; 
00148         unsigned int w; 
00149         unsigned int h; 
00150     } vpx_image_rect_t; 
00169     vpx_image_t *vpx_img_alloc(vpx_image_t  *img,
00170                                vpx_img_fmt_t fmt,
00171                                unsigned int d_w,
00172                                unsigned int d_h,
00173                                unsigned int align);
00174 
00194     vpx_image_t *vpx_img_wrap(vpx_image_t  *img,
00195                               vpx_img_fmt_t fmt,
00196                               unsigned int d_w,
00197                               unsigned int d_h,
00198                               unsigned int align,
00199                               unsigned char      *img_data);
00200 
00201 
00215     int vpx_img_set_rect(vpx_image_t  *img,
00216                          unsigned int  x,
00217                          unsigned int  y,
00218                          unsigned int  w,
00219                          unsigned int  h);
00220 
00221 
00229     void vpx_img_flip(vpx_image_t *img);
00230 
00237     void vpx_img_free(vpx_image_t *img);
00238 
00239 #endif
00240 #ifdef __cplusplus
00241 }
00242 #endif