| 1 |
/* |
| 2 |
* Copyright (c) 2022, Intel Corporation |
| 3 |
* |
| 4 |
* Permission is hereby granted, free of charge, to any person obtaining a |
| 5 |
* copy of this software and associated documentation files (the "Software"), |
| 6 |
* to deal in the Software without restriction, including without limitation |
| 7 |
* the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 8 |
* and/or sell copies of the Software, and to permit persons to whom the |
| 9 |
* Software is furnished to do so, subject to the following conditions: |
| 10 |
* |
| 11 |
* The above copyright notice and this permission notice shall be included |
| 12 |
* in all copies or substantial portions of the Software. |
| 13 |
* |
| 14 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
| 15 |
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 16 |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 17 |
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR |
| 18 |
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
| 19 |
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
| 20 |
* OTHER DEALINGS IN THE SOFTWARE. |
| 21 |
*/ |
| 22 |
//! |
| 23 |
//! \file media_bin_mgr.h |
| 24 |
//! |
| 25 |
|
| 26 |
#ifndef MEDIA_BIN_MGR_H__ |
| 27 |
#define MEDIA_BIN_MGR_H__ |
| 28 |
|
| 29 |
#if defined(MEDIA_BIN_SUPPORT) && !defined(MEDIA_BIN_DLL) |
| 30 |
#define DECLARE_SHARED_ARRAY_UINT8(ARRAY_NAME) extern uint8_t *ARRAY_NAME |
| 31 |
#define DECLARE_SHARED_ARRAY_UINT32(ARRAY_NAME) extern unsigned int *ARRAY_NAME |
| 32 |
#elif defined(MEDIA_BIN_ULT) |
| 33 |
#define DECLARE_SHARED_ARRAY_UINT8(ARRAY_NAME) extern const uint8_t ULT_##ARRAY_NAME[]; extern uint8_t *ARRAY_NAME |
| 34 |
#define DEFINE_SHARED_ARRAY_UINT8(ARRAY_NAME) extern const uint8_t ULT_##ARRAY_NAME[] |
| 35 |
#define DECLARE_SHARED_ARRAY_UINT32(ARRAY_NAME) extern const unsigned int ULT_##ARRAY_NAME[]; extern unsigned int *ARRAY_NAME |
| 36 |
#define DEFINE_SHARED_ARRAY_UINT32(ARRAY_NAME) extern const unsigned int ULT_##ARRAY_NAME[] |
| 37 |
#else |
| 38 |
#define DECLARE_SHARED_ARRAY_UINT8(ARRAY_NAME) extern const uint8_t ARRAY_NAME[] |
| 39 |
#define DEFINE_SHARED_ARRAY_UINT8(ARRAY_NAME) extern const uint8_t ARRAY_NAME[] |
| 40 |
#define DECLARE_SHARED_ARRAY_UINT32(ARRAY_NAME) extern const unsigned int ARRAY_NAME[] |
| 41 |
#define DEFINE_SHARED_ARRAY_UINT32(ARRAY_NAME) extern const unsigned int ARRAY_NAME[] |
| 42 |
#endif |
| 43 |
|
| 44 |
#if defined(MEDIA_BIN_SUPPORT) |
| 45 |
#define DECLARE_SHARED_ARRAY_SIZE_UINT32(ARRAY_SIZE) extern unsigned int ARRAY_SIZE |
| 46 |
#define DEFINE_SHARED_ARRAY_SIZE_UINT32(ARRAY_SIZE, SIZE) extern unsigned int ARRAY_SIZE = SIZE |
| 47 |
#elif defined(MEDIA_BIN_ULT) |
| 48 |
#define DECLARE_SHARED_ARRAY_SIZE_UINT32(ARRAY_SIZE) extern const unsigned int ULT_##ARRAY_SIZE; extern unsigned int ARRAY_SIZE |
| 49 |
#define DEFINE_SHARED_ARRAY_SIZE_UINT32(ARRAY_SIZE, SIZE) extern const unsigned int ULT_##ARRAY_SIZE = SIZE |
| 50 |
#else |
| 51 |
#define DECLARE_SHARED_ARRAY_SIZE_UINT32(ARRAY_SIZE) extern const unsigned int ARRAY_SIZE |
| 52 |
#define DEFINE_SHARED_ARRAY_SIZE_UINT32(ARRAY_SIZE, SIZE) extern const unsigned int ARRAY_SIZE = SIZE |
| 53 |
#endif |
| 54 |
|
| 55 |
#if defined(MEDIA_BIN_SUPPORT) |
| 56 |
#include <string> |
| 57 |
#include <map> |
| 58 |
|
| 59 |
typedef struct _MEDIA_BIN_INFO |
| 60 |
{ |
| 61 |
uint32_t* size; |
| 62 |
void** data; |
| 63 |
} MEDIA_BIN_INFO; |
| 64 |
|
| 65 |
#if defined(MEDIA_BIN_DLL) |
| 66 |
|
| 67 |
typedef struct _MEDIA_BIN_DATA_INFO |
| 68 |
{ |
| 69 |
uint32_t size; |
| 70 |
const void* data; |
| 71 |
} MEDIA_BIN_DATA_INFO; |
| 72 |
|
| 73 |
bool RegisterMediaBin(const char* name, uint32_t size, const void* data); |
| 74 |
bool GetMediaBinInternal(std::map<std::string, MEDIA_BIN_INFO>& map); |
| 75 |
|
| 76 |
#else |
| 77 |
bool LoadMediaBinInternal(const char* name, uint32_t* p_size, void** data); |
| 78 |
|
| 79 |
template <typename T> |
| 80 |
bool LoadMediaBin(const char* name, uint32_t* p_size, T** data) |
| 81 |
{ |
| 82 |
return LoadMediaBinInternal(name, p_size, (void**)data); |
| 83 |
} |
| 84 |
#endif |
| 85 |
#endif // (MEDIA_BIN_SUPPORT) |
| 86 |
|
| 87 |
#endif // MEDIA_BIN_MGR_H__ |