| 39 | }; |
| 40 | |
| 41 | static 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, ¶ms, ¶m_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 | |
| 87 | static int vaapi_encode_make_param_buffer(AVCodecContext *avctx, |
| 88 | VAAPIEncodePicture *pic, |
no test coverage detected