Skip to content

Commit 7a82103

Browse files
committed
Merge branch 'feature/add_element_caps' into 'main'
Add element caps implementation Closes AUD-5770 See merge request adf/multimedia/esp-gmf!13
2 parents e90253e + f5272a9 commit 7a82103

34 files changed

+1601
-97
lines changed

gmf_core/helpers/include/esp_fourcc.h

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,25 @@
3333
- Add audio, video and pixel format with fourcc(four character code)
3434
*/
3535

36+
typedef uint32_t esp_fourcc_t; // 32-bit FOURCC code
37+
3638
#define ESP_FOURCC_TO_INT(a, b, c, d) ((uint32_t)(a) | ((uint32_t)(b) << 8) | ((uint32_t)(c) << 16) | ((uint32_t)(d) << 24))
3739

38-
#define ESP_FOURCC_TO_STR(fourcc) \
39-
(char[]) \
40-
{ \
41-
(char)((fourcc) & 0xFF), \
42-
(char)(((fourcc) >> 8) & 0xFF), \
43-
(char)(((fourcc) >> 16) & 0xFF), \
44-
(char)(((fourcc) >> 24) & 0xFF), \
45-
'\0' \
40+
// Convert 32-bit FOURCC to string
41+
static inline void gmf_fourcc_to_str(uint32_t fourcc, char out[5]) {
42+
for (int i = 0; i < 4; i++) {
43+
out[i] = (char)((fourcc >> (i * 4)) & 0xFF);
4644
}
45+
out[4] = '\0';
46+
}
47+
48+
// Macro to convert an FOURCC code to a string
49+
#define ESP_FOURCC_TO_STR(fourcc) ({ \
50+
static char fourcc_str[5]; \
51+
fourcc_str[0] = fourcc_str[1] = fourcc_str[2] = fourcc_str[3] = fourcc_str[4] = '\0'; \
52+
gmf_fourcc_to_str(fourcc, fourcc_str); \
53+
fourcc_str; \
54+
})
4755

4856
/***************************************************************/
4957
/* Video codec */
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
/*
2+
* Espressif Modified MIT License
3+
*
4+
* Copyright (c) 2025 Espressif Systems (Shanghai) Co., LTD
5+
*
6+
* Permission is hereby granted for use **exclusively** with Espressif Systems products.
7+
* This includes the right to use, copy, modify, merge, publish, distribute, and sublicense
8+
* the Software, subject to the following conditions:
9+
*
10+
* 1. This Software **must be used in conjunction with Espressif Systems products**.
11+
* 2. The above copyright notice and this permission notice shall be included in all copies
12+
* or substantial portions of the Software.
13+
* 3. Redistribution of the Software in source or binary form **for use with non-Espressif products**
14+
* is strictly prohibited.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
17+
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
18+
* PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
19+
* FOR ANY CLAIM, DAMAGES, OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20+
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21+
* DEALINGS IN THE SOFTWARE.
22+
*
23+
* SPDX-License-Identifier: LicenseRef-Espressif-Modified-MIT
24+
*/
25+
26+
#pragma once
27+
28+
#ifdef __cplusplus
29+
extern "C" {
30+
#endif /* __cplusplus */
31+
32+
33+
// Convert string to character code
34+
static inline uint64_t gmf_str_to_cc(const char *str, int max_len)
35+
{
36+
uint64_t result = 0;
37+
if (str && strlen(str) <= max_len) {
38+
memcpy(&result, str, strlen(str));
39+
}
40+
return result;
41+
}
42+
43+
// Convert 64-bit EIGHTCC to string
44+
static inline void gmf_eightcc_to_str(uint64_t eightcc, char out[9])
45+
{
46+
for (int i = 0; i < 8; i++) {
47+
out[i] = (char)((eightcc >> (i * 8)) & 0xFF);
48+
}
49+
out[8] = '\0'; // Null-terminate the string
50+
}
51+
52+
// Macro to convert a string to an 8-byte identifier (EIGHTCC)
53+
#define STR_2_EIGHTCC(str) gmf_str_to_cc(str, 8)
54+
55+
// Macro to convert a string to an 4-byte identifier (FOURCC)
56+
#define STR_2_FOURTCC(str) gmf_str_to_cc(str, 4)
57+
58+
// Macro to convert an EIGHTCC code to a string
59+
#define EIGHTCC_2_STR(eightcc) ({ \
60+
static char eightcc_str[9]; \
61+
gmf_eightcc_to_str(eightcc, eightcc_str); \
62+
eightcc_str; \
63+
})
64+
65+
/***************************************************************************/
66+
/* Definition of Audio Capabilities */
67+
/***************************************************************************/
68+
#define ESP_GMF_CAPS_AUDIO_DECODER STR_2_EIGHTCC("AUDDEC")
69+
#define ESP_GMF_CAPS_AUDIO_ENCODER STR_2_EIGHTCC("AUDENC")
70+
#define ESP_GMF_CAPS_AUDIO_ALC STR_2_EIGHTCC("AUDALC")
71+
#define ESP_GMF_CAPS_AUDIO_BIT_CONVERT STR_2_EIGHTCC("AUDBTCVT")
72+
#define ESP_GMF_CAPS_AUDIO_CHANNEL_CONVERT STR_2_EIGHTCC("AUDCHCVT")
73+
#define ESP_GMF_CAPS_AUDIO_RATE_CONVERT STR_2_EIGHTCC("AUDRTCVT")
74+
#define ESP_GMF_CAPS_AUDIO_MIXER STR_2_EIGHTCC("AUDMIXER")
75+
#define ESP_GMF_CAPS_AUDIO_EQUALIZER STR_2_EIGHTCC("AUDEQ")
76+
#define ESP_GMF_CAPS_AUDIO_SONIC STR_2_EIGHTCC("AUDSONIC")
77+
#define ESP_GMF_CAPS_AUDIO_FADE STR_2_EIGHTCC("AUDFADE")
78+
#define ESP_GMF_CAPS_AUDIO_DEINTERLEAVE STR_2_EIGHTCC("AUDDITLV")
79+
#define ESP_GMF_CAPS_AUDIO_INTERLEAVE STR_2_EIGHTCC("AUDINTLV")
80+
81+
82+
/***************************************************************************/
83+
/* Definition of Video Capabilities */
84+
/***************************************************************************/
85+
#define ESP_GMF_CAPS_VIDEO_DECODER STR_2_EIGHTCC("VIDDEC")
86+
#define ESP_GMF_CAPS_VIDEO_ENCODER STR_2_EIGHTCC("VIDENC")
87+
88+
89+
#ifdef __cplusplus
90+
}
91+
#endif /* __cplusplus */

gmf_core/include/esp_gmf_cache.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
*
2323
*/
2424

25-
#pragma once
25+
#pragma once
2626

2727
#include <string.h>
2828
#include "esp_gmf_oal_mem.h"
@@ -188,11 +188,11 @@ static inline esp_gmf_err_t esp_gmf_cache_acquire(esp_gmf_cache_t *handle, uint3
188188
*load_out = &handle->load;
189189
ESP_LOGD("GMF_CACHE", "ACQ, filled: %ld, Origin_valid_size: %d", handle->buf_filled, handle->origin_load.valid_size);
190190

191-
/*
192-
* 1. If the original buffer has sufficient data, return its address directly to the user
193-
* 2. Copy the remaining data from the original buffer to the cache buffer
194-
* 3. If the original buffer does not have enough data for the user, provide the cached buffer address instead
195-
*/
191+
/**
192+
* 1. If the original buffer has sufficient data, return its address directly to the user
193+
* 2. Copy the remaining data from the original buffer to the cache buffer
194+
* 3. If the original buffer does not have enough data for the user, provide the cached buffer address instead
195+
*/
196196

197197
if (handle->buf_filled == 0) {
198198
if (handle->origin_load.valid_size >= expected_size) {
@@ -207,8 +207,8 @@ static inline esp_gmf_err_t esp_gmf_cache_acquire(esp_gmf_cache_t *handle, uint3
207207
}
208208
if (handle->buf_filled || (handle->origin_load.valid_size < expected_size)) {
209209
int n = (handle->buf_len - handle->buf_filled) > handle->origin_load.valid_size
210-
? handle->origin_load.valid_size
211-
: (handle->buf_len - handle->buf_filled);
210+
? handle->origin_load.valid_size
211+
: (handle->buf_len - handle->buf_filled);
212212
memcpy(handle->buf + handle->buf_filled, handle->origin_load.buf, n);
213213
handle->origin_load.buf += n;
214214
handle->origin_load.valid_size -= n;
@@ -230,7 +230,7 @@ static inline esp_gmf_err_t esp_gmf_cache_acquire(esp_gmf_cache_t *handle, uint3
230230
/**
231231
* @brief Release the payload data previously acquired with `esp_gmf_cache_acquire`
232232
*
233-
* @note The filled portion of the buffer is cleared only if its size equals the buffer length
233+
* @note The filled portion of the buffer is cleared only if its size equals the buffer length
234234
*
235235
* @param[in] handle Pointer to the cache handle
236236
* @param[in] load Pointer to the payload data to be released

0 commit comments

Comments
 (0)