blob: 9664a87d5b2cfe2969bbc4531fa381b3f44714f9 [file] [log] [blame]
fei.dengf7a0cd32023-08-29 09:36:37 +00001/*
2 * Copyright (C) 2021 Amlogic Corporation.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16#ifndef __RENDER_COMMON_H__
17#define __RENDER_COMMON_H__
18#include <stdint.h>
19#include <stdlib.h>
20#include <stdarg.h>
21
22#ifdef __cplusplus
23extern "C" {
24#endif
25
26#define RENDER_MAX_PLANES 3
27
28/*allocate render buffer flag */
29typedef enum _BufferFlag {
30 BUFFER_FLAG_NONE = 0,
31 BUFFER_FLAG_DMA_BUFFER = 1 << 1,
32 BUFFER_FLAG_RAW_BUFFER = 1 << 2,
33} RenderBufferFlag;
34
35typedef struct _RenderRawBuffer {
36 void *dataPtr; //video render buffer pointer
37 int size; //video render buffer size
38} RenderRawBuffer;
39
40typedef struct _RenderDmaBuffer {
41 int width;
42 int height;
43 int planeCnt;
44 uint32_t handle[RENDER_MAX_PLANES];
45 uint32_t stride[RENDER_MAX_PLANES];
46 uint32_t offset[RENDER_MAX_PLANES];
47 uint32_t size[RENDER_MAX_PLANES];
48 int fd[RENDER_MAX_PLANES];
49} RenderDmaBuffer;
50
51typedef struct _RenderBuffer {
52 int id; //buffer id,set by video render
53 int flag; /*render buffer flag, refer to RenderBufferFlag*/
54 RenderDmaBuffer dma;
55 RenderRawBuffer raw;
56 int64_t pts; //time is nano second
57 int64_t time; //frame display time
58 void *priv; //user data passed to render lib
59 int reserved[4]; //reserved for extend
60} RenderBuffer;
61
62/*video render rectangle*/
fei.deng7ac1aeb2023-12-05 01:38:57 +000063typedef struct _RenderRect{
fei.dengf7a0cd32023-08-29 09:36:37 +000064 int x;
65 int y;
66 int w;
67 int h;
68} RenderRect;
69
70/*video frame size*/
71typedef struct _RenderFrameSize {
72 int width;
73 int height;
74} RenderFrameSize;
75
fei.deng7ac1aeb2023-12-05 01:38:57 +000076typedef struct {
77 int num; //numerator
78 int denom; //denominator
79} RenderFraction;
80
fei.deng649b0e22024-09-03 18:57:13 +080081/*video frame display info*/
82typedef struct _FrameDisplayInfo{
83 int64_t pts;
84 int64_t duration;
85 int reserved[2]; //reserved for extend
86} FrameDisplayInfo;
87
fei.dengf7a0cd32023-08-29 09:36:37 +000088typedef enum _RenderMsgType {
89 //notify a msg
90 MSG_NOTIFY = 0,
91 //frame buffer is released
92 MSG_RELEASE_BUFFER = 100, //the msg value type is RenderBuffer
93 //frame buffer is displayed
94 MSG_DISPLAYED_BUFFER = 101, //the msg value type is RenderBuffer
95 //the frame buffer is droped
96 MSG_DROPED_BUFFER = 102,//the msg value type is RenderBuffer
97 //first frame displayed msg
98 MSG_FIRST_FRAME = 103, //the msg value type is frame pts
99 //under flow msg
100 MSG_UNDER_FLOW = 104, //the msg value type is null
101 //pause with special pts
102 MSG_PAUSED_PTS = 105, //the msg value type is RenderBuffer
fei.deng1c94a342024-08-05 19:33:28 +0800103 //av sync done
104 MSG_AVSYNC_DONE = 106, //the msg value type is null
fei.deng649b0e22024-09-03 18:57:13 +0800105 //video freeze msg
106 MSG_FRAME_FREEZE = 107, //the msg value type is FrameDisplayInfo
107 //av re-sync msg
108 MSG_AV_RESYNC = 108, //the msg value type is FrameDisplayInfo
fei.dengf7a0cd32023-08-29 09:36:37 +0000109} RenderMsgType;
110
111/**video format*/
112typedef enum {
113 VIDEO_FORMAT_UNKNOWN,
114 VIDEO_FORMAT_ENCODED,
115 VIDEO_FORMAT_I420,
116 VIDEO_FORMAT_YV12,
117 VIDEO_FORMAT_YUY2,
118 VIDEO_FORMAT_UYVY,
119 VIDEO_FORMAT_AYUV,
120 VIDEO_FORMAT_RGBx,
121 VIDEO_FORMAT_BGRx,
122 VIDEO_FORMAT_xRGB,
123 VIDEO_FORMAT_xBGR,
124 VIDEO_FORMAT_RGBA,
125 VIDEO_FORMAT_BGRA,
126 VIDEO_FORMAT_ARGB,
127 VIDEO_FORMAT_ABGR,
128 VIDEO_FORMAT_RGB,
129 VIDEO_FORMAT_BGR,
130 VIDEO_FORMAT_Y41B,
131 VIDEO_FORMAT_Y42B,
132 VIDEO_FORMAT_YVYU,
133 VIDEO_FORMAT_Y444,
134 VIDEO_FORMAT_v210,
135 VIDEO_FORMAT_v216,
136 VIDEO_FORMAT_NV12,
137 VIDEO_FORMAT_NV21,
138 VIDEO_FORMAT_GRAY8,
139 VIDEO_FORMAT_GRAY16_BE,
140 VIDEO_FORMAT_GRAY16_LE,
141 VIDEO_FORMAT_v308,
142 VIDEO_FORMAT_RGB16,
143 VIDEO_FORMAT_BGR16,
144 VIDEO_FORMAT_RGB15,
145 VIDEO_FORMAT_BGR15,
146 VIDEO_FORMAT_UYVP,
147 VIDEO_FORMAT_A420,
148 VIDEO_FORMAT_RGB8P,
149 VIDEO_FORMAT_YUV9,
150 VIDEO_FORMAT_YVU9,
151 VIDEO_FORMAT_IYU1,
152 VIDEO_FORMAT_ARGB64,
153 VIDEO_FORMAT_AYUV64,
154 VIDEO_FORMAT_r210,
155 VIDEO_FORMAT_I420_10BE,
156 VIDEO_FORMAT_I420_10LE,
157 VIDEO_FORMAT_I422_10BE,
158 VIDEO_FORMAT_I422_10LE,
159 VIDEO_FORMAT_Y444_10BE,
160 VIDEO_FORMAT_Y444_10LE,
161 VIDEO_FORMAT_GBR,
162 VIDEO_FORMAT_GBR_10BE,
163 VIDEO_FORMAT_GBR_10LE,
164 VIDEO_FORMAT_NV16,
165 VIDEO_FORMAT_NV24,
166 VIDEO_FORMAT_NV12_64Z32,
167 VIDEO_FORMAT_A420_10BE,
168 VIDEO_FORMAT_A420_10LE,
169 VIDEO_FORMAT_A422_10BE,
170 VIDEO_FORMAT_A422_10LE,
171 VIDEO_FORMAT_A444_10BE,
172 VIDEO_FORMAT_A444_10LE,
173 VIDEO_FORMAT_NV61,
174 VIDEO_FORMAT_P010_10BE,
175 VIDEO_FORMAT_P010_10LE,
176 VIDEO_FORMAT_IYU2,
177 VIDEO_FORMAT_VYUY,
178 VIDEO_FORMAT_GBRA,
179 VIDEO_FORMAT_GBRA_10BE,
180 VIDEO_FORMAT_GBRA_10LE,
181 VIDEO_FORMAT_GBR_12BE,
182 VIDEO_FORMAT_GBR_12LE,
183 VIDEO_FORMAT_GBRA_12BE,
184 VIDEO_FORMAT_GBRA_12LE,
185 VIDEO_FORMAT_I420_12BE,
186 VIDEO_FORMAT_I420_12LE,
187 VIDEO_FORMAT_I422_12BE,
188 VIDEO_FORMAT_I422_12LE,
189 VIDEO_FORMAT_Y444_12BE,
190 VIDEO_FORMAT_Y444_12LE,
191 VIDEO_FORMAT_GRAY10_LE32,
192 VIDEO_FORMAT_NV12_10LE32,
193 VIDEO_FORMAT_NV16_10LE32,
194 VIDEO_FORMAT_NV12_10LE40,
195 VIDEO_FORMAT_Y210,
196 VIDEO_FORMAT_Y410,
197 VIDEO_FORMAT_VUYA,
198 VIDEO_FORMAT_BGR10A2_LE,
199} RenderVideoFormat;
200
201#ifdef __cplusplus
202}
203#endif
204#endif /*__RENDER_COMMON_H__*/