@@ -129,6 +129,16 @@ static enum AVPixelFormat d3d11va_get_format(AVCodecContext* ctx, const enum AVP
129129 return AV_PIX_FMT_NONE ;
130130}
131131
132+ static enum AVPixelFormat d3d12va_get_format (AVCodecContext * ctx , const enum AVPixelFormat * pix_fmts )
133+ {
134+ while (* pix_fmts != AV_PIX_FMT_NONE ) {
135+ if (* pix_fmts == AV_PIX_FMT_D3D12 )
136+ return * pix_fmts ;
137+ pix_fmts ++ ;
138+ }
139+ return AV_PIX_FMT_NONE ;
140+ }
141+
132142static enum AVPixelFormat vulkan_get_format (AVCodecContext * ctx , const enum AVPixelFormat * pix_fmts )
133143{
134144 while (* pix_fmts != AV_PIX_FMT_NONE ) {
@@ -139,7 +149,7 @@ static enum AVPixelFormat vulkan_get_format(AVCodecContext* ctx, const enum AVPi
139149 return AV_PIX_FMT_NONE ;
140150}
141151
142- static const char * hw_device_names [] = { [ 4 ] = "dxva2" , [ 5 ] = "d3d11va" , [ 6 ] = "vulkan" };
152+ static const char * hw_device_names [] = { "dxva2" , "d3d11va" , "d3d12va" , "vulkan" };
143153
144154int open_decoder (AVCodecContext * * ctx , const AVCodecParameters * codecpar , const AVCodec * codec , const int thread_count , const double drc ,
145155 const char * ff_options , int * prefer_hw_decoder , AVBufferRef * hw_device_ctx )
@@ -186,7 +196,7 @@ int open_decoder(AVCodecContext** ctx, const AVCodecParameters* codecpar, const
186196 enum AVPixelFormat hw_pix_fmt = AV_PIX_FMT_NONE ;
187197 if (* prefer_hw_decoder == 3 )
188198 ++ * prefer_hw_decoder ;
189- type = av_hwdevice_find_type_by_name (hw_device_names [* prefer_hw_decoder ]);
199+ type = av_hwdevice_find_type_by_name (hw_device_names [* prefer_hw_decoder - 4 ]);
190200 if (type != AV_HWDEVICE_TYPE_NONE ) {
191201 for (int i = 0 ;; ++ i ) {
192202 const AVCodecHWConfig * config = avcodec_get_hw_config (codec , i );
@@ -206,6 +216,9 @@ int open_decoder(AVCodecContext** ctx, const AVCodecParameters* codecpar, const
206216 case AV_PIX_FMT_D3D11 :
207217 c -> get_format = d3d11va_get_format ;
208218 break ;
219+ case AV_PIX_FMT_D3D12 :
220+ c -> get_format = d3d12va_get_format ;
221+ break ;
209222 default :
210223 c -> get_format = vulkan_get_format ;
211224 break ;
0 commit comments