H.264 Codec for ESP32-S3
Loading...
Searching...
No Matches
esp_h264_alloc.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#pragma once
8#include "H264Config.h"
9#include "esp_idf_version.h"
10#include "esp_heap_caps.h"
11
12#define ESP_H264_MEM_INTERNAL MALLOC_CAP_INTERNAL
13#define ESP_H264_MEM_SPIRAM MALLOC_CAP_SPIRAM
14#define ALIGN_UP(num, align) (((num) + ((align) - 1)) & ~((align) - 1))
15
16/**
17 * @brief Free memory previously allocated
18 */
19#define esp_h264_free heap_caps_free
20
21#ifdef __cplusplus
22extern "C" {
23#endif
24
25
26/**
27 * @brief Allocate an aligned chunk of memory which has the given capabilities.
28 *
29 * @param[in] alignment How the pointer received needs to be aligned must be a power of two.
30 * If the value is less than cache line size, the value will be forced cache line size.
31 * @param[in] n Number of continuing chunks of memory to allocate
32 * @param[in] size Size, in bytes, of a chunk of memory to allocate
33 * @param[in] caps ESP_H264_MEM_INTERNAL or ESP_H264_MEM_SPIRAM
34 *
35 * @return
36 * - NULL Failure
37 * - others A pointer to the memory allocated on success
38 */
39void *esp_h264_aligned_calloc(uint32_t alignment, uint32_t n, uint32_t size, uint32_t *actual_size, uint32_t caps);
40
41/**
42 * @brief Allocate a chunk of memory as preference in decreasing order. And helper function for calloc a cache aligned data memory buffer
43 *
44 * @param[in] n Number of continuing chunks of memory to allocate
45 * @param[in] size Size, in bytes, of a chunk of memory to allocate
46 * @param[in] caps1 ESP_H264_MEM_INTERNAL or ESP_H264_MEM_SPIRAM
47 * @param[in] caps2 ESP_H264_MEM_INTERNAL or ESP_H264_MEM_SPIRAM
48 *
49 * @return
50 * - NULL Failure
51 * - others A pointer to the memory allocated on success
52 */
53void *esp_h264_calloc_prefer(uint32_t n, uint32_t size, uint32_t *actual_size, uint32_t caps1, uint32_t caps2);
54
55#ifdef __cplusplus
56}
57#endif
void * esp_h264_aligned_calloc(uint32_t alignment, uint32_t n, uint32_t size, uint32_t *actual_size, uint32_t caps)
Allocate an aligned chunk of memory which has the given capabilities.
Definition: esp_h264_alloc.c:13
void * esp_h264_calloc_prefer(uint32_t n, uint32_t size, uint32_t *actual_size, uint32_t caps1, uint32_t caps2)
Allocate a chunk of memory as preference in decreasing order. And helper function for calloc a cache ...
Definition: esp_h264_alloc.c:27