@@ -53,6 +53,7 @@ DEFINE_GUID(DXVADDI_Intel_ModeH264_E, 0x604F8E68, 0x4951,0x4C54,0x88,0xFE,0xAB,0
5353DEFINE_GUID (DXVA2_ModeVC1_D , 0x1b81beA3 , 0xa0c7 ,0x11d3 ,0xb9 ,0x84 ,0x00 ,0xc0 ,0x4f ,0x2e ,0x73 ,0xc5 );
5454DEFINE_GUID (DXVA2_ModeVC1_D2010 , 0x1b81beA4 , 0xa0c7 ,0x11d3 ,0xb9 ,0x84 ,0x00 ,0xc0 ,0x4f ,0x2e ,0x73 ,0xc5 );
5555DEFINE_GUID (DXVA2_ModeHEVC_VLD_Main , 0x5b11d51b , 0x2f4c ,0x4452 ,0xbc ,0xc3 ,0x09 ,0xf2 ,0xa1 ,0x16 ,0x0c ,0xc0 );
56+ DEFINE_GUID (DXVA2_ModeHEVC_VLD_Main10 ,0x107af0e0 , 0xef1a ,0x4d19 ,0xab ,0xa8 ,0x67 ,0xa1 ,0x63 ,0x07 ,0x3d ,0x13 );
5657DEFINE_GUID (DXVA2_ModeVP9_VLD_Profile0 , 0x463707f8 , 0xa1d0 ,0x4585 ,0x87 ,0x6d ,0x83 ,0xaa ,0x6d ,0x60 ,0xb8 ,0x9e );
5758DEFINE_GUID (DXVA2_NoEncrypt , 0x1b81beD0 , 0xa0c7 ,0x11d3 ,0xb9 ,0x84 ,0x00 ,0xc0 ,0x4f ,0x2e ,0x73 ,0xc5 );
5859DEFINE_GUID (GUID_NULL , 0x00000000 , 0x0000 ,0x0000 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 );
@@ -84,6 +85,7 @@ static const dxva2_mode dxva2_modes[] = {
8485
8586 /* HEVC/H.265 */
8687 { & DXVA2_ModeHEVC_VLD_Main , AV_CODEC_ID_HEVC },
88+ { & DXVA2_ModeHEVC_VLD_Main10 ,AV_CODEC_ID_HEVC },
8789
8890 /* VP8/9 */
8991 { & DXVA2_ModeVP9_VLD_Profile0 , AV_CODEC_ID_VP9 },
@@ -115,6 +117,7 @@ typedef struct DXVA2Context {
115117 surface_info * surface_infos ;
116118 uint32_t num_surfaces ;
117119 uint64_t surface_age ;
120+ D3DFORMAT surface_format ;
118121
119122 AVFrame * tmp_frame ;
120123} DXVA2Context ;
@@ -261,13 +264,24 @@ static int dxva2_retrieve_data(AVCodecContext *s, AVFrame *frame)
261264 D3DSURFACE_DESC surfaceDesc ;
262265 D3DLOCKED_RECT LockedRect ;
263266 HRESULT hr ;
264- int ret ;
267+ int ret , nbytes ;
265268
266269 IDirect3DSurface9_GetDesc (surface , & surfaceDesc );
267270
268271 ctx -> tmp_frame -> width = frame -> width ;
269272 ctx -> tmp_frame -> height = frame -> height ;
270- ctx -> tmp_frame -> format = AV_PIX_FMT_NV12 ;
273+ switch (ctx -> surface_format ){
274+ case MKTAG ('N' ,'V' ,'1' ,'2' ):
275+ ctx -> tmp_frame -> format = AV_PIX_FMT_NV12 ;
276+ nbytes = 1 ;
277+ break ;
278+ case MKTAG ('P' ,'0' ,'1' ,'0' ):
279+ ctx -> tmp_frame -> format = AV_PIX_FMT_P010 ;
280+ nbytes = 2 ;
281+ break ;
282+ default :
283+ av_assert0 (0 );
284+ }
271285
272286 ret = av_frame_get_buffer (ctx -> tmp_frame , 32 );
273287 if (ret < 0 )
@@ -281,11 +295,11 @@ static int dxva2_retrieve_data(AVCodecContext *s, AVFrame *frame)
281295
282296 av_image_copy_plane (ctx -> tmp_frame -> data [0 ], ctx -> tmp_frame -> linesize [0 ],
283297 (uint8_t * )LockedRect .pBits ,
284- LockedRect .Pitch , frame -> width , frame -> height );
298+ LockedRect .Pitch , frame -> width * nbytes , frame -> height );
285299
286300 av_image_copy_plane (ctx -> tmp_frame -> data [1 ], ctx -> tmp_frame -> linesize [1 ],
287301 (uint8_t * )LockedRect .pBits + LockedRect .Pitch * surfaceDesc .Height ,
288- LockedRect .Pitch , frame -> width , frame -> height / 2 );
302+ LockedRect .Pitch , frame -> width * nbytes , frame -> height / 2 );
289303
290304 IDirect3DSurface9_UnlockRect (surface );
291305
@@ -470,6 +484,7 @@ static int dxva2_create_decoder(AVCodecContext *s)
470484 GUID * guid_list = NULL ;
471485 unsigned guid_count = 0 , i , j ;
472486 GUID device_guid = GUID_NULL ;
487+ const D3DFORMAT surface_format = (s -> profile == FF_PROFILE_HEVC_MAIN_10 ) ? MKTAG ('P' ,'0' ,'1' ,'0' ) : MKTAG ('N' ,'V' ,'1' ,'2' );
473488 D3DFORMAT target_format = 0 ;
474489 DXVA2_VideoDesc desc = { 0 };
475490 DXVA2_ConfigPictureDecode config ;
@@ -503,7 +518,7 @@ static int dxva2_create_decoder(AVCodecContext *s)
503518 }
504519 for (j = 0 ; j < target_count ; j ++ ) {
505520 const D3DFORMAT format = target_list [j ];
506- if (format == MKTAG ( 'N' , 'V' , '1' , '2' ) ) {
521+ if (format == surface_format ) {
507522 target_format = format ;
508523 break ;
509524 }
@@ -558,6 +573,7 @@ static int dxva2_create_decoder(AVCodecContext *s)
558573
559574 ctx -> surfaces = av_mallocz (ctx -> num_surfaces * sizeof (* ctx -> surfaces ));
560575 ctx -> surface_infos = av_mallocz (ctx -> num_surfaces * sizeof (* ctx -> surface_infos ));
576+ ctx -> surface_format = target_format ;
561577
562578 if (!ctx -> surfaces || !ctx -> surface_infos ) {
563579 av_log (NULL , loglevel , "Unable to allocate surface arrays\n" );
0 commit comments