34 int type,
char *
data,
size_t bit_len)
38 VABufferID param_buffer, data_buffer;
40 VAEncPackedHeaderParameterBuffer
params = {
42 .bit_length = bit_len,
43 .has_emulation_bytes = 1,
52 VAEncPackedHeaderParameterBufferType,
53 sizeof(params), 1, ¶ms, ¶m_buffer);
54 if (vas != VA_STATUS_SUCCESS) {
56 "for packed header (type %d): %d (%s).\n",
57 type, vas, vaErrorStr(vas));
63 VAEncPackedHeaderDataBufferType,
64 (bit_len + 7) / 8, 1, data, &data_buffer);
65 if (vas != VA_STATUS_SUCCESS) {
67 "for packed header (type %d): %d (%s).\n",
68 type, vas, vaErrorStr(vas));
74 "(%zu bits).\n", type, param_buffer, data_buffer, bit_len);
93 type, len, 1, data, &buffer);
94 if (vas != VA_STATUS_SUCCESS) {
96 "(type %d): %d (%s).\n", type, vas, vaErrorStr(vas));
115 VAEncMiscParameterBuffer
header = {
118 size_t buffer_size =
sizeof(
header) + len;
121 memcpy(buffer, &header,
sizeof(header));
122 memcpy(buffer +
sizeof(header), data, len);
125 VAEncMiscParameterBufferType,
126 buffer, buffer_size);
147 if (vas != VA_STATUS_SUCCESS) {
149 "%d (%s).\n", vas, vaErrorStr(vas));
177 for (i = 0; i < pic->
nb_refs; i++) {
185 for (i = 0; i < pic->
nb_refs; i++) {
229 VAEncSequenceParameterBufferType,
251 "parameters: %d.\n", err);
255 VAEncPictureParameterBufferType,
265 bit_len = 8 *
sizeof(
data);
269 "header: %d.\n", err);
282 bit_len = 8 *
sizeof(
data);
286 "header: %d.\n", err);
306 "buffer %d: %d.\n", i, err);
321 bit_len = 8 *
sizeof(
data);
328 "header %d: %d.\n", i, err);
361 for (i = 0; i < rounding; i++)
364 for (i = 0; i < (rounding + 1) / 2; i++)
366 for (i = 0; i < rounding / 2; i++)
369 }
else if (rounding < 0) {
389 "%d-%d (%d blocks).\n", i, slice->
row_start,
406 "parameters: %d.\n", err);
413 bit_len = 8 *
sizeof(
data);
418 "header: %d.\n", err);
430 VAEncSliceParameterBufferType,
440 if (vas != VA_STATUS_SUCCESS) {
442 "%d (%s).\n", vas, vaErrorStr(vas));
444 goto fail_with_picture;
449 if (vas != VA_STATUS_SUCCESS) {
451 "%d (%s).\n", vas, vaErrorStr(vas));
453 goto fail_with_picture;
457 if (vas != VA_STATUS_SUCCESS) {
459 "%d (%s).\n", vas, vaErrorStr(vas));
475 if (vas != VA_STATUS_SUCCESS) {
477 "param buffer %#x: %d (%s).\n",
513 VACodedBufferSegment *buf_list, *
buf;
524 if (vas != VA_STATUS_SUCCESS) {
526 "%d (%s).\n", vas, vaErrorStr(vas));
531 for (buf = buf_list;
buf; buf = buf->next) {
533 "(status %08x).\n", buf->size, buf->status);
539 memcpy(pkt->
data, buf->buf, buf->size);
548 if (vas != VA_STATUS_SUCCESS) {
550 "%d (%s).\n", vas, vaErrorStr(vas));
577 "%"PRId64
"/%"PRId64
".\n",
646 int is_ref,
int in_dpb,
int prev)
682 for (i = 0; i < pic->
nb_refs; i++) {
720 for (pic = start->
next; pic; pic = pic->
next) {
730 for (ref = end->
refs[1]; ref; ref = ref->
refs[1])
739 for (pic = start->
next; pic != end; pic = pic->
next)
741 for (pic = start->
next, i = 1; 2 * i < len; pic = pic->next, i++);
753 for (ref = end->
refs[1]; ref; ref = ref->
refs[1])
758 current_depth + 1, &next);
763 current_depth + 1, last);
772 int i, b_counter, closed_gop_end;
782 for (i = 0; i < pic->
nb_refs; i++) {
792 "encode next.\n", pic->
b_depth);
803 for (pic = ctx->
pic_start; pic; pic = next) {
821 if (next && next->force_idr)
836 "need more input for reference pictures.\n");
841 "need more input for timestamps.\n");
922 for (pic = ctx->
pic_start; pic; pic = next) {
947 "frames ignored due to lack of API support.\n");
1057 pkt->
dts = INT64_MIN;
1098 {
"YUV400", VA_RT_FORMAT_YUV400, 8, 1, },
1099 {
"YUV420", VA_RT_FORMAT_YUV420, 8, 3, 1, 1 },
1100 {
"YUV422", VA_RT_FORMAT_YUV422, 8, 3, 1, 0 },
1101 {
"YUV444", VA_RT_FORMAT_YUV444, 8, 3, 0, 0 },
1102 {
"YUV411", VA_RT_FORMAT_YUV411, 8, 3, 2, 0 },
1103 #if VA_CHECK_VERSION(0, 38, 1) 1104 {
"YUV420_10", VA_RT_FORMAT_YUV420_10BPP, 10, 3, 1, 1 },
1109 VAEntrypointEncSlice,
1110 VAEntrypointEncPicture,
1111 #if VA_CHECK_VERSION(0, 39, 2) 1112 VAEntrypointEncSliceLP,
1116 #if VA_CHECK_VERSION(0, 39, 2) 1117 static const VAEntrypoint vaapi_encode_entrypoints_low_power[] = {
1118 VAEntrypointEncSliceLP,
1126 VAProfile *va_profiles =
NULL;
1127 VAEntrypoint *va_entrypoints =
NULL;
1129 const VAEntrypoint *usable_entrypoints;
1132 VAConfigAttrib rt_format_attr;
1134 const char *profile_string, *entrypoint_string;
1139 #if VA_CHECK_VERSION(0, 39, 2) 1140 usable_entrypoints = vaapi_encode_entrypoints_low_power;
1143 "supported with this VAAPI version.\n");
1173 vas = vaQueryConfigProfiles(ctx->
hwctx->
display, va_profiles, &n);
1174 if (vas != VA_STATUS_SUCCESS) {
1176 vas, vaErrorStr(vas));
1185 if (depth != profile->
depth ||
1196 #if VA_CHECK_VERSION(1, 0, 0) 1197 profile_string = vaProfileStr(profile->
va_profile);
1199 profile_string =
"(no profile names)";
1202 for (j = 0; j <
n; j++) {
1208 "is not supported by driver.\n", profile_string,
1229 if (!va_entrypoints) {
1234 va_entrypoints, &n);
1235 if (vas != VA_STATUS_SUCCESS) {
1237 "profile %s (%d): %d (%s).\n", profile_string,
1243 for (i = 0; i <
n; i++) {
1244 for (j = 0; usable_entrypoints[j]; j++) {
1245 if (va_entrypoints[i] == usable_entrypoints[j])
1248 if (usable_entrypoints[j])
1253 "for profile %s (%d).\n", profile_string, ctx->
va_profile);
1259 #if VA_CHECK_VERSION(1, 0, 0) 1262 entrypoint_string =
"(no entrypoint names)";
1268 rt_format = &vaapi_encode_rt_formats[
i];
1269 if (rt_format->
depth == depth &&
1277 "found for profile %s (%d) entrypoint %s (%d).\n",
1284 rt_format_attr = (VAConfigAttrib) { VAConfigAttribRTFormat };
1287 &rt_format_attr, 1);
1288 if (vas != VA_STATUS_SUCCESS) {
1290 "config attribute: %d (%s).\n", vas, vaErrorStr(vas));
1295 if (rt_format_attr.value == VA_ATTRIB_NOT_SUPPORTED) {
1297 "supported by driver: assuming surface RT format %s " 1298 "is valid.\n", rt_format->
name);
1299 }
else if (!(rt_format_attr.value & rt_format->
value)) {
1301 "by driver for encoding profile %s (%d) entrypoint %s (%d).\n",
1308 "format %s (%#x).\n", rt_format->
name, rt_format->
value);
1311 .type = VAConfigAttribRTFormat,
1312 .value = rt_format->
value,
1330 #if VA_CHECK_VERSION(1, 1, 0) 1335 #if VA_CHECK_VERSION(1, 3, 0) 1347 uint32_t supported_va_rc_modes;
1349 int64_t rc_bits_per_second;
1350 int rc_target_percentage;
1353 int64_t hrd_buffer_size;
1354 int64_t hrd_initial_buffer_fullness;
1356 VAConfigAttrib rc_attr = { VAConfigAttribRateControl };
1358 char supported_rc_modes_string[64];
1363 if (vas != VA_STATUS_SUCCESS) {
1365 "config attribute: %d (%s).\n", vas, vaErrorStr(vas));
1368 if (rc_attr.value == VA_ATTRIB_NOT_SUPPORTED) {
1370 "supported rate control modes: assuming CQP only.\n");
1371 supported_va_rc_modes = VA_RC_CQP;
1372 strcpy(supported_rc_modes_string,
"unknown");
1374 char *str = supported_rc_modes_string;
1375 size_t len =
sizeof(supported_rc_modes_string);
1376 int i, first = 1, res;
1378 supported_va_rc_modes = rc_attr.value;
1380 rc_mode = &vaapi_encode_rc_modes[
i];
1381 if (supported_va_rc_modes & rc_mode->
va_mode) {
1383 first ?
"" :
", ", rc_mode->
name);
1397 supported_rc_modes_string);
1412 #define TRY_RC_MODE(mode, fail) do { \ 1413 rc_mode = &vaapi_encode_rc_modes[mode]; \ 1414 if (!(rc_mode->va_mode & supported_va_rc_modes)) { \ 1416 av_log(avctx, AV_LOG_ERROR, "Driver does not support %s " \ 1417 "RC mode (supported modes: %s).\n", rc_mode->name, \ 1418 supported_rc_modes_string); \ 1419 return AVERROR(EINVAL); \ 1421 av_log(avctx, AV_LOG_DEBUG, "Driver does not support %s " \ 1422 "RC mode.\n", rc_mode->name); \ 1425 goto rc_mode_found; \ 1462 "RC mode compatible with selected options " 1463 "(supported modes: %s).\n", supported_rc_modes_string);
1470 "RC mode.\n", rc_mode->
name);
1480 rc_bits_per_second = avctx->
bit_rate;
1486 rc_target_percentage = 100;
1493 }
else if (rc_mode->
maxrate) {
1497 "bitrate (%"PRId64
") must not be greater than " 1498 "maxrate (%"PRId64
").\n", avctx->
bit_rate,
1503 rc_target_percentage = (avctx->
bit_rate * 100) /
1510 rc_bits_per_second = 2 * avctx->
bit_rate;
1511 rc_target_percentage = 50;
1516 "in %s RC mode.\n", rc_mode->
name);
1518 rc_bits_per_second = avctx->
bit_rate;
1519 rc_target_percentage = 100;
1522 rc_bits_per_second = 0;
1523 rc_target_percentage = 100;
1534 "using default (%d).\n", rc_quality);
1550 "must have initial buffer size (%d) <= " 1551 "buffer size (%"PRId64
").\n",
1557 hrd_initial_buffer_fullness = hrd_buffer_size * 3 / 4;
1560 rc_window_size = (hrd_buffer_size * 1000) / rc_bits_per_second;
1564 "in %s RC mode.\n", rc_mode->
name);
1567 hrd_buffer_size = 0;
1568 hrd_initial_buffer_fullness = 0;
1572 rc_window_size = 1000;
1576 if (rc_bits_per_second > UINT32_MAX ||
1577 hrd_buffer_size > UINT32_MAX ||
1578 hrd_initial_buffer_fullness > UINT32_MAX) {
1580 "greater are not supported by VAAPI.\n");
1590 if (rc_attr.value == VA_ATTRIB_NOT_SUPPORTED) {
1595 .type = VAConfigAttribRateControl,
1603 if (rc_mode->
va_mode != VA_RC_CQP) {
1606 "converging in %d frames with %d%% accuracy.\n",
1607 rc_bits_per_second, rc_window_size,
1608 rc_target_percentage);
1609 }
else if (rc_mode->
bitrate) {
1611 "%"PRId64
" bps over %d ms.\n", rc_target_percentage,
1612 rc_bits_per_second, rc_window_size);
1615 ctx->
rc_params = (VAEncMiscParameterRateControl) {
1616 .bits_per_second = rc_bits_per_second,
1617 .target_percentage = rc_target_percentage,
1618 .window_size = rc_window_size,
1620 .min_qp = (avctx->
qmin > 0 ? avctx->
qmin : 0),
1621 .basic_unit_size = 0,
1622 #
if VA_CHECK_VERSION(1, 1, 0)
1623 .ICQ_quality_factor = av_clip(rc_quality, 1, 51),
1624 .max_qp = (avctx->
qmax > 0 ? avctx->
qmax : 0),
1626 #
if VA_CHECK_VERSION(1, 3, 0)
1627 .quality_factor = rc_quality,
1631 VAEncMiscParameterTypeRateControl,
1638 "initial fullness %"PRId64
" bits.\n",
1639 hrd_buffer_size, hrd_initial_buffer_fullness);
1642 .initial_buffer_fullness = hrd_initial_buffer_fullness,
1643 .buffer_size = hrd_buffer_size,
1646 VAEncMiscParameterTypeHRD,
1659 fr_num, fr_den, (
double)fr_num / fr_den);
1661 ctx->
fr_params = (VAEncMiscParameterFrameRate) {
1662 .framerate = (
unsigned int)fr_den << 16 | fr_num,
1664 #if VA_CHECK_VERSION(0, 40, 0) 1666 VAEncMiscParameterTypeFrameRate,
1678 VAConfigAttrib attr = { VAConfigAttribEncMaxRefFrames };
1679 uint32_t ref_l0, ref_l1;
1685 if (vas != VA_STATUS_SUCCESS) {
1687 "attribute: %d (%s).\n", vas, vaErrorStr(vas));
1691 if (attr.value == VA_ATTRIB_NOT_SUPPORTED) {
1692 ref_l0 = ref_l1 = 0;
1694 ref_l0 = attr.value & 0xffff;
1695 ref_l1 = attr.value >> 16 & 0xffff;
1702 }
else if (ref_l0 < 1) {
1704 "reference frames.\n");
1707 ref_l1 < 1 || avctx->max_b_frames < 1) {
1709 "(supported references: %d / %d).\n", ref_l0, ref_l1);
1715 "(supported references: %d / %d).\n", ref_l0, ref_l1);
1741 VAConfigAttrib attr[2] = { { VAConfigAttribEncMaxSlices },
1742 { VAConfigAttribEncSliceStructure } };
1744 uint32_t max_slices, slice_structure;
1750 "but this codec does not support controlling slices.\n");
1760 if (avctx->
slices <= 1) {
1770 if (vas != VA_STATUS_SUCCESS) {
1772 "attributes: %d (%s).\n", vas, vaErrorStr(vas));
1775 max_slices = attr[0].value;
1776 slice_structure = attr[1].value;
1777 if (max_slices == VA_ATTRIB_NOT_SUPPORTED ||
1778 slice_structure == VA_ATTRIB_NOT_SUPPORTED) {
1780 "pictures as multiple slices.\n.");
1791 "configured number of slices (%d < %d); using " 1795 req_slices = avctx->
slices;
1797 if (slice_structure & VA_ENC_SLICE_STRUCTURE_ARBITRARY_ROWS ||
1798 slice_structure & VA_ENC_SLICE_STRUCTURE_ARBITRARY_MACROBLOCKS) {
1801 }
else if (slice_structure & VA_ENC_SLICE_STRUCTURE_POWER_OF_TWO_ROWS) {
1803 for (k = 1;; k *= 2) {
1809 #if VA_CHECK_VERSION(1, 0, 0) 1810 }
else if (slice_structure & VA_ENC_SLICE_STRUCTURE_EQUAL_ROWS) {
1816 "slice structure modes (%#x).\n", slice_structure);
1822 "%d (from %d) due to driver constraints on slice " 1827 "encoding with %d slices (max %"PRIu32
").\n",
1833 "(default size %d block rows).\n",
1842 VAConfigAttrib attr = { VAConfigAttribEncPackedHeaders };
1848 if (vas != VA_STATUS_SUCCESS) {
1850 "attribute: %d (%s).\n", vas, vaErrorStr(vas));
1854 if (attr.value == VA_ATTRIB_NOT_SUPPORTED) {
1857 "packed headers (wanted %#x).\n",
1861 "packed headers (none wanted).\n");
1867 "wanted packed headers (wanted %#x, found %#x).\n",
1871 "available (wanted %#x, found %#x).\n",
1880 .type = VAConfigAttribEncPackedHeaders,
1889 "sequence headers, but a global header is requested.\n");
1891 "this may result in a stream which is not usable for some " 1892 "purposes (e.g. not muxable to some containers).\n");
1900 #if VA_CHECK_VERSION(0, 36, 0) 1903 VAConfigAttrib attr = { VAConfigAttribEncQualityRange };
1910 if (vas != VA_STATUS_SUCCESS) {
1912 "config attribute: %d (%s).\n", vas, vaErrorStr(vas));
1916 if (attr.value == VA_ATTRIB_NOT_SUPPORTED) {
1919 "supported: will use default quality level.\n");
1922 if (quality > attr.value) {
1924 "valid range is 0-%d, using %d.\n",
1925 attr.value, attr.value);
1926 quality = attr.value;
1929 ctx->quality_params = (VAEncMiscParameterBufferQualityLevel) {
1930 .quality_level = quality,
1933 VAEncMiscParameterTypeQualityLevel,
1934 &ctx->quality_params,
1935 sizeof(ctx->quality_params));
1939 "not supported with this VAAPI version.\n");
1950 VABufferID buffer_id;
1952 buffer_id = (VABufferID)(uintptr_t)
data;
1964 VABufferID buffer_id;
1973 VAEncCodedBufferType,
1975 (1 << 16), 1, 0, &buffer_id);
1976 if (vas != VA_STATUS_SUCCESS) {
1978 "output buffer: %d (%s).\n", vas, vaErrorStr(vas));
2047 "size %dx%d (constraints: width %d-%d height %d-%d).\n",
2073 "frame context: %d.\n", err);
2093 "required to associate the encoding device.\n");
2145 if (vas != VA_STATUS_SUCCESS) {
2147 "configuration: %d (%s).\n", vas, vaErrorStr(vas));
2163 if (vas != VA_STATUS_SUCCESS) {
2165 "context: %d (%s).\n", vas, vaErrorStr(vas));
2208 "failed: %d.\n", err);
2217 size_t bit_len = 8 *
sizeof(
data);
2222 "for extradata: %d.\n", err);
2248 for (pic = ctx->
pic_start; pic; pic = next) {
This struct aggregates all the (hardware/vendor-specific) "high-level" state, i.e.
VASurfaceID input_surface
static int vaapi_encode_pick_next(AVCodecContext *avctx, VAAPIEncodePicture **pic_out)
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it...
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
const void * global_params[MAX_GLOBAL_PARAMS]
VAAPI-specific data associated with a frame pool.
This structure describes decoded (raw) audio or video data.
VAEntrypoint va_entrypoint
static const VAAPIEncodeRTFormat vaapi_encode_rt_formats[]
#define AV_LOG_WARNING
Something somehow does not look correct.
int64_t bit_rate
the average bitrate
int max_b_frames
maximum number of B-frames between non-B-frames Note: The output will be delayed by max_b_frames+1 re...
int rc_initial_buffer_occupancy
Number of bits which should be loaded into the rc buffer before decoding starts.
static av_cold int vaapi_encode_profile_entrypoint(AVCodecContext *avctx)
int width
The allocated dimensions of the frames in this pool.
static int vaapi_encode_make_packed_header(AVCodecContext *avctx, VAAPIEncodePicture *pic, int type, char *data, size_t bit_len)
static const char *const picture_type_name[]
void * av_hwdevice_hwconfig_alloc(AVBufferRef *ref)
Allocate a HW-specific configuration structure for a given HW device.
enum AVPixelFormat format
The pixel format identifying the underlying HW surface type.
void * codec_sequence_params
AVBufferRef * input_frames_ref
size_t picture_params_size
AVHWDeviceContext * device
static int vaapi_encode_clear_old(AVCodecContext *avctx)
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
static int vaapi_encode_wait(AVCodecContext *avctx, VAAPIEncodePicture *pic)
int(* init_picture_params)(AVCodecContext *avctx, VAAPIEncodePicture *pic)
int max_width
The maximum size of frames in this hw_frames_ctx.
static int vaapi_encode_discard(AVCodecContext *avctx, VAAPIEncodePicture *pic)
static int vaapi_encode_make_param_buffer(AVCodecContext *avctx, VAAPIEncodePicture *pic, int type, char *data, size_t len)
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
void av_hwframe_constraints_free(AVHWFramesConstraints **constraints)
Free an AVHWFrameConstraints structure.
unsigned int va_packed_headers
#define av_assert0(cond)
assert() equivalent, that is always enabled.
int ff_vaapi_encode_send_frame(AVCodecContext *avctx, const AVFrame *frame)
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
const VAAPIEncodeRCMode * rc_mode
static int vaapi_encode_issue(AVCodecContext *avctx, VAAPIEncodePicture *pic)
static av_cold int end(AVCodecContext *avctx)
int(* write_sequence_header)(AVCodecContext *avctx, char *data, size_t *data_len)
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
static AVBufferRef * vaapi_encode_alloc_output_buffer(void *opaque, int size)
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
uint8_t * extradata
some codecs need / can use extradata like Huffman tables.
AVBufferRef * output_buffer_ref
void * hwctx
The format-specific data, allocated and freed by libavutil along with this context.
VABufferID * param_buffers
static void vaapi_encode_remove_refs(AVCodecContext *avctx, VAAPIEncodePicture *pic, int level)
struct VAAPIEncodePicture * prev
#define AVERROR_EOF
End of file.
#define AV_LOG_VERBOSE
Detailed information.
The driver does not destroy parameter buffers when they are used by vaRenderPicture().
VASurfaceID recon_surface
#define AV_BUFFER_FLAG_READONLY
Always treat the buffer as read-only, even when it has only one reference.
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
static const uint8_t header[24]
void * av_realloc_array(void *ptr, size_t nmemb, size_t size)
Allocate, reallocate, or free an array.
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
int av_new_packet(AVPacket *pkt, int size)
Allocate the payload of a packet and initialize its fields with default values.
VAConfigAttrib config_attributes[MAX_CONFIG_ATTRIBUTES]
AVHWFramesContext * input_frames
#define i(width, name, range_min, range_max)
int(* configure)(AVCodecContext *avctx)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
VAAPI hardware pipeline configuration details.
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
static int vaapi_encode_make_misc_param_buffer(AVCodecContext *avctx, VAAPIEncodePicture *pic, int type, const void *data, size_t len)
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
static av_cold int vaapi_encode_init_packed_headers(AVCodecContext *avctx)
int qmax
maximum quantizer
int(* init_sequence_params)(AVCodecContext *avctx)
int(* write_picture_header)(AVCodecContext *avctx, VAAPIEncodePicture *pic, char *data, size_t *data_len)
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
int flags
AV_CODEC_FLAG_*.
simple assert() macros that are a bit more flexible than ISO C assert().
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
AVBufferRef * av_buffer_create(uint8_t *data, int size, void(*free)(void *opaque, uint8_t *data), void *opaque, int flags)
Create an AVBuffer from an existing array.
int av_hwframe_ctx_init(AVBufferRef *ref)
Finalize the context before use.
static int vaapi_encode_check_frame(AVCodecContext *avctx, const AVFrame *frame)
void * codec_picture_params
int av_hwframe_get_buffer(AVBufferRef *hwframe_ref, AVFrame *frame, int flags)
Allocate a new frame attached to the given AVHWFramesContext.
AVHWFramesContext * recon_frames
#define TRY_RC_MODE(mode, fail)
int flags
A combination of AV_PKT_FLAG values.
int rc_buffer_size
decoder bitstream buffer size
static av_cold int vaapi_encode_init_gop_structure(AVCodecContext *avctx)
VAAPIEncodeSlice * slices
uint8_t nb_components
The number of components each pixel has, (1-4)
#define AV_CODEC_FLAG_QSCALE
Use fixed qscale.
int width
picture width / height.
AVBufferRef * hw_frames_ctx
A reference to the AVHWFramesContext describing the input (for encoding) or output (decoding) frames...
const VAAPIEncodeProfile * profile
#define FF_PROFILE_UNKNOWN
const VAAPIEncodeProfile * profiles
av_cold int ff_vaapi_encode_init(AVCodecContext *avctx)
int global_params_type[MAX_GLOBAL_PARAMS]
VAEncMiscParameterRateControl rc_params
VAAPIEncodePicture * next_prev
struct VAAPIEncodePicture * next
int(* write_extra_buffer)(AVCodecContext *avctx, VAAPIEncodePicture *pic, int index, int *type, char *data, size_t *data_len)
void * codec_picture_params
int64_t ts_ring[MAX_REORDER_DELAY *3]
AVBufferPool * output_buffer_pool
int ff_vaapi_encode_receive_packet(AVCodecContext *avctx, AVPacket *pkt)
AVBufferPool * av_buffer_pool_init2(int size, void *opaque, AVBufferRef *(*alloc)(void *opaque, int size), void(*pool_free)(void *opaque))
Allocate and initialize a buffer pool with a more complex allocator.
#define FF_ARRAY_ELEMS(a)
static void vaapi_encode_add_ref(AVCodecContext *avctx, VAAPIEncodePicture *pic, VAAPIEncodePicture *target, int is_ref, int in_dpb, int prev)
VADisplay display
The VADisplay handle, to be filled by the user.
struct VAAPIEncodePicture * refs[MAX_PICTURE_REFERENCES]
int min_width
The minimum size of frames in this hw_frames_ctx.
int(* init_slice_params)(AVCodecContext *avctx, VAAPIEncodePicture *pic, VAAPIEncodeSlice *slice)
const struct VAAPIEncodeType * codec
static VAAPIEncodePicture * vaapi_encode_alloc(AVCodecContext *avctx)
Libavcodec external API header.
static void vaapi_encode_set_b_pictures(AVCodecContext *avctx, VAAPIEncodePicture *start, VAAPIEncodePicture *end, VAAPIEncodePicture *prev, int current_depth, VAAPIEncodePicture **last)
This struct describes the constraints on hardware frames attached to a given device with a hardware-s...
VAAPIEncodePicture * pic_start
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
main external API structure.
AVHWFramesConstraints * av_hwdevice_get_hwframe_constraints(AVBufferRef *ref, const void *hwconfig)
Get the constraints on HW frames given a device and the HW-specific configuration to be used with tha...
uint8_t * data
The data buffer.
int qmin
minimum quantizer
void * hwctx
The format-specific data, allocated and freed automatically along with this context.
unsigned int driver_quirks
Driver quirks to apply - this is filled by av_hwdevice_ctx_init(), with reference to a table of known...
void av_buffer_pool_uninit(AVBufferPool **ppool)
Mark the pool as being available for freeing.
This struct describes a set or pool of "hardware" frames (i.e.
int(* write_extra_header)(AVCodecContext *avctx, VAAPIEncodePicture *pic, int index, int *type, char *data, size_t *data_len)
AVBufferRef * recon_frames_ref
static av_cold int vaapi_encode_init_quality(AVCodecContext *avctx)
int global_quality
Global quality for codecs which cannot change it per frame.
VAAPIEncodePicture * pic_end
static const VAAPIEncodeRCMode vaapi_encode_rc_modes[]
size_t picture_priv_data_size
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
AVBufferRef * device_ref
A reference to the parent AVHWDeviceContext.
#define AV_CODEC_FLAG_GLOBAL_HEADER
Place global headers in extradata instead of every keyframe.
size_t global_params_size[MAX_GLOBAL_PARAMS]
int gop_size
the number of pictures in a group of pictures, or 0 for intra_only
A reference to a data buffer.
size_t sequence_params_size
const char const char * params
VAEncMiscParameterHRD hrd_params
common internal and external API header
static int ref[MAX_W *MAX_W]
AVBufferRef * av_hwframe_ctx_alloc(AVBufferRef *device_ref_in)
Allocate an AVHWFramesContext tied to a given device context.
AVBufferRef * av_buffer_ref(AVBufferRef *buf)
Create a new reference to an AVBuffer.
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
int slices
Number of slices.
static av_cold int vaapi_encode_create_recon_frames(AVCodecContext *avctx)
static const VAEntrypoint vaapi_encode_entrypoints_normal[]
VAEncMiscParameterFrameRate fr_params
enum AVPixelFormat * valid_sw_formats
A list of possible values for sw_format in the hw_frames_ctx, terminated by AV_PIX_FMT_NONE.
void * codec_slice_params
static int vaapi_encode_free(AVCodecContext *avctx, VAAPIEncodePicture *pic)
VAConfigID config_id
ID of a VAAPI pipeline configuration.
static void vaapi_encode_free_output_buffer(void *opaque, uint8_t *data)
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed...
unsigned int desired_packed_headers
VASurfaceID * surface_ids
The surfaces IDs of all surfaces in the pool after creation.
static av_cold int vaapi_encode_init_slice_structure(AVCodecContext *avctx)
AVBufferRef * av_buffer_pool_get(AVBufferPool *pool)
Allocate a new AVBuffer, reusing an old buffer from the pool when available.
#define av_malloc_array(a, b)
#define AV_CODEC_FLAG_CLOSED_GOP
static av_cold int vaapi_encode_init_rate_control(AVCodecContext *avctx)
const char * av_get_pix_fmt_name(enum AVPixelFormat pix_fmt)
Return the short name for a pixel format, NULL in case pix_fmt is unknown.
int depth
Number of bits in the component.
enum AVPixelFormat sw_format
The pixel format identifying the actual data layout of the hardware frames.
#define AVERROR_EXTERNAL
Generic error in an external library.
AVPixelFormat
Pixel format.
This structure stores compressed data.
struct VAAPIEncodePicture * dpb[MAX_DPB_SIZE]
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
av_cold int ff_vaapi_encode_close(AVCodecContext *avctx)
static av_cold void vaapi_encode_add_global_param(AVCodecContext *avctx, int type, void *buffer, size_t size)
int64_t rc_max_rate
maximum bitrate
void * av_mallocz_array(size_t nmemb, size_t size)
Allocate a memory block for an array with av_mallocz().
static int vaapi_encode_output(AVCodecContext *avctx, VAAPIEncodePicture *pic, AVPacket *pkt)
AVVAAPIDeviceContext * hwctx
int(* write_slice_header)(AVCodecContext *avctx, VAAPIEncodePicture *pic, VAAPIEncodeSlice *slice, char *data, size_t *data_len)