40 int type,
char *
data,
size_t bit_len)
44 VABufferID param_buffer, data_buffer;
46 VAEncPackedHeaderParameterBuffer
params = {
48 .bit_length = bit_len,
49 .has_emulation_bytes = 1,
58 VAEncPackedHeaderParameterBufferType,
59 sizeof(params), 1, ¶ms, ¶m_buffer);
60 if (vas != VA_STATUS_SUCCESS) {
62 "for packed header (type %d): %d (%s).\n",
63 type, vas, vaErrorStr(vas));
69 VAEncPackedHeaderDataBufferType,
70 (bit_len + 7) / 8, 1, data, &data_buffer);
71 if (vas != VA_STATUS_SUCCESS) {
73 "for packed header (type %d): %d (%s).\n",
74 type, vas, vaErrorStr(vas));
80 "(%zu bits).\n", type, param_buffer, data_buffer, bit_len);
99 type, len, 1, data, &buffer);
100 if (vas != VA_STATUS_SUCCESS) {
102 "(type %d): %d (%s).\n", type, vas, vaErrorStr(vas));
121 VAEncMiscParameterBuffer
header = {
124 size_t buffer_size =
sizeof(
header) + len;
127 memcpy(buffer, &header,
sizeof(header));
128 memcpy(buffer +
sizeof(header), data, len);
131 VAEncMiscParameterBufferType,
132 buffer, buffer_size);
153 if (vas != VA_STATUS_SUCCESS) {
155 "%d (%s).\n", vas, vaErrorStr(vas));
184 for (i = 0; i < rounding; i++)
187 for (i = 0; i < (rounding + 1) / 2; i++)
189 for (i = 0; i < rounding / 2; i++)
192 }
else if (rounding < 0) {
212 "%d-%d (%d blocks).\n", i, slice->
row_start,
239 "width:%2d height:%2d (%d blocks).\n", index, ctx->
col_bd[i],
266 for (i = 0; i < pic->
nb_refs; i++) {
274 for (i = 0; i < pic->
nb_refs; i++) {
318 VAEncSequenceParameterBufferType,
340 "parameters: %d.\n", err);
344 VAEncPictureParameterBufferType,
354 bit_len = 8 *
sizeof(
data);
358 "header: %d.\n", err);
371 bit_len = 8 *
sizeof(
data);
375 "header: %d.\n", err);
395 "buffer %d: %d.\n", i, err);
410 bit_len = 8 *
sizeof(
data);
417 "header %d: %d.\n", i, err);
458 "parameters: %d.\n", err);
465 bit_len = 8 *
sizeof(
data);
470 "header: %d.\n", err);
482 VAEncSliceParameterBufferType,
490 #if VA_CHECK_VERSION(1, 0, 0) 496 VAEncMiscParameterBufferROI param_roi;
501 av_assert0(roi_size && sd->size % roi_size == 0);
502 nb_roi = sd->size / roi_size;
506 "supported by driver (%d > %d).\n",
519 for (i = 0; i < nb_roi; i++) {
527 pic->
roi[
i] = (VAEncROI) {
534 .roi_value = av_clip_int8(v),
538 param_roi = (VAEncMiscParameterBufferROI) {
540 .max_delta_qp = INT8_MAX,
541 .min_delta_qp = INT8_MIN,
543 .roi_flags.bits.roi_value_is_qp_delta = 1,
547 VAEncMiscParameterTypeROI,
557 if (vas != VA_STATUS_SUCCESS) {
559 "%d (%s).\n", vas, vaErrorStr(vas));
561 goto fail_with_picture;
566 if (vas != VA_STATUS_SUCCESS) {
568 "%d (%s).\n", vas, vaErrorStr(vas));
570 goto fail_with_picture;
574 if (vas != VA_STATUS_SUCCESS) {
576 "%d (%s).\n", vas, vaErrorStr(vas));
592 if (vas != VA_STATUS_SUCCESS) {
594 "param buffer %#x: %d (%s).\n",
629 VACodedBufferSegment *buf_list, *buf;
642 if (vas != VA_STATUS_SUCCESS) {
644 "%d (%s).\n", vas, vaErrorStr(vas));
649 for (buf = buf_list; buf; buf = buf->next)
650 total_size += buf->size;
658 for (buf = buf_list; buf; buf = buf->next) {
660 "(status %08x).\n", buf->size, buf->status);
662 memcpy(ptr, buf->buf, buf->size);
672 if (vas != VA_STATUS_SUCCESS) {
674 "%d (%s).\n", vas, vaErrorStr(vas));
701 "%"PRId64
"/%"PRId64
".\n",
769 int is_ref,
int in_dpb,
int prev)
805 for (i = 0; i < pic->
nb_refs; i++) {
843 for (pic = start->
next; pic; pic = pic->
next) {
853 for (ref = end->
refs[1]; ref; ref = ref->
refs[1])
862 for (pic = start->
next; pic != end; pic = pic->
next)
864 for (pic = start->
next, i = 1; 2 * i < len; pic = pic->next, i++);
876 for (ref = end->
refs[1]; ref; ref = ref->
refs[1])
881 current_depth + 1, &next);
886 current_depth + 1, last);
895 int i, b_counter, closed_gop_end;
905 for (i = 0; i < pic->
nb_refs; i++) {
915 "encode next.\n", pic->
b_depth);
926 for (pic = ctx->
pic_start; pic; pic = next) {
944 if (next && next->force_idr)
959 "need more input for reference pictures.\n");
964 "need more input for timestamps.\n");
1014 if (b_counter > 0) {
1045 for (pic = ctx->
pic_start; pic; pic = next) {
1070 "frames ignored due to lack of API support.\n");
1080 "frames ignored due to lack of driver support.\n");
1203 pkt->
dts = INT64_MIN;
1244 {
"YUV400", VA_RT_FORMAT_YUV400, 8, 1, },
1245 {
"YUV420", VA_RT_FORMAT_YUV420, 8, 3, 1, 1 },
1246 {
"YUV422", VA_RT_FORMAT_YUV422, 8, 3, 1, 0 },
1247 #if VA_CHECK_VERSION(1, 2, 0) 1248 {
"YUV422_10", VA_RT_FORMAT_YUV422_10, 10, 3, 1, 0 },
1250 {
"YUV444", VA_RT_FORMAT_YUV444, 8, 3, 0, 0 },
1251 {
"YUV411", VA_RT_FORMAT_YUV411, 8, 3, 2, 0 },
1252 #if VA_CHECK_VERSION(0, 38, 1) 1253 {
"YUV420_10", VA_RT_FORMAT_YUV420_10BPP, 10, 3, 1, 1 },
1258 VAEntrypointEncSlice,
1259 VAEntrypointEncPicture,
1260 #if VA_CHECK_VERSION(0, 39, 2) 1261 VAEntrypointEncSliceLP,
1265 #if VA_CHECK_VERSION(0, 39, 2) 1266 static const VAEntrypoint vaapi_encode_entrypoints_low_power[] = {
1267 VAEntrypointEncSliceLP,
1275 VAProfile *va_profiles =
NULL;
1276 VAEntrypoint *va_entrypoints =
NULL;
1278 const VAEntrypoint *usable_entrypoints;
1281 VAConfigAttrib rt_format_attr;
1283 const char *profile_string, *entrypoint_string;
1288 #if VA_CHECK_VERSION(0, 39, 2) 1289 usable_entrypoints = vaapi_encode_entrypoints_low_power;
1292 "supported with this VAAPI version.\n");
1322 vas = vaQueryConfigProfiles(ctx->
hwctx->
display, va_profiles, &n);
1323 if (vas != VA_STATUS_SUCCESS) {
1325 vas, vaErrorStr(vas));
1334 if (depth != profile->
depth ||
1345 #if VA_CHECK_VERSION(1, 0, 0) 1346 profile_string = vaProfileStr(profile->
va_profile);
1348 profile_string =
"(no profile names)";
1351 for (j = 0; j < n; j++) {
1357 "is not supported by driver.\n", profile_string,
1378 if (!va_entrypoints) {
1383 va_entrypoints, &n);
1384 if (vas != VA_STATUS_SUCCESS) {
1386 "profile %s (%d): %d (%s).\n", profile_string,
1392 for (i = 0; i < n; i++) {
1393 for (j = 0; usable_entrypoints[j]; j++) {
1394 if (va_entrypoints[i] == usable_entrypoints[j])
1397 if (usable_entrypoints[j])
1402 "for profile %s (%d).\n", profile_string, ctx->
va_profile);
1408 #if VA_CHECK_VERSION(1, 0, 0) 1411 entrypoint_string =
"(no entrypoint names)";
1417 rt_format = &vaapi_encode_rt_formats[
i];
1418 if (rt_format->
depth == depth &&
1426 "found for profile %s (%d) entrypoint %s (%d).\n",
1433 rt_format_attr = (VAConfigAttrib) { VAConfigAttribRTFormat };
1436 &rt_format_attr, 1);
1437 if (vas != VA_STATUS_SUCCESS) {
1439 "config attribute: %d (%s).\n", vas, vaErrorStr(vas));
1444 if (rt_format_attr.value == VA_ATTRIB_NOT_SUPPORTED) {
1446 "supported by driver: assuming surface RT format %s " 1447 "is valid.\n", rt_format->
name);
1448 }
else if (!(rt_format_attr.value & rt_format->
value)) {
1450 "by driver for encoding profile %s (%d) entrypoint %s (%d).\n",
1457 "format %s (%#x).\n", rt_format->
name, rt_format->
value);
1460 .type = VAConfigAttribRTFormat,
1461 .value = rt_format->
value,
1479 #if VA_CHECK_VERSION(1, 1, 0) 1484 #if VA_CHECK_VERSION(1, 3, 0) 1496 uint32_t supported_va_rc_modes;
1498 int64_t rc_bits_per_second;
1499 int rc_target_percentage;
1502 int64_t hrd_buffer_size;
1503 int64_t hrd_initial_buffer_fullness;
1505 VAConfigAttrib rc_attr = { VAConfigAttribRateControl };
1507 char supported_rc_modes_string[64];
1512 if (vas != VA_STATUS_SUCCESS) {
1514 "config attribute: %d (%s).\n", vas, vaErrorStr(vas));
1517 if (rc_attr.value == VA_ATTRIB_NOT_SUPPORTED) {
1519 "supported rate control modes: assuming CQP only.\n");
1520 supported_va_rc_modes = VA_RC_CQP;
1521 strcpy(supported_rc_modes_string,
"unknown");
1523 char *
str = supported_rc_modes_string;
1524 size_t len =
sizeof(supported_rc_modes_string);
1527 supported_va_rc_modes = rc_attr.value;
1529 rc_mode = &vaapi_encode_rc_modes[
i];
1530 if (supported_va_rc_modes & rc_mode->
va_mode) {
1532 first ?
"" :
", ", rc_mode->
name);
1546 supported_rc_modes_string);
1561 #define TRY_RC_MODE(mode, fail) do { \ 1562 rc_mode = &vaapi_encode_rc_modes[mode]; \ 1563 if (!(rc_mode->va_mode & supported_va_rc_modes)) { \ 1565 av_log(avctx, AV_LOG_ERROR, "Driver does not support %s " \ 1566 "RC mode (supported modes: %s).\n", rc_mode->name, \ 1567 supported_rc_modes_string); \ 1568 return AVERROR(EINVAL); \ 1570 av_log(avctx, AV_LOG_DEBUG, "Driver does not support %s " \ 1571 "RC mode.\n", rc_mode->name); \ 1574 goto rc_mode_found; \ 1611 "RC mode compatible with selected options " 1612 "(supported modes: %s).\n", supported_rc_modes_string);
1619 "RC mode.\n", rc_mode->
name);
1629 rc_bits_per_second = avctx->
bit_rate;
1635 rc_target_percentage = 100;
1642 }
else if (rc_mode->
maxrate) {
1646 "bitrate (%"PRId64
") must not be greater than " 1647 "maxrate (%"PRId64
").\n", avctx->
bit_rate,
1652 rc_target_percentage = (avctx->
bit_rate * 100) /
1659 rc_bits_per_second = 2 * avctx->
bit_rate;
1660 rc_target_percentage = 50;
1665 "in %s RC mode.\n", rc_mode->
name);
1667 rc_bits_per_second = avctx->
bit_rate;
1668 rc_target_percentage = 100;
1671 rc_bits_per_second = 0;
1672 rc_target_percentage = 100;
1683 "using default (%d).\n", rc_quality);
1699 "must have initial buffer size (%d) <= " 1700 "buffer size (%"PRId64
").\n",
1706 hrd_initial_buffer_fullness = hrd_buffer_size * 3 / 4;
1709 rc_window_size = (hrd_buffer_size * 1000) / rc_bits_per_second;
1713 "in %s RC mode.\n", rc_mode->
name);
1716 hrd_buffer_size = 0;
1717 hrd_initial_buffer_fullness = 0;
1721 rc_window_size = 1000;
1725 if (rc_bits_per_second > UINT32_MAX ||
1726 hrd_buffer_size > UINT32_MAX ||
1727 hrd_initial_buffer_fullness > UINT32_MAX) {
1729 "greater are not supported by VAAPI.\n");
1739 if (rc_attr.value == VA_ATTRIB_NOT_SUPPORTED) {
1744 .type = VAConfigAttribRateControl,
1752 if (rc_mode->
va_mode != VA_RC_CQP) {
1755 "converging in %d frames with %d%% accuracy.\n",
1756 rc_bits_per_second, rc_window_size,
1757 rc_target_percentage);
1758 }
else if (rc_mode->
bitrate) {
1760 "%"PRId64
" bps over %d ms.\n", rc_target_percentage,
1761 rc_bits_per_second, rc_window_size);
1764 ctx->
rc_params = (VAEncMiscParameterRateControl) {
1765 .bits_per_second = rc_bits_per_second,
1766 .target_percentage = rc_target_percentage,
1767 .window_size = rc_window_size,
1769 .min_qp = (avctx->
qmin > 0 ? avctx->
qmin : 0),
1770 .basic_unit_size = 0,
1771 #
if VA_CHECK_VERSION(1, 1, 0)
1772 .ICQ_quality_factor = av_clip(rc_quality, 1, 51),
1773 .max_qp = (avctx->
qmax > 0 ? avctx->
qmax : 0),
1775 #
if VA_CHECK_VERSION(1, 3, 0)
1776 .quality_factor = rc_quality,
1780 VAEncMiscParameterTypeRateControl,
1787 "initial fullness %"PRId64
" bits.\n",
1788 hrd_buffer_size, hrd_initial_buffer_fullness);
1791 .initial_buffer_fullness = hrd_initial_buffer_fullness,
1792 .buffer_size = hrd_buffer_size,
1795 VAEncMiscParameterTypeHRD,
1808 fr_num, fr_den, (
double)fr_num / fr_den);
1810 ctx->
fr_params = (VAEncMiscParameterFrameRate) {
1811 .framerate = (
unsigned int)fr_den << 16 | fr_num,
1813 #if VA_CHECK_VERSION(0, 40, 0) 1815 VAEncMiscParameterTypeFrameRate,
1827 VAConfigAttrib attr = { VAConfigAttribEncMaxRefFrames };
1828 uint32_t ref_l0, ref_l1;
1834 if (vas != VA_STATUS_SUCCESS) {
1836 "attribute: %d (%s).\n", vas, vaErrorStr(vas));
1840 if (attr.value == VA_ATTRIB_NOT_SUPPORTED) {
1841 ref_l0 = ref_l1 = 0;
1843 ref_l0 = attr.value & 0xffff;
1844 ref_l1 = attr.value >> 16 & 0xffff;
1851 }
else if (ref_l0 < 1) {
1853 "reference frames.\n");
1856 ref_l1 < 1 || avctx->max_b_frames < 1) {
1858 "(supported references: %d / %d).\n", ref_l0, ref_l1);
1864 "(supported references: %d / %d).\n", ref_l0, ref_l1);
1888 uint32_t slice_structure)
1900 "configured number of slices (%d < %d); using " 1904 req_slices = avctx->
slices;
1906 if (slice_structure & VA_ENC_SLICE_STRUCTURE_ARBITRARY_ROWS ||
1907 slice_structure & VA_ENC_SLICE_STRUCTURE_ARBITRARY_MACROBLOCKS) {
1910 }
else if (slice_structure & VA_ENC_SLICE_STRUCTURE_POWER_OF_TWO_ROWS) {
1912 for (k = 1;; k *= 2) {
1918 #if VA_CHECK_VERSION(1, 0, 0) 1919 }
else if (slice_structure & VA_ENC_SLICE_STRUCTURE_EQUAL_ROWS) {
1925 "slice structure modes (%#x).\n", slice_structure);
1933 uint32_t slice_structure)
1938 if (!(slice_structure & VA_ENC_SLICE_STRUCTURE_ARBITRARY_MACROBLOCKS ||
1939 (slice_structure & VA_ENC_SLICE_STRUCTURE_ARBITRARY_ROWS &&
1942 "current tile requirement.\n", slice_structure);
1949 "for configured number of tile (%d x %d); ",
1965 if (avctx->
slices != req_tiles)
1967 "mismatches with configured number of tile (%d != %d); " 1968 "using requested tile number for slice.\n",
1969 avctx->
slices, req_tiles);
1996 VAConfigAttrib attr[3] = { { VAConfigAttribEncMaxSlices },
1997 { VAConfigAttribEncSliceStructure },
1998 #if VA_CHECK_VERSION(1, 1, 0) 1999 { VAConfigAttribEncTileSupport },
2003 uint32_t max_slices, slice_structure;
2009 "but this codec does not support controlling slices.\n");
2029 if (vas != VA_STATUS_SUCCESS) {
2031 "attributes: %d (%s).\n", vas, vaErrorStr(vas));
2034 max_slices = attr[0].value;
2035 slice_structure = attr[1].value;
2036 if (max_slices == VA_ATTRIB_NOT_SUPPORTED ||
2037 slice_structure == VA_ATTRIB_NOT_SUPPORTED) {
2039 "pictures as multiple slices.\n.");
2044 #if VA_CHECK_VERSION(1, 1, 0) 2045 uint32_t tile_support = attr[2].value;
2046 if (tile_support == VA_ATTRIB_NOT_SUPPORTED) {
2048 "pictures as multiple tiles.\n.");
2053 "not supported with this VAAPI version.\n");
2067 "%d (from %d) due to driver constraints on slice " 2072 "encoding with %d slices (max %"PRIu32
").\n",
2086 VAConfigAttrib attr = { VAConfigAttribEncPackedHeaders };
2092 if (vas != VA_STATUS_SUCCESS) {
2094 "attribute: %d (%s).\n", vas, vaErrorStr(vas));
2098 if (attr.value == VA_ATTRIB_NOT_SUPPORTED) {
2101 "packed headers (wanted %#x).\n",
2105 "packed headers (none wanted).\n");
2111 "wanted packed headers (wanted %#x, found %#x).\n",
2115 "available (wanted %#x, found %#x).\n",
2124 .type = VAConfigAttribEncPackedHeaders,
2133 "sequence headers, but a global header is requested.\n");
2135 "this may result in a stream which is not usable for some " 2136 "purposes (e.g. not muxable to some containers).\n");
2144 #if VA_CHECK_VERSION(0, 36, 0) 2147 VAConfigAttrib attr = { VAConfigAttribEncQualityRange };
2154 if (vas != VA_STATUS_SUCCESS) {
2156 "config attribute: %d (%s).\n", vas, vaErrorStr(vas));
2160 if (attr.value == VA_ATTRIB_NOT_SUPPORTED) {
2163 "supported: will use default quality level.\n");
2166 if (quality > attr.value) {
2168 "valid range is 0-%d, using %d.\n",
2169 attr.value, attr.value);
2170 quality = attr.value;
2173 ctx->quality_params = (VAEncMiscParameterBufferQualityLevel) {
2177 VAEncMiscParameterTypeQualityLevel,
2178 &ctx->quality_params,
2179 sizeof(ctx->quality_params));
2183 "not supported with this VAAPI version.\n");
2191 #if VA_CHECK_VERSION(1, 0, 0) 2194 VAConfigAttrib attr = { VAConfigAttribEncROI };
2200 if (vas != VA_STATUS_SUCCESS) {
2202 "config attribute: %d (%s).\n", vas, vaErrorStr(vas));
2206 if (attr.value == VA_ATTRIB_NOT_SUPPORTED) {
2209 VAConfigAttribValEncROI roi = {
2210 .value = attr.value,
2216 roi.bits.roi_rc_qp_delta_support);
2227 VABufferID buffer_id;
2229 buffer_id = (VABufferID)(uintptr_t)
data;
2241 VABufferID buffer_id;
2250 VAEncCodedBufferType,
2252 (1 << 16), 1, 0, &buffer_id);
2253 if (vas != VA_STATUS_SUCCESS) {
2255 "output buffer: %d (%s).\n", vas, vaErrorStr(vas));
2324 "size %dx%d (constraints: width %d-%d height %d-%d).\n",
2350 "frame context: %d.\n", err);
2375 "required to associate the encoding device.\n");
2431 if (vas != VA_STATUS_SUCCESS) {
2433 "configuration: %d (%s).\n", vas, vaErrorStr(vas));
2449 if (vas != VA_STATUS_SUCCESS) {
2451 "context: %d (%s).\n", vas, vaErrorStr(vas));
2494 "failed: %d.\n", err);
2503 size_t bit_len = 8 *
sizeof(
data);
2508 "for extradata: %d.\n", err);
2533 for (pic = ctx->
pic_start; pic; pic = next) {
This struct aggregates all the (hardware/vendor-specific) "high-level" state, i.e.
VASurfaceID input_surface
int top
Distance in pixels from the top edge of the frame to the top and bottom edges and from the left edge ...
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
ptrdiff_t const GLvoid * data
int col_bd[MAX_TILE_COLS+1]
static int vaapi_encode_make_tile_slice(AVCodecContext *avctx, VAAPIEncodePicture *pic)
static const VAAPIEncodeRTFormat vaapi_encode_rt_formats[]
#define AV_LOG_WARNING
Something somehow does not look correct.
int64_t bit_rate
the average bitrate
#define HW_CONFIG_ENCODER_FRAMES(format, device_type_)
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 int vaapi_encode_send_frame(AVCodecContext *avctx, AVFrame *frame)
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 av_frame_move_ref(AVFrame *dst, AVFrame *src)
Move everything contained in src to dst and reset src.
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
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 qoffset
Quantisation offset.
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
AVFrameSideData * av_frame_get_side_data(const AVFrame *frame, enum AVFrameSideDataType type)
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.
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)
trying all byte sequences megabyte in length and selecting the best looking sequence will yield cases to try But first
int(* write_sequence_header)(AVCodecContext *avctx, char *data, size_t *data_len)
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.
Structure to hold side data for an AVFrame.
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.
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.
uint32_t self_size
Must be set to the size of this data structure (that is, sizeof(AVRegionOfInterest)).
static const uint8_t header[24]
The driver does not destroy parameter buffers when they are used by vaRenderPicture().
void * av_realloc_array(void *ptr, size_t nmemb, size_t size)
#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
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.
int row_height[MAX_TILE_ROWS]
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().
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 row_bd[MAX_TILE_ROWS+1]
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)
enum AVPictureType pict_type
Picture type of the frame.
#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
trying all byte sequences megabyte in length and selecting the best looking sequence will yield cases to try But a word about quality
VAAPIEncodePicture * next_prev
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
struct VAAPIEncodePicture * next
int(* write_extra_buffer)(AVCodecContext *avctx, VAAPIEncodePicture *pic, int index, int *type, char *data, size_t *data_len)
Structure describing a single Region Of Interest.
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 col_width[MAX_TILE_COLS]
static av_cold int vaapi_encode_init_tile_slice_structure(AVCodecContext *avctx, uint32_t slice_structure)
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.
Regions Of Interest, the data is an array of AVRegionOfInterest type, the number of array element is ...
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
VAEncMiscParameterHRD hrd_params
static av_cold int vaapi_encode_init_row_slice_structure(AVCodecContext *avctx, uint32_t slice_structure)
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.
static int vaapi_encode_make_row_slice(AVCodecContext *avctx, VAAPIEncodePicture *pic)
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding...
static av_cold int vaapi_encode_init_roi(AVCodecContext *avctx)
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.
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later.That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another.Frame references ownership and permissions
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)
const AVCodecHWConfigInternal *const ff_vaapi_encode_hw_configs[]
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
int ff_encode_get_frame(AVCodecContext *avctx, AVFrame *frame)
Called by encoders to get the next frame for encoding.
void * av_mallocz_array(size_t nmemb, size_t size)
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)