| 73 | } |
| 74 | |
| 75 | int ff_vaapi_decode_make_slice_buffer(AVCodecContext *avctx, |
| 76 | VAAPIDecodePicture *pic, |
| 77 | const void *params_data, |
| 78 | int nb_params, |
| 79 | size_t params_size, |
| 80 | const void *slice_data, |
| 81 | size_t slice_size) |
| 82 | { |
| 83 | VAAPIDecodeContext *ctx = avctx->internal->hwaccel_priv_data; |
| 84 | VAStatus vas; |
| 85 | int index; |
| 86 | |
| 87 | av_assert0(pic->nb_slices <= pic->nb_slice_buffers_allocated); |
| 88 | if (pic->nb_slices == pic->nb_slice_buffers_allocated) { |
| 89 | VABufferID *tmp = |
| 90 | av_realloc_array(pic->slice_buffers, |
| 91 | pic->nb_slice_buffers_allocated ? pic->nb_slice_buffers_allocated * 2 : 64, |
| 92 | 2 * sizeof(*pic->slice_buffers)); |
| 93 | if (!tmp) |
| 94 | return AVERROR(ENOMEM); |
| 95 | |
| 96 | pic->slice_buffers = tmp; |
| 97 | pic->nb_slice_buffers_allocated = pic->nb_slice_buffers_allocated ? pic->nb_slice_buffers_allocated * 2 : 64; |
| 98 | } |
| 99 | av_assert0(pic->nb_slices + 1 <= pic->nb_slice_buffers_allocated); |
| 100 | |
| 101 | index = 2 * pic->nb_slices; |
| 102 | |
| 103 | vas = vaCreateBuffer(ctx->hwctx->display, ctx->va_context, |
| 104 | VASliceParameterBufferType, |
| 105 | params_size, nb_params, (void*)params_data, |
| 106 | &pic->slice_buffers[index]); |
| 107 | if (vas != VA_STATUS_SUCCESS) { |
| 108 | av_log(avctx, AV_LOG_ERROR, "Failed to create slice " |
| 109 | "parameter buffer: %d (%s).\n", vas, vaErrorStr(vas)); |
| 110 | return AVERROR(EIO); |
| 111 | } |
| 112 | |
| 113 | av_log(avctx, AV_LOG_DEBUG, "Slice %d param buffer (%zu bytes) " |
| 114 | "is %#x.\n", pic->nb_slices, params_size, |
| 115 | pic->slice_buffers[index]); |
| 116 | |
| 117 | vas = vaCreateBuffer(ctx->hwctx->display, ctx->va_context, |
| 118 | VASliceDataBufferType, |
| 119 | slice_size, 1, (void*)slice_data, |
| 120 | &pic->slice_buffers[index + 1]); |
| 121 | if (vas != VA_STATUS_SUCCESS) { |
| 122 | av_log(avctx, AV_LOG_ERROR, "Failed to create slice " |
| 123 | "data buffer (size %zu): %d (%s).\n", |
| 124 | slice_size, vas, vaErrorStr(vas)); |
| 125 | vaDestroyBuffer(ctx->hwctx->display, |
| 126 | pic->slice_buffers[index]); |
| 127 | return AVERROR(EIO); |
| 128 | } |
| 129 | |
| 130 | av_log(avctx, AV_LOG_DEBUG, "Slice %d data buffer (%zu bytes) " |
| 131 | "is %#x.\n", pic->nb_slices, slice_size, |
| 132 | pic->slice_buffers[index + 1]); |
no test coverage detected