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