HVE
HVE Hardware Video Encoder library
hve.h
Go to the documentation of this file.
1 /*
2  * HVE Hardware Video Encoder C library header
3  *
4  * Copyright 2019-2021 (C) Bartosz Meglicki <meglickib@gmail.com>
5  *
6  * This Source Code Form is subject to the terms of the Mozilla Public
7  * License, v. 2.0. If a copy of the MPL was not distributed with this
8  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9  *
10  */
11 
25 #ifndef HVE_H
26 #define HVE_H
27 
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31 
32 #include <libavcodec/avcodec.h>
33 
43 struct hve;
44 
152 {
153  int width;
154  int height;
157  int framerate;
158  const char *device;
159  const char *encoder;
160  const char *pixel_format;
161  int profile;
163  int bit_rate;
164  int qp;
165  int gop_size;
167  int low_power;
168 };
169 
183 struct hve_frame
184 {
185  uint8_t *data[AV_NUM_DATA_POINTERS];
186  int linesize[AV_NUM_DATA_POINTERS];
187 };
188 
193 {
195  HVE_OK=0,
196 };
197 
207 struct hve *hve_init(const struct hve_config *config);
208 
217 void hve_close(struct hve* h);
218 
261 int hve_send_frame(struct hve *h,struct hve_frame *frame);
262 
263 
299 AVPacket *hve_receive_packet(struct hve *h, int *error);
300 
303 #ifdef __cplusplus
304 }
305 #endif
306 
307 #endif
int bit_rate
average bitrate in VBR mode (bit_rate != 0 and qp == 0)
Definition: hve.h:163
const char * device
NULL / "" or device, e.g. "/dev/dri/renderD128".
Definition: hve.h:158
int input_height
optional scaling if non-zero and different from height
Definition: hve.h:156
int compression_level
speed-quality tradeoff, 0 for default, 1 for the highest quality, 7 for the fastest ...
Definition: hve.h:166
hve_retval_enum
Constants returned by most of library functions.
Definition: hve.h:192
int width
width of the encoded frames
Definition: hve.h:153
int hve_send_frame(struct hve *h, struct hve_frame *frame)
Send frame to hardware for encoding.
Definition: hve.c:344
error occured with errno set
Definition: hve.h:194
succesfull execution
Definition: hve.h:195
Encoder configuration.
Definition: hve.h:151
int gop_size
group of pictures size, 0 for default, -1 for intra only
Definition: hve.h:165
int qp
quantization parameter in CQP mode (qp != 0 and bit_rate == 0)
Definition: hve.h:164
const char * pixel_format
NULL / "" for NV12 or format, e.g. "rgb0", "bgr0", "nv12", "yuv420p", "p010le".
Definition: hve.h:160
int low_power
alternative limited low-power encoding if non-zero
Definition: hve.h:167
struct hve * hve_init(const struct hve_config *config)
initialize internal library data.
Definition: hve.c:57
Data to be encoded (single frame).
Definition: hve.h:183
int input_width
optional scaling if non-zero and different from width
Definition: hve.h:155
int profile
0 to guess from input or profile e.g. FF_PROFILE_H264_MAIN, FF_PROFILE_H264_HIGH, FF_PROFILE_HEVC_MAI...
Definition: hve.h:161
AVPacket * hve_receive_packet(struct hve *h, int *error)
Retrieve encoded frame data from hardware.
Definition: hve.c:432
const char * encoder
NULL / "" or encoder, e.g. "h264_vaapi".
Definition: hve.h:159
int framerate
framerate of the encoded video
Definition: hve.h:157
void hve_close(struct hve *h)
free library resources
Definition: hve.c:162
int max_b_frames
maximum number of B-frames between non-B-frames (disable if you need low latency) ...
Definition: hve.h:162
int height
height of the encoded frames
Definition: hve.h:154
Internal library data passed around by the user.
Definition: hve.c:25