mirror of
				https://github.com/jojo61/vdr-plugin-softhdcuvid.git
				synced 2025-03-01 10:39:28 +00:00 
			
		
		
		
	Compare commits
	
		
			50 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|  | 7e387fa3f1 | ||
|  | f3e5a14fdf | ||
|  | aa0c2f80e4 | ||
|  | 215f251572 | ||
|  | a425ec94e0 | ||
|  | 91961bdffe | ||
|  | f741dff042 | ||
|  | 7a31761c89 | ||
|  | d5ca73c22f | ||
|  | 6704b2ca5a | ||
|  | e0bbaceec0 | ||
|  | 45043b9ffc | ||
|  | a56b3737c7 | ||
|  | e59eeba0d2 | ||
|  | 838dfab45b | ||
|  | ddd44e6f62 | ||
|  | 1390139cbd | ||
|  | f72653c3c1 | ||
|  | 4b9cd22405 | ||
|  | 38bda0c834 | ||
|  | 45c86f12dd | ||
|  | e2e9ae94d7 | ||
|  | 4837f7fa35 | ||
|  | 7f054f8320 | ||
|  | ad7acde1f4 | ||
|  | e5c48a4bb7 | ||
|  | fb67617d63 | ||
|  | 8aa807eec6 | ||
|  | 0621ed064d | ||
|  | 9219f06c5a | ||
|  | 7b41b9b45a | ||
|  | 58c39d51f4 | ||
|  | d78e905411 | ||
|  | 7b10c2d0a3 | ||
|  | 9714824a5a | ||
|  | 3e9b909685 | ||
|  | 464f7de014 | ||
|  | da33b90f94 | ||
|  | 90194d4b6c | ||
|  | 45a83eaa3f | ||
|  | 37f87e2511 | ||
|  | bd9184db01 | ||
|  | 101bffd01f | ||
|  | 43085a3608 | ||
|  | 3de7a17105 | ||
|  | c229e77151 | ||
|  | af370721d4 | ||
|  | 79fa8efc6a | ||
|  | d5dec38d62 | ||
|  | 74847c9bed | 
							
								
								
									
										2
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										2
									
								
								Makefile
									
									
									
									
									
								
							| @@ -28,7 +28,7 @@ LIBPLACEBO ?= 1 | |||||||
| LIBPLACEBO_GL ?= 0 | LIBPLACEBO_GL ?= 0 | ||||||
|  |  | ||||||
| # use YADIF deint - only available with cuvid | # use YADIF deint - only available with cuvid | ||||||
| #YADIF = 1 | YADIF = 1 | ||||||
|  |  | ||||||
| # use gamma correction | # use gamma correction | ||||||
| #GAMMA ?= 0 | #GAMMA ?= 0 | ||||||
|   | |||||||
| @@ -37,7 +37,6 @@ A software and GPU emulated UHD output device plugin for VDR. | |||||||
|     o PIP (Picture-in-Picture) (only for CUVID) |     o PIP (Picture-in-Picture) (only for CUVID) | ||||||
|  |  | ||||||
|  |  | ||||||
| To compile you must have the 'requires' installed. |  | ||||||
|  |  | ||||||
|  |  | ||||||
| This is a fork of johns original softhddevice work and I reworked it to support HEVC with CUDA and opengl output. | This is a fork of johns original softhddevice work and I reworked it to support HEVC with CUDA and opengl output. | ||||||
| @@ -83,7 +82,6 @@ You have to adapt the Makefile. There are 3 possible Version that you can build: | |||||||
|     runs without X Server. There are several commandline options to select the resolution and refresh rate. |     runs without X Server. There are several commandline options to select the resolution and refresh rate. | ||||||
|     I recommend to use libplacebo and set LIBPLACEBO_GL=1 in the Makefile. |     I recommend to use libplacebo and set LIBPLACEBO_GL=1 in the Makefile. | ||||||
|  |  | ||||||
|     Libplacebo API Version >= 113 is needed. |  | ||||||
|  |  | ||||||
|  |  | ||||||
| Install: | Install: | ||||||
| @@ -122,6 +120,9 @@ Beginners Guide for libplacebo: | |||||||
|  |  | ||||||
|     All other settings can be in their default state. |     All other settings can be in their default state. | ||||||
|  |  | ||||||
|  | 	Note for NUC11/12 Users: | ||||||
|  | 	Provide paramete -w alsa-no-test to get Audio working. | ||||||
|  |  | ||||||
|     Beginning with libplacebo API 58 user shaders from mpv are supported. Use -S parameter to set the shader. |     Beginning with libplacebo API 58 user shaders from mpv are supported. Use -S parameter to set the shader. | ||||||
|     The plugins searches the shaders in $ConfigDir/plugins/shaders for the shaders. One example shader is |     The plugins searches the shaders in $ConfigDir/plugins/shaders for the shaders. One example shader is | ||||||
|     provided in the shader subdirectory. Copy it to e.g.: /etc/vdr/plugins/shaders and then start |     provided in the shader subdirectory. Copy it to e.g.: /etc/vdr/plugins/shaders and then start | ||||||
|   | |||||||
							
								
								
									
										63
									
								
								audio.c
									
									
									
									
									
								
							
							
						
						
									
										63
									
								
								audio.c
									
									
									
									
									
								
							| @@ -93,6 +93,7 @@ static const AudioModule NoopModule; ///< forward definition of noop module | |||||||
| //  Variables | //  Variables | ||||||
| //---------------------------------------------------------------------------- | //---------------------------------------------------------------------------- | ||||||
|  |  | ||||||
|  | char AudioAlsaNotest;          ///< disable Audio capbility test | ||||||
| char AudioAlsaDriverBroken;   ///< disable broken driver message | char AudioAlsaDriverBroken;   ///< disable broken driver message | ||||||
| char AudioAlsaNoCloseOpen;    ///< disable alsa close/open fix | char AudioAlsaNoCloseOpen;    ///< disable alsa close/open fix | ||||||
| char AudioAlsaCloseOpenDelay; ///< enable alsa close/open delay fix | char AudioAlsaCloseOpenDelay; ///< enable alsa close/open delay fix | ||||||
| @@ -927,6 +928,7 @@ static snd_pcm_t *AlsaOpenPCM(int passthrough) { | |||||||
|     const char *device; |     const char *device; | ||||||
|     snd_pcm_t *handle; |     snd_pcm_t *handle; | ||||||
|     int err; |     int err; | ||||||
|  |     char tmp[80]; | ||||||
|  |  | ||||||
|     // &&|| hell |     // &&|| hell | ||||||
|     if (!(passthrough && ((device = AudioPassthroughDevice) || (device = getenv("ALSA_PASSTHROUGH_DEVICE")))) && |     if (!(passthrough && ((device = AudioPassthroughDevice) || (device = getenv("ALSA_PASSTHROUGH_DEVICE")))) && | ||||||
| @@ -936,31 +938,43 @@ static snd_pcm_t *AlsaOpenPCM(int passthrough) { | |||||||
|     if (!AudioDoingInit) { // reduce blabla during init |     if (!AudioDoingInit) { // reduce blabla during init | ||||||
|         Info(_("audio/alsa: using %sdevice '%s'\n"), passthrough ? "pass-through " : "", device); |         Info(_("audio/alsa: using %sdevice '%s'\n"), passthrough ? "pass-through " : "", device); | ||||||
|     } |     } | ||||||
|  |     //printf("audio/alsa: using %sdevice '%s'\n", passthrough ? "pass-through " : "", device); | ||||||
|  |      | ||||||
|     // |     // | ||||||
|     // for AC3 pass-through try to set the non-audio bit, use AES0=6 |     // for AC3 pass-through try to set the non-audio bit, use AES0=6 | ||||||
|     // |     // | ||||||
|     if (passthrough && AudioAppendAES) { |     if (passthrough && AudioAppendAES) { | ||||||
| #if 0 |         if (!(strchr(device, ':'))) { | ||||||
| 	// FIXME: not yet finished |             sprintf(tmp, | ||||||
| 	char *buf; |                         //"AES0=%d,AES1=%d,AES2=0,AES3=%d", | ||||||
| 	const char *s; |                         "%s:AES0=%d,AES1=%d,AES2=0", | ||||||
| 	int n; |                         device, | ||||||
|  |                         IEC958_AES0_NONAUDIO | IEC958_AES0_PRO_EMPHASIS_NONE, | ||||||
|  |                         IEC958_AES1_CON_ORIGINAL | IEC958_AES1_CON_PCM_CODER); | ||||||
|  |                         //map_iec958_srate(ao->samplerate)); | ||||||
|  |         }  | ||||||
|  |         else { | ||||||
|  |             sprintf(tmp, | ||||||
|  |                         //"AES0=%d,AES1=%d,AES2=0,AES3=%d", | ||||||
|  |                         "%s,AES0=%d,AES1=%d,AES2=0", | ||||||
|  |                         device, | ||||||
|  |                         IEC958_AES0_NONAUDIO | IEC958_AES0_PRO_EMPHASIS_NONE, | ||||||
|  |                         IEC958_AES1_CON_ORIGINAL | IEC958_AES1_CON_PCM_CODER); | ||||||
|  |                         //map_iec958_srate(ao->samplerate)); | ||||||
|  |         } | ||||||
|          |          | ||||||
| 	n = strlen(device); |         printf( "opening device '%s' => '%s'\n", device, tmp); | ||||||
| 	buf = alloca(n + sizeof(":AES0=6") + 1); |         if ((err = snd_pcm_open(&handle, tmp, SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK)) < 0 ) { | ||||||
| 	strcpy(buf, device); |             Error(_("audio/alsa: playback open '%s' error: %s\n"), device, snd_strerror(err)); | ||||||
| 	if (!(s = strchr(buf, ':'))) { |             return NULL; | ||||||
| 	    // no alsa parameters |  | ||||||
| 	    strcpy(buf + n, ":AES=6"); |  | ||||||
| 	} |  | ||||||
| 	Debug(3, "audio/alsa: try '%s'\n", buf); |  | ||||||
| #endif |  | ||||||
|         }  |         }  | ||||||
|  |     } else { | ||||||
|         // open none blocking; if device is already used, we don't want wait |         // open none blocking; if device is already used, we don't want wait | ||||||
|         if ((err = snd_pcm_open(&handle, device, SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK)) < 0) { |         if ((err = snd_pcm_open(&handle, device, SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK)) < 0) { | ||||||
|             Error(_("audio/alsa: playback open '%s' error: %s\n"), device, snd_strerror(err)); |             Error(_("audio/alsa: playback open '%s' error: %s\n"), device, snd_strerror(err)); | ||||||
|             return NULL; |             return NULL; | ||||||
|         } |         } | ||||||
|  |     } | ||||||
|  |  | ||||||
|     if ((err = snd_pcm_nonblock(handle, 0)) < 0) { |     if ((err = snd_pcm_nonblock(handle, 0)) < 0) { | ||||||
|         Error(_("audio/alsa: can't set block mode: %s\n"), snd_strerror(err)); |         Error(_("audio/alsa: can't set block mode: %s\n"), snd_strerror(err)); | ||||||
| @@ -2173,6 +2187,24 @@ found: | |||||||
|     AudioDoingInit = 1; |     AudioDoingInit = 1; | ||||||
|     AudioRingInit(); |     AudioRingInit(); | ||||||
|     AudioUsedModule->Init(); |     AudioUsedModule->Init(); | ||||||
|  |  | ||||||
|  |     if (AudioAlsaNotest) { | ||||||
|  |         for (u = 0; u < AudioRatesMax; ++u) { | ||||||
|  |          | ||||||
|  |             AudioChannelMatrix[u][1]=AudioChannelMatrix[u][2]=2; | ||||||
|  |             AudioChannelMatrix[u][3]=AudioChannelMatrix[u][4]=4; | ||||||
|  |             AudioChannelMatrix[u][5]=AudioChannelMatrix[u][6]=6; | ||||||
|  |             AudioChannelMatrix[u][7]=AudioChannelMatrix[u][8]=8; | ||||||
|  |             printf("audio: %6dHz supports %d %d %d %d %d %d %d %d channels\n", AudioRatesTable[u], | ||||||
|  |                 AudioChannelMatrix[u][1], AudioChannelMatrix[u][2], AudioChannelMatrix[u][3], AudioChannelMatrix[u][4], | ||||||
|  |                 AudioChannelMatrix[u][5], AudioChannelMatrix[u][6], AudioChannelMatrix[u][7], AudioChannelMatrix[u][8]); | ||||||
|  |  | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         AudioChannelsInHw[1]=AudioChannelsInHw[3]=AudioChannelsInHw[4]=AudioChannelsInHw[5]=AudioChannelsInHw[6]=AudioChannelsInHw[7]=AudioChannelsInHw[8]=0; | ||||||
|  |         AudioChannelsInHw[2]=2; | ||||||
|  |     } | ||||||
|  |     else { | ||||||
|         // |         // | ||||||
|         //	Check which channels/rates/formats are supported |         //	Check which channels/rates/formats are supported | ||||||
|         //	FIXME: we force 44.1Khz and 48Khz must be supported equal |         //	FIXME: we force 44.1Khz and 48Khz must be supported equal | ||||||
| @@ -2290,10 +2322,11 @@ found: | |||||||
|             } |             } | ||||||
|         } |         } | ||||||
|         for (u = 0; u < AudioRatesMax; ++u) { |         for (u = 0; u < AudioRatesMax; ++u) { | ||||||
|         Info(_("audio: %6dHz supports %d %d %d %d %d %d %d %d channels\n"), AudioRatesTable[u], |             Debug(3,"audio: %6dHz supports %d %d %d %d %d %d %d %d channels\n", AudioRatesTable[u], | ||||||
|                 AudioChannelMatrix[u][1], AudioChannelMatrix[u][2], AudioChannelMatrix[u][3], AudioChannelMatrix[u][4], |                 AudioChannelMatrix[u][1], AudioChannelMatrix[u][2], AudioChannelMatrix[u][3], AudioChannelMatrix[u][4], | ||||||
|                 AudioChannelMatrix[u][5], AudioChannelMatrix[u][6], AudioChannelMatrix[u][7], AudioChannelMatrix[u][8]); |                 AudioChannelMatrix[u][5], AudioChannelMatrix[u][6], AudioChannelMatrix[u][7], AudioChannelMatrix[u][8]); | ||||||
|         } |         } | ||||||
|  |     } | ||||||
| #ifdef USE_AUDIO_THREAD | #ifdef USE_AUDIO_THREAD | ||||||
|     if (AudioUsedModule->Thread) { // supports threads |     if (AudioUsedModule->Thread) { // supports threads | ||||||
|         AudioInitThread(); |         AudioInitThread(); | ||||||
|   | |||||||
							
								
								
									
										1
									
								
								audio.h
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								audio.h
									
									
									
									
									
								
							| @@ -60,6 +60,7 @@ extern void AudioExit(void);               ///< cleanup and exit audio module | |||||||
| //  Variables | //  Variables | ||||||
| //---------------------------------------------------------------------------- | //---------------------------------------------------------------------------- | ||||||
|  |  | ||||||
|  | extern char AudioAlsaNotest;         ///< disable Alsa capability test | ||||||
| extern char AudioAlsaDriverBroken;   ///< disable broken driver message | extern char AudioAlsaDriverBroken;   ///< disable broken driver message | ||||||
| extern char AudioAlsaNoCloseOpen;    ///< disable alsa close/open fix | extern char AudioAlsaNoCloseOpen;    ///< disable alsa close/open fix | ||||||
| extern char AudioAlsaCloseOpenDelay; ///< enable alsa close/open delay fix | extern char AudioAlsaCloseOpenDelay; ///< enable alsa close/open delay fix | ||||||
|   | |||||||
							
								
								
									
										70
									
								
								codec.c
									
									
									
									
									
								
							
							
						
						
									
										70
									
								
								codec.c
									
									
									
									
									
								
							| @@ -234,20 +234,6 @@ void CodecVideoOpen(VideoDecoder *decoder, int codec_id) { | |||||||
|                 break; |                 break; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| #endif |  | ||||||
| #ifdef RASPI |  | ||||||
|     switch (codec_id) { |  | ||||||
|         case AV_CODEC_ID_MPEG2VIDEO: |  | ||||||
|             name = "mpeg2_v4l2m2m"; |  | ||||||
|             break; |  | ||||||
|         case AV_CODEC_ID_H264: |  | ||||||
|             name = "h264_v4l2m2m"; |  | ||||||
|             //	name = "h264_mmal"; |  | ||||||
|             break; |  | ||||||
|         case AV_CODEC_ID_HEVC: |  | ||||||
|             name = "hevc_v4l2m2m"; |  | ||||||
|             break; |  | ||||||
|     } |  | ||||||
| #endif | #endif | ||||||
|     if (name && (video_codec = avcodec_find_decoder_by_name(name))) { |     if (name && (video_codec = avcodec_find_decoder_by_name(name))) { | ||||||
|         Debug(3, "codec: decoder found\n"); |         Debug(3, "codec: decoder found\n"); | ||||||
| @@ -264,31 +250,27 @@ void CodecVideoOpen(VideoDecoder *decoder, int codec_id) { | |||||||
|         Fatal(_("codec: can't allocate video codec context\n")); |         Fatal(_("codec: can't allocate video codec context\n")); | ||||||
|     } |     } | ||||||
|  |  | ||||||
| #ifndef RASPI |  | ||||||
|     if (!HwDeviceContext) { |     if (!HwDeviceContext) { | ||||||
|         Fatal("codec: no hw device context to be used"); |         Fatal("codec: no hw device context to be used"); | ||||||
|     } |     } | ||||||
|     decoder->VideoCtx->hw_device_ctx = av_buffer_ref(HwDeviceContext); |     decoder->VideoCtx->hw_device_ctx = av_buffer_ref(HwDeviceContext); | ||||||
| #else |  | ||||||
|     decoder->VideoCtx->pix_fmt = AV_PIX_FMT_DRM_PRIME; /* request a DRM frame */ |  | ||||||
|     //	decoder->VideoCtx->pix_fmt = AV_PIX_FMT_MMAL;	/* request a DRM frame |  | ||||||
|     //*/ |  | ||||||
| #endif |  | ||||||
|  |  | ||||||
|     // FIXME: for software decoder use all cpus, otherwise 1 |     // FIXME: for software decoder use all cpus, otherwise 1 | ||||||
|     decoder->VideoCtx->thread_count = 1; |     decoder->VideoCtx->thread_count = 1; | ||||||
|  |  | ||||||
|     decoder->VideoCtx->pkt_timebase.num = 1; |     decoder->VideoCtx->pkt_timebase.num = 1; | ||||||
|     decoder->VideoCtx->pkt_timebase.den = 90000; |     decoder->VideoCtx->pkt_timebase.den = 90000; | ||||||
|     decoder->VideoCtx->framerate.num = 50; |     //decoder->VideoCtx->framerate.num = 50; | ||||||
|     decoder->VideoCtx->framerate.den = 1; |     //decoder->VideoCtx->framerate.den = 1; | ||||||
|  |  | ||||||
|     pthread_mutex_lock(&CodecLockMutex); |     pthread_mutex_lock(&CodecLockMutex); | ||||||
|     // open codec |     // open codec | ||||||
| #ifdef YADIF | #ifdef YADIF | ||||||
|     deint = 2; |     deint = 2; | ||||||
| #endif | #endif | ||||||
| #if defined VAAPI && !defined RASPI |  | ||||||
|  | #if defined VAAPI | ||||||
|  | #if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59,8,100) | ||||||
|     // decoder->VideoCtx->extra_hw_frames = 8; // VIDEO_SURFACES_MAX +1 |     // decoder->VideoCtx->extra_hw_frames = 8; // VIDEO_SURFACES_MAX +1 | ||||||
|     if (video_codec->capabilities & (AV_CODEC_CAP_AUTO_THREADS)) { |     if (video_codec->capabilities & (AV_CODEC_CAP_AUTO_THREADS)) { | ||||||
|         Debug(3, "codec: auto threads enabled"); |         Debug(3, "codec: auto threads enabled"); | ||||||
| @@ -299,6 +281,7 @@ void CodecVideoOpen(VideoDecoder *decoder, int codec_id) { | |||||||
|         Debug(3, "codec: supports truncated packets"); |         Debug(3, "codec: supports truncated packets"); | ||||||
|         // decoder->VideoCtx->flags |= CODEC_FLAG_TRUNCATED; |         // decoder->VideoCtx->flags |= CODEC_FLAG_TRUNCATED; | ||||||
|     } |     } | ||||||
|  | #endif | ||||||
|     // FIXME: own memory management for video frames. |     // FIXME: own memory management for video frames. | ||||||
|     if (video_codec->capabilities & AV_CODEC_CAP_DR1) { |     if (video_codec->capabilities & AV_CODEC_CAP_DR1) { | ||||||
|         Debug(3, "codec: can use own buffer management"); |         Debug(3, "codec: can use own buffer management"); | ||||||
| @@ -315,22 +298,10 @@ void CodecVideoOpen(VideoDecoder *decoder, int codec_id) { | |||||||
|     } |     } | ||||||
|     //    if (av_opt_set_int(decoder->VideoCtx, "refcounted_frames", 1, 0) < 0) |     //    if (av_opt_set_int(decoder->VideoCtx, "refcounted_frames", 1, 0) < 0) | ||||||
|     //	  Fatal(_("VAAPI Refcounts invalid\n")); |     //	  Fatal(_("VAAPI Refcounts invalid\n")); | ||||||
|  | #if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59,8,100) | ||||||
|     decoder->VideoCtx->thread_safe_callbacks = 0; |     decoder->VideoCtx->thread_safe_callbacks = 0; | ||||||
|  |  | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| #ifdef RASPI |  | ||||||
|     decoder->VideoCtx->codec_id = codec_id; |  | ||||||
|     decoder->VideoCtx->flags |= AV_CODEC_FLAG_BITEXACT; |  | ||||||
|     if (video_codec->capabilities & AV_CODEC_CAP_FRAME_THREADS || AV_CODEC_CAP_SLICE_THREADS) { |  | ||||||
|         Debug(3, "codec: supports frame threads"); |  | ||||||
|         decoder->VideoCtx->thread_count = 4; |  | ||||||
|         //   decoder->VideoCtx->thread_type |= FF_THREAD_FRAME; |  | ||||||
|     } |  | ||||||
|     if (video_codec->capabilities & AV_CODEC_CAP_SLICE_THREADS) { |  | ||||||
|         Debug(3, "codec: supports slice threads"); |  | ||||||
|         decoder->VideoCtx->thread_type |= FF_THREAD_SLICE; |  | ||||||
|     } |  | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| #ifdef CUVID | #ifdef CUVID | ||||||
| @@ -340,12 +311,12 @@ void CodecVideoOpen(VideoDecoder *decoder, int codec_id) { | |||||||
|             pthread_mutex_unlock(&CodecLockMutex); |             pthread_mutex_unlock(&CodecLockMutex); | ||||||
|             Fatal(_("codec: can't set option deint to video codec!\n")); |             Fatal(_("codec: can't set option deint to video codec!\n")); | ||||||
|         } |         } | ||||||
| #if 1 |  | ||||||
|         if (av_opt_set_int(decoder->VideoCtx->priv_data, "surfaces", 9, 0) < 0) { |         if (av_opt_set_int(decoder->VideoCtx->priv_data, "surfaces", 10, 0) < 0) { | ||||||
|             pthread_mutex_unlock(&CodecLockMutex); |             pthread_mutex_unlock(&CodecLockMutex); | ||||||
|             Fatal(_("codec: can't set option surfces to video codec!\n")); |             Fatal(_("codec: can't set option surfces to video codec!\n")); | ||||||
|         } |         } | ||||||
| #endif |  | ||||||
|         if (av_opt_set(decoder->VideoCtx->priv_data, "drop_second_field", "false", 0) < 0) { |         if (av_opt_set(decoder->VideoCtx->priv_data, "drop_second_field", "false", 0) < 0) { | ||||||
|             pthread_mutex_unlock(&CodecLockMutex); |             pthread_mutex_unlock(&CodecLockMutex); | ||||||
|             Fatal(_("codec: can't set option drop 2.field to video codec!\n")); |             Fatal(_("codec: can't set option drop 2.field to video codec!\n")); | ||||||
| @@ -355,12 +326,10 @@ void CodecVideoOpen(VideoDecoder *decoder, int codec_id) { | |||||||
|             pthread_mutex_unlock(&CodecLockMutex); |             pthread_mutex_unlock(&CodecLockMutex); | ||||||
|             Fatal(_("codec: can't set option deint to video codec!\n")); |             Fatal(_("codec: can't set option deint to video codec!\n")); | ||||||
|         } |         } | ||||||
| #if 1 |  | ||||||
|         if (av_opt_set_int(decoder->VideoCtx->priv_data, "surfaces", 13, 0) < 0) { |         if (av_opt_set_int(decoder->VideoCtx->priv_data, "surfaces", 13, 0) < 0) { | ||||||
|             pthread_mutex_unlock(&CodecLockMutex); |             pthread_mutex_unlock(&CodecLockMutex); | ||||||
|             Fatal(_("codec: can't set option surfces to video codec!\n")); |             Fatal(_("codec: can't set option surfces to video codec!\n")); | ||||||
|         } |         } | ||||||
| #endif |  | ||||||
|         if (av_opt_set(decoder->VideoCtx->priv_data, "drop_second_field", "false", 0) < 0) { |         if (av_opt_set(decoder->VideoCtx->priv_data, "drop_second_field", "false", 0) < 0) { | ||||||
|             pthread_mutex_unlock(&CodecLockMutex); |             pthread_mutex_unlock(&CodecLockMutex); | ||||||
|             Fatal(_("codec: can't set option drop 2.field  to video codec!\n")); |             Fatal(_("codec: can't set option drop 2.field  to video codec!\n")); | ||||||
| @@ -401,7 +370,7 @@ void CodecVideoOpen(VideoDecoder *decoder, int codec_id) { | |||||||
|  |  | ||||||
|     // reset buggy ffmpeg/libav flag |     // reset buggy ffmpeg/libav flag | ||||||
|     decoder->GetFormatDone = 0; |     decoder->GetFormatDone = 0; | ||||||
| #if defined(YADIF) || defined(RASPI) | #if defined(YADIF) | ||||||
|     decoder->filter = 0; |     decoder->filter = 0; | ||||||
| #endif | #endif | ||||||
| } | } | ||||||
| @@ -521,8 +490,7 @@ void CodecVideoDecode(VideoDecoder *decoder, const AVPacket *avpkt) { | |||||||
|                             decoder->filter = 2; |                             decoder->filter = 2; | ||||||
|                         } |                         } | ||||||
|                     } |                     } | ||||||
|                     if (frame->interlaced_frame && decoder->filter == 2 && |                     if (decoder->filter == 2) {  | ||||||
|                         (frame->height != 720)) { // broken ZDF sends Interlaced flag |  | ||||||
|                         push_filters(video_ctx, decoder->HwDecoder, frame); |                         push_filters(video_ctx, decoder->HwDecoder, frame); | ||||||
|                         continue; |                         continue; | ||||||
|                     } |                     } | ||||||
| @@ -554,7 +522,6 @@ next_part: | |||||||
|     pkt = avpkt; // use copy |     pkt = avpkt; // use copy | ||||||
|     got_frame = 0; |     got_frame = 0; | ||||||
|  |  | ||||||
|     // printf("decode packet  %d\n",(GetusTicks()-first_time)/1000000); |  | ||||||
|     ret1 = avcodec_send_packet(video_ctx, pkt); |     ret1 = avcodec_send_packet(video_ctx, pkt); | ||||||
|  |  | ||||||
|     // first_time = GetusTicks(); |     // first_time = GetusTicks(); | ||||||
| @@ -574,12 +541,12 @@ 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; | ||||||
|                 got_frame = 1; |                 got_frame = 1; | ||||||
|             } else { |             } else { | ||||||
|                 got_frame = 0; |                 got_frame = 0; | ||||||
|             } |             } | ||||||
|             //		  printf("got %s packet from |             //printf("got %s packet from decoder\n",got_frame?"1":"no"); | ||||||
|             // decoder\n",got_frame?"1":"no"); |  | ||||||
|             if (got_frame) { // frame completed |             if (got_frame) { // frame completed | ||||||
| //		printf("video frame pts %#012" PRIx64 " | //		printf("video frame pts %#012" PRIx64 " | ||||||
| //%dms\n",frame->pts,(int)(apts - frame->pts) / 90); | //%dms\n",frame->pts,(int)(apts - frame->pts) / 90); | ||||||
| @@ -587,15 +554,14 @@ next_part: | |||||||
|                 if (decoder->filter) { |                 if (decoder->filter) { | ||||||
|                     if (decoder->filter == 1) { |                     if (decoder->filter == 1) { | ||||||
|                         if (init_filters(video_ctx, decoder->HwDecoder, frame) < 0) { |                         if (init_filters(video_ctx, decoder->HwDecoder, frame) < 0) { | ||||||
|                             Fatal(_("video: Init of YADIF Filter failed\n")); |                             Debug(3,"video: Init of YADIF Filter failed\n"); | ||||||
|                             decoder->filter = 0; |                             decoder->filter = 0; | ||||||
|                         } else { |                         } else { | ||||||
|                             Debug(3, "Init YADIF ok\n"); |                             Debug(3, "Init YADIF ok\n"); | ||||||
|                             decoder->filter = 2; |                             decoder->filter = 2; | ||||||
|                         } |                         } | ||||||
|                     } |                     } | ||||||
|                     if (frame->interlaced_frame && decoder->filter == 2 && |                     if (decoder->filter == 2) {  | ||||||
|                         (frame->height != 720)) { // broken ZDF sends Interlaced flag |  | ||||||
|                         ret = push_filters(video_ctx, decoder->HwDecoder, frame); |                         ret = push_filters(video_ctx, decoder->HwDecoder, frame); | ||||||
|                         // av_frame_unref(frame); |                         // av_frame_unref(frame); | ||||||
|                         continue; |                         continue; | ||||||
| @@ -905,7 +871,7 @@ 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: format change %s %dHz *%d channels%s%s%s%s%s\n", |     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, |           av_get_sample_fmt_name(audio_ctx->sample_fmt), audio_ctx->sample_rate, audio_ctx->channels, | ||||||
|           CodecPassthrough & CodecPCM ? " PCM" : "", CodecPassthrough & CodecMPA ? " MPA" : "", |           CodecPassthrough & CodecPCM ? " PCM" : "", CodecPassthrough & CodecMPA ? " MPA" : "", | ||||||
|           CodecPassthrough & CodecAC3 ? " AC-3" : "", CodecPassthrough & CodecEAC3 ? " E-AC-3" : "", |           CodecPassthrough & CodecAC3 ? " AC-3" : "", CodecPassthrough & CodecEAC3 ? " E-AC-3" : "", | ||||||
| @@ -923,7 +889,7 @@ static int CodecAudioUpdateHelper(AudioDecoder *audio_decoder, int *passthrough) | |||||||
|         (CodecPassthrough & CodecEAC3 && audio_ctx->codec_id == AV_CODEC_ID_EAC3)) { |         (CodecPassthrough & CodecEAC3 && audio_ctx->codec_id == AV_CODEC_ID_EAC3)) { | ||||||
|         if (audio_ctx->codec_id == AV_CODEC_ID_EAC3) { |         if (audio_ctx->codec_id == AV_CODEC_ID_EAC3) { | ||||||
|             // E-AC-3 over HDMI some receivers need HBR |             // E-AC-3 over HDMI some receivers need HBR | ||||||
|             audio_decoder->HwSampleRate *= 4; |             //audio_decoder->HwSampleRate *= 4; | ||||||
|         } |         } | ||||||
|         audio_decoder->HwChannels = 2; |         audio_decoder->HwChannels = 2; | ||||||
|         audio_decoder->SpdifIndex = 0; // reset buffer |         audio_decoder->SpdifIndex = 0; // reset buffer | ||||||
|   | |||||||
							
								
								
									
										23
									
								
								drm.c
									
									
									
									
									
								
							
							
						
						
									
										23
									
								
								drm.c
									
									
									
									
									
								
							| @@ -168,6 +168,7 @@ void set_video_mode(int width, int height) { | |||||||
|     drmModeConnector *connector; |     drmModeConnector *connector; | ||||||
|     drmModeModeInfo *mode; |     drmModeModeInfo *mode; | ||||||
|     int ii; |     int ii; | ||||||
|  |     printf("Set video mode %d &%d\n",width,height); | ||||||
|     if (height != 1080 && height != 2160) |     if (height != 1080 && height != 2160) | ||||||
|         return; |         return; | ||||||
|     connector = drmModeGetConnector(render->fd_drm, render->connector_id); |     connector = drmModeGetConnector(render->fd_drm, render->connector_id); | ||||||
| @@ -206,11 +207,7 @@ static int FindDevice(VideoRender *render) { | |||||||
|     int i, ii = 0; |     int i, ii = 0; | ||||||
|     char connectorstr[10]; |     char connectorstr[10]; | ||||||
|     int found = 0; |     int found = 0; | ||||||
| #ifdef RASPI |  | ||||||
|     render->fd_drm = open("/dev/dri/card1", O_RDWR); |  | ||||||
| #else |  | ||||||
|     render->fd_drm = open("/dev/dri/card0", O_RDWR); |     render->fd_drm = open("/dev/dri/card0", O_RDWR); | ||||||
| #endif |  | ||||||
|     if (render->fd_drm < 0) { |     if (render->fd_drm < 0) { | ||||||
|         fprintf(stderr, "FindDevice: cannot open /dev/dri/card0: %m\n"); |         fprintf(stderr, "FindDevice: cannot open /dev/dri/card0: %m\n"); | ||||||
|         return -errno; |         return -errno; | ||||||
| @@ -278,10 +275,12 @@ static int FindDevice(VideoRender *render) { | |||||||
|                 connector->connector_type_id); |                 connector->connector_type_id); | ||||||
|         printf("Connector >%s< is %sconnected\n", connectorstr, |         printf("Connector >%s< is %sconnected\n", connectorstr, | ||||||
|                connector->connection == DRM_MODE_CONNECTED ? "" : "not "); |                connector->connection == DRM_MODE_CONNECTED ? "" : "not "); | ||||||
|  |         Debug(3,"Connector >%s< is %sconnected\n", connectorstr, | ||||||
|  |                connector->connection == DRM_MODE_CONNECTED ? "" : "not "); | ||||||
|         if (DRMConnector && strcmp(DRMConnector, connectorstr)) |         if (DRMConnector && strcmp(DRMConnector, connectorstr)) | ||||||
|             continue; |             continue; | ||||||
|  |  | ||||||
|         if (connector->connection == DRM_MODE_CONNECTED && connector->count_modes > 0) { |         if (/*connector->connection == DRM_MODE_CONNECTED && */ connector->count_modes > 0) { | ||||||
|             float aspect = (float)connector->mmWidth / (float)connector->mmHeight; |             float aspect = (float)connector->mmWidth / (float)connector->mmHeight; | ||||||
|             if ((aspect > 1.70) && (aspect < 1.85)) { |             if ((aspect > 1.70) && (aspect < 1.85)) { | ||||||
|                 render->mmHeight = 90; |                 render->mmHeight = 90; | ||||||
| @@ -309,7 +308,7 @@ static int FindDevice(VideoRender *render) { | |||||||
|                 mode = &connector->modes[ii]; |                 mode = &connector->modes[ii]; | ||||||
|  |  | ||||||
|                 printf("Mode %d %dx%d Rate %d\n", ii, mode->hdisplay, mode->vdisplay, mode->vrefresh); |                 printf("Mode %d %dx%d Rate %d\n", ii, mode->hdisplay, mode->vdisplay, mode->vrefresh); | ||||||
|  |                 Debug(3,"Mode %d %dx%d Rate %d\n", ii, mode->hdisplay, mode->vdisplay, mode->vrefresh); | ||||||
|                 if (VideoWindowWidth && VideoWindowHeight) { // preset by command line |                 if (VideoWindowWidth && VideoWindowHeight) { // preset by command line | ||||||
|                     if (VideoWindowWidth == mode->hdisplay && VideoWindowHeight == mode->vdisplay && |                     if (VideoWindowWidth == mode->hdisplay && VideoWindowHeight == mode->vdisplay && | ||||||
|                         mode->vrefresh == DRMRefresh && !(mode->flags & DRM_MODE_FLAG_INTERLACE)) { |                         mode->vrefresh == DRMRefresh && !(mode->flags & DRM_MODE_FLAG_INTERLACE)) { | ||||||
| @@ -328,11 +327,16 @@ static int FindDevice(VideoRender *render) { | |||||||
|             found = 1; |             found = 1; | ||||||
|             i = resources->count_connectors; // uuuuhh |             i = resources->count_connectors; // uuuuhh | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  |         if (found) { | ||||||
|             VideoWindowWidth = render->mode.hdisplay; |             VideoWindowWidth = render->mode.hdisplay; | ||||||
|             VideoWindowHeight = render->mode.vdisplay; |             VideoWindowHeight = render->mode.vdisplay; | ||||||
|         if (found) |          | ||||||
|             printf("Use Mode %d %dx%d Rate %d\n", ii, render->mode.hdisplay, render->mode.vdisplay, |             printf("Use Mode %d %dx%d Rate %d\n", ii, render->mode.hdisplay, render->mode.vdisplay, | ||||||
|                    render->mode.vrefresh); |                    render->mode.vrefresh); | ||||||
|  |             Debug(3,"Use Mode %d %dx%d Rate %d\n", ii, render->mode.hdisplay, render->mode.vdisplay, | ||||||
|  |                    render->mode.vrefresh); | ||||||
|  |         } | ||||||
|         drmModeFreeConnector(connector); |         drmModeFreeConnector(connector); | ||||||
|     } |     } | ||||||
|     if (!found) { |     if (!found) { | ||||||
| @@ -372,11 +376,7 @@ static int FindDevice(VideoRender *render) { | |||||||
|         for (k = 0; k < plane->count_formats; k++) { |         for (k = 0; k < plane->count_formats; k++) { | ||||||
|             if (encoder->possible_crtcs & plane->possible_crtcs) { |             if (encoder->possible_crtcs & plane->possible_crtcs) { | ||||||
|                 switch (plane->formats[k]) { |                 switch (plane->formats[k]) { | ||||||
| #ifdef RASPI |  | ||||||
|                     case DRM_FORMAT_ARGB8888: |  | ||||||
| #else |  | ||||||
|                     case DRM_FORMAT_XRGB2101010: |                     case DRM_FORMAT_XRGB2101010: | ||||||
| #endif |  | ||||||
|                         if (!render->video_plane) { |                         if (!render->video_plane) { | ||||||
|                             render->video_plane = plane->plane_id; |                             render->video_plane = plane->plane_id; | ||||||
|                         } |                         } | ||||||
| @@ -492,6 +492,7 @@ static void drm_swap_buffers() { | |||||||
|     uint32_t fb; |     uint32_t fb; | ||||||
|  |  | ||||||
|     eglSwapBuffers(eglDisplay, eglSurface); |     eglSwapBuffers(eglDisplay, eglSurface); | ||||||
|  |     usleep(1000); | ||||||
|     struct gbm_bo *bo = gbm_surface_lock_front_buffer(gbm.surface); |     struct gbm_bo *bo = gbm_surface_lock_front_buffer(gbm.surface); | ||||||
| #if 1 | #if 1 | ||||||
|     if (bo == NULL) |     if (bo == NULL) | ||||||
|   | |||||||
| @@ -20,11 +20,7 @@ void ConvertColor(const GLint &colARGB, glm::vec4 &col) { | |||||||
| #ifdef CUVID | #ifdef CUVID | ||||||
| const char *glversion = "#version 330 core "; | const char *glversion = "#version 330 core "; | ||||||
| #else | #else | ||||||
| #ifdef RASPI |  | ||||||
| const char *glversion = "#version 300 es  "; | const char *glversion = "#version 300 es  "; | ||||||
| #else |  | ||||||
| const char *glversion = "#version 300 es  "; |  | ||||||
| #endif |  | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| const char *rectVertexShader = "%s\n \ | const char *rectVertexShader = "%s\n \ | ||||||
| @@ -730,14 +726,15 @@ bool cOglCmdDeleteFb::Execute(void) { | |||||||
|  |  | ||||||
| //------------------ cOglCmdRenderFbToBufferFb -------------------- | //------------------ cOglCmdRenderFbToBufferFb -------------------- | ||||||
| cOglCmdRenderFbToBufferFb::cOglCmdRenderFbToBufferFb(cOglFb *fb, cOglFb *buffer, GLint x, GLint y, GLint transparency, | cOglCmdRenderFbToBufferFb::cOglCmdRenderFbToBufferFb(cOglFb *fb, cOglFb *buffer, GLint x, GLint y, GLint transparency, | ||||||
|                                                      GLint drawPortX, GLint drawPortY) |                                                      GLint drawPortX, GLint drawPortY, bool alphablending) | ||||||
|     : cOglCmd(fb) { |     : cOglCmd(fb) { | ||||||
|     this->buffer = buffer; |     this->buffer = buffer; | ||||||
|     this->x = (GLfloat)x; |     this->x = (GLfloat)x; | ||||||
|     this->y = (GLfloat)y; |     this->y = (GLfloat)y; | ||||||
|     this->drawPortX = (GLfloat)drawPortX; |     this->drawPortX = (GLfloat)drawPortX; | ||||||
|     this->drawPortY = (GLfloat)drawPortY; |     this->drawPortY = (GLfloat)drawPortY; | ||||||
|     this->transparency = transparency; |      this->transparency = (alphablending ? transparency : ALPHA_OPAQUE); | ||||||
|  |     this->alphablending = alphablending; | ||||||
| } | } | ||||||
|  |  | ||||||
| bool cOglCmdRenderFbToBufferFb::Execute(void) { | bool cOglCmdRenderFbToBufferFb::Execute(void) { | ||||||
| @@ -777,11 +774,14 @@ bool cOglCmdRenderFbToBufferFb::Execute(void) { | |||||||
|  |  | ||||||
|     if (!fb->BindTexture()) |     if (!fb->BindTexture()) | ||||||
|         return false; |         return false; | ||||||
|  |     if (!alphablending) | ||||||
|  |         VertexBuffers[vbTexture]->DisableBlending(); | ||||||
|     VertexBuffers[vbTexture]->Bind(); |     VertexBuffers[vbTexture]->Bind(); | ||||||
|     VertexBuffers[vbTexture]->SetVertexData(quadVertices); |     VertexBuffers[vbTexture]->SetVertexData(quadVertices); | ||||||
|     VertexBuffers[vbTexture]->DrawArrays(); |     VertexBuffers[vbTexture]->DrawArrays(); | ||||||
|     VertexBuffers[vbTexture]->Unbind(); |     VertexBuffers[vbTexture]->Unbind(); | ||||||
|  |     if (!alphablending) | ||||||
|  |         VertexBuffers[vbTexture]->EnableBlending(); | ||||||
|     buffer->Unbind(); |     buffer->Unbind(); | ||||||
|  |  | ||||||
|     return true; |     return true; | ||||||
| @@ -837,6 +837,8 @@ cOglCmdDrawRectangle::cOglCmdDrawRectangle(cOglFb *fb, GLint x, GLint y, GLint w | |||||||
| } | } | ||||||
|  |  | ||||||
| bool cOglCmdDrawRectangle::Execute(void) { | bool cOglCmdDrawRectangle::Execute(void) { | ||||||
|  |     if (width <= 0 || height <= 0) | ||||||
|  |         return false; | ||||||
|     GLfloat x1 = x; |     GLfloat x1 = x; | ||||||
|     GLfloat y1 = y; |     GLfloat y1 = y; | ||||||
|     GLfloat x2 = x + width; |     GLfloat x2 = x + width; | ||||||
| @@ -883,6 +885,8 @@ cOglCmdDrawEllipse::cOglCmdDrawEllipse(cOglFb *fb, GLint x, GLint y, GLint width | |||||||
| } | } | ||||||
|  |  | ||||||
| bool cOglCmdDrawEllipse::Execute(void) { | bool cOglCmdDrawEllipse::Execute(void) { | ||||||
|  |     if (width <= 0 || height <= 0) | ||||||
|  |         return false; | ||||||
|     int numVertices = 0; |     int numVertices = 0; | ||||||
|     GLfloat *vertices = NULL; |     GLfloat *vertices = NULL; | ||||||
|  |  | ||||||
| @@ -1090,6 +1094,8 @@ cOglCmdDrawSlope::cOglCmdDrawSlope(cOglFb *fb, GLint x, GLint y, GLint width, GL | |||||||
| } | } | ||||||
|  |  | ||||||
| bool cOglCmdDrawSlope::Execute(void) { | bool cOglCmdDrawSlope::Execute(void) { | ||||||
|  |     if (width <= 0 || height <= 0) | ||||||
|  |         return false; | ||||||
|     bool falling = type & 0x02; |     bool falling = type & 0x02; | ||||||
|     bool vertical = type & 0x04; |     bool vertical = type & 0x04; | ||||||
|  |  | ||||||
| @@ -1177,7 +1183,7 @@ cOglCmdDrawText::~cOglCmdDrawText(void) { free(symbols); } | |||||||
| bool cOglCmdDrawText::Execute(void) { | bool cOglCmdDrawText::Execute(void) { | ||||||
|     cOglFont *f = cOglFont::Get(*fontName, fontSize); |     cOglFont *f = cOglFont::Get(*fontName, fontSize); | ||||||
|  |  | ||||||
|     if (!f) |     if (!f || !symbols[0]) | ||||||
|         return false; |         return false; | ||||||
|  |  | ||||||
|     VertexBuffers[vbText]->ActivateShader(); |     VertexBuffers[vbText]->ActivateShader(); | ||||||
| @@ -1256,10 +1262,13 @@ cOglCmdDrawImage::cOglCmdDrawImage(cOglFb *fb, tColor *argb, GLint width, GLint | |||||||
| cOglCmdDrawImage::~cOglCmdDrawImage(void) { free(argb); } | cOglCmdDrawImage::~cOglCmdDrawImage(void) { free(argb); } | ||||||
|  |  | ||||||
| bool cOglCmdDrawImage::Execute(void) { | bool cOglCmdDrawImage::Execute(void) { | ||||||
|  |     if (width <= 0 || height <= 0) | ||||||
|  |         return false; | ||||||
|     GLuint texture; |     GLuint texture; | ||||||
|  |  | ||||||
| #ifdef USE_DRM | #ifdef USE_DRM | ||||||
|     //  pthread_mutex_lock(&OSDMutex); |     //esyslog("upload Image\n"); | ||||||
|  |     pthread_mutex_lock(&OSDMutex); | ||||||
|     GlxDrawopengl(); // here we need the Shared Context for upload |     GlxDrawopengl(); // here we need the Shared Context for upload | ||||||
|     GlxCheck(); |     GlxCheck(); | ||||||
| #endif | #endif | ||||||
| @@ -1275,13 +1284,13 @@ bool cOglCmdDrawImage::Execute(void) { | |||||||
| #ifdef USE_DRM   | #ifdef USE_DRM   | ||||||
|     GlxInitopengl(); // Reset Context |     GlxInitopengl(); // Reset Context | ||||||
|     GlxCheck(); |     GlxCheck(); | ||||||
| //  pthread_mutex_unlock(&OSDMutex); |     pthread_mutex_unlock(&OSDMutex); | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|     GLfloat x1 = x;                   // left |     GLfloat x1 = x;                   // left | ||||||
|     GLfloat y1 = y;                   // top |     GLfloat y1 = y;                   // top | ||||||
|     GLfloat x2 = x + width;  // right |     GLfloat x2 = x + width * scaleX;  // right | ||||||
|     GLfloat y2 = y + height; // bottom |     GLfloat y2 = y + height * scaleY; // bottom | ||||||
|  |  | ||||||
|     GLfloat quadVertices[] = { |     GLfloat quadVertices[] = { | ||||||
|         x1, y2, 0.0, 1.0, // left bottom |         x1, y2, 0.0, 1.0, // left bottom | ||||||
| @@ -1315,17 +1324,21 @@ bool cOglCmdDrawImage::Execute(void) { | |||||||
| } | } | ||||||
|  |  | ||||||
| //------------------ cOglCmdDrawTexture -------------------- | //------------------ cOglCmdDrawTexture -------------------- | ||||||
| cOglCmdDrawTexture::cOglCmdDrawTexture(cOglFb *fb, sOglImage *imageRef, GLint x, GLint y) : cOglCmd(fb) { | cOglCmdDrawTexture::cOglCmdDrawTexture(cOglFb *fb, sOglImage *imageRef, GLint x, GLint y, double scaleX, double scaleY) : cOglCmd(fb) { | ||||||
|     this->imageRef = imageRef; |     this->imageRef = imageRef; | ||||||
|     this->x = x; |     this->x = x; | ||||||
|     this->y = y; |     this->y = y; | ||||||
|  |     this->scaleX = scaleX; | ||||||
|  |     this->scaleY = scaleY; | ||||||
| } | } | ||||||
|  |  | ||||||
| bool cOglCmdDrawTexture::Execute(void) { | bool cOglCmdDrawTexture::Execute(void) { | ||||||
|  |     if (imageRef->width <= 0 || imageRef->height <= 0) | ||||||
|  |         return false; | ||||||
|     GLfloat x1 = x;                             // top |     GLfloat x1 = x;                             // top | ||||||
|     GLfloat y1 = y;                             // left |     GLfloat y1 = y;                             // left | ||||||
|     GLfloat x2 = x + imageRef->width;  // right |     GLfloat x2 = x + imageRef->width * scaleX;  // right | ||||||
|     GLfloat y2 = y + imageRef->height; // bottom |     GLfloat y2 = y + imageRef->height * scaleY; // bottom | ||||||
|  |  | ||||||
|     GLfloat quadVertices[] = { |     GLfloat quadVertices[] = { | ||||||
|         // Pos	  // TexCoords |         // Pos	  // TexCoords | ||||||
| @@ -1363,7 +1376,8 @@ cOglCmdStoreImage::~cOglCmdStoreImage(void) { free(data); } | |||||||
|  |  | ||||||
| bool cOglCmdStoreImage::Execute(void) { | bool cOglCmdStoreImage::Execute(void) { | ||||||
| #ifdef USE_DRM | #ifdef USE_DRM | ||||||
|     //  pthread_mutex_lock(&OSDMutex); |     return false; | ||||||
|  |     pthread_mutex_lock(&OSDMutex); | ||||||
|     GlxDrawopengl(); // here we need the Shared Context for upload |     GlxDrawopengl(); // here we need the Shared Context for upload | ||||||
|     GlxCheck(); |     GlxCheck(); | ||||||
| #endif | #endif | ||||||
| @@ -1380,7 +1394,7 @@ bool cOglCmdStoreImage::Execute(void) { | |||||||
| #ifdef USE_DRM | #ifdef USE_DRM | ||||||
|     GlxInitopengl(); // Reset Context |     GlxInitopengl(); // Reset Context | ||||||
|     GlxCheck(); |     GlxCheck(); | ||||||
| //  pthread_mutex_lock(&OSDMutex); |     pthread_mutex_lock(&OSDMutex); | ||||||
| #endif | #endif | ||||||
|     return true; |     return true; | ||||||
| } | } | ||||||
| @@ -1460,7 +1474,9 @@ int cOglThread::StoreImage(const cImage &image) { | |||||||
|     if (!maxCacheSize) { |     if (!maxCacheSize) { | ||||||
|         return 0; |         return 0; | ||||||
|     } |     } | ||||||
|  | #ifdef USE_DRM | ||||||
|  |     return 0; | ||||||
|  | #endif | ||||||
|     if (image.Width() > maxTextureSize || image.Height() > maxTextureSize) { |     if (image.Width() > maxTextureSize || image.Height() > maxTextureSize) { | ||||||
|         esyslog("[softhddev] cannot store image of %dpx x %dpx " |         esyslog("[softhddev] cannot store image of %dpx x %dpx " | ||||||
|                 "(maximum size is %dpx x %dpx) - falling back to " |                 "(maximum size is %dpx x %dpx) - falling back to " | ||||||
| @@ -1640,6 +1656,7 @@ void cOglThread::Action(void) { | |||||||
|  |  | ||||||
| bool cOglThread::InitOpenGL(void) { | bool cOglThread::InitOpenGL(void) { | ||||||
| #ifdef USE_DRM | #ifdef USE_DRM | ||||||
|  |     esyslog("InitOpenGL\n"); | ||||||
|     GlxInitopengl(); |     GlxInitopengl(); | ||||||
| #else | #else | ||||||
|     const char *displayName = X11DisplayName; |     const char *displayName = X11DisplayName; | ||||||
| @@ -1651,7 +1668,7 @@ bool cOglThread::InitOpenGL(void) { | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     dsyslog("[softhddev]OpenGL using display %s", displayName); |     esyslog("[softhddev]OpenGL using display %s", displayName); | ||||||
|  |  | ||||||
|     int argc = 3; |     int argc = 3; | ||||||
|     char *buffer[3]; |     char *buffer[3]; | ||||||
| @@ -1815,6 +1832,10 @@ void cOglPixmap::Fill(tColor Color) { | |||||||
| } | } | ||||||
|  |  | ||||||
| void cOglPixmap::DrawImage(const cPoint &Point, const cImage &Image) { | void cOglPixmap::DrawImage(const cPoint &Point, const cImage &Image) { | ||||||
|  |     DrawScaledImage(Point, Image); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | void cOglPixmap::DrawScaledImage(const cPoint &Point, const cImage &Image, double FactorX, double FactorY, bool AntiAlias) { | ||||||
|     if (!oglThread->Active()) |     if (!oglThread->Active()) | ||||||
|         return; |         return; | ||||||
|     tColor *argb = MALLOC(tColor, Image.Width() * Image.Height()); |     tColor *argb = MALLOC(tColor, Image.Width() * Image.Height()); | ||||||
| @@ -1823,19 +1844,25 @@ void cOglPixmap::DrawImage(const cPoint &Point, const cImage &Image) { | |||||||
|         return; |         return; | ||||||
|     memcpy(argb, Image.Data(), sizeof(tColor) * Image.Width() * Image.Height()); |     memcpy(argb, Image.Data(), sizeof(tColor) * Image.Width() * Image.Height()); | ||||||
|  |  | ||||||
|     oglThread->DoCmd(new cOglCmdDrawImage(fb, argb, Image.Width(), Image.Height(), Point.X(), Point.Y())); |     oglThread->DoCmd(new cOglCmdDrawImage(fb, argb, Image.Width(), Image.Height(), Point.X(), Point.Y(), true, FactorX, FactorY)); | ||||||
|     SetDirty(); |     SetDirty(); | ||||||
|     MarkDrawPortDirty(cRect(Point, cSize(Image.Width(), Image.Height())).Intersected(DrawPort().Size())); |     MarkDrawPortDirty(cRect(Point, cSize(Image.Width() * FactorX, Image.Height() * FactorY)).Intersected(DrawPort().Size())); | ||||||
| } | } | ||||||
|  |  | ||||||
| void cOglPixmap::DrawImage(const cPoint &Point, int ImageHandle) { | void cOglPixmap::DrawImage(const cPoint &Point, int ImageHandle) { | ||||||
|  |     DrawScaledImage(Point, ImageHandle); | ||||||
|  | } | ||||||
|  |  | ||||||
|  | void cOglPixmap::DrawScaledImage(const cPoint &Point, int ImageHandle, double FactorX, double FactorY, bool AntiAlias) { | ||||||
|     if (!oglThread->Active()) |     if (!oglThread->Active()) | ||||||
|         return; |         return; | ||||||
|  |  | ||||||
|     if (ImageHandle < 0 && oglThread->GetImageRef(ImageHandle)) { |     if (ImageHandle < 0 && oglThread->GetImageRef(ImageHandle)) { | ||||||
|         sOglImage *img = oglThread->GetImageRef(ImageHandle); |         sOglImage *img = oglThread->GetImageRef(ImageHandle); | ||||||
|  |  | ||||||
|         oglThread->DoCmd(new cOglCmdDrawTexture(fb, img, Point.X(), Point.Y())); |         oglThread->DoCmd(new cOglCmdDrawTexture(fb, img, Point.X(), Point.Y(), FactorX, FactorY)); | ||||||
|  |         SetDirty(); | ||||||
|  |         MarkDrawPortDirty(cRect(Point, cSize(img->width * FactorX, img->height * FactorY)).Intersected(DrawPort().Size())); | ||||||
|     } |     } | ||||||
|     /* |     /* | ||||||
|        Fallback to VDR implementation, needs to separate cSoftOsdProvider from |        Fallback to VDR implementation, needs to separate cSoftOsdProvider from | ||||||
| @@ -1843,8 +1870,6 @@ void cOglPixmap::DrawImage(const cPoint &Point, int ImageHandle) { | |||||||
|        DrawImage(Point, *cSoftOsdProvider::GetImageData(ImageHandle)); |        DrawImage(Point, *cSoftOsdProvider::GetImageData(ImageHandle)); | ||||||
|        } |        } | ||||||
|      */ |      */ | ||||||
|     SetDirty(); |  | ||||||
|     MarkDrawPortDirty(DrawPort()); |  | ||||||
| } | } | ||||||
|  |  | ||||||
| void cOglPixmap::DrawPixel(const cPoint &Point, tColor Color) { | void cOglPixmap::DrawPixel(const cPoint &Point, tColor Color) { | ||||||
| @@ -2085,6 +2110,14 @@ cPixmap *cOglOsd::CreatePixmap(int Layer, const cRect &ViewPort, const cRect &Dr | |||||||
|     return NULL; |     return NULL; | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
|  | extern "C" {void VideoSetOsdSize(int, int ) ;} | ||||||
|  |  | ||||||
|  | void SetOsdPosition(int Left, int Top, int Width, int Height) { | ||||||
|  |     printf("Set OSD Position %d %d\n",Width,Height); | ||||||
|  |   VideoSetOsdSize( Width, Height) ;  | ||||||
|  | } | ||||||
|  |  | ||||||
| void cOglOsd::DestroyPixmap(cPixmap *Pixmap) { | void cOglOsd::DestroyPixmap(cPixmap *Pixmap) { | ||||||
|     if (!oglThread->Active()) |     if (!oglThread->Active()) | ||||||
|         return; |         return; | ||||||
| @@ -2130,10 +2163,16 @@ void cOglOsd::Flush(void) { | |||||||
|         for (int i = 0; i < oglPixmaps.Size(); i++) { |         for (int i = 0; i < oglPixmaps.Size(); i++) { | ||||||
|             if (oglPixmaps[i]) { |             if (oglPixmaps[i]) { | ||||||
|                 if (oglPixmaps[i]->Layer() == layer) { |                 if (oglPixmaps[i]->Layer() == layer) { | ||||||
|                     oglThread->DoCmd(new cOglCmdRenderFbToBufferFb( |                     bool alphablending = layer == 0 ? false : true; // Decide wether to render (with alpha) or copy a pixmap | ||||||
|                         oglPixmaps[i]->Fb(), bFb, oglPixmaps[i]->ViewPort().X(), |                     oglThread->DoCmd(new cOglCmdRenderFbToBufferFb( oglPixmaps[i]->Fb(),  | ||||||
|                         (!isSubtitleOsd) ? oglPixmaps[i]->ViewPort().Y() : 0, oglPixmaps[i]->Alpha(), |                                                                     bFb, | ||||||
|                         oglPixmaps[i]->DrawPort().X(), oglPixmaps[i]->DrawPort().Y())); |                                                                     oglPixmaps[i]->ViewPort().X(),  | ||||||
|  |                                                                     (!isSubtitleOsd) ? oglPixmaps[i]->ViewPort().Y() : 0, | ||||||
|  |                                                                     oglPixmaps[i]->Alpha(),  | ||||||
|  |                                                                     oglPixmaps[i]->DrawPort().X(),  | ||||||
|  |                                                                     oglPixmaps[i]->DrawPort().Y(), | ||||||
|  |                                                                     alphablending | ||||||
|  |                                                                     )); | ||||||
|                     oglPixmaps[i]->SetDirty(false); |                     oglPixmaps[i]->SetDirty(false); | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
|   | |||||||
| @@ -290,10 +290,11 @@ class cOglCmdRenderFbToBufferFb : public cOglCmd { | |||||||
|     GLfloat x, y; |     GLfloat x, y; | ||||||
|     GLfloat drawPortX, drawPortY; |     GLfloat drawPortX, drawPortY; | ||||||
|     GLint transparency; |     GLint transparency; | ||||||
|  |     GLint alphablending; | ||||||
|  |  | ||||||
|   public: |   public: | ||||||
|     cOglCmdRenderFbToBufferFb(cOglFb *fb, cOglFb *buffer, GLint x, GLint y, GLint transparency, GLint drawPortX, |     cOglCmdRenderFbToBufferFb(cOglFb *fb, cOglFb *buffer, GLint x, GLint y, GLint transparency, GLint drawPortX, | ||||||
|                               GLint drawPortY); |                               GLint drawPortY, bool alphablending); | ||||||
|     virtual ~cOglCmdRenderFbToBufferFb(void){}; |     virtual ~cOglCmdRenderFbToBufferFb(void){}; | ||||||
|     virtual const char *Description(void) { return "Render Framebuffer to Buffer"; } |     virtual const char *Description(void) { return "Render Framebuffer to Buffer"; } | ||||||
|     virtual bool Execute(void); |     virtual bool Execute(void); | ||||||
| @@ -402,9 +403,10 @@ class cOglCmdDrawTexture : public cOglCmd { | |||||||
|   private: |   private: | ||||||
|     sOglImage *imageRef; |     sOglImage *imageRef; | ||||||
|     GLint x, y; |     GLint x, y; | ||||||
|  |     GLfloat scaleX, scaleY; | ||||||
|  |  | ||||||
|   public: |   public: | ||||||
|     cOglCmdDrawTexture(cOglFb *fb, sOglImage *imageRef, GLint x, GLint y); |     cOglCmdDrawTexture(cOglFb *fb, sOglImage *imageRef, GLint x, GLint y, double scaleX = 1.0f, double scaleY = 1.0f); | ||||||
|     virtual ~cOglCmdDrawTexture(void){}; |     virtual ~cOglCmdDrawTexture(void){}; | ||||||
|     virtual const char *Description(void) { return "Draw Texture"; } |     virtual const char *Description(void) { return "Draw Texture"; } | ||||||
|     virtual bool Execute(void); |     virtual bool Execute(void); | ||||||
| @@ -500,6 +502,8 @@ class cOglPixmap : public cPixmap { | |||||||
|     virtual void Fill(tColor Color); |     virtual void Fill(tColor Color); | ||||||
|     virtual void DrawImage(const cPoint &Point, const cImage &Image); |     virtual void DrawImage(const cPoint &Point, const cImage &Image); | ||||||
|     virtual void DrawImage(const cPoint &Point, int ImageHandle); |     virtual void DrawImage(const cPoint &Point, int ImageHandle); | ||||||
|  |     virtual void DrawScaledImage(const cPoint &Point, const cImage &Image, double FactorX = 1.0f, double FactorY = 1.0f, bool AntiAlias = false); | ||||||
|  |     virtual void DrawScaledImage(const cPoint &Point, int ImageHandle, double FactorX = 1.0f, double FactorY = 1.0f, bool AntiAlias = false); | ||||||
|     virtual void DrawPixel(const cPoint &Point, tColor Color); |     virtual void DrawPixel(const cPoint &Point, tColor Color); | ||||||
|     virtual void DrawBitmap(const cPoint &Point, const cBitmap &Bitmap, tColor ColorFg = 0, tColor ColorBg = 0, |     virtual void DrawBitmap(const cPoint &Point, const cBitmap &Bitmap, tColor ColorFg = 0, tColor ColorBg = 0, | ||||||
|                             bool Overlay = false); |                             bool Overlay = false); | ||||||
| @@ -528,6 +532,7 @@ class cOglOsd : public cOsd { | |||||||
|   public: |   public: | ||||||
|     cOglOsd(int Left, int Top, uint Level, std::shared_ptr<cOglThread> oglThread); |     cOglOsd(int Left, int Top, uint Level, std::shared_ptr<cOglThread> oglThread); | ||||||
|     virtual ~cOglOsd(); |     virtual ~cOglOsd(); | ||||||
|  |     static void SetOsdPosition(int Left, int Top, int Width, int Height); | ||||||
|     virtual eOsdError SetAreas(const tArea *Areas, int NumAreas); |     virtual eOsdError SetAreas(const tArea *Areas, int NumAreas); | ||||||
|     virtual cPixmap *CreatePixmap(int Layer, const cRect &ViewPort, const cRect &DrawPort = cRect::Null); |     virtual cPixmap *CreatePixmap(int Layer, const cRect &ViewPort, const cRect &DrawPort = cRect::Null); | ||||||
|     virtual void DestroyPixmap(cPixmap *Pixmap); |     virtual void DestroyPixmap(cPixmap *Pixmap); | ||||||
|   | |||||||
| @@ -4,11 +4,7 @@ | |||||||
| #ifdef CUVID | #ifdef CUVID | ||||||
| const char *gl_version = "#version 330"; | const char *gl_version = "#version 330"; | ||||||
| #else | #else | ||||||
| #ifdef RASPI |  | ||||||
| const char *gl_version = "#version 300 es "; | const char *gl_version = "#version 300 es "; | ||||||
| #else |  | ||||||
| const char *gl_version = "#version 300 es "; |  | ||||||
| #endif |  | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| /* Color conversion matrix: RGB = m * YUV + c | /* Color conversion matrix: RGB = m * YUV + c | ||||||
|   | |||||||
							
								
								
									
										109
									
								
								softhdcuvid.cpp
									
									
									
									
									
								
							
							
						
						
									
										109
									
								
								softhdcuvid.cpp
									
									
									
									
									
								
							| @@ -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.6" | static const char *const VERSION = "3.16" | ||||||
| #ifdef GIT_REV | #ifdef GIT_REV | ||||||
|                                    "-GIT" GIT_REV |                                    "-GIT" GIT_REV | ||||||
| #endif | #endif | ||||||
| @@ -645,33 +645,104 @@ void cSoftOsd::Flush(void) { | |||||||
| // Dummy Pixmap for skins | // Dummy Pixmap for skins | ||||||
| class cDummyPixmap : public cPixmap { | class cDummyPixmap : public cPixmap { | ||||||
|   public: |   public: | ||||||
|     cDummyPixmap(int Layer, const cRect &ViewPort, const cRect &DrawPort = cRect::Null) : cPixmap(Layer, ViewPort, DrawPort) {} |     cDummyPixmap(int Layer, const cRect &ViewPort, const cRect &DrawPort = cRect::Null) | ||||||
|  |         : cPixmap(Layer, ViewPort, DrawPort) {} | ||||||
|     virtual ~cDummyPixmap(void) {} |     virtual ~cDummyPixmap(void) {} | ||||||
|     virtual void Clear(void) {} |     virtual void Clear(void) {} | ||||||
|     virtual void Fill(tColor Color) { (void)Color; } |     virtual void Fill(tColor Color) { (void)Color; } | ||||||
|     virtual void DrawImage(const cPoint &Point, const cImage &Image) { (void)Point; (void)Image; } |     virtual void DrawImage(const cPoint &Point, const cImage &Image) { | ||||||
|     virtual void DrawImage(const cPoint &Point, int ImageHandle) { (void)Point; (void)ImageHandle; } |         (void)Point; | ||||||
|     virtual void DrawPixel(const cPoint &Point, tColor Color) { (void)Point; (void)Color; } |         (void)Image; | ||||||
|     virtual void DrawBitmap(const cPoint &Point, const cBitmap &Bitmap, tColor ColorFg = 0, tColor ColorBg = 0, bool Overlay = false) { |     } | ||||||
|         (void) Point; (void)Bitmap; (void)ColorFg; (void)ColorBg; (void)Overlay; } |     virtual void DrawImage(const cPoint &Point, int ImageHandle) { | ||||||
|     virtual void DrawText(const cPoint &Point, const char *s, tColor ColorFg, tColor ColorBg, const cFont *Font, int Width = 0, int Height = 0, int Alignment = taDefault) { |         (void)Point; | ||||||
|         (void)Point; (void)s; (void)ColorFg; (void) ColorBg; (void) Font; (void)Width; (void)Height; (void)Alignment; } |         (void)ImageHandle; | ||||||
|     virtual void DrawRectangle(const cRect &Rect, tColor Color) { (void)Rect; (void)Color; } |     } | ||||||
|     virtual void DrawEllipse(const cRect &Rect, tColor Color, int Quadrants = 0) { (void)Rect; (void)Color; (void)Quadrants; } |     virtual void DrawScaledImage(const cPoint &Point, const cImage &Image, double FactorX, double FactorY, bool AntiAlias) { | ||||||
|     virtual void DrawSlope(const cRect &Rect, tColor Color, int Type) { (void)Rect; (void)Color; (void)Type; } |         (void)Point; | ||||||
|     virtual void Render(const cPixmap *Pixmap, const cRect &Source, const cPoint &Dest) { (void)Pixmap; (void)Source; (void)Dest; } |         (void)Image; | ||||||
|     virtual void Copy(const cPixmap *Pixmap, const cRect &Source, const cPoint &Dest) { (void)Pixmap; (void)Source; (void)Dest; } |         (void)FactorX; | ||||||
|     virtual void Scroll(const cPoint &Dest, const cRect &Source = cRect::Null) { (void)Dest; (void)Source; } |         (void)FactorY; | ||||||
|     virtual void Pan(const cPoint &Dest, const cRect &Source = cRect::Null) { (void)Dest; (void)Source; } |         (void)AntiAlias; | ||||||
|  |     } | ||||||
|  |     virtual void DrawScaledImage(const cPoint &Point, int ImageHandle, double FactorX, double FactorY, bool AntiAlias) { | ||||||
|  |         (void)Point; | ||||||
|  |         (void)ImageHandle; | ||||||
|  |         (void)FactorX; | ||||||
|  |         (void)FactorY; | ||||||
|  |         (void)AntiAlias; | ||||||
|  |     } | ||||||
|  |     virtual void DrawPixel(const cPoint &Point, tColor Color) { | ||||||
|  |         (void)Point; | ||||||
|  |         (void)Color; | ||||||
|  |     } | ||||||
|  |     virtual void DrawBitmap(const cPoint &Point, const cBitmap &Bitmap, tColor ColorFg = 0, tColor ColorBg = 0, | ||||||
|  |                             bool Overlay = false) { | ||||||
|  |         (void)Point; | ||||||
|  |         (void)Bitmap; | ||||||
|  |         (void)ColorFg; | ||||||
|  |         (void)ColorBg; | ||||||
|  |         (void)Overlay; | ||||||
|  |     } | ||||||
|  |     virtual void DrawText(const cPoint &Point, const char *s, tColor ColorFg, tColor ColorBg, const cFont *Font, | ||||||
|  |                           int Width = 0, int Height = 0, int Alignment = taDefault) { | ||||||
|  |         (void)Point; | ||||||
|  |         (void)s; | ||||||
|  |         (void)ColorFg; | ||||||
|  |         (void)ColorBg; | ||||||
|  |         (void)Font; | ||||||
|  |         (void)Width; | ||||||
|  |         (void)Height; | ||||||
|  |         (void)Alignment; | ||||||
|  |     } | ||||||
|  |     virtual void DrawRectangle(const cRect &Rect, tColor Color) { | ||||||
|  |         (void)Rect; | ||||||
|  |         (void)Color; | ||||||
|  |     } | ||||||
|  |     virtual void DrawEllipse(const cRect &Rect, tColor Color, int Quadrants = 0) { | ||||||
|  |         (void)Rect; | ||||||
|  |         (void)Color; | ||||||
|  |         (void)Quadrants; | ||||||
|  |     } | ||||||
|  |     virtual void DrawSlope(const cRect &Rect, tColor Color, int Type) { | ||||||
|  |         (void)Rect; | ||||||
|  |         (void)Color; | ||||||
|  |         (void)Type; | ||||||
|  |     } | ||||||
|  |     virtual void Render(const cPixmap *Pixmap, const cRect &Source, const cPoint &Dest) { | ||||||
|  |         (void)Pixmap; | ||||||
|  |         (void)Source; | ||||||
|  |         (void)Dest; | ||||||
|  |     } | ||||||
|  |     virtual void Copy(const cPixmap *Pixmap, const cRect &Source, const cPoint &Dest) { | ||||||
|  |         (void)Pixmap; | ||||||
|  |         (void)Source; | ||||||
|  |         (void)Dest; | ||||||
|  |     } | ||||||
|  |     virtual void Scroll(const cPoint &Dest, const cRect &Source = cRect::Null) { | ||||||
|  |         (void)Dest; | ||||||
|  |         (void)Source; | ||||||
|  |     } | ||||||
|  |     virtual void Pan(const cPoint &Dest, const cRect &Source = cRect::Null) { | ||||||
|  |         (void)Dest; | ||||||
|  |         (void)Source; | ||||||
|  |     } | ||||||
| }; | }; | ||||||
|  |  | ||||||
| // Dummy OSD for OpenGL OSD if no X Server is available | // Dummy OSD for OpenGL OSD if no X Server is available | ||||||
| class cDummyOsd : public cOsd { | class cDummyOsd : public cOsd { | ||||||
|   private: |   private: | ||||||
|     cDummyPixmap *p; |     cDummyPixmap *p; | ||||||
|  |  | ||||||
|   public: |   public: | ||||||
|     cDummyOsd(int Left, int Top, uint Level) : cOsd(Left, Top, Level) {} |     cDummyOsd(int Left, int Top, uint Level) : cOsd(Left, Top, Level) {} | ||||||
|     virtual ~cDummyOsd() {} |     virtual ~cDummyOsd() {} | ||||||
|  |     static void SetOsdPosition(int Left, int Top, int Width, int Height) { | ||||||
|  |         (void) Left; | ||||||
|  |         (void) Top; | ||||||
|  |         (void) Width; | ||||||
|  |         (void) Height; | ||||||
|  |     } | ||||||
|     virtual cPixmap *CreatePixmap(int Layer, const cRect &ViewPort, const cRect &DrawPort = cRect::Null) { |     virtual cPixmap *CreatePixmap(int Layer, const cRect &ViewPort, const cRect &DrawPort = cRect::Null) { | ||||||
|         p = new cDummyPixmap(Layer, ViewPort, DrawPort); |         p = new cDummyPixmap(Layer, ViewPort, DrawPort); | ||||||
|         return p; |         return p; | ||||||
| @@ -1096,9 +1167,9 @@ void cMenuSetupSoft::Create(void) { | |||||||
|  |  | ||||||
|     if (scalers == 0) { |     if (scalers == 0) { | ||||||
|         scalingtest[0] = (char *)"Off"; |         scalingtest[0] = (char *)"Off"; | ||||||
|         for (scalers = 0; pl_named_filters[scalers].name != NULL; scalers++) { |         for (scalers = 0; pl_filter_presets[scalers].name != NULL; scalers++) { | ||||||
|             scaling[scalers] = (char *)pl_named_filters[scalers].name; |             scaling[scalers] = (char *)pl_filter_presets[scalers].name; | ||||||
|             scalingtest[scalers + 1] = (char *)pl_named_filters[scalers].name; |             scalingtest[scalers + 1] = (char *)pl_filter_presets[scalers].name; | ||||||
|             // printf("Scaler %s\n",pl_named_filters[scalers].name); |             // printf("Scaler %s\n",pl_named_filters[scalers].name); | ||||||
|         } |         } | ||||||
|         // scalers -= 2; |         // scalers -= 2; | ||||||
|   | |||||||
| @@ -364,7 +364,7 @@ static int Ac3Check(const uint8_t *data, int size) { | |||||||
|         if ((data[4] & 0xF0) == 0xF0) { // invalid fscod fscod2 |         if ((data[4] & 0xF0) == 0xF0) { // invalid fscod fscod2 | ||||||
|             return 0; |             return 0; | ||||||
|         } |         } | ||||||
|         frame_size = ((data[2] & 0x03) << 8) + data[3] + 1; |         frame_size = ((data[2] & 0x07) << 8) + data[3] + 1; | ||||||
|         frame_size *= 2; |         frame_size *= 2; | ||||||
|     } else { // AC-3 |     } else { // AC-3 | ||||||
|         int fscod; |         int fscod; | ||||||
| @@ -2817,8 +2817,8 @@ const char *CommandLineHelp(void) { | |||||||
|            "\tstill-h264-hw-decoder\tenable h264 hw decoder for still-pictures\n" |            "\tstill-h264-hw-decoder\tenable h264 hw decoder for still-pictures\n" | ||||||
|            "\talsa-driver-broken\tdisable broken alsa driver message\n" |            "\talsa-driver-broken\tdisable broken alsa driver message\n" | ||||||
|            "\talsa-no-close-open\tdisable close open to fix alsa no sound bug\n" |            "\talsa-no-close-open\tdisable close open to fix alsa no sound bug\n" | ||||||
|            "\talsa-close-open-delay\tenable close open delay to fix no sound " |            "\talsa-no-test\tdisable Alsa Capability test on start for NUC11/12\n" | ||||||
|            "bug\n" |            "\talsa-close-open-delay\tenable close open delay to fix no sound bug\n" | ||||||
|            "\tignore-repeat-pict\tdisable repeat pict message\n" |            "\tignore-repeat-pict\tdisable repeat pict message\n" | ||||||
|            "\tuse-possible-defect-frames prefer faster channel switch\n" |            "\tuse-possible-defect-frames prefer faster channel switch\n" | ||||||
|            "	 -D\t\tstart in detached mode\n"; |            "	 -D\t\tstart in detached mode\n"; | ||||||
| @@ -2908,6 +2908,8 @@ int ProcessArgs(int argc, char *const argv[]) { | |||||||
|                     AudioAlsaDriverBroken = 1; |                     AudioAlsaDriverBroken = 1; | ||||||
|                 } else if (!strcasecmp("alsa-no-close-open", optarg)) { |                 } else if (!strcasecmp("alsa-no-close-open", optarg)) { | ||||||
|                     AudioAlsaNoCloseOpen = 1; |                     AudioAlsaNoCloseOpen = 1; | ||||||
|  |                 } else if (!strcasecmp("alsa-no-test", optarg)) { | ||||||
|  |                     AudioAlsaNotest = 1; | ||||||
|                 } else if (!strcasecmp("alsa-close-open-delay", optarg)) { |                 } else if (!strcasecmp("alsa-close-open-delay", optarg)) { | ||||||
|                     AudioAlsaCloseOpenDelay = 1; |                     AudioAlsaCloseOpenDelay = 1; | ||||||
|                 } else if (!strcasecmp("ignore-repeat-pict", optarg)) { |                 } else if (!strcasecmp("ignore-repeat-pict", optarg)) { | ||||||
|   | |||||||
							
								
								
									
										394
									
								
								video.c
									
									
									
									
									
								
							
							
						
						
									
										394
									
								
								video.c
									
									
									
									
									
								
							| @@ -158,12 +158,9 @@ typedef enum { | |||||||
| #if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(57, 74, 100) | #if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(57, 74, 100) | ||||||
| #include <libavcodec/vaapi.h> | #include <libavcodec/vaapi.h> | ||||||
| #endif | #endif | ||||||
|  | #include <libavutil/hwcontext_vaapi.h> | ||||||
| #include <libdrm/drm_fourcc.h> | #include <libdrm/drm_fourcc.h> | ||||||
| #include <va/va_drmcommon.h> | #include <va/va_drmcommon.h> | ||||||
| #ifdef RASPI |  | ||||||
| #include <libavutil/hwcontext_drm.h> |  | ||||||
| #endif |  | ||||||
| #include <libavutil/hwcontext_vaapi.h> |  | ||||||
| #define TO_AVHW_DEVICE_CTX(x) ((AVHWDeviceContext *)x->data) | #define TO_AVHW_DEVICE_CTX(x) ((AVHWDeviceContext *)x->data) | ||||||
| #define TO_AVHW_FRAMES_CTX(x) ((AVHWFramesContext *)x->data) | #define TO_AVHW_FRAMES_CTX(x) ((AVHWFramesContext *)x->data) | ||||||
| #define TO_VAAPI_DEVICE_CTX(x) ((AVVAAPIDeviceContext *)TO_AVHW_DEVICE_CTX(x)->hwctx) | #define TO_VAAPI_DEVICE_CTX(x) ((AVVAAPIDeviceContext *)TO_AVHW_DEVICE_CTX(x)->hwctx) | ||||||
| @@ -341,7 +338,7 @@ typedef struct { | |||||||
|  |  | ||||||
| #define NUM_SHADERS 5 // Number of supported user shaders with placebo | #define NUM_SHADERS 5 // Number of supported user shaders with placebo | ||||||
|  |  | ||||||
| #if defined VAAPI && !defined RASPI | #if defined VAAPI | ||||||
| #define PIXEL_FORMAT AV_PIX_FMT_VAAPI | #define PIXEL_FORMAT AV_PIX_FMT_VAAPI | ||||||
| #define SWAP_BUFFER_SIZE 3 | #define SWAP_BUFFER_SIZE 3 | ||||||
| #endif | #endif | ||||||
| @@ -349,21 +346,13 @@ typedef struct { | |||||||
| #define PIXEL_FORMAT AV_PIX_FMT_CUDA | #define PIXEL_FORMAT AV_PIX_FMT_CUDA | ||||||
| #define SWAP_BUFFER_SIZE 3 | #define SWAP_BUFFER_SIZE 3 | ||||||
| #endif | #endif | ||||||
| #if defined RASPI |  | ||||||
| #define PIXEL_FORMAT AV_PIX_FMT_MMAL |  | ||||||
| #define SWAP_BUFFER_SIZE 3 |  | ||||||
| #endif |  | ||||||
| //---------------------------------------------------------------------------- | //---------------------------------------------------------------------------- | ||||||
| //  Variables | //  Variables | ||||||
| //---------------------------------------------------------------------------- | //---------------------------------------------------------------------------- | ||||||
| AVBufferRef *HwDeviceContext; ///< ffmpeg HW device context | AVBufferRef *HwDeviceContext; ///< ffmpeg HW device context | ||||||
| char VideoIgnoreRepeatPict;   ///< disable repeat pict warning | char VideoIgnoreRepeatPict;   ///< disable repeat pict warning | ||||||
|  |  | ||||||
| #ifdef RASPI |  | ||||||
| int Planes = 3; |  | ||||||
| #else |  | ||||||
| int Planes = 2; | int Planes = 2; | ||||||
| #endif |  | ||||||
|  |  | ||||||
| unsigned char *posd; | unsigned char *posd; | ||||||
|  |  | ||||||
| @@ -475,7 +464,7 @@ extern void AudioVideoReady(int64_t); ///< tell audio video is ready | |||||||
| static pthread_t VideoThread;          ///< video decode thread | static pthread_t VideoThread;          ///< video decode thread | ||||||
| static pthread_cond_t VideoWakeupCond; ///< wakeup condition variable | static pthread_cond_t VideoWakeupCond; ///< wakeup condition variable | ||||||
| static pthread_mutex_t VideoMutex;     ///< video condition mutex | static pthread_mutex_t VideoMutex;     ///< video condition mutex | ||||||
| static pthread_mutex_t VideoLockMutex; ///< video lock mutex | pthread_mutex_t VideoLockMutex; ///< video lock mutex | ||||||
| pthread_mutex_t OSDMutex;              ///< OSD update mutex | pthread_mutex_t OSDMutex;              ///< OSD update mutex | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| @@ -628,6 +617,8 @@ char *eglErrorString(EGLint error) { | |||||||
| static void VideoSetPts(int64_t *pts_p, int interlaced, const AVCodecContext *video_ctx, const AVFrame *frame) { | static void VideoSetPts(int64_t *pts_p, int interlaced, const AVCodecContext *video_ctx, const AVFrame *frame) { | ||||||
|     int64_t pts; |     int64_t pts; | ||||||
|     int duration; |     int duration; | ||||||
|  |     static int64_t lastpts; | ||||||
|  |  | ||||||
|  |  | ||||||
|     // |     // | ||||||
|     //	Get duration for this frame. |     //	Get duration for this frame. | ||||||
| @@ -675,11 +666,12 @@ static void VideoSetPts(int64_t *pts_p, int interlaced, const AVCodecContext *vi | |||||||
|             Debug(3, "++++++++++++++++++++++++++++++++++++starte audio\n"); |             Debug(3, "++++++++++++++++++++++++++++++++++++starte audio\n"); | ||||||
|             AudioVideoReady(pts); |             AudioVideoReady(pts); | ||||||
|         } |         } | ||||||
|         if (*pts_p != pts) { |         if (*pts_p != pts && lastpts != pts) { | ||||||
|             Debug(4, "video: %#012" PRIx64 "->%#012" PRIx64 " delta=%4" PRId64 " pts\n", *pts_p, pts, pts - *pts_p); |             Debug(4, "video: %#012" PRIx64 "->%#012" PRIx64 " delta=%4" PRId64 " pts\n", *pts_p, pts, pts - *pts_p); | ||||||
|             *pts_p = pts; |             *pts_p = pts; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |     lastpts = pts; | ||||||
| } | } | ||||||
|  |  | ||||||
| int CuvidMessage(int level, const char *format, ...); | int CuvidMessage(int level, const char *format, ...); | ||||||
| @@ -833,6 +825,8 @@ static uint64_t test_time = 0; | |||||||
| #define Lock_and_SharedContext                                                                                        \ | #define Lock_and_SharedContext                                                                                        \ | ||||||
|     {                                                                                                                 \ |     {                                                                                                                 \ | ||||||
|         VideoThreadLock();                                                                                            \ |         VideoThreadLock();                                                                                            \ | ||||||
|  |         Debug(4,"Lock OSDMutex %s %d\n",__FILE__, __LINE__);                                                          \ | ||||||
|  |         pthread_mutex_lock(&OSDMutex);                                                                                \ | ||||||
|         eglMakeCurrent(eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, eglSharedContext);                                 \ |         eglMakeCurrent(eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, eglSharedContext);                                 \ | ||||||
|         EglCheck();                                                                                                   \ |         EglCheck();                                                                                                   \ | ||||||
|     } |     } | ||||||
| @@ -840,10 +834,14 @@ static uint64_t test_time = 0; | |||||||
|     {                                                                                                                 \ |     {                                                                                                                 \ | ||||||
|         eglMakeCurrent(eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);                                   \ |         eglMakeCurrent(eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);                                   \ | ||||||
|         EglCheck();                                                                                                   \ |         EglCheck();                                                                                                   \ | ||||||
|  |         Debug(4,"UnLock OSDMutex %s %d\n",__FILE__, __LINE__);                                                        \ | ||||||
|  |         pthread_mutex_unlock(&OSDMutex);                                                                              \ | ||||||
|         VideoThreadUnlock();                                                                                          \ |         VideoThreadUnlock();                                                                                          \ | ||||||
|     } |     } | ||||||
| #define SharedContext                                                                                                 \ | #define SharedContext                                                                                                 \ | ||||||
|     {                                                                                                                 \ |     {                                                                                                                 \ | ||||||
|  |         Debug(4,"Lock OSDMutex %s %d\n",__FILE__, __LINE__);                                                          \ | ||||||
|  |         pthread_mutex_lock(&OSDMutex);                                                                                \ | ||||||
|         eglMakeCurrent(eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, eglSharedContext);                                 \ |         eglMakeCurrent(eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, eglSharedContext);                                 \ | ||||||
|         EglCheck();                                                                                                   \ |         EglCheck();                                                                                                   \ | ||||||
|     } |     } | ||||||
| @@ -851,6 +849,8 @@ static uint64_t test_time = 0; | |||||||
|     {                                                                                                                 \ |     {                                                                                                                 \ | ||||||
|         eglMakeCurrent(eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);                                   \ |         eglMakeCurrent(eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);                                   \ | ||||||
|         EglCheck();                                                                                                   \ |         EglCheck();                                                                                                   \ | ||||||
|  |         Debug(4,"UnLock OSDMutex %s %d\n",__FILE__, __LINE__);                                                        \ | ||||||
|  |         pthread_mutex_unlock(&OSDMutex);                                                                              \ | ||||||
|     } |     } | ||||||
| #else | #else | ||||||
| #ifdef PLACEBO | #ifdef PLACEBO | ||||||
| @@ -1227,7 +1227,7 @@ static void EglExit(void) { | |||||||
|     // must destroy glx |     // must destroy glx | ||||||
|     // if (glXGetCurrentContext() == glxContext) { |     // if (glXGetCurrentContext() == glxContext) { | ||||||
|     // if currently used, set to none |     // if currently used, set to none | ||||||
|     glXMakeCurrent(XlibDisplay, None, NULL); |     // glXMakeCurrent(XlibDisplay, None, NULL); | ||||||
|     // } |     // } | ||||||
|     if (OSDcontext) { |     if (OSDcontext) { | ||||||
|         glXDestroyContext(XlibDisplay, OSDcontext); |         glXDestroyContext(XlibDisplay, OSDcontext); | ||||||
| @@ -1444,27 +1444,31 @@ struct file { | |||||||
| }; | }; | ||||||
|  |  | ||||||
| typedef struct priv { | typedef struct priv { | ||||||
|  | #if PL_API_VER >= 229 | ||||||
|  |     const struct pl_gpu_t *gpu; | ||||||
|  |     const struct pl_vulkan_t *vk; | ||||||
|  |     const struct pl_vk_inst_t *vk_inst; | ||||||
|  | #else | ||||||
|     const struct pl_gpu *gpu; |     const struct pl_gpu *gpu; | ||||||
|     const struct pl_vulkan *vk; |     const struct pl_vulkan *vk; | ||||||
|     const struct pl_vk_inst *vk_inst; |     const struct pl_vk_inst *vk_inst; | ||||||
|     struct pl_context *ctx; |  | ||||||
| #if PL_API_VER >= 113 |  | ||||||
|     struct pl_custom_lut *lut; |  | ||||||
| #endif | #endif | ||||||
|  |     struct pl_context *ctx; | ||||||
|  |     struct pl_custom_lut *lut; | ||||||
|     struct pl_renderer *renderer; |     struct pl_renderer *renderer; | ||||||
|     struct pl_renderer *renderertest; |     struct pl_renderer *renderertest; | ||||||
|     const struct pl_swapchain *swapchain; |     const struct pl_swapchain *swapchain; | ||||||
|     struct pl_context_params context; |     struct pl_log_params context; | ||||||
|     // struct pl_frame r_target; |  | ||||||
|     // struct pl_render_params r_params; |  | ||||||
|     // struct pl_tex	  final_fbo; |  | ||||||
| #ifndef PLACEBO_GL | #ifndef PLACEBO_GL | ||||||
|     VkSurfaceKHR pSurface; |     VkSurfaceKHR pSurface; | ||||||
| #endif | #endif | ||||||
|     // VkSemaphore sig_in; |  | ||||||
|     int has_dma_buf; |     int has_dma_buf; | ||||||
| #ifdef PLACEBO_GL | #ifdef PLACEBO_GL | ||||||
|  | #if PL_API_VER >= 229 | ||||||
|  |     struct pl_opengl_t *gl; | ||||||
|  | #else | ||||||
|     struct pl_opengl *gl; |     struct pl_opengl *gl; | ||||||
|  | #endif | ||||||
| #endif | #endif | ||||||
|     const struct pl_hook *hook[NUM_SHADERS]; |     const struct pl_hook *hook[NUM_SHADERS]; | ||||||
|     int num_shaders; |     int num_shaders; | ||||||
| @@ -1473,6 +1477,9 @@ typedef struct priv { | |||||||
|  |  | ||||||
| static priv *p; | static priv *p; | ||||||
| static struct pl_overlay osdoverlay; | static struct pl_overlay osdoverlay; | ||||||
|  | #if PL_API_VER >= 229 | ||||||
|  | static struct pl_overlay_part part; | ||||||
|  | #endif | ||||||
|  |  | ||||||
| static int semid; | static int semid; | ||||||
| struct itimerval itimer; | struct itimerval itimer; | ||||||
| @@ -1866,7 +1873,6 @@ static bool create_context_cb(EGLDisplay display, int es_version, EGLContext *ou | |||||||
|                              EGL_NONE}; |                              EGL_NONE}; | ||||||
|     EGLint num_configs = 0; |     EGLint num_configs = 0; | ||||||
|  |  | ||||||
| #ifndef RASPI |  | ||||||
|     attribs = attributes10; |     attribs = attributes10; | ||||||
|     *bpp = 10; |     *bpp = 10; | ||||||
|     if (!eglChooseConfig(display, attributes10, NULL, 0, |     if (!eglChooseConfig(display, attributes10, NULL, 0, | ||||||
| @@ -1879,9 +1885,7 @@ static bool create_context_cb(EGLDisplay display, int es_version, EGLContext *ou | |||||||
|                              &num_configs)) { // try 8 Bit |                              &num_configs)) { // try 8 Bit | ||||||
|             num_configs = 0; |             num_configs = 0; | ||||||
|         } |         } | ||||||
|     } else |     } else if (num_configs == 0) { | ||||||
| #endif |  | ||||||
|         if (num_configs == 0) { |  | ||||||
|         EglCheck(); |         EglCheck(); | ||||||
|         Debug(3, " 10 Bit egl Failed\n"); |         Debug(3, " 10 Bit egl Failed\n"); | ||||||
|         attribs = attributes8; |         attribs = attributes8; | ||||||
| @@ -2014,22 +2018,20 @@ static CuvidDecoder *CuvidNewHwDecoder(VideoStream *stream) { | |||||||
|         Fatal("codec: can't allocate HW video codec context err %04x", i); |         Fatal("codec: can't allocate HW video codec context err %04x", i); | ||||||
|     } |     } | ||||||
| #endif | #endif | ||||||
| #if defined(VAAPI) && !defined(RASPI) | #if defined(VAAPI) | ||||||
|     // if ((i = av_hwdevice_ctx_create(&hw_device_ctx, AV_HWDEVICE_TYPE_VAAPI, |     // if ((i = av_hwdevice_ctx_create(&hw_device_ctx, AV_HWDEVICE_TYPE_VAAPI, | ||||||
|     // ":0.0" , NULL, 0)) != 0 ) { |     // ":0.0" , NULL, 0)) != 0 ) { | ||||||
|     if ((i = av_hwdevice_ctx_create(&hw_device_ctx, AV_HWDEVICE_TYPE_VAAPI, "/dev/dri/renderD128", NULL, 0)) != 0) { |     if ((i = av_hwdevice_ctx_create(&hw_device_ctx, AV_HWDEVICE_TYPE_VAAPI, "/dev/dri/renderD128", NULL, 0)) != 0) { | ||||||
|         Fatal("codec: can't allocate HW video codec context err %04x", i); |         Fatal("codec: can't allocate HW video codec context err %04x", i); | ||||||
|     } |     } | ||||||
| #endif | #endif | ||||||
| #ifndef RASPI |  | ||||||
|     HwDeviceContext = av_buffer_ref(hw_device_ctx); |     HwDeviceContext = av_buffer_ref(hw_device_ctx); | ||||||
| #endif |  | ||||||
|  |  | ||||||
|     if (!(decoder = calloc(1, sizeof(*decoder)))) { |     if (!(decoder = calloc(1, sizeof(*decoder)))) { | ||||||
|         Error(_("video/cuvid: out of memory\n")); |         Error(_("video/cuvid: out of memory\n")); | ||||||
|         return NULL; |         return NULL; | ||||||
|     } |     } | ||||||
| #if defined(VAAPI) && !defined(RASPI) | #if defined(VAAPI) | ||||||
|     VaDisplay = TO_VAAPI_DEVICE_CTX(HwDeviceContext)->display; |     VaDisplay = TO_VAAPI_DEVICE_CTX(HwDeviceContext)->display; | ||||||
|     decoder->VaDisplay = VaDisplay; |     decoder->VaDisplay = VaDisplay; | ||||||
| #endif | #endif | ||||||
| @@ -2353,9 +2355,6 @@ void createTextureDst(CuvidDecoder *decoder, int anz, unsigned int size_x, unsig | |||||||
|         img->repr.alpha = PL_ALPHA_UNKNOWN; |         img->repr.alpha = PL_ALPHA_UNKNOWN; | ||||||
|         img->color.primaries = pl_color_primaries_guess(size_x, size_y); // Gammut  overwritten later |         img->color.primaries = pl_color_primaries_guess(size_x, size_y); // Gammut  overwritten later | ||||||
|         img->color.transfer = PL_COLOR_TRC_BT_1886;                      // overwritten later |         img->color.transfer = PL_COLOR_TRC_BT_1886;                      // overwritten later | ||||||
|         img->color.light = PL_COLOR_LIGHT_SCENE_709_1886;                // needs config ??? |  | ||||||
|         img->color.sig_peak = 0.0f;                                      // needs config	 ???? |  | ||||||
|         img->color.sig_avg = 0.0f; |  | ||||||
|         img->num_overlays = 0; |         img->num_overlays = 0; | ||||||
|     } |     } | ||||||
|     NoContext; |     NoContext; | ||||||
| @@ -2381,13 +2380,19 @@ void generateVAAPIImage(CuvidDecoder *decoder, int index, const AVFrame *frame, | |||||||
|         return; |         return; | ||||||
|     } |     } | ||||||
|     // vaSyncSurface(decoder->VaDisplay, (unsigned int)frame->data[3]); |     // vaSyncSurface(decoder->VaDisplay, (unsigned int)frame->data[3]); | ||||||
|  |  | ||||||
|     Lock_and_SharedContext; |     Lock_and_SharedContext; | ||||||
|  |  | ||||||
|     for (n = 0; n < 2; n++) { //  Set DMA_BUF from VAAPI decoder to Textures |     for (n = 0; n < 2; n++) { //  Set DMA_BUF from VAAPI decoder to Textures | ||||||
|         int id = desc.layers[n].object_index[0]; |         int id = desc.layers[n].object_index[0]; | ||||||
|         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; |         struct pl_fmt *fmt; | ||||||
|  | #else | ||||||
|  |         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); | ||||||
| @@ -2450,7 +2455,9 @@ void generateVAAPIImage(CuvidDecoder *decoder, int index, const AVFrame *frame, | |||||||
|  |  | ||||||
|         decoder->pl_frames[index].planes[n].texture = pl_tex_create(p->gpu, &tex_params); |         decoder->pl_frames[index].planes[n].texture = pl_tex_create(p->gpu, &tex_params); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     Unlock_and_NoContext; |     Unlock_and_NoContext; | ||||||
|  |  | ||||||
| } | } | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| @@ -2495,21 +2502,12 @@ void createTextureDst(CuvidDecoder *decoder, int anz, unsigned int size_x, unsig | |||||||
|             glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); |             glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); | ||||||
|             glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); |             glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); | ||||||
|             glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); |             glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); | ||||||
| #ifdef RASPI |  | ||||||
|             if (PixFmt == AV_PIX_FMT_NV12) |  | ||||||
|                 glTexImage2D(GL_TEXTURE_2D, 0, GL_R8, n == 0 ? size_x : size_x / 2, n == 0 ? size_y : size_y / 2, 0, |  | ||||||
|                              GL_RED, GL_UNSIGNED_BYTE, NULL); |  | ||||||
|             else |  | ||||||
|                 glTexImage2D(GL_TEXTURE_2D, 0, GL_R16, n == 0 ? size_x : size_x / 2, n == 0 ? size_y : size_y / 2, 0, |  | ||||||
|                              GL_RED, GL_UNSIGNED_SHORT, NULL); |  | ||||||
| #else |  | ||||||
|             if (PixFmt == AV_PIX_FMT_NV12) |             if (PixFmt == AV_PIX_FMT_NV12) | ||||||
|                 glTexImage2D(GL_TEXTURE_2D, 0, n == 0 ? GL_R8 : GL_RG8, n == 0 ? size_x : size_x / 2, |                 glTexImage2D(GL_TEXTURE_2D, 0, n == 0 ? GL_R8 : GL_RG8, n == 0 ? size_x : size_x / 2, | ||||||
|                              n == 0 ? size_y : size_y / 2, 0, n == 0 ? GL_RED : GL_RG, GL_UNSIGNED_BYTE, NULL); |                              n == 0 ? size_y : size_y / 2, 0, n == 0 ? GL_RED : GL_RG, GL_UNSIGNED_BYTE, NULL); | ||||||
|             else |             else | ||||||
|                 glTexImage2D(GL_TEXTURE_2D, 0, n == 0 ? GL_R16 : GL_RG16, n == 0 ? size_x : size_x / 2, |                 glTexImage2D(GL_TEXTURE_2D, 0, n == 0 ? GL_R16 : GL_RG16, n == 0 ? size_x : size_x / 2, | ||||||
|                              n == 0 ? size_y : size_y / 2, 0, n == 0 ? GL_RED : GL_RG, GL_UNSIGNED_SHORT, NULL); |                              n == 0 ? size_y : size_y / 2, 0, n == 0 ? GL_RED : GL_RG, GL_UNSIGNED_SHORT, NULL); | ||||||
| #endif |  | ||||||
|             SDK_CHECK_ERROR_GL(); |             SDK_CHECK_ERROR_GL(); | ||||||
|             // register this texture with CUDA |             // register this texture with CUDA | ||||||
| #ifdef CUVID | #ifdef CUVID | ||||||
| @@ -2522,6 +2520,7 @@ void createTextureDst(CuvidDecoder *decoder, int anz, unsigned int size_x, unsig | |||||||
| #endif | #endif | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     glBindTexture(GL_TEXTURE_2D, 0); |     glBindTexture(GL_TEXTURE_2D, 0); | ||||||
|     GlxCheck(); |     GlxCheck(); | ||||||
| #ifdef VAAPI | #ifdef VAAPI | ||||||
| @@ -2542,11 +2541,23 @@ void createTextureDst(CuvidDecoder *decoder, int anz, unsigned int size_x, unsig | |||||||
|         attribs[num_attribs] = EGL_NONE;                                                                              \ |         attribs[num_attribs] = EGL_NONE;                                                                              \ | ||||||
|     } while (0) |     } while (0) | ||||||
|  |  | ||||||
| #define ADD_PLANE_ATTRIBS(plane)                                                                                      \ |  | ||||||
|  | #define ADD_DMABUF_PLANE_ATTRIBS(plane, fd, offset, stride)         \ | ||||||
|     do {                                                            \ |     do {                                                            \ | ||||||
|         ADD_ATTRIB(EGL_DMA_BUF_PLANE##plane##_FD_EXT, desc.objects[desc.layers[n].object_index[plane]].fd);           \ |         ADD_ATTRIB(EGL_DMA_BUF_PLANE ## plane ## _FD_EXT,           \ | ||||||
|         ADD_ATTRIB(EGL_DMA_BUF_PLANE##plane##_OFFSET_EXT, desc.layers[n].offset[plane]);                              \ |                    fd);                                             \ | ||||||
|         ADD_ATTRIB(EGL_DMA_BUF_PLANE##plane##_PITCH_EXT, desc.layers[n].pitch[plane]);                                \ |         ADD_ATTRIB(EGL_DMA_BUF_PLANE ## plane ## _OFFSET_EXT,       \ | ||||||
|  |                    offset);                                         \ | ||||||
|  |         ADD_ATTRIB(EGL_DMA_BUF_PLANE ## plane ## _PITCH_EXT,        \ | ||||||
|  |                    stride);                                         \ | ||||||
|  |     } while (0) | ||||||
|  |  | ||||||
|  | #define ADD_DMABUF_PLANE_MODIFIERS(plane, mod)                      \ | ||||||
|  |     do {                                                            \ | ||||||
|  |         ADD_ATTRIB(EGL_DMA_BUF_PLANE ## plane ## _MODIFIER_LO_EXT,  \ | ||||||
|  |                    (uint32_t) ((mod) & 0xFFFFFFFFlu));              \ | ||||||
|  |         ADD_ATTRIB(EGL_DMA_BUF_PLANE ## plane ## _MODIFIER_HI_EXT,  \ | ||||||
|  |                    (uint32_t) (((mod) >> 32u) & 0xFFFFFFFFlu));     \ | ||||||
|     } while (0) |     } while (0) | ||||||
|  |  | ||||||
| void generateVAAPIImage(CuvidDecoder *decoder, VASurfaceID index, const AVFrame *frame, int image_width, | void generateVAAPIImage(CuvidDecoder *decoder, VASurfaceID index, const AVFrame *frame, int image_width, | ||||||
| @@ -2555,7 +2566,7 @@ void generateVAAPIImage(CuvidDecoder *decoder, VASurfaceID index, const AVFrame | |||||||
|  |  | ||||||
|     uint64_t first_time; |     uint64_t first_time; | ||||||
|  |  | ||||||
| #if defined(VAAPI) && !defined(RASPI) | #if defined(VAAPI) | ||||||
|     VADRMPRIMESurfaceDescriptor desc; |     VADRMPRIMESurfaceDescriptor desc; | ||||||
|  |  | ||||||
|     vaSyncSurface(decoder->VaDisplay, (VASurfaceID)(uintptr_t)frame->data[3]); |     vaSyncSurface(decoder->VaDisplay, (VASurfaceID)(uintptr_t)frame->data[3]); | ||||||
| @@ -2570,26 +2581,26 @@ void generateVAAPIImage(CuvidDecoder *decoder, VASurfaceID index, const AVFrame | |||||||
|     // vaSyncSurface(decoder->VaDisplay, (VASurfaceID) (uintptr_t) |     // vaSyncSurface(decoder->VaDisplay, (VASurfaceID) (uintptr_t) | ||||||
|     // frame->data[3]); |     // frame->data[3]); | ||||||
| #endif | #endif | ||||||
| #ifdef RASPI |     pthread_mutex_lock(&OSDMutex); | ||||||
|     AVDRMFrameDescriptor desc; |  | ||||||
|  |  | ||||||
|     memcpy(&desc, frame->data[0], sizeof(desc)); |  | ||||||
|  |  | ||||||
| #endif |  | ||||||
|  |  | ||||||
|     eglMakeCurrent(eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, eglSharedContext); |     eglMakeCurrent(eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, eglSharedContext); | ||||||
|     EglCheck(); |     EglCheck(); | ||||||
|  |  | ||||||
|     for (int n = 0; n < Planes; n++) { |     for (int n = 0; n < Planes; n++) { | ||||||
|         int attribs[20] = {EGL_NONE}; |         int attribs[20] = {EGL_NONE}; | ||||||
|         uint num_attribs = 0; |         uint num_attribs = 0; | ||||||
|         int fd; |         int id = desc.layers[n].object_index[0]; | ||||||
|  |         int fd = desc.objects[id].fd; | ||||||
|  |  | ||||||
|  | #if defined(VAAPI) | ||||||
|  | //Debug(3,"Plane %d w %d h %d layers %d planes %d pitch %d format %04x\n",n,image_width,image_height,desc.num_layers,desc.layers[n].num_planes,desc.layers[n].pitch[0],desc.layers[n].drm_format); | ||||||
|  |         | ||||||
|          |          | ||||||
| #if defined(VAAPI) && !defined(RASPI) |  | ||||||
|         ADD_ATTRIB(EGL_LINUX_DRM_FOURCC_EXT, desc.layers[n].drm_format); |  | ||||||
|         ADD_ATTRIB(EGL_WIDTH, n == 0 ? image_width : image_width / 2); |         ADD_ATTRIB(EGL_WIDTH, n == 0 ? image_width : image_width / 2); | ||||||
|         ADD_ATTRIB(EGL_HEIGHT, n == 0 ? image_height : image_height / 2); |         ADD_ATTRIB(EGL_HEIGHT, n == 0 ? image_height : image_height / 2); | ||||||
|         ADD_PLANE_ATTRIBS(0); |         ADD_DMABUF_PLANE_MODIFIERS(0, desc.objects[id].drm_format_modifier); | ||||||
|  |         ADD_ATTRIB(EGL_LINUX_DRM_FOURCC_EXT, desc.layers[n].drm_format); | ||||||
|  |         ADD_DMABUF_PLANE_ATTRIBS(0, fd, desc.layers[n].offset[0],desc.layers[n].pitch[0]); | ||||||
|  |          | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|         decoder->images[index * Planes + n] = |         decoder->images[index * Planes + n] = | ||||||
| @@ -2600,12 +2611,22 @@ void generateVAAPIImage(CuvidDecoder *decoder, VASurfaceID index, const AVFrame | |||||||
|  |  | ||||||
|         glBindTexture(GL_TEXTURE_2D, decoder->gl_textures[index * Planes + n]); |         glBindTexture(GL_TEXTURE_2D, decoder->gl_textures[index * Planes + n]); | ||||||
|         EGLImageTargetTexture2DOES(GL_TEXTURE_2D, decoder->images[index * Planes + n]); |         EGLImageTargetTexture2DOES(GL_TEXTURE_2D, decoder->images[index * Planes + n]); | ||||||
|         decoder->fds[index * Planes + n] = desc.objects[n].fd; |         if (n==0) { | ||||||
|  |           decoder->fds[index * Planes + n] = fd; | ||||||
|  |            | ||||||
|  |         } | ||||||
|  |         else if (fd == decoder->fds[index * Planes]) { | ||||||
|  |           decoder->fds[index * Planes + n] = 0; | ||||||
|  |         } | ||||||
|  |         else { | ||||||
|  |             decoder->fds[index * Planes + n] = fd; | ||||||
|  |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     glBindTexture(GL_TEXTURE_2D, 0); |     glBindTexture(GL_TEXTURE_2D, 0); | ||||||
|     eglMakeCurrent(eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); |     eglMakeCurrent(eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); | ||||||
|     EglCheck(); |     EglCheck(); | ||||||
|  |     pthread_mutex_unlock(&OSDMutex); | ||||||
|     return; |     return; | ||||||
|  |  | ||||||
| esh_failed: | esh_failed: | ||||||
| @@ -2614,6 +2635,7 @@ esh_failed: | |||||||
|         close(desc.objects[n].fd); |         close(desc.objects[n].fd); | ||||||
|     eglMakeCurrent(eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); |     eglMakeCurrent(eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); | ||||||
|     EglCheck(); |     EglCheck(); | ||||||
|  |     pthread_mutex_unlock(&OSDMutex); | ||||||
| } | } | ||||||
| #endif | #endif | ||||||
| #endif | #endif | ||||||
| @@ -2669,8 +2691,6 @@ int push_filters(AVCodecContext *dec_ctx, CuvidDecoder *decoder, AVFrame *frame) | |||||||
|     while ((ret = av_buffersink_get_frame(decoder->buffersink_ctx, filt_frame)) >= 0) { |     while ((ret = av_buffersink_get_frame(decoder->buffersink_ctx, filt_frame)) >= 0) { | ||||||
|         filt_frame->pts /= 2; |         filt_frame->pts /= 2; | ||||||
|         decoder->Interlaced = 0; |         decoder->Interlaced = 0; | ||||||
|         // printf("vaapideint video:new	 %#012" PRIx64 " old %#012" PRIx64 |  | ||||||
|         // "\n",filt_frame->pts,frame->pts); |  | ||||||
|         CuvidSyncRenderFrame(decoder, dec_ctx, filt_frame); |         CuvidSyncRenderFrame(decoder, dec_ctx, filt_frame); | ||||||
|         filt_frame = av_frame_alloc(); // get new frame |         filt_frame = av_frame_alloc(); // get new frame | ||||||
|     } |     } | ||||||
| @@ -2947,7 +2967,19 @@ static enum AVPixelFormat Cuvid_get_format(CuvidDecoder *decoder, AVCodecContext | |||||||
|             VideoThreadUnlock(); |             VideoThreadUnlock(); | ||||||
|             // dont show first frame |             // dont show first frame | ||||||
| #endif | #endif | ||||||
| #ifdef YADIF |         } else { | ||||||
|  |             decoder->SyncCounter = 0; | ||||||
|  |             decoder->FrameCounter = 0; | ||||||
|  |             decoder->FramesDisplayed = 0; | ||||||
|  |             decoder->StartCounter = 0; | ||||||
|  |             decoder->Closing = 0; | ||||||
|  |             decoder->PTS = AV_NOPTS_VALUE; | ||||||
|  |             VideoDeltaPTS = 0; | ||||||
|  |             decoder->InputAspect = video_ctx->sample_aspect_ratio; | ||||||
|  |             CuvidUpdateOutput(decoder); // update aspect/scaling | ||||||
|  |         } | ||||||
|  |  | ||||||
|  | #if defined YADIF && defined CUVID | ||||||
|         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 | ||||||
| @@ -2960,17 +2992,6 @@ static enum AVPixelFormat Cuvid_get_format(CuvidDecoder *decoder, AVCodecContext | |||||||
|             Fatal(_("codec: can't set option deint to video codec!\n")); |             Fatal(_("codec: can't set option deint to video codec!\n")); | ||||||
|         } |         } | ||||||
| #endif | #endif | ||||||
|         } else { |  | ||||||
|             decoder->SyncCounter = 0; |  | ||||||
|             decoder->FrameCounter = 0; |  | ||||||
|             decoder->FramesDisplayed = 0; |  | ||||||
|             decoder->StartCounter = 0; |  | ||||||
|             decoder->Closing = 0; |  | ||||||
|             decoder->PTS = AV_NOPTS_VALUE; |  | ||||||
|             VideoDeltaPTS = 0; |  | ||||||
|             decoder->InputAspect = video_ctx->sample_aspect_ratio; |  | ||||||
|             CuvidUpdateOutput(decoder); // update aspect/scaling |  | ||||||
|         } |  | ||||||
|  |  | ||||||
|         CuvidMessage(2, "GetFormat Init ok %dx%d\n", video_ctx->width, video_ctx->height); |         CuvidMessage(2, "GetFormat Init ok %dx%d\n", video_ctx->width, video_ctx->height); | ||||||
|         decoder->InputAspect = video_ctx->sample_aspect_ratio; |         decoder->InputAspect = video_ctx->sample_aspect_ratio; | ||||||
| @@ -3060,18 +3081,10 @@ int get_RGB(CuvidDecoder *decoder) { | |||||||
|     glUniform1i(texLoc, 0); |     glUniform1i(texLoc, 0); | ||||||
|     texLoc = glGetUniformLocation(gl_prog, "texture1"); |     texLoc = glGetUniformLocation(gl_prog, "texture1"); | ||||||
|     glUniform1i(texLoc, 1); |     glUniform1i(texLoc, 1); | ||||||
| #ifdef RASPI |  | ||||||
|     texLoc = glGetUniformLocation(gl_prog, "texture2"); |  | ||||||
|     glUniform1i(texLoc, 2); |  | ||||||
| #endif |  | ||||||
|     glActiveTexture(GL_TEXTURE0); |     glActiveTexture(GL_TEXTURE0); | ||||||
|     glBindTexture(GL_TEXTURE_2D, decoder->gl_textures[current * Planes + 0]); |     glBindTexture(GL_TEXTURE_2D, decoder->gl_textures[current * Planes + 0]); | ||||||
|     glActiveTexture(GL_TEXTURE1); |     glActiveTexture(GL_TEXTURE1); | ||||||
|     glBindTexture(GL_TEXTURE_2D, decoder->gl_textures[current * Planes + 1]); |     glBindTexture(GL_TEXTURE_2D, decoder->gl_textures[current * Planes + 1]); | ||||||
| #ifdef RASPI |  | ||||||
|     glActiveTexture(GL_TEXTURE2); |  | ||||||
|     glBindTexture(GL_TEXTURE_2D, decoder->gl_textures[current * Planes + 2]); |  | ||||||
| #endif |  | ||||||
|     glBindFramebuffer(GL_FRAMEBUFFER, fb); |     glBindFramebuffer(GL_FRAMEBUFFER, fb); | ||||||
|  |  | ||||||
|     render_pass_quad(1, 0.0, 0.0); |     render_pass_quad(1, 0.0, 0.0); | ||||||
| @@ -3183,13 +3196,11 @@ int get_RGB(CuvidDecoder *decoder) { | |||||||
|     target.repr.bits.bit_shift = 0; |     target.repr.bits.bit_shift = 0; | ||||||
|     target.color.primaries = PL_COLOR_PRIM_BT_709; |     target.color.primaries = PL_COLOR_PRIM_BT_709; | ||||||
|     target.color.transfer = PL_COLOR_TRC_BT_1886; |     target.color.transfer = PL_COLOR_TRC_BT_1886; | ||||||
|     target.color.light = PL_COLOR_LIGHT_DISPLAY; |  | ||||||
|     target.color.sig_peak = 0; |  | ||||||
|     target.color.sig_avg = 0; |  | ||||||
|  |  | ||||||
|     if (ovl) { |     if (ovl) { | ||||||
|         target.overlays = ovl; |         target.overlays = ovl; | ||||||
|         target.num_overlays = 1; |         target.num_overlays = 1; | ||||||
|  | #if PL_API_VER < 229 | ||||||
| #ifdef PLACEBO_GL | #ifdef PLACEBO_GL | ||||||
|         x0 = ovl->rect.x0; |         x0 = ovl->rect.x0; | ||||||
|         y1 = ovl->rect.y0; |         y1 = ovl->rect.y0; | ||||||
| @@ -3209,6 +3220,28 @@ int get_RGB(CuvidDecoder *decoder) { | |||||||
|         ovl->rect.x1 = (float)x1 * faktorx; |         ovl->rect.x1 = (float)x1 * faktorx; | ||||||
|         ovl->rect.y1 = (float)y1 * faktory; |         ovl->rect.y1 = (float)y1 * faktory; | ||||||
| #endif | #endif | ||||||
|  | #else | ||||||
|  | #ifdef PLACEBO_GL | ||||||
|  |         x0 = part.dst.x0; | ||||||
|  |         y1 = part.dst.y0; | ||||||
|  |         x1 = part.dst.x1; | ||||||
|  |         y0 = part.dst.y1; | ||||||
|  |         part.dst.x0 = (float)x0 * faktorx; | ||||||
|  |         part.dst.y0 = (float)y0 * faktory; | ||||||
|  |         part.dst.x1 = (float)x1 * faktorx; | ||||||
|  |         part.dst.y1 = (float)y1 * faktory; | ||||||
|  | #else | ||||||
|  |         x0 = part.dst.x0; | ||||||
|  |         y0 = part.dst.y0; | ||||||
|  |         x1 = part.dst.x1; | ||||||
|  |         y1 = part.dst.y1; | ||||||
|  |         part.dst.x0 = (float)x0 * faktorx; | ||||||
|  |         part.dst.y0 = (float)y0 * faktory; | ||||||
|  |         part.dst.x1 = (float)x1 * faktorx; | ||||||
|  |         part.dst.y1 = (float)y1 * faktory; | ||||||
|  | #endif | ||||||
|  | #endif | ||||||
|  |  | ||||||
|  |  | ||||||
|     } else { |     } else { | ||||||
|         target.overlays = 0; |         target.overlays = 0; | ||||||
| @@ -3222,6 +3255,7 @@ int get_RGB(CuvidDecoder *decoder) { | |||||||
|     pl_gpu_finish(p->gpu); |     pl_gpu_finish(p->gpu); | ||||||
|  |  | ||||||
|     if (ovl) { |     if (ovl) { | ||||||
|  | #if PL_API_VER < 229 | ||||||
| #ifdef PLACEBO_GL | #ifdef PLACEBO_GL | ||||||
|         ovl->rect.x0 = x0; |         ovl->rect.x0 = x0; | ||||||
|         ovl->rect.y0 = y1; |         ovl->rect.y0 = y1; | ||||||
| @@ -3232,6 +3266,19 @@ int get_RGB(CuvidDecoder *decoder) { | |||||||
|         ovl->rect.y0 = y0; |         ovl->rect.y0 = y0; | ||||||
|         ovl->rect.x1 = x1; |         ovl->rect.x1 = x1; | ||||||
|         ovl->rect.y1 = y1; |         ovl->rect.y1 = y1; | ||||||
|  | #endif | ||||||
|  | #else | ||||||
|  | #ifdef PLACEBO_GL | ||||||
|  |         part.dst.x0 = x0; | ||||||
|  |         part.dst.y0 = y1; | ||||||
|  |         part.dst.x1 = x1; | ||||||
|  |         part.dst.y1 = y0; | ||||||
|  | #else | ||||||
|  |         part.dst.x0 = x0; | ||||||
|  |         part.dst.y0 = y0; | ||||||
|  |         part.dst.x1 = x1; | ||||||
|  |         part.dst.y1 = y1; | ||||||
|  | #endif | ||||||
| #endif | #endif | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -3501,35 +3548,12 @@ static void CuvidRenderFrame(CuvidDecoder *decoder, const AVCodecContext *video_ | |||||||
|  |  | ||||||
|     //    printf("Patched  colorspace %d Primaries %d TRC |     //    printf("Patched  colorspace %d Primaries %d TRC | ||||||
|     //    %d\n",frame->colorspace,frame->color_primaries,frame->color_trc); |     //    %d\n",frame->colorspace,frame->color_primaries,frame->color_trc); | ||||||
| #ifdef RASPI |  | ||||||
|     // |  | ||||||
|     //	Check image, format, size |  | ||||||
|     // |  | ||||||
|     if ( // decoder->PixFmt != video_ctx->pix_fmt |  | ||||||
|         video_ctx->width != decoder->InputWidth |  | ||||||
|         //	|| decoder->ColorSpace != color |  | ||||||
|         || video_ctx->height != decoder->InputHeight) { |  | ||||||
|         Debug(3, "fmt %02d:%02d	 width %d:%d hight %d:%d\n", decoder->ColorSpace, frame->colorspace, video_ctx->width, |  | ||||||
|               decoder->InputWidth, video_ctx->height, decoder->InputHeight); |  | ||||||
|         decoder->PixFmt = AV_PIX_FMT_NV12; |  | ||||||
|         decoder->InputWidth = video_ctx->width; |  | ||||||
|         decoder->InputHeight = video_ctx->height; |  | ||||||
|         CuvidCleanup(decoder); |  | ||||||
|         decoder->SurfacesNeeded = VIDEO_SURFACES_MAX + 1; |  | ||||||
|         CuvidSetupOutput(decoder); |  | ||||||
|     } |  | ||||||
| #endif |  | ||||||
|     // |     // | ||||||
|     //	Copy data from frame to image |     //	Copy data from frame to image | ||||||
|     // |     // | ||||||
| #ifdef RASPI |  | ||||||
|     if (video_ctx->pix_fmt == 0) { |  | ||||||
| #else |  | ||||||
|     if (video_ctx->pix_fmt == PIXEL_FORMAT) { |     if (video_ctx->pix_fmt == PIXEL_FORMAT) { | ||||||
| #endif |  | ||||||
|         int w = decoder->InputWidth; |         int w = decoder->InputWidth; | ||||||
|         int h = decoder->InputHeight; |         int h = decoder->InputHeight; | ||||||
|  |  | ||||||
|         decoder->ColorSpace = color; // save colorspace |         decoder->ColorSpace = color; // save colorspace | ||||||
|         decoder->trc = frame->color_trc; |         decoder->trc = frame->color_trc; | ||||||
|         decoder->color_primaries = frame->color_primaries; |         decoder->color_primaries = frame->color_primaries; | ||||||
| @@ -3557,8 +3581,13 @@ static void CuvidRenderFrame(CuvidDecoder *decoder, const AVCodecContext *video_ | |||||||
|             // %p\n",surface,decoder->pl_frames[surface].planes[0].texture,decoder->pl_frames[surface].planes[1].texture); |             // %p\n",surface,decoder->pl_frames[surface].planes[0].texture,decoder->pl_frames[surface].planes[1].texture); | ||||||
|             bool ok = pl_tex_upload(p->gpu, &(struct pl_tex_transfer_params){ |             bool ok = pl_tex_upload(p->gpu, &(struct pl_tex_transfer_params){ | ||||||
|                                                 .tex = decoder->pl_frames[surface].planes[0].texture, |                                                 .tex = decoder->pl_frames[surface].planes[0].texture, | ||||||
|  | #if PL_API_VER < 292 | ||||||
|                                                 .stride_w = output->linesize[0], |                                                 .stride_w = output->linesize[0], | ||||||
|                                                 .stride_h = h, |                                                 .stride_h = h, | ||||||
|  | #else | ||||||
|  |                                                 .row_pitch = output->linesize[0], | ||||||
|  |                                                 .depth_pitch = h, | ||||||
|  | #endif | ||||||
|                                                 .ptr = output->data[0], |                                                 .ptr = output->data[0], | ||||||
|                                                 .rc.x1 = w, |                                                 .rc.x1 = w, | ||||||
|                                                 .rc.y1 = h, |                                                 .rc.y1 = h, | ||||||
| @@ -3566,8 +3595,13 @@ static void CuvidRenderFrame(CuvidDecoder *decoder, const AVCodecContext *video_ | |||||||
|                                             }); |                                             }); | ||||||
|             ok &= pl_tex_upload(p->gpu, &(struct pl_tex_transfer_params){ |             ok &= pl_tex_upload(p->gpu, &(struct pl_tex_transfer_params){ | ||||||
|                                             .tex = decoder->pl_frames[surface].planes[1].texture, |                                             .tex = decoder->pl_frames[surface].planes[1].texture, | ||||||
|  | #if PL_API_VER < 292 | ||||||
|                                             .stride_w = output->linesize[0] / 2, |                                             .stride_w = output->linesize[0] / 2, | ||||||
|                                             .stride_h = h / 2, |                                             .stride_h = h / 2, | ||||||
|  | #else | ||||||
|  |                                             .row_pitch = output->linesize[0] / 2, | ||||||
|  |                                             .depth_pitch = h, | ||||||
|  | #endif                                            | ||||||
|                                             .ptr = output->data[1], |                                             .ptr = output->data[1], | ||||||
|                                             .rc.x1 = w / 2, |                                             .rc.x1 = w / 2, | ||||||
|                                             .rc.y1 = h / 2, |                                             .rc.y1 = h / 2, | ||||||
| @@ -3750,7 +3784,6 @@ static void CuvidMixVideo(CuvidDecoder *decoder, __attribute__((unused)) int lev | |||||||
|     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; | ||||||
|     const struct pl_fmt *fmt; |  | ||||||
|     struct pl_tex *tex0, *tex1; |     struct pl_tex *tex0, *tex1; | ||||||
|  |  | ||||||
|     struct pl_frame *img; |     struct pl_frame *img; | ||||||
| @@ -3768,6 +3801,7 @@ static void CuvidMixVideo(CuvidDecoder *decoder, __attribute__((unused)) int lev | |||||||
|     AVFrameSideData *sd, *sd1 = NULL, *sd2 = NULL; |     AVFrameSideData *sd, *sd1 = NULL, *sd2 = NULL; | ||||||
|  |  | ||||||
| #ifdef PLACEBO | #ifdef PLACEBO | ||||||
|  |  | ||||||
|     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; | ||||||
| @@ -3821,19 +3855,11 @@ static void CuvidMixVideo(CuvidDecoder *decoder, __attribute__((unused)) int lev | |||||||
|     glUniform1i(texLoc, 0); |     glUniform1i(texLoc, 0); | ||||||
|     texLoc = glGetUniformLocation(gl_prog, "texture1"); |     texLoc = glGetUniformLocation(gl_prog, "texture1"); | ||||||
|     glUniform1i(texLoc, 1); |     glUniform1i(texLoc, 1); | ||||||
| #ifdef RASPI |  | ||||||
|     texLoc = glGetUniformLocation(gl_prog, "texture2"); |  | ||||||
|     glUniform1i(texLoc, 2); |  | ||||||
| #endif |  | ||||||
|  |  | ||||||
|     glActiveTexture(GL_TEXTURE0); |     glActiveTexture(GL_TEXTURE0); | ||||||
|     glBindTexture(GL_TEXTURE_2D, decoder->gl_textures[current * Planes + 0]); |     glBindTexture(GL_TEXTURE_2D, decoder->gl_textures[current * Planes + 0]); | ||||||
|     glActiveTexture(GL_TEXTURE1); |     glActiveTexture(GL_TEXTURE1); | ||||||
|     glBindTexture(GL_TEXTURE_2D, decoder->gl_textures[current * Planes + 1]); |     glBindTexture(GL_TEXTURE_2D, decoder->gl_textures[current * Planes + 1]); | ||||||
| #ifdef RASPI |  | ||||||
|     glActiveTexture(GL_TEXTURE2); |  | ||||||
|     glBindTexture(GL_TEXTURE_2D, decoder->gl_textures[current * Planes + 2]); |  | ||||||
| #endif |  | ||||||
|  |  | ||||||
|     render_pass_quad(0, xcropf, ycropf); |     render_pass_quad(0, xcropf, ycropf); | ||||||
|  |  | ||||||
| @@ -3848,6 +3874,12 @@ static void CuvidMixVideo(CuvidDecoder *decoder, __attribute__((unused)) int lev | |||||||
|     memcpy(&render_params, &pl_render_default_params, sizeof(render_params)); |     memcpy(&render_params, &pl_render_default_params, sizeof(render_params)); | ||||||
|     render_params.deband_params = &deband; |     render_params.deband_params = &deband; | ||||||
|  |  | ||||||
|  |     // provide LUT Table | ||||||
|  |     if (LUTon) | ||||||
|  |         render_params.lut = p->lut; | ||||||
|  |     else | ||||||
|  |         render_params.lut = NULL; | ||||||
|  |          | ||||||
|     frame = decoder->frames[current]; |     frame = decoder->frames[current]; | ||||||
|  |  | ||||||
|     // Fix Color Parameters |     // Fix Color Parameters | ||||||
| @@ -3858,7 +3890,6 @@ static void CuvidMixVideo(CuvidDecoder *decoder, __attribute__((unused)) int lev | |||||||
|             memcpy(&img->repr, &pl_color_repr_sdtv, sizeof(struct pl_color_repr)); |             memcpy(&img->repr, &pl_color_repr_sdtv, sizeof(struct pl_color_repr)); | ||||||
|             img->color.primaries = PL_COLOR_PRIM_BT_601_625; |             img->color.primaries = PL_COLOR_PRIM_BT_601_625; | ||||||
|             img->color.transfer = PL_COLOR_TRC_BT_1886; |             img->color.transfer = PL_COLOR_TRC_BT_1886; | ||||||
|             img->color.light = PL_COLOR_LIGHT_DISPLAY; |  | ||||||
|             pl->shift_x = 0.0f; |             pl->shift_x = 0.0f; | ||||||
|             break; |             break; | ||||||
|         case AVCOL_SPC_BT709: |         case AVCOL_SPC_BT709: | ||||||
| @@ -3872,9 +3903,10 @@ static void CuvidMixVideo(CuvidDecoder *decoder, __attribute__((unused)) int lev | |||||||
|             memcpy(&img->repr, &pl_color_repr_uhdtv, sizeof(struct pl_color_repr)); |             memcpy(&img->repr, &pl_color_repr_uhdtv, sizeof(struct pl_color_repr)); | ||||||
|             memcpy(&img->color, &pl_color_space_bt2020_hlg, sizeof(struct pl_color_space)); |             memcpy(&img->color, &pl_color_space_bt2020_hlg, sizeof(struct pl_color_space)); | ||||||
|             deband.grain = 0.0f; // no grain in HDR |             deband.grain = 0.0f; // no grain in HDR | ||||||
|             img->color.sig_scale = 1.0f; |  | ||||||
|             pl->shift_x = -0.5f; |             pl->shift_x = -0.5f; | ||||||
|  |             // Kein LUT bei HDR | ||||||
|  |             render_params.lut = NULL; | ||||||
|  | #if 0 | ||||||
|             if ((sd = av_frame_get_side_data(frame, AV_FRAME_DATA_ICC_PROFILE))) { |             if ((sd = av_frame_get_side_data(frame, AV_FRAME_DATA_ICC_PROFILE))) { | ||||||
|                 img->profile = (struct pl_icc_profile){ |                 img->profile = (struct pl_icc_profile){ | ||||||
|                     .data = sd->data, |                     .data = sd->data, | ||||||
| @@ -3903,13 +3935,14 @@ static void CuvidMixVideo(CuvidDecoder *decoder, __attribute__((unused)) int lev | |||||||
|             // Make sure this value is more or less legal |             // Make sure this value is more or less legal | ||||||
|             if (img->color.sig_peak < 1.0 || img->color.sig_peak > 50.0) |             if (img->color.sig_peak < 1.0 || img->color.sig_peak > 50.0) | ||||||
|                 img->color.sig_peak = 0.0; |                 img->color.sig_peak = 0.0; | ||||||
|  | #endif | ||||||
| #if defined VAAPI || defined USE_DRM | #if defined VAAPI || defined USE_DRM | ||||||
|             render_params.peak_detect_params = NULL; |             render_params.peak_detect_params = NULL; | ||||||
|             render_params.deband_params = NULL; |             render_params.deband_params = NULL; | ||||||
|             render_params.dither_params = NULL; |             render_params.dither_params = NULL; | ||||||
|             render_params.skip_anti_aliasing = true; |             render_params.skip_anti_aliasing = true; | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|             break; |             break; | ||||||
|  |  | ||||||
|         default: // fallback |         default: // fallback | ||||||
| @@ -3943,7 +3976,6 @@ static void CuvidMixVideo(CuvidDecoder *decoder, __attribute__((unused)) int lev | |||||||
|             if (decoder->ColorSpace == AVCOL_SPC_BT470BG) { |             if (decoder->ColorSpace == AVCOL_SPC_BT470BG) { | ||||||
|                 target->color.primaries = PL_COLOR_PRIM_BT_601_625; |                 target->color.primaries = PL_COLOR_PRIM_BT_601_625; | ||||||
|                 target->color.transfer = PL_COLOR_TRC_BT_1886; |                 target->color.transfer = PL_COLOR_TRC_BT_1886; | ||||||
|                 target->color.light = PL_COLOR_LIGHT_DISPLAY; |  | ||||||
|             } else { |             } else { | ||||||
|                 memcpy(&target->color, &pl_color_space_bt709, sizeof(struct pl_color_space)); |                 memcpy(&target->color, &pl_color_space_bt709, sizeof(struct pl_color_space)); | ||||||
|             } |             } | ||||||
| @@ -3955,7 +3987,6 @@ static void CuvidMixVideo(CuvidDecoder *decoder, __attribute__((unused)) int lev | |||||||
|             } else if (decoder->ColorSpace == AVCOL_SPC_BT470BG) { |             } else if (decoder->ColorSpace == AVCOL_SPC_BT470BG) { | ||||||
|                 target->color.primaries = PL_COLOR_PRIM_BT_601_625; |                 target->color.primaries = PL_COLOR_PRIM_BT_601_625; | ||||||
|                 target->color.transfer = PL_COLOR_TRC_BT_1886; |                 target->color.transfer = PL_COLOR_TRC_BT_1886; | ||||||
|                 target->color.light = PL_COLOR_LIGHT_DISPLAY; |  | ||||||
|                 ; |                 ; | ||||||
|             } else { |             } else { | ||||||
|                 memcpy(&target->color, &pl_color_space_bt709, sizeof(struct pl_color_space)); |                 memcpy(&target->color, &pl_color_space_bt709, sizeof(struct pl_color_space)); | ||||||
| @@ -3983,8 +4014,6 @@ static void CuvidMixVideo(CuvidDecoder *decoder, __attribute__((unused)) int lev | |||||||
|     } |     } | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|     // printf("sys %d prim %d trc %d light |  | ||||||
|     // %d\n",img->repr.sys,img->color.primaries,img->color.transfer,img->color.light); |  | ||||||
|     //  Source crop |     //  Source crop | ||||||
|     if (VideoScalerTest) { // right side defined scaler |     if (VideoScalerTest) { // right side defined scaler | ||||||
|  |  | ||||||
| @@ -4059,8 +4088,11 @@ static void CuvidMixVideo(CuvidDecoder *decoder, __attribute__((unused)) int lev | |||||||
|  |  | ||||||
|     // render_params.upscaler = &pl_filter_ewa_lanczos; |     // render_params.upscaler = &pl_filter_ewa_lanczos; | ||||||
|  |  | ||||||
|     render_params.upscaler = pl_named_filters[VideoScaling[decoder->Resolution]].filter; |     render_params.upscaler = pl_filter_presets[VideoScaling[decoder->Resolution]].filter; | ||||||
|     render_params.downscaler = pl_named_filters[VideoScaling[decoder->Resolution]].filter; |     render_params.downscaler = pl_filter_presets[VideoScaling[decoder->Resolution]].filter; | ||||||
|  |  | ||||||
|  |     if (level) | ||||||
|  |         render_params.skip_target_clearing = 1; | ||||||
|  |  | ||||||
|     render_params.color_adjustment = &colors; |     render_params.color_adjustment = &colors; | ||||||
|  |  | ||||||
| @@ -4108,13 +4140,9 @@ static void CuvidMixVideo(CuvidDecoder *decoder, __attribute__((unused)) int lev | |||||||
|         render_params.num_hooks = p->num_shaders; |         render_params.num_hooks = p->num_shaders; | ||||||
|     } |     } | ||||||
| #endif | #endif | ||||||
| #if PL_API_VER >= 113 |  | ||||||
|     // provide LUT Table |      | ||||||
|     if (LUTon) |  | ||||||
|         render_params.lut = p->lut; |  | ||||||
|     else |  | ||||||
|         render_params.lut = NULL; |  | ||||||
| #endif |  | ||||||
|  |  | ||||||
|     if (decoder->newchannel && current == 0) { |     if (decoder->newchannel && current == 0) { | ||||||
|         colors.brightness = -1.0f; |         colors.brightness = -1.0f; | ||||||
| @@ -4131,7 +4159,8 @@ static void CuvidMixVideo(CuvidDecoder *decoder, __attribute__((unused)) int lev | |||||||
|     if (!pl_render_image(p->renderer, &decoder->pl_frames[current], target, &render_params)) { |     if (!pl_render_image(p->renderer, &decoder->pl_frames[current], target, &render_params)) { | ||||||
|         Debug(4, "Failed rendering frame!\n"); |         Debug(4, "Failed rendering frame!\n"); | ||||||
|     } |     } | ||||||
|     //   pl_gpu_finish(p->gpu); |      | ||||||
|  |      | ||||||
|     // printf("Rendertime %ld -- \n,",GetusTicks() - tt); |     // printf("Rendertime %ld -- \n,",GetusTicks() - tt); | ||||||
|  |  | ||||||
|     if (VideoScalerTest) { // left side test scaler |     if (VideoScalerTest) { // left side test scaler | ||||||
| @@ -4154,11 +4183,12 @@ static void CuvidMixVideo(CuvidDecoder *decoder, __attribute__((unused)) int lev | |||||||
|         target->crop.y1 = dst_video_rect.y1; |         target->crop.y1 = dst_video_rect.y1; | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|         render_params.upscaler = pl_named_filters[VideoScalerTest - 1].filter; |         render_params.upscaler = pl_filter_presets[VideoScalerTest - 1].filter; | ||||||
|         render_params.downscaler = pl_named_filters[VideoScalerTest - 1].filter; |         render_params.downscaler = pl_filter_presets[VideoScalerTest - 1].filter; | ||||||
|  |  | ||||||
|         //	render_params.lut = NULL; |         //	render_params.lut = NULL; | ||||||
|         render_params.num_hooks = 0; |         render_params.num_hooks = 0; | ||||||
|  |         render_params.skip_target_clearing = 1; | ||||||
|  |  | ||||||
|         if (!p->renderertest) |         if (!p->renderertest) | ||||||
|             p->renderertest = pl_renderer_create(p->ctx, p->gpu); |             p->renderertest = pl_renderer_create(p->ctx, p->gpu); | ||||||
| @@ -4185,11 +4215,16 @@ void make_osd_overlay(int x, int y, int width, int height) { | |||||||
|  |  | ||||||
|     pl = &osdoverlay; |     pl = &osdoverlay; | ||||||
|  |  | ||||||
|  | #if PL_API_VER < 229 | ||||||
|     if (pl->plane.texture && (pl->plane.texture->params.w != width || pl->plane.texture->params.h != height)) { |     if (pl->plane.texture && (pl->plane.texture->params.w != width || pl->plane.texture->params.h != height)) { | ||||||
|         //	  pl_tex_clear(p->gpu, pl->plane.texture, (float[4]) { 0 }); |  | ||||||
|         pl_tex_destroy(p->gpu, &pl->plane.texture); |         pl_tex_destroy(p->gpu, &pl->plane.texture); | ||||||
|  | #else | ||||||
|  |     if (pl->tex && (pl->tex->params.w != width || pl->tex->params.h != height)) { | ||||||
|  |         pl_tex_destroy(p->gpu, &pl->tex); | ||||||
|  | #endif | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  | #if PL_API_VER < 229 | ||||||
|     // make texture for OSD |     // make texture for OSD | ||||||
|     if (pl->plane.texture == NULL) { |     if (pl->plane.texture == NULL) { | ||||||
|         pl->plane.texture = pl_tex_create( |         pl->plane.texture = pl_tex_create( | ||||||
| @@ -4210,12 +4245,29 @@ void make_osd_overlay(int x, int y, int width, int height) { | |||||||
|     pl->plane.component_mapping[1] = PL_CHANNEL_G; |     pl->plane.component_mapping[1] = PL_CHANNEL_G; | ||||||
|     pl->plane.component_mapping[2] = PL_CHANNEL_B; |     pl->plane.component_mapping[2] = PL_CHANNEL_B; | ||||||
|     pl->plane.component_mapping[3] = PL_CHANNEL_A; |     pl->plane.component_mapping[3] = PL_CHANNEL_A; | ||||||
|  | #else | ||||||
|  |  // make texture for OSD | ||||||
|  |     if (pl->tex == NULL) { | ||||||
|  |         pl->tex = pl_tex_create( | ||||||
|  |             p->gpu, &(struct pl_tex_params) { | ||||||
|  |                 .w = width, .h = height, .d = 0, .format = fmt, .sampleable = true, .host_writable = true, | ||||||
|  |                 .blit_dst = true, | ||||||
|  |             }); | ||||||
|  |     } | ||||||
|  |     // make overlay | ||||||
|  |     pl_tex_clear(p->gpu, pl->tex, (float[4]){0}); | ||||||
|  |     part.src.x0 = 0.0f; | ||||||
|  |     part.src.y0 = 0.0f; | ||||||
|  |     part.src.x1 = width; | ||||||
|  |     part.src.y1 = height; | ||||||
|  | #endif | ||||||
|     pl->mode = PL_OVERLAY_NORMAL; |     pl->mode = PL_OVERLAY_NORMAL; | ||||||
|     pl->repr.sys = PL_COLOR_SYSTEM_RGB; |     pl->repr.sys = PL_COLOR_SYSTEM_RGB; | ||||||
|     pl->repr.levels = PL_COLOR_LEVELS_PC; |     pl->repr.levels = PL_COLOR_LEVELS_PC; | ||||||
|     pl->repr.alpha = PL_ALPHA_INDEPENDENT; |     pl->repr.alpha = PL_ALPHA_INDEPENDENT; | ||||||
|  |  | ||||||
|     memcpy(&osdoverlay.color, &pl_color_space_srgb, sizeof(struct pl_color_space)); |     memcpy(&osdoverlay.color, &pl_color_space_srgb, sizeof(struct pl_color_space)); | ||||||
|  | #if PL_API_VER < 229 | ||||||
| #ifdef PLACEBO_GL | #ifdef PLACEBO_GL | ||||||
|     pl->rect.x0 = x; |     pl->rect.x0 = x; | ||||||
|     pl->rect.y1 = VideoWindowHeight - y; // Boden von oben |     pl->rect.y1 = VideoWindowHeight - y; // Boden von oben | ||||||
| @@ -4228,6 +4280,21 @@ void make_osd_overlay(int x, int y, int width, int height) { | |||||||
|     pl->rect.x1 = x + width; |     pl->rect.x1 = x + width; | ||||||
|     pl->rect.y1 = VideoWindowHeight - height - y + offset; |     pl->rect.y1 = VideoWindowHeight - height - y + offset; | ||||||
| #endif | #endif | ||||||
|  | #else | ||||||
|  |     osdoverlay.parts = ∂ | ||||||
|  |     osdoverlay.num_parts = 1; | ||||||
|  | #ifdef PLACEBO_GL | ||||||
|  |     part.dst.x0 = x; | ||||||
|  |     part.dst.y1 = VideoWindowHeight - y; // Boden von oben | ||||||
|  |     part.dst.x1 = x + width; | ||||||
|  |     part.dst.y0 = VideoWindowHeight - height - y; | ||||||
|  | #else | ||||||
|  |     part.dst.x0 = x; | ||||||
|  |     part.dst.y0 = VideoWindowHeight - y + offset; // Boden von oben | ||||||
|  |     part.dst.x1 = x + width; | ||||||
|  |     part.dst.y1 = VideoWindowHeight - height - y + offset; | ||||||
|  | #endif | ||||||
|  | #endif | ||||||
| } | } | ||||||
| #endif | #endif | ||||||
| /// | /// | ||||||
| @@ -4360,24 +4427,29 @@ static void CuvidDisplayFrame(void) { | |||||||
|             if ((VideoShowBlackPicture && !decoder->TrickSpeed) || |             if ((VideoShowBlackPicture && !decoder->TrickSpeed) || | ||||||
|                 (VideoShowBlackPicture && decoder->Closing < -300)) { |                 (VideoShowBlackPicture && decoder->Closing < -300)) { | ||||||
|                 CuvidBlackSurface(decoder); |                 CuvidBlackSurface(decoder); | ||||||
|                 CuvidMessage(4, "video/cuvid: black surface displayed\n"); |                 CuvidMessage(4, "video/cuvid: black surface displayed Filled %d\n",filled); | ||||||
|             } |             } | ||||||
|             continue; |             continue; | ||||||
|         } |         } | ||||||
|         valid_frame = 1; |         valid_frame = 1; | ||||||
| #ifdef PLACEBO | #ifdef PLACEBO | ||||||
|  |         //pthread_mutex_lock(&OSDMutex); | ||||||
|         if (OsdShown == 1) { // New OSD opened |         if (OsdShown == 1) { // New OSD opened | ||||||
|             pthread_mutex_lock(&OSDMutex); |              | ||||||
|             make_osd_overlay(OSDx, OSDy, OSDxsize, OSDysize); |             make_osd_overlay(OSDx, OSDy, OSDxsize, OSDysize); | ||||||
|             if (posd) { |             if (posd) { | ||||||
|                 pl_tex_upload(p->gpu, &(struct pl_tex_transfer_params){ |                 pl_tex_upload(p->gpu, &(struct pl_tex_transfer_params){ | ||||||
|                                           // upload OSD |                                           // upload OSD | ||||||
|  | #if PL_API_VER >= 229 | ||||||
|  |                                           .tex = osdoverlay.tex, | ||||||
|  | #else | ||||||
|                                           .tex = osdoverlay.plane.texture, |                                           .tex = osdoverlay.plane.texture, | ||||||
|  | #endif | ||||||
|                                           .ptr = posd, |                                           .ptr = posd, | ||||||
|                                       }); |                                       }); | ||||||
|             } |             } | ||||||
|             OsdShown = 2; |             OsdShown = 2; | ||||||
|             pthread_mutex_unlock(&OSDMutex); |              | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         if (OsdShown == 2) { |         if (OsdShown == 2) { | ||||||
| @@ -4385,7 +4457,7 @@ static void CuvidDisplayFrame(void) { | |||||||
|         } else { |         } else { | ||||||
|             CuvidMixVideo(decoder, i, &target, NULL); |             CuvidMixVideo(decoder, i, &target, NULL); | ||||||
|         } |         } | ||||||
|  |         //pthread_mutex_unlock(&OSDMutex); | ||||||
| #else | #else | ||||||
|         CuvidMixVideo(decoder, i); |         CuvidMixVideo(decoder, i); | ||||||
| #endif | #endif | ||||||
| @@ -4402,6 +4474,9 @@ static void CuvidDisplayFrame(void) { | |||||||
|             decoder->grab = 0; |             decoder->grab = 0; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  | #ifdef PLACEBO | ||||||
|  |     pl_gpu_finish(p->gpu); | ||||||
|  | #endif | ||||||
|  |  | ||||||
| #ifndef PLACEBO | #ifndef PLACEBO | ||||||
|     //	add osd to surface |     //	add osd to surface | ||||||
| @@ -4468,9 +4543,14 @@ static void CuvidDisplayFrame(void) { | |||||||
|     // first_time = GetusTicks(); |     // first_time = GetusTicks(); | ||||||
|     if (!pl_swapchain_submit_frame(p->swapchain)) |     if (!pl_swapchain_submit_frame(p->swapchain)) | ||||||
|         Fatal(_("Failed to submit swapchain buffer\n"));  |         Fatal(_("Failed to submit swapchain buffer\n"));  | ||||||
|     pl_swapchain_swap_buffers(p->swapchain); // swap buffers |  | ||||||
|     NoContext; |  | ||||||
|     VideoThreadUnlock(); |     VideoThreadUnlock(); | ||||||
|  |     pl_swapchain_swap_buffers(p->swapchain); // swap buffers | ||||||
|  | #ifdef PLACEBO_GL | ||||||
|  |     eglMakeCurrent(eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); | ||||||
|  |     EglCheck();   | ||||||
|  | #endif | ||||||
|  |      | ||||||
|  |     | ||||||
| #else // not PLACEBO | #else // not PLACEBO | ||||||
| #ifdef CUVID | #ifdef CUVID | ||||||
|     glXGetVideoSyncSGI(&Count); // get current frame |     glXGetVideoSyncSGI(&Count); // get current frame | ||||||
| @@ -4813,7 +4893,7 @@ static void CuvidSyncRenderFrame(CuvidDecoder *decoder, const AVCodecContext *vi | |||||||
|     // if video output buffer is full, wait and display surface. |     // if video output buffer is full, wait and display surface. | ||||||
|     // loop for interlace |     // loop for interlace | ||||||
|     if (atomic_read(&decoder->SurfacesFilled) >= VIDEO_SURFACES_MAX) { |     if (atomic_read(&decoder->SurfacesFilled) >= VIDEO_SURFACES_MAX) { | ||||||
|         Fatal("video/cuvid: this code part shouldn't be used\n"); |         //Fatal("video/cuvid: this code part shouldn't be used\n"); | ||||||
|         return; |         return; | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -5517,7 +5597,7 @@ void InitPlacebo() { | |||||||
|     p->context.log_cb = &pl_log_intern; |     p->context.log_cb = &pl_log_intern; | ||||||
|     p->context.log_level = PL_LOG_WARN; // WARN |     p->context.log_level = PL_LOG_WARN; // WARN | ||||||
|  |  | ||||||
|     p->ctx = pl_context_create(PL_API_VER, &p->context); |     p->ctx = pl_log_create(PL_API_VER, &p->context); | ||||||
|     if (!p->ctx) { |     if (!p->ctx) { | ||||||
|         Fatal(_("Failed initializing libplacebo\n")); |         Fatal(_("Failed initializing libplacebo\n")); | ||||||
|     } |     } | ||||||
| @@ -5595,7 +5675,9 @@ void InitPlacebo() { | |||||||
|                                                          .surface = p->pSurface, |                                                          .surface = p->pSurface, | ||||||
|                                                          .present_mode = VK_PRESENT_MODE_FIFO_KHR, |                                                          .present_mode = VK_PRESENT_MODE_FIFO_KHR, | ||||||
|                                                          .swapchain_depth = SWAP_BUFFER_SIZE, |                                                          .swapchain_depth = SWAP_BUFFER_SIZE, | ||||||
|  | #if PL_API_VER < 229 | ||||||
|                                                          .prefer_hdr = true, |                                                          .prefer_hdr = true, | ||||||
|  | #endif | ||||||
|                                                      }); |                                                      }); | ||||||
|  |  | ||||||
| #endif | #endif | ||||||
| @@ -5677,8 +5759,13 @@ void exit_display() { | |||||||
|         return; |         return; | ||||||
|     } |     } | ||||||
|     pl_gpu_finish(p->gpu); |     pl_gpu_finish(p->gpu); | ||||||
|  | #if PL_API_VER >= 229 | ||||||
|  |     if (osdoverlay.tex) | ||||||
|  |         pl_tex_destroy(p->gpu, &osdoverlay.tex); | ||||||
|  | #else | ||||||
|     if (osdoverlay.plane.texture) |     if (osdoverlay.plane.texture) | ||||||
|         pl_tex_destroy(p->gpu, &osdoverlay.plane.texture); |         pl_tex_destroy(p->gpu, &osdoverlay.plane.texture); | ||||||
|  | #endif | ||||||
|  |  | ||||||
|     //	 pl_renderer_destroy(&p->renderer); |     //	 pl_renderer_destroy(&p->renderer); | ||||||
|     if (p->renderertest) { |     if (p->renderertest) { | ||||||
| @@ -5696,7 +5783,7 @@ void exit_display() { | |||||||
|     pl_vk_inst_destroy(&p->vk_inst); |     pl_vk_inst_destroy(&p->vk_inst); | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|     pl_context_destroy(&p->ctx); |     pl_log_destroy(&p->ctx); | ||||||
| #if PL_API_VER >= 113 | #if PL_API_VER >= 113 | ||||||
|     pl_lut_free(&p->lut); |     pl_lut_free(&p->lut); | ||||||
| #endif | #endif | ||||||
| @@ -6813,10 +6900,10 @@ void VideoSetAbove() { | |||||||
| void VideoSetDeinterlace(int mode[VideoResolutionMax]) { | void VideoSetDeinterlace(int mode[VideoResolutionMax]) { | ||||||
| #ifdef CUVID | #ifdef CUVID | ||||||
|     VideoDeinterlace[0] = mode[0]; // 576i |     VideoDeinterlace[0] = mode[0]; // 576i | ||||||
|     VideoDeinterlace[1] = 1;       // mode[1];  // 720p |     VideoDeinterlace[1] = 0;       // mode[1];  // 720p | ||||||
|     VideoDeinterlace[2] = mode[2]; // fake 1080 |     VideoDeinterlace[2] = mode[2]; // fake 1080 | ||||||
|     VideoDeinterlace[3] = mode[3]; // 1080 |     VideoDeinterlace[3] = mode[3]; // 1080 | ||||||
|     VideoDeinterlace[4] = 1;       // mode[4];  2160p |     VideoDeinterlace[4] = 0;       // mode[4];  2160p | ||||||
| #else | #else | ||||||
|     VideoDeinterlace[0] = 1; // 576i |     VideoDeinterlace[0] = 1; // 576i | ||||||
|     VideoDeinterlace[1] = 0; // mode[1];  // 720p |     VideoDeinterlace[1] = 0; // mode[1];  // 720p | ||||||
| @@ -7022,7 +7109,6 @@ void VideoInit(const char *display_name) { | |||||||
|     if (!display_name && !(display_name = getenv("DISPLAY"))) { |     if (!display_name && !(display_name = getenv("DISPLAY"))) { | ||||||
|         // if no environment variable, use :0.0 as default display name |         // if no environment variable, use :0.0 as default display name | ||||||
|         display_name = ":0.0"; |         display_name = ":0.0"; | ||||||
|      |  | ||||||
|     } |     } | ||||||
|     if (!getenv("DISPLAY")) { |     if (!getenv("DISPLAY")) { | ||||||
|         // force set DISPLAY environment variable, otherwise nvidia driver |         // force set DISPLAY environment variable, otherwise nvidia driver | ||||||
| @@ -7212,16 +7298,16 @@ int GlxInitopengl() { | |||||||
|         if (!eglOSDContext) { |         if (!eglOSDContext) { | ||||||
|             EglCheck(); |             EglCheck(); | ||||||
|             Fatal(_("video/egl: can't create thread egl context\n")); |             Fatal(_("video/egl: can't create thread egl context\n")); | ||||||
|             return NULL; |             return 1; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|     eglMakeCurrent(eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, eglOSDContext); |     eglMakeCurrent(eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, eglOSDContext); | ||||||
|     return; |     return 0; | ||||||
| } | } | ||||||
|  |  | ||||||
| int GlxDrawopengl() { | int GlxDrawopengl() { | ||||||
|     eglMakeCurrent(eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, eglSharedContext); |     eglMakeCurrent(eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, eglSharedContext); | ||||||
|     return; |     return 0; | ||||||
| } | } | ||||||
|  |  | ||||||
| void GlxDestroy() { | void GlxDestroy() { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user