mirror of
				https://github.com/jojo61/vdr-plugin-softhdcuvid.git
				synced 2025-03-01 10:39:28 +00:00 
			
		
		
		
	Compare commits
	
		
			19 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|  | 230bb5ca11 | ||
|  | f026e8e86d | ||
|  | 9dd936df86 | ||
|  | 4e5529efcf | ||
|  | 20f1bd45e6 | ||
|  | 7a7e09ff7a | ||
|  | c4a660ede2 | ||
|  | 8e495266e2 | ||
|  | f27e4fb35f | ||
|  | e14ea73a00 | ||
|  | 72cb77f771 | ||
|  | c679d812d1 | ||
|  | 47b461ab46 | ||
|  | 8629946041 | ||
|  | a222f6a1d5 | ||
|  | b51589aaa9 | ||
|  | c3af54aae0 | ||
|  | 4e96489e35 | ||
|  | 65017da5ac | 
							
								
								
									
										18
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								Makefile
									
									
									
									
									
								
							| @@ -24,7 +24,7 @@ DRM ?= 0 | |||||||
|  |  | ||||||
| # use libplacebo - | # use libplacebo - | ||||||
| # available for all decoders but for DRM you need LIBPLACEBO_GL | # available for all decoders but for DRM you need LIBPLACEBO_GL | ||||||
| LIBPLACEBO ?= 1 | LIBPLACEBO ?= 0 | ||||||
| LIBPLACEBO_GL ?= 0 | LIBPLACEBO_GL ?= 0 | ||||||
|  |  | ||||||
| # use YADIF deint - only available with cuvid | # use YADIF deint - only available with cuvid | ||||||
| @@ -35,7 +35,6 @@ YADIF = 1 | |||||||
|  |  | ||||||
| CONFIG := -DDEBUG 		# remove '#' to enable debug output | CONFIG := -DDEBUG 		# remove '#' to enable debug output | ||||||
|  |  | ||||||
|  |  | ||||||
| #--------------------- no more config needed past this point-------------------------------- | #--------------------- no more config needed past this point-------------------------------- | ||||||
|  |  | ||||||
| # sanitize selections -------- | # sanitize selections -------- | ||||||
| @@ -159,29 +158,29 @@ endif | |||||||
|  |  | ||||||
| ifeq ($(LIBPLACEBO_GL),1) | ifeq ($(LIBPLACEBO_GL),1) | ||||||
| CONFIG += -DPLACEBO_GL -DPLACEBO | CONFIG += -DPLACEBO_GL -DPLACEBO | ||||||
| LIBS += -lepoxy | _CFLAGS += $(shell pkg-config --cflags libplacebo) | ||||||
| LIBS += -lplacebo | LIBS += $(shell pkg-config --libs epoxy libplacebo) | ||||||
| else | else | ||||||
| LIBS += -lEGL | LIBS += $(shell pkg-config --libs egl) | ||||||
| endif | endif | ||||||
|  |  | ||||||
| ifeq ($(LIBPLACEBO),1) | ifeq ($(LIBPLACEBO),1) | ||||||
| CONFIG += -DPLACEBO | CONFIG += -DPLACEBO | ||||||
| LIBS += -lEGL | _CFLAGS += $(shell pkg-config --cflags libplacebo) | ||||||
| LIBS += -lplacebo | LIBS += $(shell pkg-config --libs egl libplacebo) | ||||||
| endif | endif | ||||||
|  |  | ||||||
| ifeq ($(DRM),1) | ifeq ($(DRM),1) | ||||||
| PLUGIN = softhddrm | PLUGIN = softhddrm | ||||||
| CONFIG += -DUSE_DRM -DVAAPI | CONFIG += -DUSE_DRM -DVAAPI | ||||||
| _CFLAGS += $(shell pkg-config --cflags libdrm) | _CFLAGS += $(shell pkg-config --cflags libdrm) | ||||||
| LIBS += -lgbm -ldrm -lEGL | LIBS += $(shell pkg-config --libs egl gbm libdrm) | ||||||
| endif | endif | ||||||
|  |  | ||||||
| ifeq ($(CUVID),1) | ifeq ($(CUVID),1) | ||||||
| #CONFIG += -DUSE_PIP			# PIP support | #CONFIG += -DUSE_PIP			# PIP support | ||||||
| CONFIG += -DCUVID			# enable CUVID decoder | CONFIG += -DCUVID			# enable CUVID decoder | ||||||
| LIBS += -lEGL -lGL | LIBS += $(shell pkg-config --libs egl gl) | ||||||
| ifeq ($(YADIF),1) | ifeq ($(YADIF),1) | ||||||
| CONFIG += -DYADIF			# Yadif only with CUVID | CONFIG += -DYADIF			# Yadif only with CUVID | ||||||
| endif | endif | ||||||
| @@ -274,6 +273,7 @@ LIBS += -lcuda -lnvcuvid | |||||||
| endif | endif | ||||||
|  |  | ||||||
| LIBS += -lGLEW -lGLU  -ldl -lglut | LIBS += -lGLEW -lGLU  -ldl -lglut | ||||||
|  | #LIBS += -ldl $(shell pkg-config --libs glew glu glut) | ||||||
|  |  | ||||||
| ### Includes and Defines (add further entries here): | ### Includes and Defines (add further entries here): | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										108
									
								
								codec.c
									
									
									
									
									
								
							
							
						
						
									
										108
									
								
								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 | ||||||
| @@ -389,15 +389,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 +517,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 +545,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; | ||||||
| @@ -716,9 +720,6 @@ void CodecAudioOpen(AudioDecoder *audio_decoder, int codec_id) { | |||||||
|         Fatal(_("codec: can't allocate audio codec context\n")); |         Fatal(_("codec: can't allocate audio codec context\n")); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     if (CodecDownmix) { |  | ||||||
|         audio_decoder->AudioCtx->request_channel_layout = AV_CH_LAYOUT_STEREO; |  | ||||||
|     } |  | ||||||
|     pthread_mutex_lock(&CodecLockMutex); |     pthread_mutex_lock(&CodecLockMutex); | ||||||
|     // open codec |     // open codec | ||||||
|     if (1) { |     if (1) { | ||||||
| @@ -758,8 +759,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); | ||||||
|     } |     } | ||||||
| } | } | ||||||
| @@ -871,19 +876,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 = 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)) { | ||||||
| @@ -912,9 +933,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; | ||||||
| } | } | ||||||
| @@ -1143,6 +1170,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; | ||||||
| @@ -1153,6 +1186,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) { | ||||||
| @@ -1161,14 +1200,25 @@ static void CodecAudioUpdateFormat(AudioDecoder *audio_decoder) { | |||||||
|     } |     } | ||||||
| #endif | #endif | ||||||
|      |      | ||||||
|     audio_decoder->Resample = swr_alloc_set_opts(audio_decoder->Resample, audio_ctx->channel_layout, AV_SAMPLE_FMT_S16, | #if LIBSWRESAMPLE_VERSION_INT < AV_VERSION_INT(4,5,100) | ||||||
|                                                  audio_decoder->HwSampleRate, audio_ctx->channel_layout, |     audio_decoder->Resample = | ||||||
|                                                  audio_ctx->sample_fmt, audio_ctx->sample_rate, 0, NULL); |         swr_alloc_set_opts(audio_decoder->Resample, dmlayout, | ||||||
|  |         AV_SAMPLE_FMT_S16, audio_decoder->HwSampleRate, | ||||||
|  |         audio_ctx->channel_layout, audio_ctx->sample_fmt, | ||||||
|  | #else | ||||||
|  |         swr_alloc_set_opts2(&audio_decoder->Resample, &dmlayout, | ||||||
|  |         AV_SAMPLE_FMT_S16, audio_decoder->HwSampleRate, | ||||||
|  |         &audio_ctx->ch_layout, audio_ctx->sample_fmt, | ||||||
|  | #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")); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |  | ||||||
| } | } | ||||||
|  |  | ||||||
| /** | /** | ||||||
| @@ -1211,7 +1261,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) { | ||||||
| @@ -1220,13 +1274,15 @@ void CodecAudioDecode(AudioDecoder *audio_decoder, const AVPacket *avpkt) { | |||||||
|             if (CodecAudioPassthroughHelper(audio_decoder, avpkt)) { |             if (CodecAudioPassthroughHelper(audio_decoder, avpkt)) { | ||||||
|                 return; |                 return; | ||||||
|             } |             } | ||||||
|  |              | ||||||
|             if (audio_decoder->Resample) { |             if (audio_decoder->Resample) { | ||||||
|                 uint8_t outbuf[8192 * 2 * 8]; |                 uint8_t outbuf[8192  * 2 * 8]; | ||||||
|                 uint8_t *out[1]; |                 uint8_t *out[1]; | ||||||
|  |  | ||||||
|                 out[0] = outbuf; |                 out[0] = outbuf; | ||||||
|                 ret = swr_convert(audio_decoder->Resample, out, sizeof(outbuf) / (2 * audio_decoder->HwChannels), |                 ret = swr_convert(audio_decoder->Resample, out, sizeof(outbuf) / (2 * audio_decoder->HwChannels), | ||||||
|                                   (const uint8_t **)frame->extended_data, frame->nb_samples); |                                   (const uint8_t **)frame->extended_data, frame->nb_samples); | ||||||
|  |                                    | ||||||
|                 if (ret > 0) { |                 if (ret > 0) { | ||||||
|                     if (!(audio_decoder->Passthrough & CodecPCM)) { |                     if (!(audio_decoder->Passthrough & CodecPCM)) { | ||||||
|                         CodecReorderAudioFrame((int16_t *)outbuf, ret * 2 * audio_decoder->HwChannels, |                         CodecReorderAudioFrame((int16_t *)outbuf, ret * 2 * audio_decoder->HwChannels, | ||||||
|   | |||||||
							
								
								
									
										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"); | ||||||
|  |  | ||||||
|     if (previous_bo) { |  | ||||||
|         drmModeRmFB(render->fd_drm, previous_fb); |  | ||||||
|         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, |     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); |                    render->saved_crtc->y, &render->connector_id, 1, &render->saved_crtc->mode); | ||||||
|     drmModeFreeCrtc(render->saved_crtc); |     drmModeFreeCrtc(render->saved_crtc); | ||||||
|  |  | ||||||
|  |     if (previous_bo) { | ||||||
|  |         drmModeRmFB(render->fd_drm, previous_fb); | ||||||
|  |         gbm_surface_release_buffer(gbm.surface, previous_bo); | ||||||
|  |     } | ||||||
|  |  | ||||||
|     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"); | ||||||
| } | } | ||||||
| @@ -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.16" | static const char *const VERSION = "3.24" | ||||||
| #ifdef GIT_REV | #ifdef GIT_REV | ||||||
|                                    "-GIT" GIT_REV |                                    "-GIT" GIT_REV | ||||||
| #endif | #endif | ||||||
|   | |||||||
							
								
								
									
										44
									
								
								video.c
									
									
									
									
									
								
							
							
						
						
									
										44
									
								
								video.c
									
									
									
									
									
								
							| @@ -1246,14 +1246,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 +1269,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 | ||||||
| } | } | ||||||
| @@ -1990,6 +1993,9 @@ make_egl() { | |||||||
|         Fatal(_("Could not make context current!\n")); |         Fatal(_("Could not make context current!\n")); | ||||||
|     } |     } | ||||||
|     EglEnabled = 1; |     EglEnabled = 1; | ||||||
|  | #ifdef USE_DRM | ||||||
|  |     drm_swap_buffers(); | ||||||
|  | #endif | ||||||
| } | } | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| @@ -2279,7 +2285,7 @@ void createTextureDst(CuvidDecoder *decoder, int anz, unsigned int size_x, unsig | |||||||
|                                &decoder->pl_frames[i].planes[n].texture); // delete old texture |                                &decoder->pl_frames[i].planes[n].texture); // delete old texture | ||||||
|             } |             } | ||||||
|  |  | ||||||
|             if (p->has_dma_buf == 0) { |             //if (p->has_dma_buf == 0) { | ||||||
|                 decoder->pl_frames[i].planes[n].texture = pl_tex_create( |                 decoder->pl_frames[i].planes[n].texture = pl_tex_create( | ||||||
|                     p->gpu, &(struct pl_tex_params) { |                     p->gpu, &(struct pl_tex_params) { | ||||||
|                         .w = n == 0 ? size_x : size_x / 2, .h = n == 0 ? size_y : size_y / 2, .d = 0, .format = fmt, |                         .w = n == 0 ? size_x : size_x / 2, .h = n == 0 ? size_y : size_y / 2, .d = 0, .format = fmt, | ||||||
| @@ -2291,7 +2297,7 @@ void createTextureDst(CuvidDecoder *decoder, int anz, unsigned int size_x, unsig | |||||||
|                         .export_handle = PL_HANDLE_FD, |                         .export_handle = PL_HANDLE_FD, | ||||||
| #endif | #endif | ||||||
|                     }); |                     }); | ||||||
|             } |             //} | ||||||
|  |  | ||||||
|             // make planes for image |             // make planes for image | ||||||
|             pl = &decoder->pl_frames[i].planes[n]; |             pl = &decoder->pl_frames[i].planes[n]; | ||||||
| @@ -2998,10 +3004,12 @@ 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 (VideoDeinterlace[decoder->Resolution]) {// need deinterlace | ||||||
|             ist->filter = 1;                       // init deint vaapi |             ist->filter = 1;                       // init deint vaapi | ||||||
|         else |         } | ||||||
|  |         else { | ||||||
|             ist->filter = 0; |             ist->filter = 0; | ||||||
|  |         } | ||||||
|  |  | ||||||
|         ist->active_hwaccel_id = HWACCEL_VAAPI; |         ist->active_hwaccel_id = HWACCEL_VAAPI; | ||||||
| #endif | #endif | ||||||
| @@ -7091,6 +7099,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