mirror of
				https://github.com/jojo61/vdr-plugin-softhdcuvid.git
				synced 2025-03-01 10:39:28 +00:00 
			
		
		
		
	Compare commits
	
		
			4 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|  | 4b1ffc5b2e | ||
|  | 1d66d9389d | ||
|  | b2fd6ba240 | ||
|  | cf9ef0c3b0 | 
							
								
								
									
										37
									
								
								codec.c
									
									
									
									
									
								
							
							
						
						
									
										37
									
								
								codec.c
									
									
									
									
									
								
							| @@ -716,6 +716,17 @@ 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) { | ||||||
|  | #if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(53,61,100) | ||||||
|  | 	    audio_decoder->AudioCtx->request_channels = 2; | ||||||
|  | #endif | ||||||
|  | #if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59,24,100) | ||||||
|  | 	    audio_decoder->AudioCtx->request_channel_layout = AV_CH_LAYOUT_STEREO; | ||||||
|  | #else | ||||||
|  |         AVChannelLayout dmlayout = AV_CHANNEL_LAYOUT_STEREO; | ||||||
|  |         av_opt_set_chlayout(audio_decoder->AudioCtx->priv_data, "downmix", &dmlayout, 0); | ||||||
|  | #endif | ||||||
|  |     } | ||||||
|     pthread_mutex_lock(&CodecLockMutex); |     pthread_mutex_lock(&CodecLockMutex); | ||||||
|     // open codec |     // open codec | ||||||
|     if (1) { |     if (1) { | ||||||
| @@ -878,7 +889,7 @@ static int CodecAudioUpdateHelper(AudioDecoder *audio_decoder, int *passthrough) | |||||||
|     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; | ||||||
|     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; |     audio_decoder->Passthrough = CodecPassthrough; | ||||||
|  |  | ||||||
|     // SPDIF/HDMI pass-through |     // SPDIF/HDMI pass-through | ||||||
| @@ -893,6 +904,10 @@ static int CodecAudioUpdateHelper(AudioDecoder *audio_decoder, int *passthrough) | |||||||
|         audio_decoder->SpdifCount = 0; |         audio_decoder->SpdifCount = 0; | ||||||
|         *passthrough = 1; |         *passthrough = 1; | ||||||
|     } |     } | ||||||
|  |      | ||||||
|  |     if (audio_decoder->HwChannels > 2 && CodecDownmix) { | ||||||
|  |         audio_decoder->HwChannels = 2; | ||||||
|  |     } | ||||||
|     // channels/sample-rate not support? |     // channels/sample-rate not support? | ||||||
|     if ((err = AudioSetup(&audio_decoder->HwSampleRate, &audio_decoder->HwChannels, *passthrough))) { |     if ((err = AudioSetup(&audio_decoder->HwSampleRate, &audio_decoder->HwChannels, *passthrough))) { | ||||||
|  |  | ||||||
| @@ -1159,20 +1174,34 @@ static void CodecAudioUpdateFormat(AudioDecoder *audio_decoder) { | |||||||
| #endif | #endif | ||||||
|  |  | ||||||
| #if LIBSWRESAMPLE_VERSION_INT < AV_VERSION_INT(4,5,100) | #if LIBSWRESAMPLE_VERSION_INT < AV_VERSION_INT(4,5,100) | ||||||
|  |     if (audio_decoder->Channels > 2 && CodecDownmix) {  | ||||||
|         audio_decoder->Resample = swr_alloc_set_opts(audio_decoder->Resample,  |         audio_decoder->Resample = swr_alloc_set_opts(audio_decoder->Resample,  | ||||||
|                                     CodecDownmix ? AV_CH_LAYOUT_STEREO : audio_ctx->channel_layout, |                                     AV_CH_LAYOUT_STEREO, 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,audio_ctx->sample_rate, | ||||||
|                                     0, NULL); |                                     0, NULL); | ||||||
|  |     } else { | ||||||
|  |         audio_decoder->Resample = swr_alloc_set_opts(audio_decoder->Resample, audio_ctx->channel_layout, | ||||||
|  | 	                                            AV_SAMPLE_FMT_S16, audio_decoder->HwSampleRate, | ||||||
|  | 	                                            audio_ctx->channel_layout, audio_ctx->sample_fmt, | ||||||
|  |                                                 audio_ctx->sample_rate, 0, NULL); | ||||||
|  |     } | ||||||
| #else | #else | ||||||
|  |     if (audio_decoder->Channels > 2 && CodecDownmix) {  // Codec does not Support Downmix | ||||||
|     //printf("last ressort downmix Layout in %lx Lyout out: %llx \n",audio_ctx->channel_layout,AV_CH_LAYOUT_STEREO); |     //printf("last ressort downmix Layout in %lx Lyout out: %llx \n",audio_ctx->channel_layout,AV_CH_LAYOUT_STEREO); | ||||||
|         audio_decoder->Resample = swr_alloc(); |         audio_decoder->Resample = swr_alloc(); | ||||||
|         av_opt_set_channel_layout(audio_decoder->Resample, "in_channel_layout",audio_ctx->channel_layout, 0); |         av_opt_set_channel_layout(audio_decoder->Resample, "in_channel_layout",audio_ctx->channel_layout, 0); | ||||||
|         av_opt_set_channel_layout(audio_decoder->Resample, "out_channel_layout", CodecDownmix ? AV_CH_LAYOUT_STEREO : audio_ctx->channel_layout ,  0); |         av_opt_set_channel_layout(audio_decoder->Resample, "out_channel_layout", AV_CH_LAYOUT_STEREO,  0); | ||||||
|         av_opt_set_int(audio_decoder->Resample, "in_sample_rate",     audio_ctx->sample_rate,                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_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, "in_sample_fmt",  audio_ctx->sample_fmt, 0); | ||||||
|         av_opt_set_sample_fmt(audio_decoder->Resample, "out_sample_fmt", AV_SAMPLE_FMT_S16,  0); |         av_opt_set_sample_fmt(audio_decoder->Resample, "out_sample_fmt", AV_SAMPLE_FMT_S16,  0); | ||||||
|  |     } | ||||||
|  |     else { | ||||||
|  |         swr_alloc_set_opts2(&audio_decoder->Resample, &audio_ctx->ch_layout, | ||||||
|  |                             AV_SAMPLE_FMT_S16, audio_decoder->HwSampleRate, | ||||||
|  |                             &audio_ctx->ch_layout, audio_ctx->sample_fmt, | ||||||
|  |                             audio_ctx->sample_rate, 0, NULL); | ||||||
|  |     } | ||||||
| #endif | #endif | ||||||
|     if (audio_decoder->Resample) { |     if (audio_decoder->Resample) { | ||||||
| 	    swr_init(audio_decoder->Resample); | 	    swr_init(audio_decoder->Resample); | ||||||
|   | |||||||
							
								
								
									
										36
									
								
								drm.c
									
									
									
									
									
								
							
							
						
						
									
										36
									
								
								drm.c
									
									
									
									
									
								
							| @@ -209,12 +209,9 @@ 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) { | ||||||
|         render->fd_drm = open("/dev/dri/card1", O_RDWR); |         fprintf(stderr, "FindDevice: cannot open /dev/dri/card0: %m\n"); | ||||||
|         if (render->fd_drm < 0) { |  | ||||||
|             fprintf(stderr, "FindDevice: cannot open /dev/dri/card0 or card1: %m\n"); |  | ||||||
|         return -errno; |         return -errno; | ||||||
|     } |     } | ||||||
|     } |  | ||||||
|  |  | ||||||
|     int ret = drmSetMaster(render->fd_drm); |     int ret = drmSetMaster(render->fd_drm); | ||||||
|  |  | ||||||
| @@ -548,7 +545,6 @@ 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) { | ||||||
| @@ -566,16 +562,15 @@ 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; | ||||||
| @@ -618,29 +613,22 @@ 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.22" | static const char *const VERSION = "3.17" | ||||||
| #ifdef GIT_REV | #ifdef GIT_REV | ||||||
|                                    "-GIT" GIT_REV |                                    "-GIT" GIT_REV | ||||||
| #endif | #endif | ||||||
|   | |||||||
							
								
								
									
										44
									
								
								video.c
									
									
									
									
									
								
							
							
						
						
									
										44
									
								
								video.c
									
									
									
									
									
								
							| @@ -1246,17 +1246,14 @@ static void EglExit(void) { | |||||||
|         glxSharedContext = NULL; |         glxSharedContext = NULL; | ||||||
|     } |     } | ||||||
| #else | #else | ||||||
| #ifdef USE_DRM |     if (eglGetCurrentContext() == eglContext) { | ||||||
|     drm_clean_up(); |         // if currently used, set to none | ||||||
|  |  | ||||||
| #endif |  | ||||||
|      |  | ||||||
|         eglMakeCurrent(eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); |         eglMakeCurrent(eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); | ||||||
|  |     } | ||||||
|     if (eglSurface) { | #ifndef USE_DRM | ||||||
|         eglDestroySurface(eglDisplay, eglSurface); |     if (eglSharedContext) { | ||||||
|  |         eglDestroyContext(eglDisplay, eglSharedContext); | ||||||
|         EglCheck(); |         EglCheck(); | ||||||
|         eglSurface = NULL; |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     if (eglContext) { |     if (eglContext) { | ||||||
| @@ -1264,15 +1261,13 @@ static void EglExit(void) { | |||||||
|         EglCheck(); |         EglCheck(); | ||||||
|         eglContext = NULL; |         eglContext = NULL; | ||||||
|     } |     } | ||||||
|     if (eglSharedContext) { |  | ||||||
|         eglDestroyContext(eglDisplay, eglSharedContext); |  | ||||||
|         EglCheck(); |  | ||||||
|         eglSharedContext = NULL; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|  |  | ||||||
|     eglTerminate(eglDisplay); |     eglTerminate(eglDisplay); | ||||||
|     eglDisplay = NULL; | #endif | ||||||
|  |  | ||||||
|  | #ifdef USE_DRM | ||||||
|  |     drm_clean_up(); | ||||||
|  | #endif | ||||||
|  |  | ||||||
| #endif | #endif | ||||||
| } | } | ||||||
| @@ -1995,9 +1990,6 @@ 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 | ||||||
|  |  | ||||||
| @@ -3006,12 +2998,10 @@ 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 | ||||||
| @@ -7101,14 +7091,6 @@ 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 | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user