H.264 Codec for ESP32-S3
Loading...
Searching...
No Matches
esp_h264_enc_dual.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
10
11#ifdef __cplusplus
12extern "C" {
13#endif
14
15/**
16 * @brief H.264 dual streams encoder handle
17 */
19
20/**
21 * @brief H.264 dual streams encoder handle
22 */
23typedef struct esp_h264_enc_dual_if {
24 esp_h264_err_t (*open)(esp_h264_enc_dual_handle_t enc); /*<! The open function */
25 esp_h264_err_t (*process)(esp_h264_enc_dual_handle_t enc, esp_h264_enc_in_frame_t *in_frame[2],
26 esp_h264_enc_out_frame_t *out_frame[2]); /*<! The process function */
27 esp_h264_err_t (*close)(esp_h264_enc_dual_handle_t enc); /*<! The close function */
28 esp_h264_err_t (*del)(esp_h264_enc_dual_handle_t enc); /*<! The delete function */
29} esp_h264_enc_dual_t;
30
31/**
32 * @brief This function opens an H.264 encoder in dual streams
33 *
34 * @param[in] enc A pointer to the H.264 dual encoder instance
35 *
36 * @return
37 * - ESP_H264_ERR_OK Succeeded
38 * - ESP_H264_ERR_FAIL Failed
39 * - ESP_H264_ERR_ARG Invalid arguments passed
40 * - ESP_H264_ERR_UNSUPPORTED Open feature is not supported by the encoder
41 */
43
44/**
45 * @brief This function performs dual encoding of H.264 video frames.
46 * The encoder supports dual channels where each channel can have a different configuration.
47 * It allows for one image encoder per channel and cannot code multiple images consecutively per channel.
48 * For IDR frame, the encoder will automatically add SPS and PPS NALU.
49 *
50 * @note The function will return ESP_H264_ERR_TIMEOUT, if `out_frame.raw_data.len` is less than actual encoded data length using hardware encoder.
51 * If the width or height of image is not multi of 16, please do the follow operation.
52 * `width = ((width +15) >> 4 << 4);`
53 * `height = ((height+15) >> 4 << 4);`
54 * `in_frame.raw_data.len = ( width * height + (width * height >> 1));`
55 * `in_frame.raw_data.buffer = heap_caps_aligned_calloc(16, 1, in_frame.raw_data.len, &in_frame.raw_data.len, MALLOC_CAP_DEFAULT);`
56 * The `out_frame.raw_data.buffer` should be allocated by the user for in_frame.raw_data.len bytes to avoid the encoded image size exceeding the `out_frame.raw_data.buffer` size.
57 * If the encoder image size is larger than `out_frame.raw_data.buffer`, it will result in ESP_H264_ERR_MEM.
58 *
59 * @param[in] enc A pointer to the H.264 dual encoder instance
60 * @param[in] in_frame An array of two pointers to unencoded input frames
61 * @param[in/out] out_frame An array of two pointers to encoded output frames
62 *
63 * @return
64 * @return
65 * - ESP_H264_ERR_OK Succeeded
66 * - ESP_H264_ERR_ARG Invalid arguments passed
67 * - ESP_H264_ERR_MEM Insufficient memory
68 * - ESP_H264_ERR_FAIL Failed
69 * - ESP_H264_ERR_TIMEOUT Timeout
70 * - ESP_H264_ERR_OVERFLOW The size of encoder image is greater than `in_frame.raw_data.len`
71 * - ESP_H264_ERR_UNSUPPORTED Process feature is not supported by the encoder
72 */
73esp_h264_err_t esp_h264_enc_dual_process(esp_h264_enc_dual_handle_t enc, esp_h264_enc_in_frame_t *in_frame[2], esp_h264_enc_out_frame_t *out_frame[2]);
74
75/**
76 * @brief This function closes the H.264 dual encoder instance specified by `enc`
77 *
78 * @param[in] enc A pointer to the H.264 dual encoder instance
79 *
80 * @return
81 * - ESP_H264_ERR_OK Succeeded
82 * - ESP_H264_ERR_ARG Invalid arguments passed
83 * - ESP_H264_ERR_UNSUPPORTED Close feature is not supported by the encoder
84 */
86
87/**
88 * @brief This function is used to delete an H.264 dual encoder
89 *
90 * @param[in] enc A pointer to the H.264 dual encoder instance
91 *
92 * @return
93 * - ESP_H264_ERR_OK Succeeded
94 * - ESP_H264_ERR_ARG Invalid arguments passed.
95 * - ESP_H264_ERR_UNSUPPORTED Delete feature is not supported by the encoder
96 */
98
99#ifdef __cplusplus
100}
101#endif
esp_h264_err_t esp_h264_enc_dual_del(esp_h264_enc_dual_handle_t enc)
This function is used to delete an H.264 dual encoder.
Definition: esp_h264_enc_dual.c:36
esp_h264_err_t esp_h264_enc_dual_close(esp_h264_enc_dual_handle_t enc)
This function closes the H.264 dual encoder instance specified by enc
Definition: esp_h264_enc_dual.c:30
esp_h264_err_t esp_h264_enc_dual_process(esp_h264_enc_dual_handle_t enc, esp_h264_enc_in_frame_t *in_frame[2], esp_h264_enc_out_frame_t *out_frame[2])
This function performs dual encoding of H.264 video frames. The encoder supports dual channels where ...
Definition: esp_h264_enc_dual.c:19
esp_h264_err_t esp_h264_enc_dual_open(esp_h264_enc_dual_handle_t enc)
This function opens an H.264 encoder in dual streams.
Definition: esp_h264_enc_dual.c:12
struct esp_h264_enc_dual_if * esp_h264_enc_dual_handle_t
H.264 dual streams encoder handle.
Definition: esp_h264_enc_dual.h:18
H.264 dual streams encoder handle.
Definition: esp_h264_enc_dual.h:23