FFmpeg
Data Structures | Functions | Variables
dxva2.c File Reference
#include <string.h>
#include <initguid.h>
#include "libavutil/avassert.h"
#include "libavutil/common.h"
#include "libavutil/log.h"
#include "libavutil/time.h"
#include "avcodec.h"
#include "decode.h"
#include "dxva2_internal.h"

Go to the source code of this file.

Data Structures

struct  dxva_mode
 

Functions

 DEFINE_GUID (ff_DXVA2_ModeMPEG2_VLD, 0xee27417f, 0x5e28, 0x4e65, 0xbe, 0xea, 0x1d, 0x26, 0xb5, 0x08, 0xad, 0xc9)
 
 DEFINE_GUID (ff_DXVA2_ModeMPEG2and1_VLD, 0x86695f12, 0x340e, 0x4f04, 0x9f, 0xd3, 0x92, 0x53, 0xdd, 0x32, 0x74, 0x60)
 
 DEFINE_GUID (ff_DXVA2_ModeH264_E, 0x1b81be68, 0xa0c7, 0x11d3, 0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5)
 
 DEFINE_GUID (ff_DXVA2_ModeH264_F, 0x1b81be69, 0xa0c7, 0x11d3, 0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5)
 
 DEFINE_GUID (ff_DXVADDI_Intel_ModeH264_E, 0x604F8E68, 0x4951, 0x4C54, 0x88, 0xFE, 0xAB, 0xD2, 0x5C, 0x15, 0xB3, 0xD6)
 
 DEFINE_GUID (ff_DXVA2_ModeVC1_D, 0x1b81beA3, 0xa0c7, 0x11d3, 0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5)
 
 DEFINE_GUID (ff_DXVA2_ModeVC1_D2010, 0x1b81beA4, 0xa0c7, 0x11d3, 0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5)
 
 DEFINE_GUID (ff_DXVA2_ModeHEVC_VLD_Main, 0x5b11d51b, 0x2f4c, 0x4452, 0xbc, 0xc3, 0x09, 0xf2, 0xa1, 0x16, 0x0c, 0xc0)
 
 DEFINE_GUID (ff_DXVA2_ModeHEVC_VLD_Main10, 0x107af0e0, 0xef1a, 0x4d19, 0xab, 0xa8, 0x67, 0xa1, 0x63, 0x07, 0x3d, 0x13)
 
 DEFINE_GUID (ff_DXVA2_ModeVP9_VLD_Profile0, 0x463707f8, 0xa1d0, 0x4585, 0x87, 0x6d, 0x83, 0xaa, 0x6d, 0x60, 0xb8, 0x9e)
 
 DEFINE_GUID (ff_DXVA2_ModeVP9_VLD_10bit_Profile2, 0xa4c749ef, 0x6ecf, 0x48aa, 0x84, 0x48, 0x50, 0xa7, 0xa1, 0x16, 0x5f, 0xf7)
 
 DEFINE_GUID (ff_DXVA2_ModeAV1_VLD_Profile0, 0xb8be4ccb, 0xcf53, 0x46ba, 0x8d, 0x59, 0xd6, 0xb8, 0xa6, 0xda, 0x5d, 0x2a)
 
 DEFINE_GUID (ff_DXVA2_NoEncrypt, 0x1b81beD0, 0xa0c7, 0x11d3, 0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5)
 
 DEFINE_GUID (ff_GUID_NULL, 0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00)
 
 DEFINE_GUID (ff_IID_IDirectXVideoDecoderService, 0xfc51a551, 0xd5e7, 0x11d9, 0xaf, 0x55, 0x00, 0x05, 0x4e, 0x43, 0xff, 0x02)
 
static int dxva_get_decoder_configuration (AVCodecContext *avctx, const void *cfg_list, unsigned cfg_count)
 
static int dxva_check_codec_compatibility (AVCodecContext *avctx, const dxva_mode *mode)
 
static void dxva_list_guids_debug (AVCodecContext *avctx, void *service, unsigned guid_count, const GUID *guid_list)
 
static int dxva_get_decoder_guid (AVCodecContext *avctx, void *service, void *surface_format, unsigned guid_count, const GUID *guid_list, GUID *decoder_guid)
 
static void bufref_free_interface (void *opaque, uint8_t *data)
 
static AVBufferRefbufref_wrap_interface (IUnknown *iface)
 
static void ff_dxva2_lock (AVCodecContext *avctx)
 
static void ff_dxva2_unlock (AVCodecContext *avctx)
 
int ff_dxva2_common_frame_params (AVCodecContext *avctx, AVBufferRef *hw_frames_ctx)
 
int ff_dxva2_decode_init (AVCodecContext *avctx)
 
int ff_dxva2_decode_uninit (AVCodecContext *avctx)
 
static void * get_surface (const AVCodecContext *avctx, const AVFrame *frame)
 
unsigned ff_dxva2_get_surface_index (const AVCodecContext *avctx, AVDXVAContext *ctx, const AVFrame *frame, int curr)
 
int ff_dxva2_commit_buffer (AVCodecContext *avctx, AVDXVAContext *ctx, DECODER_BUFFER_DESC *dsc, unsigned type, const void *data, unsigned size, unsigned mb_count)
 
static int frame_add_buf (AVFrame *frame, AVBufferRef *ref)
 
int ff_dxva2_common_end_frame (AVCodecContext *avctx, AVFrame *frame, const void *pp, unsigned pp_size, const void *qm, unsigned qm_size, int(*commit_bs_si)(AVCodecContext *, DECODER_BUFFER_DESC *bs, DECODER_BUFFER_DESC *slice))
 
int ff_dxva2_is_d3d11 (const AVCodecContext *avctx)
 
unsigned * ff_dxva2_get_report_id (const AVCodecContext *avctx, AVDXVAContext *ctx)
 

Variables

static const int prof_mpeg2_main []
 
static const int prof_h264_high []
 
static const int prof_hevc_main []
 
static const int prof_hevc_main10 []
 
static const int prof_vp9_profile0 []
 
static const int prof_vp9_profile2 []
 
static const int prof_av1_profile0 []
 
static const dxva_mode dxva_modes []
 

Function Documentation

◆ DEFINE_GUID() [1/15]

DEFINE_GUID ( ff_DXVA2_ModeMPEG2_VLD  ,
0xee27417f  ,
0x5e28  ,
0x4e65  ,
0xbe  ,
0xea  ,
0x1d  ,
0x26  ,
0xb5  ,
0x08  ,
0xad  ,
0xc9   
)

◆ DEFINE_GUID() [2/15]

DEFINE_GUID ( ff_DXVA2_ModeMPEG2and1_VLD  ,
0x86695f12  ,
0x340e  ,
0x4f04  ,
0x9f  ,
0xd3  ,
0x92  ,
0x53  ,
0xdd  ,
0x32  ,
0x74  ,
0x60   
)

◆ DEFINE_GUID() [3/15]

DEFINE_GUID ( ff_DXVA2_ModeH264_E  ,
0x1b81be68  ,
0xa0c7  ,
0x11d3  ,
0xb9  ,
0x84  ,
0x00  ,
0xc0  ,
0x4f  ,
0x2e  ,
0x73  ,
0xc5   
)

◆ DEFINE_GUID() [4/15]

DEFINE_GUID ( ff_DXVA2_ModeH264_F  ,
0x1b81be69  ,
0xa0c7  ,
0x11d3  ,
0xb9  ,
0x84  ,
0x00  ,
0xc0  ,
0x4f  ,
0x2e  ,
0x73  ,
0xc5   
)

◆ DEFINE_GUID() [5/15]

DEFINE_GUID ( ff_DXVADDI_Intel_ModeH264_E  ,
0x604F8E68  ,
0x4951  ,
0x4C54  ,
0x88  ,
0xFE  ,
0xAB  ,
0xD2  ,
0x5C  ,
0x15  ,
0xB3  ,
0xD6   
)

◆ DEFINE_GUID() [6/15]

DEFINE_GUID ( ff_DXVA2_ModeVC1_D  ,
0x1b81beA3  ,
0xa0c7  ,
0x11d3  ,
0xb9  ,
0x84  ,
0x00  ,
0xc0  ,
0x4f  ,
0x2e  ,
0x73  ,
0xc5   
)

◆ DEFINE_GUID() [7/15]

DEFINE_GUID ( ff_DXVA2_ModeVC1_D2010  ,
0x1b81beA4  ,
0xa0c7  ,
0x11d3  ,
0xb9  ,
0x84  ,
0x00  ,
0xc0  ,
0x4f  ,
0x2e  ,
0x73  ,
0xc5   
)

◆ DEFINE_GUID() [8/15]

DEFINE_GUID ( ff_DXVA2_ModeHEVC_VLD_Main  ,
0x5b11d51b  ,
0x2f4c  ,
0x4452  ,
0xbc  ,
0xc3  ,
0x09  ,
0xf2  ,
0xa1  ,
0x16  ,
0x0c  ,
0xc0   
)

◆ DEFINE_GUID() [9/15]

DEFINE_GUID ( ff_DXVA2_ModeHEVC_VLD_Main10  ,
0x107af0e0  ,
0xef1a  ,
0x4d19  ,
0xab  ,
0xa8  ,
0x67  ,
0xa1  ,
0x63  ,
0x07  ,
0x3d  ,
0x13   
)

◆ DEFINE_GUID() [10/15]

DEFINE_GUID ( ff_DXVA2_ModeVP9_VLD_Profile0  ,
0x463707f8  ,
0xa1d0  ,
0x4585  ,
0x87  ,
0x6d  ,
0x83  ,
0xaa  ,
0x6d  ,
0x60  ,
0xb8  ,
0x9e   
)

◆ DEFINE_GUID() [11/15]

DEFINE_GUID ( ff_DXVA2_ModeVP9_VLD_10bit_Profile2  ,
0xa4c749ef  ,
0x6ecf  ,
0x48aa  ,
0x84  ,
0x48  ,
0x50  ,
0xa7  ,
0xa1  ,
0x16  ,
0x5f  ,
0xf7   
)

◆ DEFINE_GUID() [12/15]

DEFINE_GUID ( ff_DXVA2_ModeAV1_VLD_Profile0  ,
0xb8be4ccb  ,
0xcf53  ,
0x46ba  ,
0x8d  ,
0x59  ,
0xd6  ,
0xb8  ,
0xa6  ,
0xda  ,
0x5d  ,
0x2a   
)

◆ DEFINE_GUID() [13/15]

DEFINE_GUID ( ff_DXVA2_NoEncrypt  ,
0x1b81beD0  ,
0xa0c7  ,
0x11d3  ,
0xb9  ,
0x84  ,
0x00  ,
0xc0  ,
0x4f  ,
0x2e  ,
0x73  ,
0xc5   
)

◆ DEFINE_GUID() [14/15]

DEFINE_GUID ( ff_GUID_NULL  ,
0x00000000  ,
0x0000  ,
0x0000  ,
0x00  ,
0x00  ,
0x00  ,
0x00  ,
0x00  ,
0x00  ,
0x00  ,
0x00   
)

◆ DEFINE_GUID() [15/15]

DEFINE_GUID ( ff_IID_IDirectXVideoDecoderService  ,
0xfc51a551  ,
0xd5e7  ,
0x11d9  ,
0xaf  ,
0x55  ,
0x00  ,
0x05  ,
0x4e  ,
0x43  ,
0xff  ,
0x02   
)

◆ dxva_get_decoder_configuration()

static int dxva_get_decoder_configuration ( AVCodecContext avctx,
const void *  cfg_list,
unsigned  cfg_count 
)
static

Definition at line 110 of file dxva2.c.

◆ dxva_check_codec_compatibility()

static int dxva_check_codec_compatibility ( AVCodecContext avctx,
const dxva_mode mode 
)
static

Definition at line 195 of file dxva2.c.

Referenced by dxva_get_decoder_guid().

◆ dxva_list_guids_debug()

static void dxva_list_guids_debug ( AVCodecContext avctx,
void *  service,
unsigned  guid_count,
const GUID *  guid_list 
)
static

Definition at line 215 of file dxva2.c.

Referenced by dxva_get_decoder_guid().

◆ dxva_get_decoder_guid()

static int dxva_get_decoder_guid ( AVCodecContext avctx,
void *  service,
void *  surface_format,
unsigned  guid_count,
const GUID *  guid_list,
GUID *  decoder_guid 
)
static

Definition at line 260 of file dxva2.c.

◆ bufref_free_interface()

static void bufref_free_interface ( void *  opaque,
uint8_t *  data 
)
static

Definition at line 307 of file dxva2.c.

Referenced by bufref_wrap_interface().

◆ bufref_wrap_interface()

static AVBufferRef* bufref_wrap_interface ( IUnknown *  iface)
static

Definition at line 312 of file dxva2.c.

◆ ff_dxva2_lock()

static void ff_dxva2_lock ( AVCodecContext avctx)
static

Definition at line 560 of file dxva2.c.

Referenced by ff_dxva2_common_end_frame(), and ff_dxva2_decode_init().

◆ ff_dxva2_unlock()

static void ff_dxva2_unlock ( AVCodecContext avctx)
static

Definition at line 576 of file dxva2.c.

Referenced by ff_dxva2_common_end_frame(), and ff_dxva2_decode_init().

◆ ff_dxva2_common_frame_params()

int ff_dxva2_common_frame_params ( AVCodecContext avctx,
AVBufferRef hw_frames_ctx 
)

Definition at line 592 of file dxva2.c.

◆ ff_dxva2_decode_init()

int ff_dxva2_decode_init ( AVCodecContext avctx)

Definition at line 655 of file dxva2.c.

◆ ff_dxva2_decode_uninit()

int ff_dxva2_decode_uninit ( AVCodecContext avctx)

Definition at line 730 of file dxva2.c.

Referenced by dxva2_av1_uninit(), and ff_dxva2_decode_init().

◆ get_surface()

static void* get_surface ( const AVCodecContext avctx,
const AVFrame frame 
)
static

Definition at line 753 of file dxva2.c.

Referenced by ff_dxva2_common_end_frame(), and ff_dxva2_get_surface_index().

◆ ff_dxva2_get_surface_index()

unsigned ff_dxva2_get_surface_index ( const AVCodecContext avctx,
AVDXVAContext ctx,
const AVFrame frame,
int  curr 
)

◆ ff_dxva2_commit_buffer()

int ff_dxva2_commit_buffer ( AVCodecContext avctx,
AVDXVAContext ctx,
DECODER_BUFFER_DESC dsc,
unsigned  type,
const void *  data,
unsigned  size,
unsigned  mb_count 
)

Definition at line 802 of file dxva2.c.

Referenced by commit_bitstream_and_slice_buffer(), and ff_dxva2_common_end_frame().

◆ frame_add_buf()

static int frame_add_buf ( AVFrame frame,
AVBufferRef ref 
)
static

Definition at line 875 of file dxva2.c.

Referenced by ff_dxva2_common_end_frame().

◆ ff_dxva2_common_end_frame()

int ff_dxva2_common_end_frame ( AVCodecContext avctx,
AVFrame frame,
const void *  pp,
unsigned  pp_size,
const void *  qm,
unsigned  qm_size,
int(*)(AVCodecContext *, DECODER_BUFFER_DESC *bs, DECODER_BUFFER_DESC *slice)  commit_bs_si 
)

◆ ff_dxva2_is_d3d11()

int ff_dxva2_is_d3d11 ( const AVCodecContext avctx)

◆ ff_dxva2_get_report_id()

unsigned* ff_dxva2_get_report_id ( const AVCodecContext avctx,
AVDXVAContext ctx 
)

Definition at line 1065 of file dxva2.c.

Variable Documentation

◆ prof_mpeg2_main

const int prof_mpeg2_main[]
static
Initial value:

Definition at line 61 of file dxva2.c.

◆ prof_h264_high

const int prof_h264_high[]
static

◆ prof_hevc_main

const int prof_hevc_main[]
static
Initial value:

Definition at line 68 of file dxva2.c.

◆ prof_hevc_main10

const int prof_hevc_main10[]
static
Initial value:

Definition at line 70 of file dxva2.c.

◆ prof_vp9_profile0

const int prof_vp9_profile0[]
static
Initial value:

Definition at line 72 of file dxva2.c.

◆ prof_vp9_profile2

const int prof_vp9_profile2[]
static
Initial value:

Definition at line 74 of file dxva2.c.

◆ prof_av1_profile0

const int prof_av1_profile0[]
static
Initial value:

Definition at line 76 of file dxva2.c.

◆ dxva_modes

const dxva_mode dxva_modes[]
static
Initial value:
= {
{ &ff_DXVA2_ModeMPEG2_VLD, AV_CODEC_ID_MPEG2VIDEO, prof_mpeg2_main },
{ &ff_DXVA2_ModeMPEG2and1_VLD, AV_CODEC_ID_MPEG2VIDEO, prof_mpeg2_main },
{ &ff_DXVA2_ModeH264_F, AV_CODEC_ID_H264, prof_h264_high },
{ &ff_DXVA2_ModeH264_E, AV_CODEC_ID_H264, prof_h264_high },
{ &ff_DXVADDI_Intel_ModeH264_E, AV_CODEC_ID_H264, prof_h264_high },
{ &ff_DXVA2_ModeVC1_D2010, AV_CODEC_ID_VC1 },
{ &ff_DXVA2_ModeVC1_D2010, AV_CODEC_ID_WMV3 },
{ &ff_DXVA2_ModeVC1_D, AV_CODEC_ID_VC1 },
{ &ff_DXVA2_ModeVC1_D, AV_CODEC_ID_WMV3 },
{ &ff_DXVA2_ModeHEVC_VLD_Main10, AV_CODEC_ID_HEVC, prof_hevc_main10 },
{ &ff_DXVA2_ModeHEVC_VLD_Main, AV_CODEC_ID_HEVC, prof_hevc_main },
{ &ff_DXVA2_ModeVP9_VLD_Profile0, AV_CODEC_ID_VP9, prof_vp9_profile0 },
{ &ff_DXVA2_ModeVP9_VLD_10bit_Profile2, AV_CODEC_ID_VP9, prof_vp9_profile2 },
{ &ff_DXVA2_ModeAV1_VLD_Profile0, AV_CODEC_ID_AV1, prof_av1_profile0 },
{ NULL, 0 },
}

Definition at line 79 of file dxva2.c.

Referenced by dxva_get_decoder_guid().

AV_PROFILE_MPEG2_SIMPLE
#define AV_PROFILE_MPEG2_SIMPLE
Definition: defs.h:104
AV_PROFILE_H264_MAIN
#define AV_PROFILE_H264_MAIN
Definition: defs.h:111
AV_PROFILE_HEVC_MAIN
#define AV_PROFILE_HEVC_MAIN
Definition: defs.h:158
prof_hevc_main
static const int prof_hevc_main[]
Definition: dxva2.c:68
prof_h264_high
static const int prof_h264_high[]
Definition: dxva2.c:64
prof_av1_profile0
static const int prof_av1_profile0[]
Definition: dxva2.c:76
AV_PROFILE_UNKNOWN
#define AV_PROFILE_UNKNOWN
Definition: defs.h:65
prof_mpeg2_main
static const int prof_mpeg2_main[]
Definition: dxva2.c:61
AV_CODEC_ID_VP9
@ AV_CODEC_ID_VP9
Definition: codec_id.h:220
prof_vp9_profile0
static const int prof_vp9_profile0[]
Definition: dxva2.c:72
AV_CODEC_ID_H264
@ AV_CODEC_ID_H264
Definition: codec_id.h:79
AV_CODEC_ID_WMV3
@ AV_CODEC_ID_WMV3
Definition: codec_id.h:123
NULL
#define NULL
Definition: coverity.c:32
AV_CODEC_ID_AV1
@ AV_CODEC_ID_AV1
Definition: codec_id.h:280
AV_PROFILE_HEVC_MAIN_10
#define AV_PROFILE_HEVC_MAIN_10
Definition: defs.h:159
AV_CODEC_ID_HEVC
@ AV_CODEC_ID_HEVC
Definition: codec_id.h:226
AV_CODEC_ID_VC1
@ AV_CODEC_ID_VC1
Definition: codec_id.h:122
AV_PROFILE_VP9_2
#define AV_PROFILE_VP9_2
Definition: defs.h:155
AV_PROFILE_H264_HIGH
#define AV_PROFILE_H264_HIGH
Definition: defs.h:113
AV_PROFILE_MPEG2_MAIN
#define AV_PROFILE_MPEG2_MAIN
Definition: defs.h:103
AV_PROFILE_H264_CONSTRAINED_BASELINE
#define AV_PROFILE_H264_CONSTRAINED_BASELINE
Definition: defs.h:110
AV_PROFILE_VP9_0
#define AV_PROFILE_VP9_0
Definition: defs.h:153
prof_hevc_main10
static const int prof_hevc_main10[]
Definition: dxva2.c:70
AV_PROFILE_AV1_MAIN
#define AV_PROFILE_AV1_MAIN
Definition: defs.h:167
AV_CODEC_ID_MPEG2VIDEO
@ AV_CODEC_ID_MPEG2VIDEO
preferred ID for MPEG-1/2 video decoding
Definition: codec_id.h:54
prof_vp9_profile2
static const int prof_vp9_profile2[]
Definition: dxva2.c:74