@@ -57,16 +57,26 @@ tvh_stream_setup(TVHStream *self, TVHCodecProfile *profile, tvh_ssc_t *ssc)
5757{
5858 enum AVCodecID icodec_id = streaming_component_type2codec_id (ssc -> es_type );
5959 const AVCodec * icodec = NULL , * ocodec = NULL ;
60+ int hwaccel = -1 ;
61+ int hwaccel_details = -1 ;
6062
6163 if (icodec_id == AV_CODEC_ID_NONE ) {
6264 tvh_stream_log (self , LOG_ERR , "unknown decoder id for '%s'" ,
6365 streaming_component_type2txt (ssc -> es_type ));
6466 return -1 ;
6567 }
68+ if ((hwaccel = tvh_codec_profile_video_get_hwaccel (profile )) < 0 ) {
69+ return -1 ;
70+ }
71+ if ((hwaccel_details = tvh_codec_profile_video_get_hwaccel_details (profile )) < 0 ) {
72+ return -1 ;
73+ }
6674#if ENABLE_MMAL
6775 if (idnode_is_instance (& profile -> idnode ,
6876 (idclass_t * )& codec_profile_video_class )) {
69- if (tvh_codec_profile_video_get_hwaccel (profile ) > 0 ) {
77+ if (hwaccel &&
78+ ((hwaccel_details == HWACCEL_AUTO && strstr (profile -> codec_name , "mmal" )) ||
79+ hwaccel_details == HWACCEL_PRIORITIZE_MMAL )) {
7080 if (icodec_id == AV_CODEC_ID_H264 ) {
7181 icodec = avcodec_find_decoder_by_name ("h264_mmal" );
7282 } else if (icodec_id == AV_CODEC_ID_MPEG2VIDEO ) {
@@ -76,16 +86,40 @@ tvh_stream_setup(TVHStream *self, TVHCodecProfile *profile, tvh_ssc_t *ssc)
7686 }
7787#endif
7888#if ENABLE_NVENC
79- if (idnode_is_instance (& profile -> idnode ,
89+ if (! icodec && idnode_is_instance (& profile -> idnode ,
8090 (idclass_t * )& codec_profile_video_class )) {
81- if (tvh_codec_profile_video_get_hwaccel (profile ) > 0 ) {
91+ if (hwaccel &&
92+ ((hwaccel_details == HWACCEL_AUTO && strstr (profile -> codec_name , "nvenc" )) ||
93+ hwaccel_details == HWACCEL_PRIORITIZE_NVDEC )) {
94+ // https://developer.nvidia.com/video-codec-sdk
8295 if (icodec_id == AV_CODEC_ID_H264 ) {
8396 icodec = avcodec_find_decoder_by_name ("h264_cuvid" );
8497 } else if (icodec_id == AV_CODEC_ID_HEVC ) {
8598 icodec = avcodec_find_decoder_by_name ("hevc_cuvid" );
8699 }
87100 }
88101 }
102+ #endif
103+ #if ENABLE_VAAPI
104+ if (!icodec && idnode_is_instance (& profile -> idnode ,
105+ (idclass_t * )& codec_profile_video_class )) {
106+ if (hwaccel &&
107+ (hwaccel_details == HWACCEL_PRIORITIZE_VAAPI )) {
108+ if (icodec_id == AV_CODEC_ID_MPEG2VIDEO ) {
109+ icodec = avcodec_find_decoder_by_name ("mpeg2_vaapi" );
110+ } else if (icodec_id == AV_CODEC_ID_H264 ) {
111+ icodec = avcodec_find_decoder_by_name ("h264_vaapi" );
112+ } else if (icodec_id == AV_CODEC_ID_HEVC ) {
113+ icodec = avcodec_find_decoder_by_name ("hevc_vaapi" );
114+ } else if (icodec_id == AV_CODEC_ID_VP9 ) {
115+ icodec = avcodec_find_decoder_by_name ("vp9_vaapi" );
116+ } else if (icodec_id == AV_CODEC_ID_VP8 ) {
117+ icodec = avcodec_find_decoder_by_name ("vp8_vaapi" );
118+ }else if (icodec_id == AV_CODEC_ID_MJPEG ) {
119+ icodec = avcodec_find_decoder_by_name ("mjpeg_vaapi" );
120+ }
121+ }
122+ }
89123#endif
90124 if (!icodec && !(icodec = avcodec_find_decoder (icodec_id ))) {
91125 tvh_stream_log (self , LOG_ERR , "failed to find decoder for '%s'" ,
0 commit comments