Lines Matching defs:avctx
97 av_log(tracer->avctx, AV_LOG_DEBUG, "%ls: %ls", scope, message); // \n is provided from AMF
110 static int amf_load_library(AVCodecContext *avctx)
112 AmfContext *ctx = avctx->priv_data;
122 ctx->timestamp_list = av_fifo_alloc2(avctx->max_b_frames + 16, sizeof(int64_t),
152 static int amf_init_from_d3d11_device(AVCodecContext *avctx, AVD3D11VADeviceContext *hwctx)
154 AmfContext *ctx = avctx->priv_data;
160 av_log(avctx, AV_LOG_ERROR, "AMF via D3D11 is not supported on the given device.\n");
162 av_log(avctx, AV_LOG_ERROR, "AMF failed to initialise on the given D3D11 device: %d.\n", res);
171 static int amf_init_from_dxva2_device(AVCodecContext *avctx, AVDXVA2DeviceContext *hwctx)
173 AmfContext *ctx = avctx->priv_data;
182 av_log(avctx, AV_LOG_ERROR, "Failed to open device handle for Direct3D9 device: %lx.\n", (unsigned long)hr);
191 av_log(avctx, AV_LOG_ERROR, "Failed to lock device handle for Direct3D9 device: %lx.\n", (unsigned long)hr);
206 av_log(avctx, AV_LOG_ERROR, "AMF via D3D9 is not supported on the given device.\n");
208 av_log(avctx, AV_LOG_ERROR, "AMF failed to initialise on given D3D9 device: %d.\n", res);
216 static int amf_init_context(AVCodecContext *avctx)
218 AmfContext *ctx = avctx->priv_data;
236 ctx->tracer.avctx = avctx;
244 if (avctx->hw_frames_ctx) {
245 AVHWFramesContext *frames_ctx = (AVHWFramesContext*)avctx->hw_frames_ctx->data;
248 av_log(avctx, AV_LOG_ERROR, "Format of input frames context (%s) is not supported by AMF.\n",
256 ret = amf_init_from_d3d11_device(avctx, frames_ctx->device_ctx->hwctx);
263 ret = amf_init_from_dxva2_device(avctx, frames_ctx->device_ctx->hwctx);
269 av_log(avctx, AV_LOG_ERROR, "AMF initialisation from a %s frames context is not supported.\n",
274 ctx->hw_frames_ctx = av_buffer_ref(avctx->hw_frames_ctx);
281 } else if (avctx->hw_device_ctx) {
282 AVHWDeviceContext *device_ctx = (AVHWDeviceContext*)avctx->hw_device_ctx->data;
287 ret = amf_init_from_d3d11_device(avctx, device_ctx->hwctx);
294 ret = amf_init_from_dxva2_device(avctx, device_ctx->hwctx);
300 av_log(avctx, AV_LOG_ERROR, "AMF initialisation from a %s device is not supported.\n",
305 ctx->hw_device_ctx = av_buffer_ref(avctx->hw_device_ctx);
312 av_log(avctx, AV_LOG_VERBOSE, "AMF initialisation succeeded via D3D11.\n");
316 av_log(avctx, AV_LOG_VERBOSE, "AMF initialisation succeeded via D3D9.\n");
326 av_log(avctx, AV_LOG_ERROR, "AMF via Vulkan is not supported on the given device.\n");
328 av_log(avctx, AV_LOG_ERROR, "AMF failed to initialise on the given Vulkan device: %d.\n", res);
331 av_log(avctx, AV_LOG_VERBOSE, "AMF initialisation succeeded via Vulkan.\n");
338 static int amf_init_encoder(AVCodecContext *avctx)
340 AmfContext *ctx = avctx->priv_data;
345 switch (avctx->codec->id) {
355 AMF_RETURN_IF_FALSE(ctx, codec_id != NULL, AVERROR(EINVAL), "Codec %d is not supported\n", avctx->codec->id);
360 pix_fmt = avctx->pix_fmt;
372 int av_cold ff_amf_encode_close(AVCodecContext *avctx)
374 AmfContext *ctx = avctx->priv_data;
413 static int amf_copy_surface(AVCodecContext *avctx, const AVFrame *frame,
432 avctx->width, avctx->height);
437 static int amf_copy_buffer(AVCodecContext *avctx, AVPacket *pkt, AMFBuffer *buffer)
439 AmfContext *ctx = avctx->priv_data;
445 if ((ret = ff_get_encode_buffer(avctx, pkt, size, 0)) < 0) {
450 switch (avctx->codec->id) {
476 if (avctx->max_b_frames > 0 && ctx->dts_delay == 0) {
481 "timestamp_list is empty while max_b_frames = %d\n", avctx->max_b_frames);
493 int ff_amf_encode_init(AVCodecContext *avctx)
497 if ((ret = amf_load_library(avctx)) == 0) {
498 if ((ret = amf_init_context(avctx)) == 0) {
499 if ((ret = amf_init_encoder(avctx)) == 0) {
504 ff_amf_encode_close(avctx);
578 int ff_amf_receive_packet(AVCodecContext *avctx, AVPacket *avpkt)
580 AmfContext *ctx = avctx->priv_data;
593 ret = ff_encode_get_frame(avctx, frame);
652 res = ctx->context->pVtbl->AllocSurface(ctx->context, AMF_MEMORY_HOST, ctx->format, avctx->width, avctx->height, &surface);
654 amf_copy_surface(avctx, frame, surface);
677 switch (avctx->codec->id) {
715 ret = amf_copy_buffer(avctx, avpkt, buffer);
744 av_log(avctx, AV_LOG_WARNING, "Data acquired but delayed frame submission got AMF_INPUT_FULL- should not happen\n");
753 av_log(avctx, AV_LOG_WARNING, "Data acquired but delayed drain submission got AMF_INPUT_FULL- should not happen\n");