mirror of
				https://github.com/jojo61/vdr-plugin-softhdcuvid.git
				synced 2025-03-01 10:39:28 +00:00 
			
		
		
		
	Compare commits
	
		
			12 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|  | 6805c4974c | ||
|  | 0ff83f0e31 | ||
|  | 230bb5ca11 | ||
|  | f026e8e86d | ||
|  | 9dd936df86 | ||
|  | 4e5529efcf | ||
|  | 20f1bd45e6 | ||
|  | 7a7e09ff7a | ||
|  | c4a660ede2 | ||
|  | 8e495266e2 | ||
|  | f27e4fb35f | ||
|  | e14ea73a00 | 
							
								
								
									
										5
									
								
								audio.c
									
									
									
									
									
								
							
							
						
						
									
										5
									
								
								audio.c
									
									
									
									
									
								
							| @@ -2283,26 +2283,31 @@ found: | |||||||
|                                 AudioChannelMatrix[u][chan] = 4; |                                 AudioChannelMatrix[u][chan] = 4; | ||||||
|                                 break; |                                 break; | ||||||
|                             } |                             } | ||||||
|  |                             __attribute__ ((fallthrough)); | ||||||
|                         case 4: |                         case 4: | ||||||
|                             if (AudioChannelsInHw[5]) { |                             if (AudioChannelsInHw[5]) { | ||||||
|                                 AudioChannelMatrix[u][chan] = 5; |                                 AudioChannelMatrix[u][chan] = 5; | ||||||
|                                 break; |                                 break; | ||||||
|                             } |                             } | ||||||
|  |                             __attribute__ ((fallthrough)); | ||||||
|                         case 5: |                         case 5: | ||||||
|                             if (AudioChannelsInHw[6]) { |                             if (AudioChannelsInHw[6]) { | ||||||
|                                 AudioChannelMatrix[u][chan] = 6; |                                 AudioChannelMatrix[u][chan] = 6; | ||||||
|                                 break; |                                 break; | ||||||
|                             } |                             } | ||||||
|  |                             __attribute__ ((fallthrough)); | ||||||
|                         case 6: |                         case 6: | ||||||
|                             if (AudioChannelsInHw[7]) { |                             if (AudioChannelsInHw[7]) { | ||||||
|                                 AudioChannelMatrix[u][chan] = 7; |                                 AudioChannelMatrix[u][chan] = 7; | ||||||
|                                 break; |                                 break; | ||||||
|                             } |                             } | ||||||
|  |                             __attribute__ ((fallthrough)); | ||||||
|                         case 7: |                         case 7: | ||||||
|                             if (AudioChannelsInHw[8]) { |                             if (AudioChannelsInHw[8]) { | ||||||
|                                 AudioChannelMatrix[u][chan] = 8; |                                 AudioChannelMatrix[u][chan] = 8; | ||||||
|                                 break; |                                 break; | ||||||
|                             } |                             } | ||||||
|  |                             __attribute__ ((fallthrough)); | ||||||
|                         case 8: |                         case 8: | ||||||
|                             if (AudioChannelsInHw[6]) { |                             if (AudioChannelsInHw[6]) { | ||||||
|                                 AudioChannelMatrix[u][chan] = 6; |                                 AudioChannelMatrix[u][chan] = 6; | ||||||
|   | |||||||
							
								
								
									
										132
									
								
								codec.c
									
									
									
									
									
								
							
							
						
						
									
										132
									
								
								codec.c
									
									
									
									
									
								
							| @@ -125,7 +125,7 @@ struct _video_decoder_ | |||||||
| */ | */ | ||||||
| static enum AVPixelFormat Codec_get_format(AVCodecContext *video_ctx, const enum AVPixelFormat *fmt) { | static enum AVPixelFormat Codec_get_format(AVCodecContext *video_ctx, const enum AVPixelFormat *fmt) { | ||||||
|     VideoDecoder *decoder; |     VideoDecoder *decoder; | ||||||
|     enum AVPixelFormat fmt1; |  | ||||||
|  |  | ||||||
|     decoder = video_ctx->opaque; |     decoder = video_ctx->opaque; | ||||||
|     // bug in ffmpeg 1.1.1, called with zero width or height |     // bug in ffmpeg 1.1.1, called with zero width or height | ||||||
| @@ -208,9 +208,13 @@ void CodecVideoDelDecoder(VideoDecoder *decoder) { free(decoder); } | |||||||
| **  @param codec_id video codec id | **  @param codec_id video codec id | ||||||
| */ | */ | ||||||
| void CodecVideoOpen(VideoDecoder *decoder, int codec_id) { | void CodecVideoOpen(VideoDecoder *decoder, int codec_id) { | ||||||
|  | #if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59,0,100) | ||||||
|     AVCodec *video_codec; |     AVCodec *video_codec; | ||||||
|  | #else | ||||||
|  |     const AVCodec *video_codec; | ||||||
|  | #endif | ||||||
|     const char *name; |     const char *name; | ||||||
|     int ret, deint = 2; |     int ret; | ||||||
|  |  | ||||||
|     Debug(3, "***************codec: Video Open using video codec ID %#06x (%s)\n", codec_id, |     Debug(3, "***************codec: Video Open using video codec ID %#06x (%s)\n", codec_id, | ||||||
|           avcodec_get_name(codec_id)); |           avcodec_get_name(codec_id)); | ||||||
| @@ -265,9 +269,7 @@ void CodecVideoOpen(VideoDecoder *decoder, int codec_id) { | |||||||
|  |  | ||||||
|     pthread_mutex_lock(&CodecLockMutex); |     pthread_mutex_lock(&CodecLockMutex); | ||||||
|     // open codec |     // open codec | ||||||
| #ifdef YADIF |  | ||||||
|     deint = 2; |  | ||||||
| #endif |  | ||||||
|  |  | ||||||
| #if defined VAAPI | #if defined VAAPI | ||||||
| #if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59,8,100) | #if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59,8,100) | ||||||
| @@ -305,6 +307,7 @@ void CodecVideoOpen(VideoDecoder *decoder, int codec_id) { | |||||||
| #endif | #endif | ||||||
|  |  | ||||||
| #ifdef CUVID | #ifdef CUVID | ||||||
|  |     int deint = 2; | ||||||
|     if (strcmp(decoder->VideoCodec->long_name, |     if (strcmp(decoder->VideoCodec->long_name, | ||||||
|                "Nvidia CUVID MPEG2VIDEO decoder") == 0) { // deinterlace for mpeg2 is somehow broken |                "Nvidia CUVID MPEG2VIDEO decoder") == 0) { // deinterlace for mpeg2 is somehow broken | ||||||
|         if (av_opt_set_int(decoder->VideoCtx->priv_data, "deint", deint, 0) < 0) { // adaptive |         if (av_opt_set_int(decoder->VideoCtx->priv_data, "deint", deint, 0) < 0) { // adaptive | ||||||
| @@ -389,15 +392,19 @@ void CodecVideoClose(VideoDecoder *video_decoder) { | |||||||
|     Debug(3, "CodecVideoClose\n"); |     Debug(3, "CodecVideoClose\n"); | ||||||
|     if (video_decoder->VideoCtx) { |     if (video_decoder->VideoCtx) { | ||||||
|         pthread_mutex_lock(&CodecLockMutex); |         pthread_mutex_lock(&CodecLockMutex); | ||||||
| #if 1 |  | ||||||
|         frame = av_frame_alloc(); |         frame = av_frame_alloc(); | ||||||
|         avcodec_send_packet(video_decoder->VideoCtx, NULL); |         avcodec_send_packet(video_decoder->VideoCtx, NULL); | ||||||
|         while (avcodec_receive_frame(video_decoder->VideoCtx, frame) >= 0) |         while (avcodec_receive_frame(video_decoder->VideoCtx, frame) >= 0) | ||||||
|             ; |             ; | ||||||
|         av_frame_free(&frame); |         av_frame_free(&frame); | ||||||
|  |  | ||||||
|  | #if LIBAVUTIL_VERSION_INT < AV_VERSION_INT(55,63,100) | ||||||
|  | 	    avcodec_close(video_decoder->VideoCtx); | ||||||
|  | 	    av_freep(&video_decoder->VideoCtx); | ||||||
|  | #else | ||||||
|  | 	    avcodec_free_context(&video_decoder->VideoCtx); | ||||||
| #endif | #endif | ||||||
|         avcodec_close(video_decoder->VideoCtx); |  | ||||||
|         av_freep(&video_decoder->VideoCtx); |  | ||||||
|         pthread_mutex_unlock(&CodecLockMutex); |         pthread_mutex_unlock(&CodecLockMutex); | ||||||
|     } |     } | ||||||
| } | } | ||||||
| @@ -513,7 +520,7 @@ void CodecVideoDecode(VideoDecoder *decoder, const AVPacket *avpkt) { | |||||||
|     int ret, ret1; |     int ret, ret1; | ||||||
|     int got_frame; |     int got_frame; | ||||||
|     int consumed = 0; |     int consumed = 0; | ||||||
|     static uint64_t first_time = 0; |     //static uint64_t first_time = 0; | ||||||
|     const AVPacket *pkt; |     const AVPacket *pkt; | ||||||
|  |  | ||||||
| next_part: | next_part: | ||||||
| @@ -541,7 +548,7 @@ next_part: | |||||||
|             frame = av_frame_alloc(); |             frame = av_frame_alloc(); | ||||||
|             ret = avcodec_receive_frame(video_ctx, frame); // get new frame |             ret = avcodec_receive_frame(video_ctx, frame); // get new frame | ||||||
|             if (ret >= 0) {                                // one is avail. |             if (ret >= 0) {                                // one is avail. | ||||||
|             first_time = frame->pts; |                 //first_time = frame->pts; | ||||||
|                 got_frame = 1; |                 got_frame = 1; | ||||||
|             } else { |             } else { | ||||||
|                 got_frame = 0; |                 got_frame = 0; | ||||||
| @@ -615,7 +622,11 @@ typedef struct _audio_decoder_ AudioDecoder; | |||||||
| /// Audio decoder structure. | /// Audio decoder structure. | ||||||
| /// | /// | ||||||
| struct _audio_decoder_ { | struct _audio_decoder_ { | ||||||
|     AVCodec *AudioCodec;      ///< audio codec | #if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59,0,100) | ||||||
|  |     AVCodec *AudioCodec;		///< audio codec | ||||||
|  | #else | ||||||
|  |     const AVCodec *AudioCodec;		///< audio codec | ||||||
|  | #endif | ||||||
|     AVCodecContext *AudioCtx; ///< audio codec context |     AVCodecContext *AudioCtx; ///< audio codec context | ||||||
|  |  | ||||||
|     char Passthrough; ///< current pass-through flags |     char Passthrough; ///< current pass-through flags | ||||||
| @@ -702,8 +713,11 @@ void CodecAudioDelDecoder(AudioDecoder *decoder) { | |||||||
| **  @param codec_id audio   codec id | **  @param codec_id audio   codec id | ||||||
| */ | */ | ||||||
| void CodecAudioOpen(AudioDecoder *audio_decoder, int codec_id) { | void CodecAudioOpen(AudioDecoder *audio_decoder, int codec_id) { | ||||||
|  | #if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59,0,100) | ||||||
|     AVCodec *audio_codec; |     AVCodec *audio_codec; | ||||||
|  | #else | ||||||
|  |     const AVCodec *audio_codec; | ||||||
|  | #endif | ||||||
|     Debug(3, "codec: using audio codec ID %#06x (%s)\n", codec_id, avcodec_get_name(codec_id)); |     Debug(3, "codec: using audio codec ID %#06x (%s)\n", codec_id, avcodec_get_name(codec_id)); | ||||||
|     if (!(audio_codec = avcodec_find_decoder(codec_id))) { |     if (!(audio_codec = avcodec_find_decoder(codec_id))) { | ||||||
|         // if (!(audio_codec = avcodec_find_decoder(codec_id))) { |         // if (!(audio_codec = avcodec_find_decoder(codec_id))) { | ||||||
| @@ -755,8 +769,12 @@ void CodecAudioClose(AudioDecoder *audio_decoder) { | |||||||
|     } |     } | ||||||
|     if (audio_decoder->AudioCtx) { |     if (audio_decoder->AudioCtx) { | ||||||
|         pthread_mutex_lock(&CodecLockMutex); |         pthread_mutex_lock(&CodecLockMutex); | ||||||
|         avcodec_close(audio_decoder->AudioCtx); | #if LIBAVUTIL_VERSION_INT < AV_VERSION_INT(55,63,100) | ||||||
|         av_freep(&audio_decoder->AudioCtx); | 	    avcodec_close(audio_decoder->AudioCtx); | ||||||
|  | 	    av_freep(&audio_decoder->AudioCtx); | ||||||
|  | #else | ||||||
|  | 	    avcodec_free_context(&audio_decoder->AudioCtx); | ||||||
|  | #endif | ||||||
|         pthread_mutex_unlock(&CodecLockMutex); |         pthread_mutex_unlock(&CodecLockMutex); | ||||||
|     } |     } | ||||||
| } | } | ||||||
| @@ -868,19 +886,35 @@ static int CodecAudioUpdateHelper(AudioDecoder *audio_decoder, int *passthrough) | |||||||
|     int err; |     int err; | ||||||
|  |  | ||||||
|     audio_ctx = audio_decoder->AudioCtx; |     audio_ctx = audio_decoder->AudioCtx; | ||||||
|     Debug(3, "codec/audio: Chanlayout %lx format change %s %dHz *%d channels%s%s%s%s%s\n",audio_ctx->channel_layout, |      | ||||||
|           av_get_sample_fmt_name(audio_ctx->sample_fmt), audio_ctx->sample_rate, audio_ctx->channels, |   | ||||||
|           CodecPassthrough & CodecPCM ? " PCM" : "", CodecPassthrough & CodecMPA ? " MPA" : "", |     Debug(3, "codec/audio: format change %s %dHz *%d channels%s%s%s%s%s%s\n", | ||||||
|           CodecPassthrough & CodecAC3 ? " AC-3" : "", CodecPassthrough & CodecEAC3 ? " E-AC-3" : "", | 	av_get_sample_fmt_name(audio_ctx->sample_fmt), audio_ctx->sample_rate, | ||||||
|           CodecPassthrough ? " pass-through" : ""); | #if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59,24,100) | ||||||
|  | 	audio_ctx->channels, CodecPassthrough & CodecPCM ? " PCM" : "", | ||||||
|  | #else | ||||||
|  | 	audio_ctx->ch_layout.nb_channels, CodecPassthrough & CodecPCM ? " PCM" : "", | ||||||
|  | #endif | ||||||
|  | 	CodecPassthrough & CodecMPA ? " MPA" : "", | ||||||
|  | 	CodecPassthrough & CodecAC3 ? " AC-3" : "", | ||||||
|  | 	CodecPassthrough & CodecEAC3 ? " E-AC-3" : "", | ||||||
|  | 	CodecPassthrough & CodecDTS ? " DTS" : "", | ||||||
|  | 	CodecPassthrough ? " pass-through" : ""); | ||||||
|  |  | ||||||
|  |  | ||||||
|     *passthrough = 0; |     *passthrough = 0; | ||||||
|     audio_decoder->SampleRate = audio_ctx->sample_rate; |     audio_decoder->SampleRate = audio_ctx->sample_rate; | ||||||
|     audio_decoder->HwSampleRate = audio_ctx->sample_rate; |     audio_decoder->HwSampleRate = audio_ctx->sample_rate; | ||||||
|  | #if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59,24,100) | ||||||
|     audio_decoder->Channels = audio_ctx->channels; |     audio_decoder->Channels = audio_ctx->channels; | ||||||
|     audio_decoder->HwChannels = CodecDownmix ? 2 : audio_ctx->channels; |     audio_decoder->HwChannels = audio_ctx->channels; | ||||||
|     audio_decoder->Passthrough = CodecPassthrough; | #else | ||||||
|  |     audio_decoder->Channels = audio_ctx->ch_layout.nb_channels; | ||||||
|  |     audio_decoder->HwChannels = audio_ctx->ch_layout.nb_channels; | ||||||
|  | #endif | ||||||
|  |     if (CodecDownmix && !CodecPassthrough) audio_decoder->HwChannels = 2; | ||||||
|  |  | ||||||
|  |     audio_decoder->Passthrough = CodecPassthrough; | ||||||
|     // SPDIF/HDMI pass-through |     // SPDIF/HDMI pass-through | ||||||
|     if ((CodecPassthrough & CodecAC3 && audio_ctx->codec_id == AV_CODEC_ID_AC3) || |     if ((CodecPassthrough & CodecAC3 && audio_ctx->codec_id == AV_CODEC_ID_AC3) || | ||||||
|         (CodecPassthrough & CodecEAC3 && audio_ctx->codec_id == AV_CODEC_ID_EAC3)) { |         (CodecPassthrough & CodecEAC3 && audio_ctx->codec_id == AV_CODEC_ID_EAC3)) { | ||||||
| @@ -909,9 +943,15 @@ static int CodecAudioUpdateHelper(AudioDecoder *audio_decoder, int *passthrough) | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     Debug(3, "codec/audio: resample %s %dHz *%d -> %s %dHz *%d\n", av_get_sample_fmt_name(audio_ctx->sample_fmt), |     Debug(3, "codec/audio: resample %s %dHz *%d -> %s %dHz *%d\n", | ||||||
|           audio_ctx->sample_rate, audio_ctx->channels, av_get_sample_fmt_name(AV_SAMPLE_FMT_S16), | 	    av_get_sample_fmt_name(audio_ctx->sample_fmt), audio_ctx->sample_rate, | ||||||
|           audio_decoder->HwSampleRate, audio_decoder->HwChannels); | #if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59,24,100) | ||||||
|  | 	    audio_ctx->channels, av_get_sample_fmt_name(AV_SAMPLE_FMT_S16), | ||||||
|  | #else | ||||||
|  | 	    audio_ctx->ch_layout.nb_channels, av_get_sample_fmt_name(AV_SAMPLE_FMT_S16), | ||||||
|  | #endif | ||||||
|  | 	    audio_decoder->HwSampleRate, audio_decoder->HwChannels); | ||||||
|  |  | ||||||
|  |  | ||||||
|     return 0; |     return 0; | ||||||
| } | } | ||||||
| @@ -1140,6 +1180,12 @@ static void CodecAudioUpdateFormat(AudioDecoder *audio_decoder) { | |||||||
|     int passthrough; |     int passthrough; | ||||||
|     const AVCodecContext *audio_ctx; |     const AVCodecContext *audio_ctx; | ||||||
|  |  | ||||||
|  | #if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59,24,100) | ||||||
|  |     int64_t dmlayout = AV_CH_LAYOUT_STEREO; | ||||||
|  | #else | ||||||
|  |     AVChannelLayout dmlayout = AV_CHANNEL_LAYOUT_STEREO; | ||||||
|  | #endif | ||||||
|  |  | ||||||
|     if (CodecAudioUpdateHelper(audio_decoder, &passthrough)) { |     if (CodecAudioUpdateHelper(audio_decoder, &passthrough)) { | ||||||
|         // FIXME: handle swresample format conversions. |         // FIXME: handle swresample format conversions. | ||||||
|         return; |         return; | ||||||
| @@ -1150,6 +1196,12 @@ static void CodecAudioUpdateFormat(AudioDecoder *audio_decoder) { | |||||||
|  |  | ||||||
|     audio_ctx = audio_decoder->AudioCtx; |     audio_ctx = audio_decoder->AudioCtx; | ||||||
|  |  | ||||||
|  | #if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59,24,100) | ||||||
|  |     if (!CodecDownmix || CodecPassthrough) dmlayout = audio_ctx->channel_layout; | ||||||
|  | #else | ||||||
|  |     if (!CodecDownmix || CodecPassthrough) dmlayout = audio_ctx->ch_layout; | ||||||
|  | #endif | ||||||
|  |  | ||||||
| #ifdef DEBUG | #ifdef DEBUG | ||||||
|     if (audio_ctx->sample_fmt == AV_SAMPLE_FMT_S16 && audio_ctx->sample_rate == audio_decoder->HwSampleRate && |     if (audio_ctx->sample_fmt == AV_SAMPLE_FMT_S16 && audio_ctx->sample_rate == audio_decoder->HwSampleRate && | ||||||
|         !CodecAudioDrift) { |         !CodecAudioDrift) { | ||||||
| @@ -1157,27 +1209,23 @@ static void CodecAudioUpdateFormat(AudioDecoder *audio_decoder) { | |||||||
|         fprintf(stderr, "no resample needed\n"); |         fprintf(stderr, "no resample needed\n"); | ||||||
|     } |     } | ||||||
| #endif | #endif | ||||||
|  |      | ||||||
| #if LIBSWRESAMPLE_VERSION_INT < AV_VERSION_INT(4,5,100) | #if LIBSWRESAMPLE_VERSION_INT < AV_VERSION_INT(4,5,100) | ||||||
|         audio_decoder->Resample = swr_alloc_set_opts(audio_decoder->Resample,  |     audio_decoder->Resample = | ||||||
|                                     CodecDownMix ? AV_CH_LAYOUT_STEREO : audio_ctx->channel_layout, |         swr_alloc_set_opts(audio_decoder->Resample, dmlayout, | ||||||
|                                     AV_SAMPLE_FMT_S16, audio_decoder->HwSampleRate, |         AV_SAMPLE_FMT_S16, audio_decoder->HwSampleRate, | ||||||
| 	                                audio_ctx->channel_layout, audio_ctx->sample_fmt,audio_ctx->sample_rate, |         audio_ctx->channel_layout, audio_ctx->sample_fmt, | ||||||
|                                     0, NULL); |  | ||||||
| #else | #else | ||||||
|     //printf("last ressort downmix Layout in %lx Lyout out: %llx \n",audio_ctx->channel_layout,AV_CH_LAYOUT_STEREO); |         swr_alloc_set_opts2(&audio_decoder->Resample, &dmlayout, | ||||||
|         audio_decoder->Resample = swr_alloc(); |         AV_SAMPLE_FMT_S16, audio_decoder->HwSampleRate, | ||||||
|         av_opt_set_channel_layout(audio_decoder->Resample, "in_channel_layout",audio_ctx->channel_layout, 0); |         &audio_ctx->ch_layout, audio_ctx->sample_fmt, | ||||||
|         av_opt_set_channel_layout(audio_decoder->Resample, "out_channel_layout", CodecDownmix ? AV_CH_LAYOUT_STEREO : audio_ctx->channel_layout ,  0); |  | ||||||
|         av_opt_set_int(audio_decoder->Resample, "in_sample_rate",     audio_ctx->sample_rate,                0); |  | ||||||
|         av_opt_set_int(audio_decoder->Resample, "out_sample_rate",    audio_ctx->sample_rate,                0); |  | ||||||
|         av_opt_set_sample_fmt(audio_decoder->Resample, "in_sample_fmt",  audio_ctx->sample_fmt, 0); |  | ||||||
|         av_opt_set_sample_fmt(audio_decoder->Resample, "out_sample_fmt", AV_SAMPLE_FMT_S16,  0); |  | ||||||
| #endif | #endif | ||||||
|  | 	   audio_ctx->sample_rate, 0, NULL);  | ||||||
|  |  | ||||||
|     if (audio_decoder->Resample) { |     if (audio_decoder->Resample) { | ||||||
| 	    swr_init(audio_decoder->Resample); | 	swr_init(audio_decoder->Resample); | ||||||
|     } else { |     } else { | ||||||
| 	    Error(_("codec/audio: can't setup resample\n")); | 	Error(_("codec/audio: can't setup resample\n")); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |  | ||||||
| @@ -1223,7 +1271,11 @@ void CodecAudioDecode(AudioDecoder *audio_decoder, const AVPacket *avpkt) { | |||||||
|             // format change |             // format change | ||||||
|             if (audio_decoder->Passthrough != CodecPassthrough || |             if (audio_decoder->Passthrough != CodecPassthrough || | ||||||
|                 audio_decoder->SampleRate != audio_ctx->sample_rate || |                 audio_decoder->SampleRate != audio_ctx->sample_rate || | ||||||
|  | #if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59,24,100) | ||||||
|                 audio_decoder->Channels != audio_ctx->channels) { |                 audio_decoder->Channels != audio_ctx->channels) { | ||||||
|  | #else | ||||||
|  |                 audio_decoder->Channels != audio_ctx->ch_layout.nb_channels) { | ||||||
|  | #endif | ||||||
|                 CodecAudioUpdateFormat(audio_decoder); |                 CodecAudioUpdateFormat(audio_decoder); | ||||||
|             } |             } | ||||||
|             if (!audio_decoder->HwSampleRate || !audio_decoder->HwChannels) { |             if (!audio_decoder->HwSampleRate || !audio_decoder->HwChannels) { | ||||||
|   | |||||||
							
								
								
									
										6
									
								
								codec.h
									
									
									
									
									
								
							
							
						
						
									
										6
									
								
								codec.h
									
									
									
									
									
								
							| @@ -56,7 +56,11 @@ struct _video_decoder_ { | |||||||
|     VideoHwDecoder *HwDecoder; ///< video hardware decoder |     VideoHwDecoder *HwDecoder; ///< video hardware decoder | ||||||
|  |  | ||||||
|     int GetFormatDone;        ///< flag get format called! |     int GetFormatDone;        ///< flag get format called! | ||||||
|     AVCodec *VideoCodec;      ///< video codec | #if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59,0,100) | ||||||
|  |      AVCodec *VideoCodec;                ///< video codec | ||||||
|  | #else | ||||||
|  |      const AVCodec *VideoCodec;          ///< video codec | ||||||
|  | #endif | ||||||
|     AVCodecContext *VideoCtx; ///< video codec context |     AVCodecContext *VideoCtx; ///< video codec context | ||||||
|     // #ifdef FFMPEG_WORKAROUND_ARTIFACTS |     // #ifdef FFMPEG_WORKAROUND_ARTIFACTS | ||||||
|     int FirstKeyFrame; ///< flag first frame |     int FirstKeyFrame; ///< flag first frame | ||||||
|   | |||||||
							
								
								
									
										38
									
								
								drm.c
									
									
									
									
									
								
							
							
						
						
									
										38
									
								
								drm.c
									
									
									
									
									
								
							| @@ -209,8 +209,11 @@ static int FindDevice(VideoRender *render) { | |||||||
|     int found = 0; |     int found = 0; | ||||||
|     render->fd_drm = open("/dev/dri/card0", O_RDWR); |     render->fd_drm = open("/dev/dri/card0", O_RDWR); | ||||||
|     if (render->fd_drm < 0) { |     if (render->fd_drm < 0) { | ||||||
|         fprintf(stderr, "FindDevice: cannot open /dev/dri/card0: %m\n"); |         render->fd_drm = open("/dev/dri/card1", O_RDWR); | ||||||
|         return -errno; |         if (render->fd_drm < 0) { | ||||||
|  |             fprintf(stderr, "FindDevice: cannot open /dev/dri/card0 or card1: %m\n"); | ||||||
|  |             return -errno; | ||||||
|  |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     int ret = drmSetMaster(render->fd_drm); |     int ret = drmSetMaster(render->fd_drm); | ||||||
| @@ -545,6 +548,7 @@ static void drm_swap_buffers() { | |||||||
|         m_need_modeset = 0; |         m_need_modeset = 0; | ||||||
|         has_modeset = 1; |         has_modeset = 1; | ||||||
|     } |     } | ||||||
|  |      | ||||||
|     drmModeSetCrtc(render->fd_drm, render->crtc_id, fb, 0, 0, &render->connector_id, 1, &render->mode); |     drmModeSetCrtc(render->fd_drm, render->crtc_id, fb, 0, 0, &render->connector_id, 1, &render->mode); | ||||||
|  |  | ||||||
|     if (previous_bo) { |     if (previous_bo) { | ||||||
| @@ -562,15 +566,16 @@ static void drm_clean_up() { | |||||||
|         return; |         return; | ||||||
|     Debug(3, "drm clean up\n"); |     Debug(3, "drm clean up\n"); | ||||||
|  |  | ||||||
|  |      | ||||||
|  |     drmModeSetCrtc(render->fd_drm, render->saved_crtc->crtc_id, render->saved_crtc->buffer_id, render->saved_crtc->x, | ||||||
|  |                    render->saved_crtc->y, &render->connector_id, 1, &render->saved_crtc->mode); | ||||||
|  |     drmModeFreeCrtc(render->saved_crtc); | ||||||
|  |  | ||||||
|     if (previous_bo) { |     if (previous_bo) { | ||||||
|         drmModeRmFB(render->fd_drm, previous_fb); |         drmModeRmFB(render->fd_drm, previous_fb); | ||||||
|         gbm_surface_release_buffer(gbm.surface, previous_bo); |         gbm_surface_release_buffer(gbm.surface, previous_bo); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     drmModeSetCrtc(render->fd_drm, render->saved_crtc->crtc_id, render->saved_crtc->buffer_id, render->saved_crtc->x, |  | ||||||
|                    render->saved_crtc->y, &render->connector_id, 1, &render->saved_crtc->mode); |  | ||||||
|     drmModeFreeCrtc(render->saved_crtc); |  | ||||||
|  |  | ||||||
|     if (has_modeset) { |     if (has_modeset) { | ||||||
|         drmModeAtomicReqPtr ModeReq; |         drmModeAtomicReqPtr ModeReq; | ||||||
|         const uint32_t flags = DRM_MODE_ATOMIC_ALLOW_MODESET; |         const uint32_t flags = DRM_MODE_ATOMIC_ALLOW_MODESET; | ||||||
| @@ -613,22 +618,29 @@ static void drm_clean_up() { | |||||||
|     if (render->hdr_blob_id) |     if (render->hdr_blob_id) | ||||||
|         drmModeDestroyPropertyBlob(render->fd_drm, render->hdr_blob_id); |         drmModeDestroyPropertyBlob(render->fd_drm, render->hdr_blob_id); | ||||||
|     render->hdr_blob_id = 0; |     render->hdr_blob_id = 0; | ||||||
|  | #if 0 | ||||||
|  |     eglMakeCurrent(eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); | ||||||
|     eglDestroySurface(eglDisplay, eglSurface); |     eglDestroySurface(eglDisplay, eglSurface); | ||||||
|     EglCheck(); |     EglCheck(); | ||||||
|     gbm_surface_destroy(gbm.surface); |  | ||||||
|     eglDestroyContext(eglDisplay, eglContext); |  | ||||||
|     EglCheck(); |  | ||||||
|     eglDestroyContext(eglDisplay, eglSharedContext); |     eglDestroyContext(eglDisplay, eglSharedContext); | ||||||
|     EglCheck(); |     EglCheck(); | ||||||
|  |     eglDestroyContext(eglDisplay, eglContext); | ||||||
|  |     EglCheck(); | ||||||
|     eglSharedContext = NULL; |     eglSharedContext = NULL; | ||||||
|  |     eglContext = NULL; | ||||||
|     eglTerminate(eglDisplay); |     eglTerminate(eglDisplay); | ||||||
|     EglCheck(); |     EglCheck(); | ||||||
|  |     eglDisplay = NULL; | ||||||
|  | #endif | ||||||
|  |     eglMakeCurrent(eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); | ||||||
|  |     eglDestroySurface(eglDisplay, eglSurface); | ||||||
|  |     EglCheck(); | ||||||
|  |     eglSurface = NULL; | ||||||
|  |     gbm_surface_destroy(gbm.surface); | ||||||
|     gbm_device_destroy(gbm.dev); |     gbm_device_destroy(gbm.dev); | ||||||
|     drmDropMaster(render->fd_drm); |     drmDropMaster(render->fd_drm); | ||||||
|     close(render->fd_drm); |     close(render->fd_drm); | ||||||
|     eglDisplay = NULL; |  | ||||||
|     free(render); |     free(render); | ||||||
|  |     render = NULL; | ||||||
|  |     Debug(3, "nach drm clean up\n"); | ||||||
| } | } | ||||||
| @@ -126,7 +126,7 @@ void pl_shader_append_v(const char *fmt, ...) { | |||||||
|         Fatal(_("Shaderlenght fault\n")); |         Fatal(_("Shaderlenght fault\n")); | ||||||
|     strcat(shv, temp); |     strcat(shv, temp); | ||||||
| } | } | ||||||
|  | #ifndef PLACEBO | ||||||
| static void compile_attach_shader(GLuint program, GLenum type, const char *source) { | static void compile_attach_shader(GLuint program, GLenum type, const char *source) { | ||||||
|     GLuint shader; |     GLuint shader; | ||||||
|     GLint status = 1234, log_length; |     GLint status = 1234, log_length; | ||||||
| @@ -159,6 +159,7 @@ static void link_shader(GLuint program) { | |||||||
|     Debug(3, "Link Status %d loglen %d\n", status, log_length); |     Debug(3, "Link Status %d loglen %d\n", status, log_length); | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
| static GLuint sc_generate_osd(GLuint gl_prog) { | static GLuint sc_generate_osd(GLuint gl_prog) { | ||||||
|  |  | ||||||
|     Debug(3, "vor create osd\n"); |     Debug(3, "vor create osd\n"); | ||||||
| @@ -209,7 +210,7 @@ static GLuint sc_generate(GLuint gl_prog, enum AVColorSpace colorspace) { | |||||||
|     int n; |     int n; | ||||||
|     GLint cmsLoc; |     GLint cmsLoc; | ||||||
|     float *m, *c, *cms; |     float *m, *c, *cms; | ||||||
|     char *frag; |     //char *frag; | ||||||
|  |  | ||||||
|     GL_init(); |     GL_init(); | ||||||
|     GLSL("%s\n", gl_version); |     GLSL("%s\n", gl_version); | ||||||
| @@ -446,3 +447,4 @@ static void render_pass_quad(int flip, float xcrop, float ycrop) { | |||||||
|     for (n = 0; vertex_vao[n].name; n++) |     for (n = 0; vertex_vao[n].name; n++) | ||||||
|         glDisableVertexAttribArray(n); |         glDisableVertexAttribArray(n); | ||||||
| } | } | ||||||
|  | #endif | ||||||
|   | |||||||
| @@ -61,7 +61,7 @@ extern void ToggleLUT(); | |||||||
| /// vdr-plugin version number. | /// vdr-plugin version number. | ||||||
| /// Makefile extracts the version number for generating the file name | /// Makefile extracts the version number for generating the file name | ||||||
| /// for the distribution archive. | /// for the distribution archive. | ||||||
| static const char *const VERSION = "3.19" | static const char *const VERSION = "3.26" | ||||||
| #ifdef GIT_REV | #ifdef GIT_REV | ||||||
|                                    "-GIT" GIT_REV |                                    "-GIT" GIT_REV | ||||||
| #endif | #endif | ||||||
|   | |||||||
							
								
								
									
										31
									
								
								softhddev.c
									
									
									
									
									
								
							
							
						
						
									
										31
									
								
								softhddev.c
									
									
									
									
									
								
							| @@ -60,7 +60,7 @@ | |||||||
| #include "codec.h" | #include "codec.h" | ||||||
| // clang-format on | // clang-format on | ||||||
|  |  | ||||||
| #ifdef DEBUG | #if 0 | ||||||
| static int DumpH264(const uint8_t *data, int size); | static int DumpH264(const uint8_t *data, int size); | ||||||
| static void DumpMpeg(const uint8_t *data, int size); | static void DumpMpeg(const uint8_t *data, int size); | ||||||
| #endif | #endif | ||||||
| @@ -662,7 +662,13 @@ static void PesParse(PesDemux *pesdx, const uint8_t *data, int size, int is_star | |||||||
|                         break; |                         break; | ||||||
|                     } |                     } | ||||||
|                     if (r > 0) { |                     if (r > 0) { | ||||||
|                         AVPacket avpkt[1]; | #if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(58,33,100) | ||||||
|  | 				        AVPacket avpkt[1]; | ||||||
|  | 				        av_init_packet(avpkt); | ||||||
|  | #else | ||||||
|  |                         AVPacket * avpkt; | ||||||
|  | 				        avpkt = av_packet_alloc(); | ||||||
|  | #endif | ||||||
|  |  | ||||||
|                         // new codec id, close and open new |                         // new codec id, close and open new | ||||||
|                         if (AudioCodecID != codec_id) { |                         if (AudioCodecID != codec_id) { | ||||||
| @@ -671,13 +677,15 @@ static void PesParse(PesDemux *pesdx, const uint8_t *data, int size, int is_star | |||||||
|                             CodecAudioOpen(MyAudioDecoder, codec_id); |                             CodecAudioOpen(MyAudioDecoder, codec_id); | ||||||
|                             AudioCodecID = codec_id; |                             AudioCodecID = codec_id; | ||||||
|                         } |                         } | ||||||
|                         av_init_packet(avpkt); |  | ||||||
|                         avpkt->data = (void *)q; |                         avpkt->data = (void *)q; | ||||||
|                         avpkt->size = r; |                         avpkt->size = r; | ||||||
|                         avpkt->pts = pesdx->PTS; |                         avpkt->pts = pesdx->PTS; | ||||||
|                         avpkt->dts = pesdx->DTS; |                         avpkt->dts = pesdx->DTS; | ||||||
|                         // FIXME: not aligned for ffmpeg |                         // FIXME: not aligned for ffmpeg | ||||||
|                         CodecAudioDecode(MyAudioDecoder, avpkt); |                         CodecAudioDecode(MyAudioDecoder, avpkt); | ||||||
|  | #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(58,33,100) | ||||||
|  | 				        av_packet_free(&avpkt); | ||||||
|  | #endif | ||||||
|                         pesdx->PTS = AV_NOPTS_VALUE; |                         pesdx->PTS = AV_NOPTS_VALUE; | ||||||
|                         pesdx->DTS = AV_NOPTS_VALUE; |                         pesdx->DTS = AV_NOPTS_VALUE; | ||||||
|                         pesdx->Skip += r; |                         pesdx->Skip += r; | ||||||
| @@ -1147,21 +1155,28 @@ int PlayAudio(const uint8_t *data, int size, uint8_t id) { | |||||||
|             break; |             break; | ||||||
|         } |         } | ||||||
|         if (r > 0) { |         if (r > 0) { | ||||||
|             AVPacket avpkt[1]; | #if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(58,33,100) | ||||||
|  | 	        AVPacket avpkt[1]; | ||||||
|  | 	        av_init_packet(avpkt); | ||||||
|  | #else | ||||||
|  | 	        AVPacket * avpkt; | ||||||
|  | 	        avpkt = av_packet_alloc(); | ||||||
|  | #endif | ||||||
|             // new codec id, close and open new |             // new codec id, close and open new | ||||||
|             if (AudioCodecID != codec_id) { |             if (AudioCodecID != codec_id) { | ||||||
|                 CodecAudioClose(MyAudioDecoder); |                 CodecAudioClose(MyAudioDecoder); | ||||||
|                 CodecAudioOpen(MyAudioDecoder, codec_id); |                 CodecAudioOpen(MyAudioDecoder, codec_id); | ||||||
|                 AudioCodecID = codec_id; |                 AudioCodecID = codec_id; | ||||||
|             } |             } | ||||||
|             av_init_packet(avpkt); |  | ||||||
|             avpkt->data = (void *)p; |             avpkt->data = (void *)p; | ||||||
|             avpkt->size = r; |             avpkt->size = r; | ||||||
|             avpkt->pts = AudioAvPkt->pts; |             avpkt->pts = AudioAvPkt->pts; | ||||||
|             avpkt->dts = AudioAvPkt->dts; |             avpkt->dts = AudioAvPkt->dts; | ||||||
|             // FIXME: not aligned for ffmpeg |             // FIXME: not aligned for ffmpeg | ||||||
|             CodecAudioDecode(MyAudioDecoder, avpkt); |             CodecAudioDecode(MyAudioDecoder, avpkt); | ||||||
|  | #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(58,33,100) | ||||||
|  | 	        av_packet_free(&avpkt); | ||||||
|  | #endif | ||||||
|             AudioAvPkt->pts = AV_NOPTS_VALUE; |             AudioAvPkt->pts = AV_NOPTS_VALUE; | ||||||
|             AudioAvPkt->dts = AV_NOPTS_VALUE; |             AudioAvPkt->dts = AV_NOPTS_VALUE; | ||||||
|             p += r; |             p += r; | ||||||
| @@ -1625,7 +1640,7 @@ static void VideoMpegEnqueue(VideoStream *stream, int64_t pts, int64_t dts, cons | |||||||
| **  @param avpkt    ffmpeg a/v packet | **  @param avpkt    ffmpeg a/v packet | ||||||
| */ | */ | ||||||
|  |  | ||||||
| #ifndef USE_PIP | #if !defined USE_PIP &&  !defined VAAPI | ||||||
| static void FixPacketForFFMpeg(VideoDecoder *vdecoder, AVPacket *avpkt) { | static void FixPacketForFFMpeg(VideoDecoder *vdecoder, AVPacket *avpkt) { | ||||||
|     uint8_t *p; |     uint8_t *p; | ||||||
|     int n; |     int n; | ||||||
| @@ -1993,7 +2008,7 @@ static void StopVideo(void) { | |||||||
| #endif | #endif | ||||||
| } | } | ||||||
|  |  | ||||||
| #ifdef DEBUG | #if 0 | ||||||
|  |  | ||||||
| /** | /** | ||||||
| **  Dump mpeg video packet. | **  Dump mpeg video packet. | ||||||
|   | |||||||
							
								
								
									
										352
									
								
								video.c
									
									
									
									
									
								
							
							
						
						
									
										352
									
								
								video.c
									
									
									
									
									
								
							| @@ -172,6 +172,7 @@ typedef enum { | |||||||
| #if !defined PLACEBO_GL | #if !defined PLACEBO_GL | ||||||
| #include <EGL/egl.h> | #include <EGL/egl.h> | ||||||
| #include <EGL/eglext.h> | #include <EGL/eglext.h> | ||||||
|  |  | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| #ifndef GL_OES_EGL_image | #ifndef GL_OES_EGL_image | ||||||
| @@ -183,6 +184,7 @@ typedef void *EGLImageKHR; | |||||||
|  |  | ||||||
| #ifdef PLACEBO | #ifdef PLACEBO | ||||||
| #ifdef PLACEBO_GL | #ifdef PLACEBO_GL | ||||||
|  | GLenum glewInit(void); | ||||||
| #include <libplacebo/opengl.h> | #include <libplacebo/opengl.h> | ||||||
| #else | #else | ||||||
| #define VK_USE_PLATFORM_XCB_KHR | #define VK_USE_PLATFORM_XCB_KHR | ||||||
| @@ -380,18 +382,12 @@ signed char VideoHardwareDecoder = -1; ///< flag use hardware decoder | |||||||
|  |  | ||||||
| static char VideoSurfaceModesChanged; ///< flag surface modes changed | static char VideoSurfaceModesChanged; ///< flag surface modes changed | ||||||
|  |  | ||||||
| /// flag use transparent OSD. |  | ||||||
| static const char VideoTransparentOsd = 1; |  | ||||||
|  |  | ||||||
| static uint32_t VideoBackground; ///< video background color | static uint32_t VideoBackground; ///< video background color | ||||||
| char VideoStudioLevels;          ///< flag use studio levels | char VideoStudioLevels;          ///< flag use studio levels | ||||||
|  |  | ||||||
| /// Default deinterlace mode. | /// Default deinterlace mode. | ||||||
| static VideoDeinterlaceModes VideoDeinterlace[VideoResolutionMax]; | static VideoDeinterlaceModes VideoDeinterlace[VideoResolutionMax]; | ||||||
|  |  | ||||||
| /// Default number of deinterlace surfaces |  | ||||||
| static const int VideoDeinterlaceSurfaces = 4; |  | ||||||
|  |  | ||||||
| /// Default skip chroma deinterlace flag (CUVID only). | /// Default skip chroma deinterlace flag (CUVID only). | ||||||
| static char VideoSkipChromaDeinterlace[VideoResolutionMax]; | static char VideoSkipChromaDeinterlace[VideoResolutionMax]; | ||||||
|  |  | ||||||
| @@ -430,7 +426,7 @@ static int DRMRefresh = 50; | |||||||
|  |  | ||||||
| static char Video60HzMode;                   ///< handle 60hz displays | static char Video60HzMode;                   ///< handle 60hz displays | ||||||
| static char VideoSoftStartSync;              ///< soft start sync audio/video | static char VideoSoftStartSync;              ///< soft start sync audio/video | ||||||
| static const int VideoSoftStartFrames = 100; ///< soft start frames | //static const int VideoSoftStartFrames = 100; ///< soft start frames | ||||||
| static char VideoShowBlackPicture;           ///< flag show black picture | static char VideoShowBlackPicture;           ///< flag show black picture | ||||||
|  |  | ||||||
| static float VideoBrightness = 0.0f; | static float VideoBrightness = 0.0f; | ||||||
| @@ -442,11 +438,14 @@ static float VideoTemperature = 0.0f; | |||||||
| static int VulkanTargetColorSpace = 0; | static int VulkanTargetColorSpace = 0; | ||||||
| static int VideoScalerTest = 0; | static int VideoScalerTest = 0; | ||||||
| static int VideoColorBlindness = 0; | static int VideoColorBlindness = 0; | ||||||
| static float VideoColorBlindnessFaktor = 1.0f; | static float VideoColorBlindnessFaktor = 1.0; | ||||||
|  |  | ||||||
|  | #ifdef PLACEBO | ||||||
| static char *shadersp[NUM_SHADERS]; | static char *shadersp[NUM_SHADERS]; | ||||||
| char MyConfigDir[200]; | char MyConfigDir[200]; | ||||||
| static int num_shaders = 0; | static int num_shaders = 0; | ||||||
|  | #endif | ||||||
|  |  | ||||||
| static int LUTon = -1; | static int LUTon = -1; | ||||||
|  |  | ||||||
| static xcb_atom_t WmDeleteWindowAtom;   ///< WM delete message atom | static xcb_atom_t WmDeleteWindowAtom;   ///< WM delete message atom | ||||||
| @@ -494,11 +493,11 @@ static char DPMSDisabled;            ///< flag we have disabled dpms | |||||||
| static char EnableDPMSatBlackScreen; ///< flag we should enable dpms at black screen | static char EnableDPMSatBlackScreen; ///< flag we should enable dpms at black screen | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| static unsigned int Count; |  | ||||||
| static int EglEnabled;          ///< use EGL | static int EglEnabled;          ///< use EGL | ||||||
| static int GlxVSyncEnabled = 1; ///< enable/disable v-sync |  | ||||||
|  |  | ||||||
| #ifdef CUVID | #ifdef CUVID | ||||||
|  | static int GlxVSyncEnabled = 1; ///< enable/disable v-sync | ||||||
|  | static unsigned int Count; | ||||||
| static GLXContext glxSharedContext; ///< shared gl context | static GLXContext glxSharedContext; ///< shared gl context | ||||||
| static GLXContext glxContext;       ///< our gl context | static GLXContext glxContext;       ///< our gl context | ||||||
|  |  | ||||||
| @@ -509,11 +508,13 @@ static void GlxSetupWindow(xcb_window_t window, int width, int height, GLXContex | |||||||
| GLXContext OSDcontext; | GLXContext OSDcontext; | ||||||
| #else | #else | ||||||
| static EGLContext eglSharedContext;     ///< shared gl context | static EGLContext eglSharedContext;     ///< shared gl context | ||||||
|  | #ifdef USE_DRM | ||||||
| static EGLContext eglOSDContext = NULL; ///< our gl context for the thread | static EGLContext eglOSDContext = NULL; ///< our gl context for the thread | ||||||
|  | #endif | ||||||
| static EGLContext eglContext;           ///< our gl context | static EGLContext eglContext;           ///< our gl context | ||||||
| static EGLConfig eglConfig; | static EGLConfig eglConfig; | ||||||
| static EGLDisplay eglDisplay; | static EGLDisplay eglDisplay; | ||||||
| static EGLSurface eglSurface, eglOSDSurface; | static EGLSurface eglSurface; | ||||||
| static EGLint eglAttrs[10]; | static EGLint eglAttrs[10]; | ||||||
| static int eglVersion = 2; | static int eglVersion = 2; | ||||||
| static EGLImageKHR(EGLAPIENTRY *CreateImageKHR)(EGLDisplay, EGLContext, EGLenum, EGLClientBuffer, const EGLint *); | static EGLImageKHR(EGLAPIENTRY *CreateImageKHR)(EGLDisplay, EGLContext, EGLenum, EGLClientBuffer, const EGLint *); | ||||||
| @@ -531,9 +532,6 @@ static void GlxSetupWindow(xcb_window_t window, int width, int height, EGLContex | |||||||
| EGLContext OSDcontext; | EGLContext OSDcontext; | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| static GLuint OsdGlTextures[2]; ///< gl texture for OSD |  | ||||||
| static int OsdIndex = 0;        ///< index into OsdGlTextures |  | ||||||
|  |  | ||||||
| //---------------------------------------------------------------------------- | //---------------------------------------------------------------------------- | ||||||
| //  Common Functions | //  Common Functions | ||||||
| //---------------------------------------------------------------------------- | //---------------------------------------------------------------------------- | ||||||
| @@ -630,8 +628,8 @@ static void VideoSetPts(int64_t *pts_p, int interlaced, const AVCodecContext *vi | |||||||
|     // } else { |     // } else { | ||||||
|     duration = interlaced ? 40 : 20; // 50Hz -> 20ms default |     duration = interlaced ? 40 : 20; // 50Hz -> 20ms default | ||||||
|     // } |     // } | ||||||
|     // Debug(4, "video: %d/%d %" PRIx64 " -> %d\n", video_ctx->framerate.den, |     Debug(4, "video: Framerate %d/%d \n", video_ctx->framerate.den, | ||||||
|     // video_ctx->framerate.num, av_frame_get_pkt_duration(frame), duration); |      video_ctx->framerate.num); | ||||||
|  |  | ||||||
|     // update video clock |     // update video clock | ||||||
|     if (*pts_p != (int64_t)AV_NOPTS_VALUE) { |     if (*pts_p != (int64_t)AV_NOPTS_VALUE) { | ||||||
| @@ -793,7 +791,7 @@ video_none: | |||||||
|     return; |     return; | ||||||
| } | } | ||||||
|  |  | ||||||
| static uint64_t test_time = 0; | //static uint64_t test_time = 0; | ||||||
|  |  | ||||||
| /// | /// | ||||||
| /// Lock video thread. | /// Lock video thread. | ||||||
| @@ -871,18 +869,7 @@ static uint64_t test_time = 0; | |||||||
|  |  | ||||||
| #ifdef USE_GLX | #ifdef USE_GLX | ||||||
|  |  | ||||||
| /// |  | ||||||
| /// GLX extension functions |  | ||||||
| ///@{ |  | ||||||
| #ifdef GLX_MESA_swap_control |  | ||||||
| static PFNGLXSWAPINTERVALMESAPROC GlxSwapIntervalMESA; |  | ||||||
| #endif |  | ||||||
| #ifdef GLX_SGI_video_sync |  | ||||||
| static PFNGLXGETVIDEOSYNCSGIPROC GlxGetVideoSyncSGI; |  | ||||||
| #endif |  | ||||||
| #ifdef GLX_SGI_swap_control |  | ||||||
| static PFNGLXSWAPINTERVALSGIPROC GlxSwapIntervalSGI; |  | ||||||
| #endif |  | ||||||
|  |  | ||||||
| /// | /// | ||||||
| /// GLX check error. | /// GLX check error. | ||||||
| @@ -896,6 +883,21 @@ static PFNGLXSWAPINTERVALSGIPROC GlxSwapIntervalSGI; | |||||||
|         }                                                                                                             \ |         }                                                                                                             \ | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |  | ||||||
|  | #ifdef CUVID | ||||||
|  | /// | ||||||
|  | /// GLX extension functions | ||||||
|  | ///@{ | ||||||
|  | #ifdef GLX_MESA_swap_control | ||||||
|  | static PFNGLXSWAPINTERVALMESAPROC GlxSwapIntervalMESA; | ||||||
|  | #endif | ||||||
|  | #ifdef GLX_SGI_video_sync | ||||||
|  | static PFNGLXGETVIDEOSYNCSGIPROC GlxGetVideoSyncSGI; | ||||||
|  | #endif | ||||||
|  | #ifdef GLX_SGI_swap_control | ||||||
|  | static PFNGLXSWAPINTERVALSGIPROC GlxSwapIntervalSGI; | ||||||
|  | #endif | ||||||
|  |  | ||||||
| /// | /// | ||||||
| /// GLX check if a GLX extension is supported. | /// GLX check if a GLX extension is supported. | ||||||
| /// | /// | ||||||
| @@ -915,6 +917,7 @@ static int GlxIsExtensionSupported(const char *ext) { | |||||||
|     } |     } | ||||||
|     return 0; |     return 0; | ||||||
| } | } | ||||||
|  | #endif | ||||||
|  |  | ||||||
| /// | /// | ||||||
| /// Setup GLX window. | /// Setup GLX window. | ||||||
| @@ -930,11 +933,12 @@ static void GlxSetupWindow(xcb_window_t window, int width, int height, GLXContex | |||||||
| static void GlxSetupWindow(xcb_window_t window, int width, int height, EGLContext context) | static void GlxSetupWindow(xcb_window_t window, int width, int height, EGLContext context) | ||||||
| #endif | #endif | ||||||
| { | { | ||||||
|  | #ifdef CUVID | ||||||
|     uint32_t start; |     uint32_t start; | ||||||
|     uint32_t end; |     uint32_t end; | ||||||
|     int i; |     int i; | ||||||
|     unsigned count; |     unsigned count; | ||||||
|  | #endif | ||||||
|  |  | ||||||
| #ifdef PLACEBO_ | #ifdef PLACEBO_ | ||||||
|     return; |     return; | ||||||
| @@ -1170,6 +1174,7 @@ static void EglInit(void) { | |||||||
| } | } | ||||||
|  |  | ||||||
| #else // VAAPI | #else // VAAPI | ||||||
|  | extern void make_egl(void); | ||||||
| static void EglInit(void) { | static void EglInit(void) { | ||||||
|     int redSize, greenSize, blueSize, alphaSize; |     int redSize, greenSize, blueSize, alphaSize; | ||||||
|     static int glewdone = 0; |     static int glewdone = 0; | ||||||
| @@ -1185,7 +1190,8 @@ static void EglInit(void) { | |||||||
|     make_egl(); |     make_egl(); | ||||||
|  |  | ||||||
|     if (!glewdone) { |     if (!glewdone) { | ||||||
|         GLenum err = glewInit(); |         //GLenum err = glewInit(); | ||||||
|  |         glewInit(); | ||||||
|  |  | ||||||
|         glewdone = 1; |         glewdone = 1; | ||||||
|         //	  if (err != GLEW_OK) { |         //	  if (err != GLEW_OK) { | ||||||
| @@ -1246,14 +1252,22 @@ static void EglExit(void) { | |||||||
|         glxSharedContext = NULL; |         glxSharedContext = NULL; | ||||||
|     } |     } | ||||||
| #else | #else | ||||||
|     if (eglGetCurrentContext() == eglContext) { | #ifdef USE_DRM | ||||||
|         // if currently used, set to none |     drm_clean_up(); | ||||||
|         eglMakeCurrent(eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); |  | ||||||
|  | #endif | ||||||
|  |      | ||||||
|  |     eglMakeCurrent(eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); | ||||||
|  |  | ||||||
|  |     if (eglSurface) { | ||||||
|  |         eglDestroySurface(eglDisplay, eglSurface); | ||||||
|  |         EglCheck(); | ||||||
|  |         eglSurface = NULL; | ||||||
|     } |     } | ||||||
| #ifndef USE_DRM |  | ||||||
|     if (eglSharedContext) { |     if (eglSharedContext) { | ||||||
|         eglDestroyContext(eglDisplay, eglSharedContext); |         eglDestroyContext(eglDisplay, eglSharedContext); | ||||||
|         EglCheck(); |         EglCheck(); | ||||||
|  |         eglSharedContext = NULL; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     if (eglContext) { |     if (eglContext) { | ||||||
| @@ -1261,13 +1275,8 @@ static void EglExit(void) { | |||||||
|         EglCheck(); |         EglCheck(); | ||||||
|         eglContext = NULL; |         eglContext = NULL; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     eglTerminate(eglDisplay); |     eglTerminate(eglDisplay); | ||||||
| #endif |     eglDisplay = NULL; | ||||||
|  |  | ||||||
| #ifdef USE_DRM |  | ||||||
|     drm_clean_up(); |  | ||||||
| #endif |  | ||||||
|  |  | ||||||
| #endif | #endif | ||||||
| } | } | ||||||
| @@ -1453,11 +1462,11 @@ typedef struct priv { | |||||||
|     const struct pl_vulkan *vk; |     const struct pl_vulkan *vk; | ||||||
|     const struct pl_vk_inst *vk_inst; |     const struct pl_vk_inst *vk_inst; | ||||||
| #endif | #endif | ||||||
|     struct pl_context *ctx; |     const struct pl_log_t *ctx; | ||||||
|     struct pl_custom_lut *lut; |     struct pl_custom_lut *lut; | ||||||
|     struct pl_renderer *renderer; |     struct pl_renderer_t *renderer; | ||||||
|     struct pl_renderer *renderertest; |     struct pl_renderer_t *renderertest; | ||||||
|     const struct pl_swapchain *swapchain; |     const struct pl_swapchain_t *swapchain; | ||||||
|     struct pl_log_params context; |     struct pl_log_params context; | ||||||
| #ifndef PLACEBO_GL | #ifndef PLACEBO_GL | ||||||
|     VkSurfaceKHR pSurface; |     VkSurfaceKHR pSurface; | ||||||
| @@ -1465,7 +1474,7 @@ typedef struct priv { | |||||||
|     int has_dma_buf; |     int has_dma_buf; | ||||||
| #ifdef PLACEBO_GL | #ifdef PLACEBO_GL | ||||||
| #if PL_API_VER >= 229 | #if PL_API_VER >= 229 | ||||||
|     struct pl_opengl_t *gl; |     const struct pl_opengl_t *gl; | ||||||
| #else | #else | ||||||
|     struct pl_opengl *gl; |     struct pl_opengl *gl; | ||||||
| #endif | #endif | ||||||
| @@ -1481,7 +1490,6 @@ static struct pl_overlay osdoverlay; | |||||||
| static struct pl_overlay_part part; | static struct pl_overlay_part part; | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| static int semid; |  | ||||||
| struct itimerval itimer; | struct itimerval itimer; | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| @@ -1813,11 +1821,6 @@ struct mp_egl_config_attr { | |||||||
| #define MP_EGL_ATTRIB(id)                                                                                             \ | #define MP_EGL_ATTRIB(id)                                                                                             \ | ||||||
|     { id, #id } |     { id, #id } | ||||||
|  |  | ||||||
| static const struct mp_egl_config_attr mp_egl_attribs[] = { |  | ||||||
|     MP_EGL_ATTRIB(EGL_CONFIG_ID),     MP_EGL_ATTRIB(EGL_RED_SIZE),   MP_EGL_ATTRIB(EGL_GREEN_SIZE), |  | ||||||
|     MP_EGL_ATTRIB(EGL_BLUE_SIZE),     MP_EGL_ATTRIB(EGL_ALPHA_SIZE), MP_EGL_ATTRIB(EGL_COLOR_BUFFER_TYPE), |  | ||||||
|     MP_EGL_ATTRIB(EGL_CONFIG_CAVEAT), MP_EGL_ATTRIB(EGL_CONFORMANT), |  | ||||||
| }; |  | ||||||
|  |  | ||||||
| const int mpgl_preferred_gl_versions[] = {460, 440, 430, 400, 330, 320, 310, 300, 210, 0}; | const int mpgl_preferred_gl_versions[] = {460, 440, 430, 400, 330, 320, 310, 300, 210, 0}; | ||||||
|  |  | ||||||
| @@ -1949,7 +1952,7 @@ static bool create_context_cb(EGLDisplay display, int es_version, EGLContext *ou | |||||||
|     return true; |     return true; | ||||||
| } | } | ||||||
|  |  | ||||||
| make_egl() { | void make_egl(void) { | ||||||
|     int bpp; |     int bpp; | ||||||
|  |  | ||||||
|     CreateImageKHR = (void *)eglGetProcAddress("eglCreateImageKHR"); |     CreateImageKHR = (void *)eglGetProcAddress("eglCreateImageKHR"); | ||||||
| @@ -1973,7 +1976,7 @@ make_egl() { | |||||||
|     if (!create_context_cb(eglDisplay, 0, &eglContext, &eglConfig, &bpp)) { |     if (!create_context_cb(eglDisplay, 0, &eglContext, &eglConfig, &bpp)) { | ||||||
|         Fatal(_("Could not create EGL Context\n")); |         Fatal(_("Could not create EGL Context\n")); | ||||||
|     } |     } | ||||||
|     int vID, n; |     int vID; | ||||||
|  |  | ||||||
|     eglGetConfigAttrib(eglDisplay, eglConfig, EGL_NATIVE_VISUAL_ID, &vID); |     eglGetConfigAttrib(eglDisplay, eglConfig, EGL_NATIVE_VISUAL_ID, &vID); | ||||||
|     Debug(3, "chose visual 0x%x bpp %d\n", vID, bpp); |     Debug(3, "chose visual 0x%x bpp %d\n", vID, bpp); | ||||||
| @@ -2246,9 +2249,9 @@ void generateCUDAImage(CuvidDecoder *decoder, int index, const AVFrame *frame, i | |||||||
| #ifdef PLACEBO | #ifdef PLACEBO | ||||||
| void createTextureDst(CuvidDecoder *decoder, int anz, unsigned int size_x, unsigned int size_y, | void createTextureDst(CuvidDecoder *decoder, int anz, unsigned int size_x, unsigned int size_y, | ||||||
|                       enum AVPixelFormat PixFmt) { |                       enum AVPixelFormat PixFmt) { | ||||||
|     int n, i, size = 1, fd; |     int n, i;  | ||||||
|     const struct pl_fmt *fmt; |     const struct pl_fmt_t *fmt; | ||||||
|     struct pl_tex *tex; |     //struct pl_tex *tex; | ||||||
|     struct pl_frame *img; |     struct pl_frame *img; | ||||||
|     struct pl_plane *pl; |     struct pl_plane *pl; | ||||||
|  |  | ||||||
| @@ -2267,10 +2270,8 @@ void createTextureDst(CuvidDecoder *decoder, int anz, unsigned int size_x, unsig | |||||||
|  |  | ||||||
|             if (PixFmt == AV_PIX_FMT_NV12) { |             if (PixFmt == AV_PIX_FMT_NV12) { | ||||||
|                 fmt = pl_find_named_fmt(p->gpu, n == 0 ? "r8" : "rg8"); // 8 Bit YUV |                 fmt = pl_find_named_fmt(p->gpu, n == 0 ? "r8" : "rg8"); // 8 Bit YUV | ||||||
|                 size = 1; |  | ||||||
|             } else { |             } else { | ||||||
|                 fmt = pl_find_named_fmt(p->gpu, n == 0 ? "r16" : "rg16"); // 10 Bit YUV |                 fmt = pl_find_named_fmt(p->gpu, n == 0 ? "r16" : "rg16"); // 10 Bit YUV | ||||||
|                 size = 2; |  | ||||||
|             } |             } | ||||||
|             if (decoder->pl_frames[i].planes[n].texture) { |             if (decoder->pl_frames[i].planes[n].texture) { | ||||||
|                 // #ifdef VAAPI |                 // #ifdef VAAPI | ||||||
| @@ -2317,7 +2318,7 @@ void createTextureDst(CuvidDecoder *decoder, int anz, unsigned int size_x, unsig | |||||||
|                 Fatal(_("Unable to create placebo textures")); |                 Fatal(_("Unable to create placebo textures")); | ||||||
|             } |             } | ||||||
| #ifdef CUVID | #ifdef CUVID | ||||||
|             fd = dup(decoder->pl_frames[i].planes[n].texture->shared_mem.handle.fd); |             int fd = dup(decoder->pl_frames[i].planes[n].texture->shared_mem.handle.fd); | ||||||
|             CUDA_EXTERNAL_MEMORY_HANDLE_DESC ext_desc = { |             CUDA_EXTERNAL_MEMORY_HANDLE_DESC ext_desc = { | ||||||
|                 .type = CU_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD, |                 .type = CU_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD, | ||||||
|                 .handle.fd = fd, |                 .handle.fd = fd, | ||||||
| @@ -2369,10 +2370,8 @@ void createTextureDst(CuvidDecoder *decoder, int anz, unsigned int size_x, unsig | |||||||
| void generateVAAPIImage(CuvidDecoder *decoder, int index, const AVFrame *frame, int image_width, int image_height) { | void generateVAAPIImage(CuvidDecoder *decoder, int index, const AVFrame *frame, int image_width, int image_height) { | ||||||
|     int n; |     int n; | ||||||
|     VAStatus status; |     VAStatus status; | ||||||
|     int toggle = 0; |  | ||||||
|     uint64_t first_time; |  | ||||||
|     VADRMPRIMESurfaceDescriptor desc; |     VADRMPRIMESurfaceDescriptor desc; | ||||||
|  |      | ||||||
|     vaSyncSurface(decoder->VaDisplay, (unsigned int)frame->data[3]); |     vaSyncSurface(decoder->VaDisplay, (unsigned int)frame->data[3]); | ||||||
|     status = |     status = | ||||||
|         vaExportSurfaceHandle(decoder->VaDisplay, (unsigned int)frame->data[3], VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME_2, |         vaExportSurfaceHandle(decoder->VaDisplay, (unsigned int)frame->data[3], VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME_2, | ||||||
| @@ -2391,11 +2390,8 @@ void generateVAAPIImage(CuvidDecoder *decoder, int index, const AVFrame *frame, | |||||||
|         int fd = desc.objects[id].fd; |         int fd = desc.objects[id].fd; | ||||||
|         uint32_t size = desc.objects[id].size; |         uint32_t size = desc.objects[id].size; | ||||||
|         uint32_t offset = desc.layers[n].offset[0]; |         uint32_t offset = desc.layers[n].offset[0]; | ||||||
| #if PL_API_VER < 229 |  | ||||||
|         struct pl_fmt *fmt; |  | ||||||
| #else |  | ||||||
|         struct pl_fmt_t *fmt; |         struct pl_fmt_t *fmt; | ||||||
| #endif |  | ||||||
|  |  | ||||||
|         if (fd == -1) { |         if (fd == -1) { | ||||||
|             printf("Fehler beim Import von Surface %d\n", index); |             printf("Fehler beim Import von Surface %d\n", index); | ||||||
| @@ -2406,15 +2402,14 @@ void generateVAAPIImage(CuvidDecoder *decoder, int index, const AVFrame *frame, | |||||||
|             size = n == 0 ? desc.width * desc.height : desc.width * desc.height / 2; |             size = n == 0 ? desc.width * desc.height : desc.width * desc.height / 2; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         //	fmt = pl_find_fourcc(p->gpu,desc.layers[n].drm_format); |         //	fmt = pl_find_fourcc(p->gpu,desc.lsayers[n].drm_format); | ||||||
| #if 1 |  | ||||||
|         if (decoder->PixFmt == AV_PIX_FMT_NV12) { |         if (decoder->PixFmt == AV_PIX_FMT_NV12) { | ||||||
|             fmt = pl_find_named_fmt(p->gpu, n == 0 ? "r8" : "rg8"); // 8 Bit YUV |             fmt = pl_find_named_fmt(p->gpu, n == 0 ? "r8" : "rg8"); // 8 Bit YUV | ||||||
|         } else { |         } else { | ||||||
|             fmt = pl_find_fourcc(p->gpu, |             fmt = pl_find_fourcc(p->gpu, | ||||||
|                                  n == 0 ? 0x20363152 : 0x32335247); // 10 Bit YUV |                                  n == 0 ? 0x20363152 : 0x32335247); // 10 Bit YUV | ||||||
|         } |         } | ||||||
| #endif |  | ||||||
|  |  | ||||||
|         assert(fmt != NULL); |         assert(fmt != NULL); | ||||||
| #ifdef PLACEBO_GL | #ifdef PLACEBO_GL | ||||||
| @@ -2567,8 +2562,6 @@ void generateVAAPIImage(CuvidDecoder *decoder, VASurfaceID index, const AVFrame | |||||||
|                         int image_height) { |                         int image_height) { | ||||||
|     VAStatus status; |     VAStatus status; | ||||||
|  |  | ||||||
|     uint64_t first_time; |  | ||||||
|  |  | ||||||
| #if defined(VAAPI) | #if defined(VAAPI) | ||||||
|     VADRMPRIMESurfaceDescriptor desc; |     VADRMPRIMESurfaceDescriptor desc; | ||||||
|  |  | ||||||
| @@ -2837,7 +2830,7 @@ static int init_generic_hwaccel(CuvidDecoder *decoder, enum AVPixelFormat hw_fmt | |||||||
|     if (decoder->cached_hw_frames_ctx) { |     if (decoder->cached_hw_frames_ctx) { | ||||||
|         AVHWFramesContext *old_fctx = (void *)decoder->cached_hw_frames_ctx->data; |         AVHWFramesContext *old_fctx = (void *)decoder->cached_hw_frames_ctx->data; | ||||||
|  |  | ||||||
|         Debug(3, "CMP %d:%d %d:%d %d:%d %d:%d %d:%d\,", new_fctx->format, old_fctx->format, new_fctx->sw_format, |         Debug(3, "CMP %d:%d %d:%d %d:%d %d:%d %d:%d\n,", new_fctx->format, old_fctx->format, new_fctx->sw_format, | ||||||
|               old_fctx->sw_format, new_fctx->width, old_fctx->width, new_fctx->height, old_fctx->height, |               old_fctx->sw_format, new_fctx->width, old_fctx->width, new_fctx->height, old_fctx->height, | ||||||
|               new_fctx->initial_pool_size, old_fctx->initial_pool_size); |               new_fctx->initial_pool_size, old_fctx->initial_pool_size); | ||||||
|         if (new_fctx->format != old_fctx->format || new_fctx->sw_format != old_fctx->sw_format || |         if (new_fctx->format != old_fctx->format || new_fctx->sw_format != old_fctx->sw_format || | ||||||
| @@ -2886,7 +2879,7 @@ error: | |||||||
| static enum AVPixelFormat Cuvid_get_format(CuvidDecoder *decoder, AVCodecContext *video_ctx, | static enum AVPixelFormat Cuvid_get_format(CuvidDecoder *decoder, AVCodecContext *video_ctx, | ||||||
|                                            const enum AVPixelFormat *fmt) { |                                            const enum AVPixelFormat *fmt) { | ||||||
|     const enum AVPixelFormat *fmt_idx; |     const enum AVPixelFormat *fmt_idx; | ||||||
|     int bitformat16 = 0, deint = 0; |     int bitformat16 = 0; | ||||||
|  |  | ||||||
|     VideoDecoder *ist = video_ctx->opaque; |     VideoDecoder *ist = video_ctx->opaque; | ||||||
|  |  | ||||||
| @@ -2983,6 +2976,7 @@ static enum AVPixelFormat Cuvid_get_format(CuvidDecoder *decoder, AVCodecContext | |||||||
|         } |         } | ||||||
|  |  | ||||||
| #if defined YADIF && defined CUVID | #if defined YADIF && defined CUVID | ||||||
|  |         int deint; | ||||||
|         if (VideoDeinterlace[decoder->Resolution] == VideoDeinterlaceYadif) { |         if (VideoDeinterlace[decoder->Resolution] == VideoDeinterlaceYadif) { | ||||||
|             deint = 0; |             deint = 0; | ||||||
|             ist->filter = 1; // init yadif_cuda |             ist->filter = 1; // init yadif_cuda | ||||||
| @@ -3001,10 +2995,15 @@ static enum AVPixelFormat Cuvid_get_format(CuvidDecoder *decoder, AVCodecContext | |||||||
| #ifdef CUVID | #ifdef CUVID | ||||||
|         ist->active_hwaccel_id = HWACCEL_CUVID; |         ist->active_hwaccel_id = HWACCEL_CUVID; | ||||||
| #else | #else | ||||||
|         if (VideoDeinterlace[decoder->Resolution]) // need deinterlace |         if (video_ctx->codec_id == AV_CODEC_ID_HEVC) { | ||||||
|             ist->filter = 1;                       // init deint vaapi |  | ||||||
|         else |  | ||||||
|             ist->filter = 0; |             ist->filter = 0; | ||||||
|  |         } | ||||||
|  |         else if (VideoDeinterlace[decoder->Resolution]) {// need deinterlace | ||||||
|  |             ist->filter = 1;                       // init deint vaapi | ||||||
|  |         } | ||||||
|  |         else { | ||||||
|  |             ist->filter = 0; | ||||||
|  |         } | ||||||
|  |  | ||||||
|         ist->active_hwaccel_id = HWACCEL_VAAPI; |         ist->active_hwaccel_id = HWACCEL_VAAPI; | ||||||
| #endif | #endif | ||||||
| @@ -3032,18 +3031,18 @@ int get_RGB(CuvidDecoder *decoder) { | |||||||
| #ifdef PLACEBO | #ifdef PLACEBO | ||||||
|     struct pl_render_params render_params = pl_render_default_params; |     struct pl_render_params render_params = pl_render_default_params; | ||||||
|     struct pl_frame target = {0}; |     struct pl_frame target = {0}; | ||||||
|     const struct pl_fmt *fmt; |     const struct pl_fmt_t *fmt; | ||||||
|  |  | ||||||
|     int offset, x1, y1, x0, y0; |     int  x1=0, y1=0, x0=0, y0=0; | ||||||
|     float faktorx, faktory; |     float faktorx, faktory; | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|     uint8_t *base; |     uint8_t *base; | ||||||
|     int width; |     int width; | ||||||
|     int height; |     int height; | ||||||
|     GLuint fb, texture; |      | ||||||
|     int current; |     int current; | ||||||
|     GLint texLoc; |      | ||||||
|  |  | ||||||
|     base = decoder->grabbase; |     base = decoder->grabbase; | ||||||
|     width = decoder->grabwidth; |     width = decoder->grabwidth; | ||||||
| @@ -3052,7 +3051,8 @@ int get_RGB(CuvidDecoder *decoder) { | |||||||
|     current = decoder->SurfacesRb[decoder->SurfaceRead]; |     current = decoder->SurfacesRb[decoder->SurfaceRead]; | ||||||
|  |  | ||||||
| #ifndef PLACEBO | #ifndef PLACEBO | ||||||
|  |     GLint texLoc; | ||||||
|  |     GLuint fb, texture; | ||||||
|     glGenTextures(1, &texture); |     glGenTextures(1, &texture); | ||||||
|     GlxCheck(); |     GlxCheck(); | ||||||
|     glBindTexture(GL_TEXTURE_2D, texture); |     glBindTexture(GL_TEXTURE_2D, texture); | ||||||
| @@ -3491,7 +3491,6 @@ extern void cudaLaunchNV12toARGBDrv(uint32_t * d_srcNV12, size_t nSourcePitch, u | |||||||
| /// @param frame    frame to display | /// @param frame    frame to display | ||||||
| /// | /// | ||||||
| static void CuvidRenderFrame(CuvidDecoder *decoder, const AVCodecContext *video_ctx, AVFrame *frame) { | static void CuvidRenderFrame(CuvidDecoder *decoder, const AVCodecContext *video_ctx, AVFrame *frame) { | ||||||
|     uint64_t first_time; |  | ||||||
|     int surface; |     int surface; | ||||||
|     enum AVColorSpace color; |     enum AVColorSpace color; | ||||||
|  |  | ||||||
| @@ -3519,33 +3518,40 @@ static void CuvidRenderFrame(CuvidDecoder *decoder, const AVCodecContext *video_ | |||||||
|  |  | ||||||
|     // Fix libav colorspace failure |     // Fix libav colorspace failure | ||||||
|     color = frame->colorspace; |     color = frame->colorspace; | ||||||
|     if (color == AVCOL_SPC_UNSPECIFIED) // failure with RTL HD and all SD channels |     if (color == AVCOL_SPC_UNSPECIFIED) { // failure with RTL HD and all SD channels | ||||||
|                                         // with vaapi |                                         // with vaapi | ||||||
|         if (frame->width > 720) |         if (frame->width > 720) { | ||||||
|             color = AVCOL_SPC_BT709; |             color = AVCOL_SPC_BT709; | ||||||
|         else |         } else { | ||||||
|             color = AVCOL_SPC_BT470BG; |             color = AVCOL_SPC_BT470BG; | ||||||
|     if (color == AVCOL_SPC_RGB) // Cuvid decoder failure with SD channels |         } | ||||||
|  |     } | ||||||
|  |     if (color == AVCOL_SPC_RGB) { // Cuvid decoder failure with SD channels | ||||||
|         color = AVCOL_SPC_BT470BG; |         color = AVCOL_SPC_BT470BG; | ||||||
|  |     } | ||||||
|     frame->colorspace = color; |     frame->colorspace = color; | ||||||
|  |  | ||||||
|     // Fix libav Color primaries failures |     // Fix libav Color primaries failures | ||||||
|     if (frame->color_primaries == AVCOL_PRI_UNSPECIFIED) // failure with RTL HD and all SD channels with |     if (frame->color_primaries == AVCOL_PRI_UNSPECIFIED) { // failure with RTL HD and all SD channels with | ||||||
|                                                          // vaapi |                                                          // vaapi | ||||||
|         if (frame->width > 720) |         if (frame->width > 720) { | ||||||
|             frame->color_primaries = AVCOL_PRI_BT709; |             frame->color_primaries = AVCOL_PRI_BT709; | ||||||
|         else |         } else { | ||||||
|             frame->color_primaries = AVCOL_PRI_BT470BG; |             frame->color_primaries = AVCOL_PRI_BT470BG; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|     if (frame->color_primaries == AVCOL_PRI_RESERVED0) // cuvid decoder failure with SD channels |     if (frame->color_primaries == AVCOL_PRI_RESERVED0) // cuvid decoder failure with SD channels | ||||||
|         frame->color_primaries = AVCOL_PRI_BT470BG; |         frame->color_primaries = AVCOL_PRI_BT470BG; | ||||||
|  |  | ||||||
|     // Fix libav Color TRC failures |     // Fix libav Color TRC failures | ||||||
|     if (frame->color_trc == AVCOL_TRC_UNSPECIFIED) // failure with RTL HD and all |     if (frame->color_trc == AVCOL_TRC_UNSPECIFIED) { // failure with RTL HD and all | ||||||
|                                                    // SD channels with vaapi |                                                    // SD channels with vaapi | ||||||
|         if (frame->width > 720) |         if (frame->width > 720) { | ||||||
|             frame->color_trc = AVCOL_TRC_BT709; |             frame->color_trc = AVCOL_TRC_BT709; | ||||||
|         else |         } else { | ||||||
|             frame->color_trc = AVCOL_TRC_SMPTE170M; |             frame->color_trc = AVCOL_TRC_SMPTE170M; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|     if (frame->color_trc == AVCOL_TRC_RESERVED0) // cuvid decoder failure with SD channels |     if (frame->color_trc == AVCOL_TRC_RESERVED0) // cuvid decoder failure with SD channels | ||||||
|         frame->color_trc = AVCOL_TRC_SMPTE170M; |         frame->color_trc = AVCOL_TRC_SMPTE170M; | ||||||
|  |  | ||||||
| @@ -3640,10 +3646,10 @@ static void CuvidRenderFrame(CuvidDecoder *decoder, const AVCodecContext *video_ | |||||||
| /// @param decoder  CUVID hw decoder | /// @param decoder  CUVID hw decoder | ||||||
| /// | /// | ||||||
| static void *CuvidGetHwAccelContext(CuvidDecoder *decoder) { | static void *CuvidGetHwAccelContext(CuvidDecoder *decoder) { | ||||||
|     unsigned int version, ret; |      | ||||||
|  |     (void)decoder; | ||||||
|     Debug(3, "Initializing cuvid hwaccel thread ID:%ld\n", (long int)syscall(186)); |     Debug(3, "Initializing cuvid hwaccel thread ID:%ld\n", (long int)syscall(186)); | ||||||
|     // turn NULL; |      | ||||||
| #ifdef CUVID | #ifdef CUVID | ||||||
|     if (decoder->cuda_ctx) { |     if (decoder->cuda_ctx) { | ||||||
|         Debug(3, "schon passiert\n"); |         Debug(3, "schon passiert\n"); | ||||||
| @@ -3651,7 +3657,7 @@ static void *CuvidGetHwAccelContext(CuvidDecoder *decoder) { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     if (!cu) { |     if (!cu) { | ||||||
|         ret = cuda_load_functions(&cu, NULL); |         int ret = cuda_load_functions(&cu, NULL); | ||||||
|         if (ret < 0) { |         if (ret < 0) { | ||||||
|             Error(_("Could not dynamically load CUDA\n")); |             Error(_("Could not dynamically load CUDA\n")); | ||||||
|             return 0; |             return 0; | ||||||
| @@ -3663,7 +3669,7 @@ static void *CuvidGetHwAccelContext(CuvidDecoder *decoder) { | |||||||
|  |  | ||||||
|     if (decoder->cuda_ctx == NULL) |     if (decoder->cuda_ctx == NULL) | ||||||
|         Fatal(_("Kein Cuda device gefunden")); |         Fatal(_("Kein Cuda device gefunden")); | ||||||
|  | //    unsigned int version; | ||||||
| //    cu->cuCtxGetApiVersion(decoder->cuda_ctx, &version); | //    cu->cuCtxGetApiVersion(decoder->cuda_ctx, &version); | ||||||
| //    Debug(3, "***********CUDA API Version %d\n", version); | //    Debug(3, "***********CUDA API Version %d\n", version); | ||||||
| #endif | #endif | ||||||
| @@ -3722,7 +3728,7 @@ static void CuvidAdvanceDecoderFrame(CuvidDecoder *decoder) { | |||||||
| #if defined PLACEBO && PL_API_VER >= 58 | #if defined PLACEBO && PL_API_VER >= 58 | ||||||
|  |  | ||||||
| static const struct pl_hook *parse_user_shader(char *shader) { | static const struct pl_hook *parse_user_shader(char *shader) { | ||||||
|     char tmp[200]; |     char tmp[400]; | ||||||
|  |  | ||||||
|     if (!shader) |     if (!shader) | ||||||
|         return NULL; |         return NULL; | ||||||
| @@ -3785,26 +3791,23 @@ static void CuvidMixVideo(CuvidDecoder *decoder, __attribute__((unused)) int lev | |||||||
|     struct pl_deband_params deband; |     struct pl_deband_params deband; | ||||||
|     struct pl_color_adjustment colors; |     struct pl_color_adjustment colors; | ||||||
|     struct pl_cone_params cone; |     struct pl_cone_params cone; | ||||||
|     struct pl_tex_vk *vkp; |     //struct pl_tex_vk *vkp; | ||||||
|     struct pl_plane *pl; |     struct pl_plane *pl; | ||||||
|     struct pl_tex *tex0, *tex1; |     //struct pl_tex *tex0, *tex1; | ||||||
|  |  | ||||||
|     struct pl_frame *img; |     struct pl_frame *img; | ||||||
|     bool ok; |     //bool ok; | ||||||
|     VdpRect video_src_rect; |     VdpRect video_src_rect; | ||||||
|     VdpRect dst_rect; |     //VdpRect dst_rect; | ||||||
|     VdpRect dst_video_rect; |     VdpRect dst_video_rect; | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|     int current; |     int current; | ||||||
|     int y; |  | ||||||
|     float xcropf, ycropf; |  | ||||||
|     GLint texLoc; |  | ||||||
|     AVFrame *frame; |  | ||||||
|     AVFrameSideData *sd, *sd1 = NULL, *sd2 = NULL; |  | ||||||
|  |  | ||||||
| #ifdef PLACEBO | #ifdef PLACEBO | ||||||
|  |      | ||||||
|  |   | ||||||
|  | #if 0 | ||||||
|     if (level) { |     if (level) { | ||||||
|         dst_rect.x0 = decoder->VideoX; // video window output (clip) |         dst_rect.x0 = decoder->VideoX; // video window output (clip) | ||||||
|         dst_rect.y0 = decoder->VideoY; |         dst_rect.y0 = decoder->VideoY; | ||||||
| @@ -3816,7 +3819,7 @@ static void CuvidMixVideo(CuvidDecoder *decoder, __attribute__((unused)) int lev | |||||||
|         dst_rect.x1 = VideoWindowWidth; |         dst_rect.x1 = VideoWindowWidth; | ||||||
|         dst_rect.y1 = VideoWindowHeight; |         dst_rect.y1 = VideoWindowHeight; | ||||||
|     } |     } | ||||||
|  | #endif | ||||||
|     video_src_rect.x0 = decoder->CropX; // video source (crop) |     video_src_rect.x0 = decoder->CropX; // video source (crop) | ||||||
|     video_src_rect.y0 = decoder->CropY; |     video_src_rect.y0 = decoder->CropY; | ||||||
|     video_src_rect.x1 = decoder->CropX + decoder->CropWidth; |     video_src_rect.x1 = decoder->CropX + decoder->CropWidth; | ||||||
| @@ -3828,12 +3831,13 @@ static void CuvidMixVideo(CuvidDecoder *decoder, __attribute__((unused)) int lev | |||||||
|     dst_video_rect.y1 = decoder->OutputY + decoder->OutputHeight; |     dst_video_rect.y1 = decoder->OutputY + decoder->OutputHeight; | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|     xcropf = (float)decoder->CropX / (float)decoder->InputWidth; |     | ||||||
|     ycropf = (float)decoder->CropY / (float)decoder->InputHeight; |  | ||||||
|  |  | ||||||
|     current = decoder->SurfacesRb[decoder->SurfaceRead]; |     current = decoder->SurfacesRb[decoder->SurfaceRead]; | ||||||
|  |  | ||||||
| #ifdef USE_DRM | #ifdef USE_DRM | ||||||
|  |      | ||||||
|  |     AVFrameSideData *sd, *sd1 = NULL, *sd2 = NULL; | ||||||
|     if (!decoder->Closing) { |     if (!decoder->Closing) { | ||||||
|         frame = decoder->frames[current]; |         frame = decoder->frames[current]; | ||||||
|         sd1 = av_frame_get_side_data(frame, AV_FRAME_DATA_MASTERING_DISPLAY_METADATA); |         sd1 = av_frame_get_side_data(frame, AV_FRAME_DATA_MASTERING_DISPLAY_METADATA); | ||||||
| @@ -3845,6 +3849,14 @@ static void CuvidMixVideo(CuvidDecoder *decoder, __attribute__((unused)) int lev | |||||||
|  |  | ||||||
|     // Render Progressive frame |     // Render Progressive frame | ||||||
| #ifndef PLACEBO | #ifndef PLACEBO | ||||||
|  |      | ||||||
|  |     GLint texLoc; | ||||||
|  |     int y;  | ||||||
|  |     float xcropf, ycropf; | ||||||
|  |  | ||||||
|  |     xcropf = (float)decoder->CropX / (float)decoder->InputWidth; | ||||||
|  |     ycropf = (float)decoder->CropY / (float)decoder->InputHeight; | ||||||
|  |  | ||||||
|     y = VideoWindowHeight - decoder->OutputY - decoder->OutputHeight; |     y = VideoWindowHeight - decoder->OutputY - decoder->OutputHeight; | ||||||
|     if (y < 0) |     if (y < 0) | ||||||
|         y = 0; |         y = 0; | ||||||
| @@ -3883,8 +3895,7 @@ static void CuvidMixVideo(CuvidDecoder *decoder, __attribute__((unused)) int lev | |||||||
|     else |     else | ||||||
|         render_params.lut = NULL; |         render_params.lut = NULL; | ||||||
|          |          | ||||||
|     frame = decoder->frames[current]; |     | ||||||
|  |  | ||||||
|     // Fix Color Parameters |     // Fix Color Parameters | ||||||
|  |  | ||||||
|     switch (decoder->ColorSpace) { |     switch (decoder->ColorSpace) { | ||||||
| @@ -3967,6 +3978,9 @@ static void CuvidMixVideo(CuvidDecoder *decoder, __attribute__((unused)) int lev | |||||||
|     // target.repr.bits.bit_shift =0; |     // target.repr.bits.bit_shift =0; | ||||||
|  |  | ||||||
| #if USE_DRM | #if USE_DRM | ||||||
|  |     AVFrame *frame; | ||||||
|  |     frame = decoder->frames[current]; | ||||||
|  |  | ||||||
|     switch (VulkanTargetColorSpace) { |     switch (VulkanTargetColorSpace) { | ||||||
|         case 0: // Monitor |         case 0: // Monitor | ||||||
|             memcpy(&target->color, &pl_color_space_monitor, sizeof(struct pl_color_space)); |             memcpy(&target->color, &pl_color_space_monitor, sizeof(struct pl_color_space)); | ||||||
| @@ -4095,7 +4109,11 @@ static void CuvidMixVideo(CuvidDecoder *decoder, __attribute__((unused)) int lev | |||||||
|     render_params.downscaler = pl_filter_presets[VideoScaling[decoder->Resolution]].filter; |     render_params.downscaler = pl_filter_presets[VideoScaling[decoder->Resolution]].filter; | ||||||
|  |  | ||||||
|     if (level) |     if (level) | ||||||
|  | #if PL_API_VER < 346 | ||||||
|         render_params.skip_target_clearing = 1; |         render_params.skip_target_clearing = 1; | ||||||
|  | #else | ||||||
|  |         render_params.border = PL_CLEAR_SKIP; | ||||||
|  | #endif | ||||||
|  |  | ||||||
|     render_params.color_adjustment = &colors; |     render_params.color_adjustment = &colors; | ||||||
|  |  | ||||||
| @@ -4191,7 +4209,11 @@ static void CuvidMixVideo(CuvidDecoder *decoder, __attribute__((unused)) int lev | |||||||
|  |  | ||||||
|         //	render_params.lut = NULL; |         //	render_params.lut = NULL; | ||||||
|         render_params.num_hooks = 0; |         render_params.num_hooks = 0; | ||||||
|  | #if PL_API_VER < 346 | ||||||
|         render_params.skip_target_clearing = 1; |         render_params.skip_target_clearing = 1; | ||||||
|  | #else | ||||||
|  |         render_params.border = PL_CLEAR_SKIP; | ||||||
|  | #endif | ||||||
|  |  | ||||||
|         if (!p->renderertest) |         if (!p->renderertest) | ||||||
|             p->renderertest = pl_renderer_create(p->ctx, p->gpu); |             p->renderertest = pl_renderer_create(p->ctx, p->gpu); | ||||||
| @@ -4204,7 +4226,7 @@ static void CuvidMixVideo(CuvidDecoder *decoder, __attribute__((unused)) int lev | |||||||
|         p->renderertest = NULL; |         p->renderertest = NULL; | ||||||
|     } |     } | ||||||
| #endif | #endif | ||||||
|     Debug(4, "video/cuvid: yy video surface %p displayed\n", current, decoder->SurfaceRead); |      | ||||||
| } | } | ||||||
|  |  | ||||||
| #ifdef PLACEBO | #ifdef PLACEBO | ||||||
| @@ -4212,7 +4234,7 @@ void make_osd_overlay(int x, int y, int width, int height) { | |||||||
|     const struct pl_fmt *fmt; |     const struct pl_fmt *fmt; | ||||||
|     struct pl_overlay *pl; |     struct pl_overlay *pl; | ||||||
|  |  | ||||||
|     int offset = VideoWindowHeight - (VideoWindowHeight - height - y) - (VideoWindowHeight - y); |      | ||||||
|  |  | ||||||
|     fmt = pl_find_named_fmt(p->gpu, "rgba8"); // 8 Bit RGB |     fmt = pl_find_named_fmt(p->gpu, "rgba8"); // 8 Bit RGB | ||||||
|  |  | ||||||
| @@ -4277,7 +4299,7 @@ void make_osd_overlay(int x, int y, int width, int height) { | |||||||
|     pl->rect.x1 = x + width; |     pl->rect.x1 = x + width; | ||||||
|     pl->rect.y0 = VideoWindowHeight - height - y; |     pl->rect.y0 = VideoWindowHeight - height - y; | ||||||
| #else | #else | ||||||
|  |     int offset = VideoWindowHeight - (VideoWindowHeight - height - y) - (VideoWindowHeight - y); | ||||||
|     pl->rect.x0 = x; |     pl->rect.x0 = x; | ||||||
|     pl->rect.y0 = VideoWindowHeight - y + offset; // Boden von oben |     pl->rect.y0 = VideoWindowHeight - y + offset; // Boden von oben | ||||||
|     pl->rect.x1 = x + width; |     pl->rect.x1 = x + width; | ||||||
| @@ -4292,6 +4314,7 @@ void make_osd_overlay(int x, int y, int width, int height) { | |||||||
|     part.dst.x1 = x + width; |     part.dst.x1 = x + width; | ||||||
|     part.dst.y0 = VideoWindowHeight - height - y; |     part.dst.y0 = VideoWindowHeight - height - y; | ||||||
| #else | #else | ||||||
|  |     int offset = VideoWindowHeight - (VideoWindowHeight - height - y) - (VideoWindowHeight - y); | ||||||
|     part.dst.x0 = x; |     part.dst.x0 = x; | ||||||
|     part.dst.y0 = VideoWindowHeight - y + offset; // Boden von oben |     part.dst.y0 = VideoWindowHeight - y + offset; // Boden von oben | ||||||
|     part.dst.x1 = x + width; |     part.dst.x1 = x + width; | ||||||
| @@ -4306,30 +4329,33 @@ void make_osd_overlay(int x, int y, int width, int height) { | |||||||
|  |  | ||||||
| static void CuvidDisplayFrame(void) { | static void CuvidDisplayFrame(void) { | ||||||
|  |  | ||||||
|     static uint64_t first_time = 0, round_time = 0; |      | ||||||
|     static uint64_t last_time = 0; |      | ||||||
|     int i; |     int i; | ||||||
|  |  | ||||||
|  | #if defined PLACEBO_GL || defined CUVID | ||||||
|  |     static uint64_t round_time = 0; | ||||||
|  |     //static uint64_t first_time = 0; | ||||||
|  | #endif | ||||||
|  |  | ||||||
|     int filled; |     int filled; | ||||||
|     CuvidDecoder *decoder; |     CuvidDecoder *decoder; | ||||||
|     int RTS_flag; |      | ||||||
|     int valid_frame = 0; |  | ||||||
|     float ldiff; |  | ||||||
|     float turnaround; |  | ||||||
|  |  | ||||||
| #ifdef PLACEBO | #ifdef PLACEBO | ||||||
|     uint64_t diff; |     //uint64_t diff; | ||||||
|     static float fdiff = 23000.0; |     //static float fdiff = 23000.0; | ||||||
|     struct pl_swapchain_frame frame; |     struct pl_swapchain_frame frame; | ||||||
|     struct pl_frame target; |     struct pl_frame target; | ||||||
|     bool ok; |     //bool ok; | ||||||
|  |  | ||||||
|     const struct pl_fmt *fmt; |     //const struct pl_fmt *fmt; | ||||||
|     const float black[4] = {0.0f, 0.0f, 0.0f, 1.0f}; |     //const float black[4] = {0.0f, 0.0f, 0.0f, 1.0f}; | ||||||
|  | #else | ||||||
|  |     int valid_frame = 0; | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| #ifndef PLACEBO | #ifndef PLACEBO | ||||||
|  |     static uint64_t last_time = 0; | ||||||
|     if (CuvidDecoderN) |     if (CuvidDecoderN) | ||||||
|         CuvidDecoders[0]->Frameproc = (float)(GetusTicks() - last_time) / 1000000.0; |         CuvidDecoders[0]->Frameproc = (float)(GetusTicks() - last_time) / 1000000.0; | ||||||
|  |  | ||||||
| @@ -4365,7 +4391,7 @@ static void CuvidDisplayFrame(void) { | |||||||
| #endif | #endif | ||||||
|  |  | ||||||
|     if (CuvidDecoderN) { |     if (CuvidDecoderN) { | ||||||
|         ldiff = (float)(GetusTicks() - round_time) / 1000000.0; |         float ldiff = (float)(GetusTicks() - round_time) / 1000000.0; | ||||||
|         if (ldiff < 100.0 && ldiff > 0.0) |         if (ldiff < 100.0 && ldiff > 0.0) | ||||||
|             CuvidDecoders[0]->Frameproc = (CuvidDecoders[0]->Frameproc + ldiff + ldiff) / 3.0; |             CuvidDecoders[0]->Frameproc = (CuvidDecoders[0]->Frameproc + ldiff + ldiff) / 3.0; | ||||||
|     } |     } | ||||||
| @@ -4379,7 +4405,7 @@ static void CuvidDisplayFrame(void) { | |||||||
|     VideoThreadLock(); |     VideoThreadLock(); | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|     last_time = GetusTicks(); |     //last_time = GetusTicks(); | ||||||
|  |  | ||||||
|     while (!pl_swapchain_start_frame(p->swapchain, &frame)) { // get new frame wait for previous to swap |     while (!pl_swapchain_start_frame(p->swapchain, &frame)) { // get new frame wait for previous to swap | ||||||
|         usleep(5); |         usleep(5); | ||||||
| @@ -4434,7 +4460,7 @@ static void CuvidDisplayFrame(void) { | |||||||
|             } |             } | ||||||
|             continue; |             continue; | ||||||
|         } |         } | ||||||
|         valid_frame = 1; |          | ||||||
| #ifdef PLACEBO | #ifdef PLACEBO | ||||||
|         //pthread_mutex_lock(&OSDMutex); |         //pthread_mutex_lock(&OSDMutex); | ||||||
|         if (OsdShown == 1) { // New OSD opened |         if (OsdShown == 1) { // New OSD opened | ||||||
| @@ -4462,6 +4488,7 @@ static void CuvidDisplayFrame(void) { | |||||||
|         } |         } | ||||||
|         //pthread_mutex_unlock(&OSDMutex); |         //pthread_mutex_unlock(&OSDMutex); | ||||||
| #else | #else | ||||||
|  |         valid_frame = 1; | ||||||
|         CuvidMixVideo(decoder, i); |         CuvidMixVideo(decoder, i); | ||||||
| #endif | #endif | ||||||
|         if (i == 0 && decoder->grab) { // Grab frame |         if (i == 0 && decoder->grab) { // Grab frame | ||||||
| @@ -4578,7 +4605,7 @@ static void CuvidDisplayFrame(void) { | |||||||
| } | } | ||||||
|  |  | ||||||
| #ifdef PLACEBO_GL | #ifdef PLACEBO_GL | ||||||
| CuvidSwapBuffer() { | void CuvidSwapBuffer() { | ||||||
| #ifndef USE_DRM | #ifndef USE_DRM | ||||||
|     eglSwapBuffers(eglDisplay, eglSurface); |     eglSwapBuffers(eglDisplay, eglSurface); | ||||||
| //    eglMakeCurrent(eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, | //    eglMakeCurrent(eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, | ||||||
| @@ -4694,7 +4721,6 @@ static void CuvidSyncDecoder(CuvidDecoder *decoder) { | |||||||
|     int filled; |     int filled; | ||||||
|     int64_t audio_clock; |     int64_t audio_clock; | ||||||
|     int64_t video_clock; |     int64_t video_clock; | ||||||
|     int err = 0; |  | ||||||
|     static int speedup = 3; |     static int speedup = 3; | ||||||
|  |  | ||||||
| #ifdef GAMMA | #ifdef GAMMA | ||||||
| @@ -4762,14 +4788,14 @@ static void CuvidSyncDecoder(CuvidDecoder *decoder) { | |||||||
| 	} | 	} | ||||||
| #endif | #endif | ||||||
|         if (abs(diff) > 5000 * 90) { // more than 5s |         if (abs(diff) > 5000 * 90) { // more than 5s | ||||||
|             err = CuvidMessage(2, "video: audio/video difference too big %d\n", diff / 90); |             CuvidMessage(2, "video: audio/video difference too big %d\n", diff / 90); | ||||||
|             // decoder->SyncCounter = 1; |             // decoder->SyncCounter = 1; | ||||||
|             // usleep(10); |             // usleep(10); | ||||||
|             goto skip_sync; |             goto skip_sync; | ||||||
|  |  | ||||||
|         } else if (diff > 100 * 90) { |         } else if (diff > 100 * 90) { | ||||||
|  |  | ||||||
|             err = CuvidMessage(4, "video: slow down video, duping frame %d\n", diff / 90); |             CuvidMessage(4, "video: slow down video, duping frame %d\n", diff / 90); | ||||||
|             ++decoder->FramesDuped; |             ++decoder->FramesDuped; | ||||||
|             if ((speedup && --speedup) || VideoSoftStartSync) |             if ((speedup && --speedup) || VideoSoftStartSync) | ||||||
|                 decoder->SyncCounter = 1; |                 decoder->SyncCounter = 1; | ||||||
| @@ -4778,13 +4804,13 @@ static void CuvidSyncDecoder(CuvidDecoder *decoder) { | |||||||
|             goto out; |             goto out; | ||||||
|  |  | ||||||
|         } else if (diff > 25 * 90) { |         } else if (diff > 25 * 90) { | ||||||
|             err = CuvidMessage(3, "video: slow down video, duping frame %d \n", diff / 90); |             CuvidMessage(3, "video: slow down video, duping frame %d \n", diff / 90); | ||||||
|             ++decoder->FramesDuped; |             ++decoder->FramesDuped; | ||||||
|             decoder->SyncCounter = 1; |             decoder->SyncCounter = 1; | ||||||
|             goto out; |             goto out; | ||||||
|         } else if ((diff < -100 * 90)) { |         } else if ((diff < -100 * 90)) { | ||||||
|             if (filled > 2) { |             if (filled > 2) { | ||||||
|                 err = CuvidMessage(3, "video: speed up video, droping frame %d\n", diff / 90); |                 CuvidMessage(3, "video: speed up video, droping frame %d\n", diff / 90); | ||||||
|                 ++decoder->FramesDropped; |                 ++decoder->FramesDropped; | ||||||
|                 CuvidAdvanceDecoderFrame(decoder); |                 CuvidAdvanceDecoderFrame(decoder); | ||||||
|             } else if ((diff < -100 * 90)) { // give it some time to get frames to drop |             } else if ((diff < -100 * 90)) { // give it some time to get frames to drop | ||||||
| @@ -5274,7 +5300,7 @@ void VideoOsdDrawARGB(int xi, int yi, int width, int height, int pitch, const ui | |||||||
|     } |     } | ||||||
|     Debug(3, "video: osd dirty %dx%d%+d%+d -> %dx%d%+d%+d\n", width, height, x, y, OsdDirtyWidth, OsdDirtyHeight, |     Debug(3, "video: osd dirty %dx%d%+d%+d -> %dx%d%+d%+d\n", width, height, x, y, OsdDirtyWidth, OsdDirtyHeight, | ||||||
|           OsdDirtyX, OsdDirtyY); |           OsdDirtyX, OsdDirtyY); | ||||||
|  |     Debug(4," dummy print %d %d %d %s",xi,yi,pitch,argb); | ||||||
|     VideoThreadUnlock(); |     VideoThreadUnlock(); | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -5578,7 +5604,7 @@ void pl_log_intern(void *stream, enum pl_log_level level, const char *msg) { | |||||||
|         [PL_LOG_FATAL] = "fatal", [PL_LOG_ERR] = "error",   [PL_LOG_WARN] = "warn", |         [PL_LOG_FATAL] = "fatal", [PL_LOG_ERR] = "error",   [PL_LOG_WARN] = "warn", | ||||||
|         [PL_LOG_INFO] = "info",   [PL_LOG_DEBUG] = "debug", [PL_LOG_TRACE] = "trace", |         [PL_LOG_INFO] = "info",   [PL_LOG_DEBUG] = "debug", [PL_LOG_TRACE] = "trace", | ||||||
|     }; |     }; | ||||||
|  |     (void)stream; | ||||||
|     printf("%5s: %s\n", prefix[level], msg); |     printf("%5s: %s\n", prefix[level], msg); | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -5688,7 +5714,8 @@ void InitPlacebo() { | |||||||
|     if (!p->swapchain) { |     if (!p->swapchain) { | ||||||
|         Fatal(_("Failed creating vulkan swapchain!")); |         Fatal(_("Failed creating vulkan swapchain!")); | ||||||
|     } |     } | ||||||
|  |      | ||||||
|  | #ifdef VAAPI | ||||||
|     if (!(p->gpu->import_caps.tex & PL_HANDLE_DMA_BUF)) { |     if (!(p->gpu->import_caps.tex & PL_HANDLE_DMA_BUF)) { | ||||||
|         p->has_dma_buf = 0; |         p->has_dma_buf = 0; | ||||||
|         Debug(3, "No support for dma_buf import \n"); |         Debug(3, "No support for dma_buf import \n"); | ||||||
| @@ -5696,16 +5723,20 @@ void InitPlacebo() { | |||||||
|         p->has_dma_buf = 1; |         p->has_dma_buf = 1; | ||||||
|         Debug(3, "dma_buf support available\n"); |         Debug(3, "dma_buf support available\n"); | ||||||
|     } |     } | ||||||
|  | #else | ||||||
|  |     p->has_dma_buf = 0; | ||||||
|  |     Debug(3, "No support for dma_buf import \n"); | ||||||
|  | #endif | ||||||
|  |  | ||||||
| #ifdef PLACEBO_GL | #ifdef PLACEBO_GL | ||||||
|     if (!pl_swapchain_resize(p->swapchain, &VideoWindowWidth, &VideoWindowHeight)) { |     if (!pl_swapchain_resize(p->swapchain, (int *)&VideoWindowWidth, (int *)&VideoWindowHeight)) { | ||||||
|         Fatal(_("libplacebo: failed initializing swapchain\n")); |         Fatal(_("libplacebo: failed initializing swapchain\n")); | ||||||
|     } |     } | ||||||
| #endif | #endif | ||||||
| #if PL_API_VER >= 113 | #if PL_API_VER >= 113 | ||||||
|     // load LUT File |     // load LUT File | ||||||
|     struct file lutf; |     struct file lutf; | ||||||
|     char tmp[200]; |     char tmp[400]; | ||||||
|  |  | ||||||
|     sprintf(tmp, "%s/%s", MyConfigDir, lut_file); |     sprintf(tmp, "%s/%s", MyConfigDir, lut_file); | ||||||
|     if (open_file(tmp, &lutf) && lutf.size) { |     if (open_file(tmp, &lutf) && lutf.size) { | ||||||
| @@ -5811,10 +5842,9 @@ void exit_display() { | |||||||
| } | } | ||||||
|  |  | ||||||
| static void *VideoHandlerThread(void *dummy) { | static void *VideoHandlerThread(void *dummy) { | ||||||
| #ifdef VAAPI | #if defined VAAPI && !defined PLACEBO_GL | ||||||
|     EGLint contextAttrs[] = {EGL_CONTEXT_CLIENT_VERSION, 3, EGL_NONE}; |     EGLint contextAttrs[] = {EGL_CONTEXT_CLIENT_VERSION, 3, EGL_NONE}; | ||||||
| #endif | #endif | ||||||
|     int redSize, greenSize, blueSize, alphaSize; |  | ||||||
|  |  | ||||||
|     prctl(PR_SET_NAME, "video display", 0, 0, 0); |     prctl(PR_SET_NAME, "video display", 0, 0, 0); | ||||||
|  |  | ||||||
| @@ -6578,13 +6608,13 @@ int VideoSetShader(char *s) { | |||||||
| #if defined PLACEBO && PL_API_VER >= 58 | #if defined PLACEBO && PL_API_VER >= 58 | ||||||
|     if (num_shaders == NUM_SHADERS) |     if (num_shaders == NUM_SHADERS) | ||||||
|         return -1; |         return -1; | ||||||
|     p = malloc(strlen(s) + 1); |     char *p = malloc(strlen(s) + 1); | ||||||
|     memcpy(p, s, strlen(s) + 1); |     memcpy(p, s, strlen(s) + 1); | ||||||
|     shadersp[num_shaders++] = p; |     shadersp[num_shaders++] = p; | ||||||
|     CuvidMessage(2, "Use Shader %s\n", s); |     CuvidMessage(2, "Use Shader %s\n", s); | ||||||
|     return 0; |     return 0; | ||||||
| #else | #else | ||||||
|     printf("Shaders are only support with placebo\n"); |     printf("Shaders are only support with placebo (%s)\n",s); | ||||||
|     return -1; |     return -1; | ||||||
| #endif | #endif | ||||||
| } | } | ||||||
| @@ -6900,7 +6930,8 @@ void VideoSetAbove() { | |||||||
| /// | /// | ||||||
| /// Set deinterlace mode. | /// Set deinterlace mode. | ||||||
| /// | /// | ||||||
| void VideoSetDeinterlace(int mode[VideoResolutionMax]) { | void VideoSetDeinterlace(int mode[]) { | ||||||
|  |      | ||||||
| #ifdef CUVID | #ifdef CUVID | ||||||
|     VideoDeinterlace[0] = mode[0]; // 576i |     VideoDeinterlace[0] = mode[0]; // 576i | ||||||
|     VideoDeinterlace[1] = 0;       // mode[1];  // 720p |     VideoDeinterlace[1] = 0;       // mode[1];  // 720p | ||||||
| @@ -6908,6 +6939,7 @@ void VideoSetDeinterlace(int mode[VideoResolutionMax]) { | |||||||
|     VideoDeinterlace[3] = mode[3]; // 1080 |     VideoDeinterlace[3] = mode[3]; // 1080 | ||||||
|     VideoDeinterlace[4] = 0;       // mode[4];  2160p |     VideoDeinterlace[4] = 0;       // mode[4];  2160p | ||||||
| #else | #else | ||||||
|  |     (void)mode; | ||||||
|     VideoDeinterlace[0] = 1; // 576i |     VideoDeinterlace[0] = 1; // 576i | ||||||
|     VideoDeinterlace[1] = 0; // mode[1];  // 720p |     VideoDeinterlace[1] = 0; // mode[1];  // 720p | ||||||
|     VideoDeinterlace[2] = 1; // fake 1080 |     VideoDeinterlace[2] = 1; // fake 1080 | ||||||
| @@ -6920,7 +6952,7 @@ void VideoSetDeinterlace(int mode[VideoResolutionMax]) { | |||||||
| /// | /// | ||||||
| /// Set skip chroma deinterlace on/off. | /// Set skip chroma deinterlace on/off. | ||||||
| /// | /// | ||||||
| void VideoSetSkipChromaDeinterlace(int onoff[VideoResolutionMax]) { | void VideoSetSkipChromaDeinterlace(int onoff[]) { | ||||||
|     VideoSkipChromaDeinterlace[0] = onoff[0]; |     VideoSkipChromaDeinterlace[0] = onoff[0]; | ||||||
|     VideoSkipChromaDeinterlace[1] = onoff[1]; |     VideoSkipChromaDeinterlace[1] = onoff[1]; | ||||||
|     VideoSkipChromaDeinterlace[2] = onoff[2]; |     VideoSkipChromaDeinterlace[2] = onoff[2]; | ||||||
| @@ -6932,7 +6964,7 @@ void VideoSetSkipChromaDeinterlace(int onoff[VideoResolutionMax]) { | |||||||
| /// | /// | ||||||
| /// Set inverse telecine on/off. | /// Set inverse telecine on/off. | ||||||
| /// | /// | ||||||
| void VideoSetInverseTelecine(int onoff[VideoResolutionMax]) { | void VideoSetInverseTelecine(int onoff[]) { | ||||||
|     VideoInverseTelecine[0] = onoff[0]; |     VideoInverseTelecine[0] = onoff[0]; | ||||||
|     VideoInverseTelecine[1] = onoff[1]; |     VideoInverseTelecine[1] = onoff[1]; | ||||||
|     VideoInverseTelecine[2] = onoff[2]; |     VideoInverseTelecine[2] = onoff[2]; | ||||||
| @@ -6944,7 +6976,7 @@ void VideoSetInverseTelecine(int onoff[VideoResolutionMax]) { | |||||||
| /// | /// | ||||||
| /// Set denoise level (0 .. 1000). | /// Set denoise level (0 .. 1000). | ||||||
| /// | /// | ||||||
| void VideoSetDenoise(int level[VideoResolutionMax]) { | void VideoSetDenoise(int level[]) { | ||||||
|     VideoDenoise[0] = level[0]; |     VideoDenoise[0] = level[0]; | ||||||
|     VideoDenoise[1] = level[1]; |     VideoDenoise[1] = level[1]; | ||||||
|     VideoDenoise[2] = level[2]; |     VideoDenoise[2] = level[2]; | ||||||
| @@ -6956,7 +6988,7 @@ void VideoSetDenoise(int level[VideoResolutionMax]) { | |||||||
| /// | /// | ||||||
| /// Set sharpness level (-1000 .. 1000). | /// Set sharpness level (-1000 .. 1000). | ||||||
| /// | /// | ||||||
| void VideoSetSharpen(int level[VideoResolutionMax]) { | void VideoSetSharpen(int level[]) { | ||||||
|     VideoSharpen[0] = level[0]; |     VideoSharpen[0] = level[0]; | ||||||
|     VideoSharpen[1] = level[1]; |     VideoSharpen[1] = level[1]; | ||||||
|     VideoSharpen[2] = level[2]; |     VideoSharpen[2] = level[2]; | ||||||
| @@ -6970,7 +7002,7 @@ void VideoSetSharpen(int level[VideoResolutionMax]) { | |||||||
| /// | /// | ||||||
| /// @param mode table with VideoResolutionMax values | /// @param mode table with VideoResolutionMax values | ||||||
| /// | /// | ||||||
| void VideoSetScaling(int mode[VideoResolutionMax]) { | void VideoSetScaling(int mode[]) { | ||||||
|     VideoScaling[0] = mode[0]; |     VideoScaling[0] = mode[0]; | ||||||
|     VideoScaling[1] = mode[1]; |     VideoScaling[1] = mode[1]; | ||||||
|     VideoScaling[2] = mode[2]; |     VideoScaling[2] = mode[2]; | ||||||
| @@ -6984,7 +7016,7 @@ void VideoSetScaling(int mode[VideoResolutionMax]) { | |||||||
| /// | /// | ||||||
| /// @param pixels table with VideoResolutionMax values | /// @param pixels table with VideoResolutionMax values | ||||||
| /// | /// | ||||||
| void VideoSetCutTopBottom(int pixels[VideoResolutionMax]) { | void VideoSetCutTopBottom(int pixels[]) { | ||||||
|     VideoCutTopBottom[0] = pixels[0]; |     VideoCutTopBottom[0] = pixels[0]; | ||||||
|     VideoCutTopBottom[1] = pixels[1]; |     VideoCutTopBottom[1] = pixels[1]; | ||||||
|     VideoCutTopBottom[2] = pixels[2]; |     VideoCutTopBottom[2] = pixels[2]; | ||||||
| @@ -6998,7 +7030,7 @@ void VideoSetCutTopBottom(int pixels[VideoResolutionMax]) { | |||||||
| /// | /// | ||||||
| /// @param pixels   table with VideoResolutionMax values | /// @param pixels   table with VideoResolutionMax values | ||||||
| /// | /// | ||||||
| void VideoSetCutLeftRight(int pixels[VideoResolutionMax]) { | void VideoSetCutLeftRight(int pixels[]) { | ||||||
|     VideoCutLeftRight[0] = pixels[0]; |     VideoCutLeftRight[0] = pixels[0]; | ||||||
|     VideoCutLeftRight[1] = pixels[1]; |     VideoCutLeftRight[1] = pixels[1]; | ||||||
|     VideoCutLeftRight[2] = pixels[2]; |     VideoCutLeftRight[2] = pixels[2]; | ||||||
| @@ -7094,6 +7126,14 @@ void VideoInit(const char *display_name) { | |||||||
|     xcb_screen_iterator_t screen_iter; |     xcb_screen_iterator_t screen_iter; | ||||||
|     xcb_screen_t const *screen; |     xcb_screen_t const *screen; | ||||||
|  |  | ||||||
|  | #ifdef VAAPI | ||||||
|  |     VideoDeinterlace[0] = 1; // 576i | ||||||
|  |     VideoDeinterlace[1] = 0; // mode[1];  // 720p | ||||||
|  |     VideoDeinterlace[2] = 1; // fake 1080 | ||||||
|  |     VideoDeinterlace[3] = 1; // 1080 | ||||||
|  |     VideoDeinterlace[4] = 0; // mode[4];  2160p | ||||||
|  | #endif | ||||||
|  |  | ||||||
| #ifdef USE_DRM | #ifdef USE_DRM | ||||||
|     VideoInitDrm(); |     VideoInitDrm(); | ||||||
| #else | #else | ||||||
|   | |||||||
							
								
								
									
										4
									
								
								video.h
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								video.h
									
									
									
									
									
								
							| @@ -249,6 +249,10 @@ extern int VideoRaiseWindow(void); | |||||||
| /// Set Shaders | /// Set Shaders | ||||||
| extern int VideoSetShader(char *); | extern int VideoSetShader(char *); | ||||||
|  |  | ||||||
|  | extern void VideoSetRefresh(char *); | ||||||
|  |  | ||||||
|  | extern void VideoSetConnector(char *); | ||||||
|  |  | ||||||
| #ifdef USE_OPENGLOSD | #ifdef USE_OPENGLOSD | ||||||
| extern void ActivateOsd(GLuint, int, int, int, int); | extern void ActivateOsd(GLuint, int, int, int, int); | ||||||
| #endif | #endif | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user