• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2019, 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 
12 /*!\file
13  * \brief Describes the internal functions associated with the aom image
14  * descriptor.
15  *
16  */
17 #ifndef AOM_AOM_INTERNAL_AOM_IMAGE_INTERNAL_H_
18 #define AOM_AOM_INTERNAL_AOM_IMAGE_INTERNAL_H_
19 
20 #include "aom/aom_image.h"
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
26 /*!\brief Array of aom_metadata structs for an image. */
27 struct aom_metadata_array {
28   size_t sz;                       /* Number of metadata structs in the list */
29   aom_metadata_t **metadata_array; /* Array of metadata structs */
30 };
31 
32 /*!\brief Alloc memory for aom_metadata_array struct.
33  *
34  * Allocate memory for aom_metadata_array struct.
35  * If sz is 0 the aom_metadata_array structs internal buffer list will be NULL,
36  * but the aom_metadata_array struct itself will still be allocated.
37  * Returns a pointer to the allocated struct or NULL on failure.
38  *
39  * \param[in]    sz       Size of internal metadata list buffer
40  */
41 aom_metadata_array_t *aom_img_metadata_array_alloc(size_t sz);
42 
43 /*!\brief Free metadata array struct.
44  *
45  * Free metadata array struct and all metadata structs inside.
46  *
47  * \param[in]    arr       Metadata array struct pointer
48  */
49 void aom_img_metadata_array_free(aom_metadata_array_t *arr);
50 
51 typedef void *(*aom_alloc_img_data_cb_fn_t)(void *priv, size_t size);
52 
53 /*!\brief Open a descriptor, allocating storage for the underlying image by
54  * using the provided callback function.
55  *
56  * Returns a descriptor for storing an image of the given format. The storage
57  * for the image is allocated by using the provided callback function. Unlike
58  * aom_img_alloc(), the returned descriptor does not own the storage for the
59  * image. The caller is responsible for freeing the storage for the image.
60  *
61  * Note: If the callback function is invoked and succeeds,
62  * aom_img_alloc_with_cb() is guaranteed to succeed. Therefore, if
63  * aom_img_alloc_with_cb() fails, the caller is assured that no storage was
64  * allocated.
65  *
66  * \param[in]    img       Pointer to storage for descriptor. If this parameter
67  *                         is NULL, the storage for the descriptor will be
68  *                         allocated on the heap.
69  * \param[in]    fmt       Format for the image
70  * \param[in]    d_w       Width of the image
71  * \param[in]    d_h       Height of the image
72  * \param[in]    align     Alignment, in bytes, of the image buffer and
73  *                         each row in the image (stride).
74  * \param[in]    alloc_cb  Callback function used to allocate storage for the
75  *                         image.
76  * \param[in]    cb_priv   The first argument ('priv') for the callback
77  *                         function.
78  *
79  * \return Returns a pointer to the initialized image descriptor. If the img
80  *         parameter is non-null, the value of the img parameter will be
81  *         returned.
82  */
83 aom_image_t *aom_img_alloc_with_cb(aom_image_t *img, aom_img_fmt_t fmt,
84                                    unsigned int d_w, unsigned int d_h,
85                                    unsigned int align,
86                                    aom_alloc_img_data_cb_fn_t alloc_cb,
87                                    void *cb_priv);
88 
89 #ifdef __cplusplus
90 }  // extern "C"
91 #endif
92 
93 #endif  // AOM_AOM_INTERNAL_AOM_IMAGE_INTERNAL_H_
94