AOMedia AV1 Codec
aom_image.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016, Alliance for Open Media. All rights reserved.
3  *
4  * This source code is subject to the terms of the BSD 2 Clause License and
5  * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License
6  * was not distributed with this source code in the LICENSE file, you can
7  * obtain it at www.aomedia.org/license/software. If the Alliance for Open
8  * Media Patent License 1.0 was not distributed with this source code in the
9  * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
10  */
11 
16 #ifndef AOM_AOM_AOM_IMAGE_H_
17 #define AOM_AOM_AOM_IMAGE_H_
18 
19 #ifdef __cplusplus
20 extern "C" {
21 #endif
22 
23 #include "aom/aom_integer.h"
24 
33 #define AOM_IMAGE_ABI_VERSION (9)
35 #define AOM_IMG_FMT_PLANAR 0x100
36 #define AOM_IMG_FMT_UV_FLIP 0x200
38 #define AOM_IMG_FMT_HIGHBITDEPTH 0x800
41 typedef enum aom_img_fmt {
42  AOM_IMG_FMT_NONE,
62 #define AOM_HAVE_IMG_FMT_NV12 1
64  AOM_IMG_FMT_PLANAR | 7,
69 } aom_img_fmt_t;
72 typedef enum aom_color_primaries {
82  8,
105  10,
130  9,
134  12,
145 typedef enum aom_color_range {
198 
200 typedef struct aom_metadata_array aom_metadata_array_t;
201 
203 typedef struct aom_metadata {
204  uint32_t type;
205  uint8_t *payload;
206  size_t sz;
209 
211 typedef struct aom_image {
220  /* Image storage dimensions */
221  unsigned int w;
222  unsigned int h;
223  unsigned int bit_depth;
225  /* Image display dimensions */
226  unsigned int d_w;
227  unsigned int d_h;
229  /* Image intended rendering dimensions */
230  unsigned int r_w;
231  unsigned int r_h;
233  /* Chroma subsampling info */
234  unsigned int x_chroma_shift;
235  unsigned int y_chroma_shift;
237 /* Image data pointers. */
238 #define AOM_PLANE_PACKED 0
239 #define AOM_PLANE_Y 0
240 #define AOM_PLANE_U 1
241 #define AOM_PLANE_V 2
242  /* planes[AOM_PLANE_V] = NULL and stride[AOM_PLANE_V] = 0 when fmt ==
243  * AOM_IMG_FMT_NV12 */
244  unsigned char *planes[3];
250  int stride[3];
251  size_t sz;
253  int bps;
261  void *user_priv;
262 
263  /* The following members should be treated as private. */
264  unsigned char *img_data;
271  void *fb_priv;
272 } aom_image_t;
296  unsigned int d_w, unsigned int d_h,
297  unsigned int align);
298 
352 aom_image_t *aom_img_wrap(aom_image_t *img, aom_img_fmt_t fmt, unsigned int d_w,
353  unsigned int d_h, unsigned int stride_align,
354  unsigned char *img_data);
355 
383  unsigned int d_w, unsigned int d_h,
384  unsigned int align,
385  unsigned int size_align,
386  unsigned int border);
387 
403 int aom_img_set_rect(aom_image_t *img, unsigned int x, unsigned int y,
404  unsigned int w, unsigned int h, unsigned int border);
405 
413 void aom_img_flip(aom_image_t *img);
414 
421 void aom_img_free(aom_image_t *img);
422 
430 int aom_img_plane_width(const aom_image_t *img, int plane);
431 
439 int aom_img_plane_height(const aom_image_t *img, int plane);
440 
456 int aom_img_add_metadata(aom_image_t *img, uint32_t type, const uint8_t *data,
457  size_t sz, aom_metadata_insert_flags_t insert_flag);
458 
471  size_t index);
472 
484 size_t aom_img_num_metadata(const aom_image_t *img);
485 
494 
509 aom_metadata_t *aom_img_metadata_alloc(uint32_t type, const uint8_t *data,
510  size_t sz,
511  aom_metadata_insert_flags_t insert_flag);
512 
519 void aom_img_metadata_free(aom_metadata_t *metadata);
520 
521 #ifdef __cplusplus
522 } // extern "C"
523 #endif
524 
525 #endif // AOM_AOM_AOM_IMAGE_H_
Definition: aom_image.h:100
unsigned char * img_data
Definition: aom_image.h:264
unsigned int d_h
Definition: aom_image.h:227
unsigned int r_w
Definition: aom_image.h:230
void * fb_priv
Definition: aom_image.h:271
Definition: aom_image.h:106
Definition: aom_image.h:137
Definition: aom_image.h:156
aom_matrix_coefficients_t mc
Definition: aom_image.h:215
Definition: aom_image.h:149
aom_image_t * aom_img_wrap(aom_image_t *img, aom_img_fmt_t fmt, unsigned int d_w, unsigned int d_h, unsigned int stride_align, unsigned char *img_data)
Open a descriptor, using existing storage for the underlying image.
aom_chroma_sample_position
List of chroma sample positions.
Definition: aom_image.h:155
Definition: aom_image.h:80
enum aom_img_fmt aom_img_fmt_t
List of supported image formats.
unsigned char * planes[3]
Definition: aom_image.h:244
Definition: aom_image.h:101
Definition: aom_image.h:129
aom_metadata_insert_flags_t insert_flag
Definition: aom_image.h:207
Definition: aom_image.h:79
Definition: aom_image.h:59
Definition: aom_image.h:95
Definition: aom_image.h:110
enum aom_color_primaries aom_color_primaries_t
List of supported color primaries.
Definition: aom_image.h:132
Definition: aom_image.h:57
enum aom_matrix_coefficients aom_matrix_coefficients_t
List of supported matrix coefficients.
#define AOM_IMG_FMT_HIGHBITDEPTH
Definition: aom_image.h:38
Definition: aom_image.h:74
unsigned int y_chroma_shift
Definition: aom_image.h:235
enum aom_metadata_insert_flags aom_metadata_insert_flags_t
List of insert flags for Metadata.
Definition: aom_image.h:146
int aom_img_add_metadata(aom_image_t *img, uint32_t type, const uint8_t *data, size_t sz, aom_metadata_insert_flags_t insert_flag)
Add metadata to image.
Definition: aom_image.h:97
Definition: aom_image.h:192
Definition: aom_image.h:86
Metadata payload.
Definition: aom_image.h:203
Definition: aom_image.h:58
int monochrome
Definition: aom_image.h:216
Image Descriptor.
Definition: aom_image.h:211
Definition: aom_image.h:136
aom_image_t * aom_img_alloc(aom_image_t *img, aom_img_fmt_t fmt, unsigned int d_w, unsigned int d_h, unsigned int align)
Open a descriptor, allocating storage for the underlying image.
Definition: aom_image.h:68
Definition: aom_image.h:102
Definition: aom_image.h:84
unsigned int w
Definition: aom_image.h:221
void aom_img_metadata_free(aom_metadata_t *metadata)
Free metadata struct.
Definition: aom_image.h:138
aom_color_primaries
List of supported color primaries.
Definition: aom_image.h:72
Definition: aom_image.h:157
Definition: aom_image.h:78
aom_image_t * aom_img_alloc_with_border(aom_image_t *img, aom_img_fmt_t fmt, unsigned int d_w, unsigned int d_h, unsigned int align, unsigned int size_align, unsigned int border)
Open a descriptor, allocating storage for the underlying image with a border.
Definition: aom_image.h:67
Definition: aom_image.h:112
Definition: aom_image.h:126
aom_metadata_insert_flags
List of insert flags for Metadata.
Definition: aom_image.h:187
Definition: aom_image.h:66
void aom_img_free(aom_image_t *img)
Close an image descriptor.
aom_transfer_characteristics_t tc
Definition: aom_image.h:214
Definition: aom_image.h:96
Definition: aom_image.h:109
Definition: aom_image.h:88
Definition: aom_image.h:104
aom_metadata_t * aom_img_metadata_alloc(uint32_t type, const uint8_t *data, size_t sz, aom_metadata_insert_flags_t insert_flag)
Allocate memory for aom_metadata struct.
Definition: aom_image.h:125
Definition: aom_image.h:122
Definition: aom_image.h:139
int self_allocd
Definition: aom_image.h:266
Definition: aom_image.h:87
Definition: aom_image.h:113
struct aom_image aom_image_t
Image Descriptor.
uint32_t type
Definition: aom_image.h:204
int aom_img_plane_width(const aom_image_t *img, int plane)
Get the width of a plane.
Definition: aom_image.h:103
struct aom_metadata_array aom_metadata_array_t
Array of aom_metadata structs for an image.
Definition: aom_image.h:200
aom_metadata_array_t * metadata
Definition: aom_image.h:269
aom_chroma_sample_position_t csp
Definition: aom_image.h:217
Definition: aom_image.h:76
const aom_metadata_t * aom_img_get_metadata(const aom_image_t *img, size_t index)
Return a metadata payload stored within the image metadata array.
Definition: aom_image.h:194
struct aom_metadata aom_metadata_t
Metadata payload.
aom_color_range
List of supported color range.
Definition: aom_image.h:145
uint8_t * payload
Definition: aom_image.h:205
Definition: aom_image.h:107
int aom_img_plane_height(const aom_image_t *img, int plane)
Get the height of a plane.
Definition: aom_image.h:73
Definition: aom_image.h:123
Definition: aom_image.h:124
unsigned int x_chroma_shift
Definition: aom_image.h:234
unsigned int h
Definition: aom_image.h:222
Definition: aom_image.h:128
size_t sz
Definition: aom_image.h:251
Definition: aom_image.h:189
#define AOM_IMG_FMT_PLANAR
Definition: aom_image.h:35
aom_transfer_characteristics
List of supported transfer functions.
Definition: aom_image.h:93
enum aom_color_range aom_color_range_t
List of supported color range.
Definition: aom_image.h:159
Definition: aom_image.h:111
Definition: aom_image.h:160
int bps
Definition: aom_image.h:253
Definition: aom_image.h:196
Definition: aom_image.h:51
Definition: aom_image.h:65
enum aom_chroma_sample_position aom_chroma_sample_position_t
List of chroma sample positions.
Definition: aom_image.h:108
int temporal_id
Definition: aom_image.h:255
Definition: aom_image.h:140
int stride[3]
Definition: aom_image.h:250
Definition: aom_image.h:121
Definition: aom_image.h:114
Definition: aom_image.h:77
void aom_img_flip(aom_image_t *img)
Flip the image vertically (top for bottom)
Definition: aom_image.h:131
Definition: aom_image.h:135
aom_color_range_t range
Definition: aom_image.h:218
Definition: aom_image.h:133
Definition: aom_image.h:99
int spatial_id
Definition: aom_image.h:256
Definition: aom_image.h:98
void aom_img_remove_metadata(aom_image_t *img)
Remove metadata from image.
Definition: aom_image.h:45
Definition: aom_image.h:81
Definition: aom_image.h:190
#define AOM_IMG_FMT_UV_FLIP
Definition: aom_image.h:36
Definition: aom_image.h:120
enum aom_transfer_characteristics aom_transfer_characteristics_t
List of supported transfer functions.
size_t aom_img_num_metadata(const aom_image_t *img)
Return the number of metadata blocks within the image.
Definition: aom_image.h:89
Definition: aom_image.h:94
Definition: aom_image.h:188
Definition: aom_image.h:127
Definition: aom_image.h:63
unsigned int bit_depth
Definition: aom_image.h:223
unsigned int r_h
Definition: aom_image.h:231
unsigned int d_w
Definition: aom_image.h:226
Definition: aom_image.h:75
Definition: aom_image.h:43
aom_matrix_coefficients
List of supported matrix coefficients.
Definition: aom_image.h:119
aom_img_fmt_t fmt
Definition: aom_image.h:212
Definition: aom_image.h:85
size_t sz
Definition: aom_image.h:206
Definition: aom_image.h:83
int aom_img_set_rect(aom_image_t *img, unsigned int x, unsigned int y, unsigned int w, unsigned int h, unsigned int border)
Set the rectangle identifying the displayed portion of the image.
void * user_priv
The following member may be set by the application to associate data with this image.
Definition: aom_image.h:261
aom_color_primaries_t cp
Definition: aom_image.h:213
int img_data_owner
Definition: aom_image.h:265