FFmpeg
Loading...
Searching...
No Matches
dxva2.c File Reference
#include <string.h>
#include <initguid.h>
#include "libavutil/avassert.h"
#include "libavutil/common.h"
#include "libavutil/log.h"
#include "libavutil/mem.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_ModeAV1_VLD_Profile2, 0x0c5f2aa1, 0xe541, 0x4089, 0xbb, 0x7b, 0x98, 0x11, 0x0a, 0x19, 0xd7, 0xc8)
 
 DEFINE_GUID (ff_DXVA2_ModeAV1_VLD_12bit_Profile2, 0x17127009, 0xa00f, 0x4ce1, 0x99, 0x4e, 0xbf, 0x40, 0x81, 0xf6, 0xf3, 0xf0)
 
 DEFINE_GUID (ff_DXVA2_ModeAV1_VLD_12bit_Profile2_420, 0x2d80bed6, 0x9cac, 0x4835, 0x9e, 0x91, 0x32, 0x7b, 0xbc, 0x4f, 0x9e, 0xe8)
 
 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 int prof_av1_profile2 []
 
static const dxva_mode dxva_modes []
 

Function Documentation

◆ DEFINE_GUID() [1/18]

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

◆ DEFINE_GUID() [2/18]

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

◆ DEFINE_GUID() [3/18]

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

◆ DEFINE_GUID() [4/18]

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

◆ DEFINE_GUID() [5/18]

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

◆ DEFINE_GUID() [6/18]

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

◆ DEFINE_GUID() [7/18]

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

◆ DEFINE_GUID() [8/18]

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

◆ DEFINE_GUID() [9/18]

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

◆ DEFINE_GUID() [10/18]

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

◆ DEFINE_GUID() [11/18]

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

◆ DEFINE_GUID() [12/18]

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

◆ DEFINE_GUID() [13/18]

DEFINE_GUID ( ff_DXVA2_ModeAV1_VLD_Profile2 ,
0x0c5f2aa1 ,
0xe541 ,
0x4089 ,
0xbb ,
0x7b ,
0x98 ,
0x11 ,
0x0a ,
0x19 ,
0xd7 ,
0xc8  )

◆ DEFINE_GUID() [14/18]

DEFINE_GUID ( ff_DXVA2_ModeAV1_VLD_12bit_Profile2 ,
0x17127009 ,
0xa00f ,
0x4ce1 ,
0x99 ,
0x4e ,
0xbf ,
0x40 ,
0x81 ,
0xf6 ,
0xf3 ,
0xf0  )

◆ DEFINE_GUID() [15/18]

DEFINE_GUID ( ff_DXVA2_ModeAV1_VLD_12bit_Profile2_420 ,
0x2d80bed6 ,
0x9cac ,
0x4835 ,
0x9e ,
0x91 ,
0x32 ,
0x7b ,
0xbc ,
0x4f ,
0x9e ,
0xe8  )

◆ DEFINE_GUID() [16/18]

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

◆ DEFINE_GUID() [17/18]

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

◆ DEFINE_GUID() [18/18]

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 119 of file dxva2.c.

◆ dxva_check_codec_compatibility()

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

Definition at line 204 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 224 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 269 of file dxva2.c.

◆ bufref_free_interface()

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

Definition at line 316 of file dxva2.c.

◆ bufref_wrap_interface()

static AVBufferRef * bufref_wrap_interface ( IUnknown * iface)
static

Definition at line 321 of file dxva2.c.

◆ ff_dxva2_lock()

static void ff_dxva2_lock ( AVCodecContext * avctx)
static

Definition at line 570 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 586 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 602 of file dxva2.c.

◆ ff_dxva2_decode_init()

int ff_dxva2_decode_init ( AVCodecContext * avctx)

Definition at line 668 of file dxva2.c.

◆ ff_dxva2_decode_uninit()

int ff_dxva2_decode_uninit ( AVCodecContext * avctx)

Definition at line 743 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 766 of file dxva2.c.

Referenced by ff_dxva2_common_end_frame(), and ff_dxva2_get_surface_index().

◆ ff_dxva2_get_surface_index()

◆ ff_dxva2_commit_buffer()

◆ frame_add_buf()

static int frame_add_buf ( AVFrame * frame,
AVBufferRef * ref )
static

Definition at line 887 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(* commit_bs_si )(AVCodecContext *, DECODER_BUFFER_DESC *bs, DECODER_BUFFER_DESC *slice) )

◆ ff_dxva2_is_d3d11()

◆ ff_dxva2_get_report_id()

unsigned * ff_dxva2_get_report_id ( const AVCodecContext * avctx,
AVDXVAContext * ctx )

Definition at line 1077 of file dxva2.c.

Variable Documentation

◆ prof_mpeg2_main

const int prof_mpeg2_main[]
static
Initial value:
#define AV_PROFILE_MPEG2_MAIN
Definition defs.h:104
#define AV_PROFILE_UNKNOWN
Definition defs.h:65
#define AV_PROFILE_MPEG2_SIMPLE
Definition defs.h:105

Definition at line 65 of file dxva2.c.

◆ prof_h264_high

const int prof_h264_high[]
static
Initial value:
#define AV_PROFILE_H264_MAIN
Definition defs.h:112
#define AV_PROFILE_H264_HIGH
Definition defs.h:114
#define AV_PROFILE_H264_CONSTRAINED_BASELINE
Definition defs.h:111

Definition at line 68 of file dxva2.c.

◆ prof_hevc_main

const int prof_hevc_main[]
static
Initial value:
#define AV_PROFILE_HEVC_MAIN
Definition defs.h:159

Definition at line 72 of file dxva2.c.

◆ prof_hevc_main10

const int prof_hevc_main10[]
static
Initial value:
#define AV_PROFILE_HEVC_MAIN_10
Definition defs.h:160

Definition at line 74 of file dxva2.c.

◆ prof_vp9_profile0

const int prof_vp9_profile0[]
static
Initial value:
#define AV_PROFILE_VP9_0
Definition defs.h:154

Definition at line 76 of file dxva2.c.

◆ prof_vp9_profile2

const int prof_vp9_profile2[]
static
Initial value:
#define AV_PROFILE_VP9_2
Definition defs.h:156

Definition at line 78 of file dxva2.c.

◆ prof_av1_profile0

const int prof_av1_profile0[]
static
Initial value:
#define AV_PROFILE_AV1_MAIN
Definition defs.h:169

Definition at line 80 of file dxva2.c.

◆ prof_av1_profile2

const int prof_av1_profile2[]
static
Initial value:

Definition at line 82 of file dxva2.c.

◆ dxva_modes

const dxva_mode dxva_modes[]
static

Definition at line 85 of file dxva2.c.

Referenced by dxva_get_decoder_guid().