Lines Matching defs:avctx
110 static int dxva_get_decoder_configuration(AVCodecContext *avctx,
114 FFDXVASharedContext *sctx = DXVA_SHARED_CONTEXT(avctx);
140 else if (avctx->codec_id == AV_CODEC_ID_H264 && ConfigBitstreamRaw == 2)
153 av_log(avctx, AV_LOG_VERBOSE, "No valid decoder configuration available\n");
195 static int dxva_check_codec_compatibility(AVCodecContext *avctx, const dxva_mode *mode)
197 if (mode->codec != avctx->codec_id)
200 if (mode->profiles && !(avctx->hwaccel_flags & AV_HWACCEL_FLAG_ALLOW_PROFILE_MISMATCH)) {
203 if (avctx->profile == mode->profiles[i]) {
215 static void dxva_list_guids_debug(AVCodecContext *avctx, void *service,
218 FFDXVASharedContext *sctx = DXVA_SHARED_CONTEXT(avctx);
221 av_log(avctx, AV_LOG_VERBOSE, "Decoder GUIDs reported as supported:\n");
226 av_log(avctx, AV_LOG_VERBOSE,
241 av_log(avctx, AV_LOG_VERBOSE, " %d", (int)format);
252 av_log(avctx, AV_LOG_VERBOSE, " %d", i);
256 av_log(avctx, AV_LOG_VERBOSE, "\n");
260 static int dxva_get_decoder_guid(AVCodecContext *avctx, void *service, void *surface_format,
263 FFDXVASharedContext *sctx = DXVA_SHARED_CONTEXT(avctx);
266 dxva_list_guids_debug(avctx, service, guid_count, guid_list);
272 if (!dxva_check_codec_compatibility(avctx, mode))
297 av_log(avctx, AV_LOG_VERBOSE, "No decoder device for codec found\n");
319 static int dxva2_get_decoder_configuration(AVCodecContext *avctx, const GUID *device_guid,
323 FFDXVASharedContext *sctx = DXVA_SHARED_CONTEXT(avctx);
331 av_log(avctx, AV_LOG_ERROR, "Unable to retrieve decoder configurations\n");
335 ret = dxva_get_decoder_configuration(avctx, cfg_list, cfg_count);
342 static int dxva2_create_decoder(AVCodecContext *avctx)
344 FFDXVASharedContext *sctx = DXVA_SHARED_CONTEXT(avctx);
348 D3DFORMAT surface_format = avctx->sw_pix_fmt == AV_PIX_FMT_YUV420P10 ?
355 AVHWFramesContext *frames_ctx = (AVHWFramesContext*)avctx->hw_frames_ctx->data;
362 av_log(avctx, AV_LOG_ERROR, "Failed to open a device handle\n");
371 av_log(avctx, AV_LOG_ERROR, "Failed to create IDirectXVideoDecoderService\n");
377 av_log(avctx, AV_LOG_ERROR, "Failed to retrieve decoder device GUIDs\n");
381 ret = dxva_get_decoder_guid(avctx, sctx->dxva2_service, &surface_format,
388 desc.SampleWidth = avctx->coded_width;
389 desc.SampleHeight = avctx->coded_height;
392 ret = dxva2_get_decoder_configuration(avctx, &device_guid, &desc, &config);
401 av_log(avctx, AV_LOG_ERROR, "Failed to create DXVA2 video decoder\n");
420 static int d3d11va_get_decoder_configuration(AVCodecContext *avctx,
432 av_log(avctx, AV_LOG_ERROR, "Unable to retrieve decoder configurations\n");
442 av_log(avctx, AV_LOG_ERROR, "Unable to retrieve decoder configurations. (hr=0x%lX)\n", hr);
448 ret = dxva_get_decoder_configuration(avctx, cfg_list, cfg_count);
465 static int d3d11va_create_decoder(AVCodecContext *avctx)
467 FFDXVASharedContext *sctx = DXVA_SHARED_CONTEXT(avctx);
473 AVHWFramesContext *frames_ctx = (AVHWFramesContext *)avctx->hw_frames_ctx->data;
482 av_log(avctx, AV_LOG_ERROR, "AVD3D11VAFramesContext.texture not set.\n");
490 av_log(avctx, AV_LOG_ERROR, "Failed to get the decoder GUIDs\n");
497 av_log(avctx, AV_LOG_ERROR, "Failed to retrieve decoder GUID %d\n", i);
503 ret = dxva_get_decoder_guid(avctx, device_hwctx->video_device, &surface_format,
509 desc.SampleWidth = avctx->coded_width;
510 desc.SampleHeight = avctx->coded_height;
514 ret = d3d11va_get_decoder_configuration(avctx, device_hwctx->video_device, &desc, &config);
536 av_log(avctx, AV_LOG_ERROR, "Could not create the decoder output view %d\n", i);
544 av_log(avctx, AV_LOG_ERROR, "Failed to create D3D11VA video decoder\n");
560 static void ff_dxva2_lock(AVCodecContext *avctx)
563 if (ff_dxva2_is_d3d11(avctx)) {
564 FFDXVASharedContext *sctx = DXVA_SHARED_CONTEXT(avctx);
565 AVDXVAContext *ctx = DXVA_CONTEXT(avctx);
576 static void ff_dxva2_unlock(AVCodecContext *avctx)
579 if (ff_dxva2_is_d3d11(avctx)) {
580 FFDXVASharedContext *sctx = DXVA_SHARED_CONTEXT(avctx);
581 AVDXVAContext *ctx = DXVA_CONTEXT(avctx);
592 int ff_dxva2_common_frame_params(AVCodecContext *avctx,
609 if (avctx->codec_id == AV_CODEC_ID_MPEG2VIDEO)
613 else if (avctx->codec_id == AV_CODEC_ID_HEVC || avctx->codec_id == AV_CODEC_ID_AV1)
622 if (avctx->codec_id == AV_CODEC_ID_H264 || avctx->codec_id == AV_CODEC_ID_HEVC)
624 else if (avctx->codec_id == AV_CODEC_ID_VP9 || avctx->codec_id == AV_CODEC_ID_AV1)
629 frames_ctx->sw_format = avctx->sw_pix_fmt == AV_PIX_FMT_YUV420P10 ?
631 frames_ctx->width = FFALIGN(avctx->coded_width, surface_alignment);
632 frames_ctx->height = FFALIGN(avctx->coded_height, surface_alignment);
655 int ff_dxva2_decode_init(AVCodecContext *avctx)
657 FFDXVASharedContext *sctx = DXVA_SHARED_CONTEXT(avctx);
659 enum AVHWDeviceType dev_type = avctx->hwaccel->pix_fmt == AV_PIX_FMT_DXVA2_VLD
664 if (avctx->hwaccel_context)
667 // (avctx->pix_fmt is not updated yet at this point)
668 sctx->pix_fmt = avctx->hwaccel->pix_fmt;
670 ret = ff_decode_get_hw_frames_ctx(avctx, dev_type);
674 frames_ctx = (AVHWFramesContext*)avctx->hw_frames_ctx->data;
678 av_log(avctx, AV_LOG_ERROR, "Invalid pixfmt for hwaccel!\n");
688 ff_dxva2_lock(avctx);
689 ret = d3d11va_create_decoder(avctx);
690 ff_dxva2_unlock(avctx);
709 ff_dxva2_lock(avctx);
710 ret = dxva2_create_decoder(avctx);
711 ff_dxva2_unlock(avctx);
726 ff_dxva2_decode_uninit(avctx);
730 int ff_dxva2_decode_uninit(AVCodecContext *avctx)
732 FFDXVASharedContext *sctx = DXVA_SHARED_CONTEXT(avctx);
753 static void *get_surface(const AVCodecContext *avctx, const AVFrame *frame)
757 FFDXVASharedContext *sctx = DXVA_SHARED_CONTEXT(avctx);
761 av_log((void *)avctx, AV_LOG_ERROR, "get_buffer frame is invalid!\n");
770 unsigned ff_dxva2_get_surface_index(const AVCodecContext *avctx,
774 void *surface = get_surface(avctx, frame);
778 if (avctx->pix_fmt == AV_PIX_FMT_D3D11)
780 if (avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD) {
787 for (i = 0; i < DXVA_CONTEXT_COUNT(avctx, ctx); i++) {
788 if (avctx->pix_fmt == AV_PIX_FMT_DXVA2_VLD && ctx->dxva2.surface[i] == surface)
797 int ff_dxva2_commit_buffer(AVCodecContext *avctx,
809 if (ff_dxva2_is_d3d11(avctx))
816 if (avctx->pix_fmt == AV_PIX_FMT_DXVA2_VLD)
821 av_log(avctx, AV_LOG_ERROR, "Failed to get a buffer for %u: 0x%x\n",
829 if (ff_dxva2_is_d3d11(avctx)) {
838 if (avctx->pix_fmt == AV_PIX_FMT_DXVA2_VLD) {
849 av_log(avctx, AV_LOG_ERROR, "Buffer for type %u was too small\n", type);
854 if (ff_dxva2_is_d3d11(avctx))
858 if (avctx->pix_fmt == AV_PIX_FMT_DXVA2_VLD)
862 av_log(avctx, AV_LOG_ERROR,
886 int ff_dxva2_common_end_frame(AVCodecContext *avctx, AVFrame *frame,
893 AVDXVAContext *ctx = DXVA_CONTEXT(avctx);
905 FFDXVASharedContext *sctx = DXVA_SHARED_CONTEXT(avctx);
914 ff_dxva2_lock(avctx);
916 if (ff_dxva2_is_d3d11(avctx))
918 get_surface(avctx, frame),
922 if (avctx->pix_fmt == AV_PIX_FMT_DXVA2_VLD)
924 get_surface(avctx, frame),
929 ff_dxva2_unlock(avctx);
934 av_log(avctx, AV_LOG_ERROR, "Failed to begin frame: 0x%x\n", (unsigned)hr);
935 ff_dxva2_unlock(avctx);
940 if (ff_dxva2_is_d3d11(avctx)) {
946 if (avctx->pix_fmt == AV_PIX_FMT_DXVA2_VLD) {
951 result = ff_dxva2_commit_buffer(avctx, ctx, buffer,
955 av_log(avctx, AV_LOG_ERROR,
963 if (ff_dxva2_is_d3d11(avctx)) {
969 if (avctx->pix_fmt == AV_PIX_FMT_DXVA2_VLD) {
974 result = ff_dxva2_commit_buffer(avctx, ctx, buffer,
978 av_log(avctx, AV_LOG_ERROR,
986 if (ff_dxva2_is_d3d11(avctx)) {
992 if (avctx->pix_fmt == AV_PIX_FMT_DXVA2_VLD) {
998 result = commit_bs_si(avctx,
1002 av_log(avctx, AV_LOG_ERROR,
1013 if (ff_dxva2_is_d3d11(avctx))
1019 if (avctx->pix_fmt == AV_PIX_FMT_DXVA2_VLD) {
1029 av_log(avctx, AV_LOG_ERROR, "Failed to execute: 0x%x\n", (unsigned)hr);
1035 if (ff_dxva2_is_d3d11(avctx))
1039 if (avctx->pix_fmt == AV_PIX_FMT_DXVA2_VLD)
1042 ff_dxva2_unlock(avctx);
1044 av_log(avctx, AV_LOG_ERROR, "Failed to end frame: 0x%x\n", (unsigned)hr);
1051 int ff_dxva2_is_d3d11(const AVCodecContext *avctx)
1054 return avctx->pix_fmt == AV_PIX_FMT_D3D11VA_VLD ||
1055 avctx->pix_fmt == AV_PIX_FMT_D3D11;