Vision Apps User Guide
codec_wrapper.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2021 Texas Instruments Incorporated - http://www.ti.com/
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *
8  * Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  *
11  * Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the
14  * distribution.
15  *
16  * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 
33 #ifndef _TI_CODEC_WRAPPER_H_
34 #define _TI_CODEC_WRAPPER_H_
35 
36 
37 /* Standard headers. */
38 #include <stdint.h>
39 
40 
52 #define CODEC_MAX_LEN_CMD_STR 4096u
53 #define CODEC_MAX_LEN_ELEM_NAME 32u
54 #define CODEC_MAX_NUM_PLANES 4u
55 #define CODEC_MAX_BUFFER_DEPTH 16u
56 #if defined(SOC_J784S4)
57 #define CODEC_MAX_NUM_CHANNELS 12u
58 #else
59 #define CODEC_MAX_NUM_CHANNELS 8u
60 #endif /* SOC_J784S4 */
61 
62 
66 typedef struct
67 {
68  char m_AppSrcNameArr[CODEC_MAX_NUM_CHANNELS][CODEC_MAX_LEN_ELEM_NAME];/* Name of the AppSrc element */
69  int32_t in_width;/* Width of the buffers input to the CodecPipeline */
70  int32_t in_height;/* Height of the buffers input to the CodecPipeline */
71  char in_format[8];/* Format of the buffers input to the CodecPipeline (eg:"NV12") */
72  uint8_t in_num_planes;/* Number of planes of the buffers input to the CodecPipeline */
73  uint8_t in_num_channels;/* Number of channels input to the CodecPipeline */
74  uint8_t in_buffer_depth;/* The input buffer pool size for the CodecPipeline */
75 
76  char m_AppSinkNameArr[CODEC_MAX_NUM_CHANNELS][CODEC_MAX_LEN_ELEM_NAME];/* Name of the AppSink element */
77  int32_t out_width;/* Width of the buffers output from the CodecPipeline */
78  int32_t out_height;/* Height of the buffers output from the CodecPipeline */
79  char out_format[8];/* Format of the buffers output from the CodecPipeline (eg:"NV12") */
80  uint8_t out_num_planes;/* Number of planes of the buffers output from the CodecPipeline */
81  uint8_t out_num_channels;/* Number of channels output from the CodecPipeline */
82  uint8_t out_buffer_depth;/* The output buffer pool size for the CodecPipeline */
83 
84  char m_cmdString[CODEC_MAX_LEN_CMD_STR];/* The command string that describes the CodecPipeline, in a format accepted by gst_parse_launch() */
85 
86  int32_t appEncode;
87  int32_t appDecode;
89 
99 
110 
121 
127 int32_t appCodecStart();
128 
136 int32_t appCodecEnqAppSrc(uint8_t idx);
137 
145 int32_t appCodecDeqAppSrc(uint8_t idx);
146 
153 int32_t appCodecEnqEosAppSrc();
154 
164 int32_t appCodecDeqAppSink(uint8_t idx);
165 
175 int32_t appCodecEnqAppSink(uint8_t idx);
176 
183 int32_t appCodecStop();
184 
190 void appCodecDeInit();
191 
192 
199 void appCodecPrintStats();
200 
201 /* @} */
202 
203 #endif /* _TI_CODEC_WRAPPER_H_ */
204 
int32_t appCodecInit(app_codec_wrapper_params_t *prm)
Launches the CODECPipeline described by user defined parameters. Initializes the codec_wrapper and ca...
#define CODEC_MAX_BUFFER_DEPTH
Definition: codec_wrapper.h:55
int32_t appCodecDeqAppSink(uint8_t idx)
Pull a buffer from the AppSink element into the bufferpool.
uint8_t in_num_channels
Definition: codec_wrapper.h:73
void appCodecDeInit()
Unmaps all buffers that were mapped and destroys all GStreamer or OpenMAX objects.
#define CODEC_MAX_NUM_CHANNELS
Definition: codec_wrapper.h:59
int32_t appCodecEnqAppSink(uint8_t idx)
Release a previously pulled CODECBuffer back to GStreamer and cleanup.
int32_t appCodecStart()
Starts the CODECPipeline that was launched previously.
#define CODEC_MAX_NUM_PLANES
Definition: codec_wrapper.h:54
int32_t appCodecSinkInit(void *data_ptr[CODEC_MAX_BUFFER_DEPTH][CODEC_MAX_NUM_CHANNELS][CODEC_MAX_NUM_PLANES])
Initializes the AppSink elements to be able to pull buffers from the CODECPipeline. Registers the data_pointers that will map to the bufferpool of pulled CODECBuffers. The output parameters (out_*) must be properly initialised.
int32_t appCodecEnqEosAppSrc()
Push EOS (End Of Stream) to the AppSrc element. Signals the elements to stop processing buffers after...
int32_t appDecode
Definition: codec_wrapper.h:87
int32_t out_width
Definition: codec_wrapper.h:77
int32_t out_height
Definition: codec_wrapper.h:78
int32_t appCodecSrcInit(void *data_ptr[CODEC_MAX_BUFFER_DEPTH][CODEC_MAX_NUM_CHANNELS][CODEC_MAX_NUM_PLANES])
Initializes the AppSrc elements to be able to push buffers to the CODECPipeline. Wraps the given allo...
int32_t appCodecDeqAppSrc(uint8_t idx)
Wait for a previously pushed buffer to be consumed by the CODECPipeline.
uint8_t in_num_planes
Definition: codec_wrapper.h:72
int32_t in_height
Definition: codec_wrapper.h:70
int32_t appEncode
Definition: codec_wrapper.h:86
int32_t in_width
Definition: codec_wrapper.h:69
uint8_t out_num_channels
Definition: codec_wrapper.h:81
uint8_t out_num_planes
Definition: codec_wrapper.h:80
int32_t appCodecStop()
Stops the CODECPipeline that was in playing state. If there is no AppSink element, waits to recieve EOS before cleaning up.
#define CODEC_MAX_LEN_CMD_STR
Definition: codec_wrapper.h:52
uint8_t in_buffer_depth
Definition: codec_wrapper.h:74
void appCodecPrintStats()
Prints the current count of the numbers of buffers pushed/pulled to/from the CODECPipeline. Not multi-thread safe.
int32_t appCodecEnqAppSrc(uint8_t idx)
Push a buffer from the bufferpool to the AppSrc element.
#define CODEC_MAX_LEN_ELEM_NAME
Definition: codec_wrapper.h:53
uint8_t out_buffer_depth
Definition: codec_wrapper.h:82
Init parameters.
Definition: codec_wrapper.h:66