MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / vaapi_encode_make_packed_header

Function vaapi_encode_make_packed_header

libavcodec/vaapi_encode.c:41–85  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

39};
40
41static int vaapi_encode_make_packed_header(AVCodecContext *avctx,
42 VAAPIEncodePicture *pic,
43 int type, char *data, size_t bit_len)
44{
45 VAAPIEncodeContext *ctx = avctx->priv_data;
46 VAStatus vas;
47 VABufferID param_buffer, data_buffer;
48 VABufferID *tmp;
49 VAEncPackedHeaderParameterBuffer params = {
50 .type = type,
51 .bit_length = bit_len,
52 .has_emulation_bytes = 1,
53 };
54
55 tmp = av_realloc_array(pic->param_buffers, pic->nb_param_buffers + 2, sizeof(*tmp));
56 if (!tmp)
57 return AVERROR(ENOMEM);
58 pic->param_buffers = tmp;
59
60 vas = vaCreateBuffer(ctx->hwctx->display, ctx->va_context,
61 VAEncPackedHeaderParameterBufferType,
62 sizeof(params), 1, &params, &param_buffer);
63 if (vas != VA_STATUS_SUCCESS) {
64 av_log(avctx, AV_LOG_ERROR, "Failed to create parameter buffer "
65 "for packed header (type %d): %d (%s).\n",
66 type, vas, vaErrorStr(vas));
67 return AVERROR(EIO);
68 }
69 pic->param_buffers[pic->nb_param_buffers++] = param_buffer;
70
71 vas = vaCreateBuffer(ctx->hwctx->display, ctx->va_context,
72 VAEncPackedHeaderDataBufferType,
73 (bit_len + 7) / 8, 1, data, &data_buffer);
74 if (vas != VA_STATUS_SUCCESS) {
75 av_log(avctx, AV_LOG_ERROR, "Failed to create data buffer "
76 "for packed header (type %d): %d (%s).\n",
77 type, vas, vaErrorStr(vas));
78 return AVERROR(EIO);
79 }
80 pic->param_buffers[pic->nb_param_buffers++] = data_buffer;
81
82 av_log(avctx, AV_LOG_DEBUG, "Packed header buffer (%d) is %#x/%#x "
83 "(%zu bits).\n", type, param_buffer, data_buffer, bit_len);
84 return 0;
85}
86
87static int vaapi_encode_make_param_buffer(AVCodecContext *avctx,
88 VAAPIEncodePicture *pic,

Callers 1

vaapi_encode_issueFunction · 0.85

Calls 2

av_realloc_arrayFunction · 0.85
av_logFunction · 0.85

Tested by

no test coverage detected