mirror of
				https://github.com/jojo61/vdr-plugin-softhdcuvid.git
				synced 2025-03-01 10:39:28 +00:00 
			
		
		
		
	Compare commits
	
		
			29 Commits
		
	
	
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					f3ae69042f | ||
| 
						 | 
					6768bc5b18 | ||
| 
						 | 
					e624e9c83d | ||
| 
						 | 
					c907239bb5 | ||
| 
						 | 
					2c8e75e3ff | ||
| 
						 | 
					e3fe68d7e6 | ||
| 
						 | 
					41da5ca526 | ||
| 
						 | 
					68fc7e4511 | ||
| 
						 | 
					46df18afe0 | ||
| 
						 | 
					0ff83f0e31 | ||
| 
						 | 
					230bb5ca11 | ||
| 
						 | 
					f026e8e86d | ||
| 
						 | 
					9dd936df86 | ||
| 
						 | 
					4e5529efcf | ||
| 
						 | 
					20f1bd45e6 | ||
| 
						 | 
					7a7e09ff7a | ||
| 
						 | 
					c4a660ede2 | ||
| 
						 | 
					8e495266e2 | ||
| 
						 | 
					f27e4fb35f | ||
| 
						 | 
					e14ea73a00 | ||
| 
						 | 
					72cb77f771 | ||
| 
						 | 
					c679d812d1 | ||
| 
						 | 
					47b461ab46 | ||
| 
						 | 
					8629946041 | ||
| 
						 | 
					a222f6a1d5 | ||
| 
						 | 
					b51589aaa9 | ||
| 
						 | 
					c3af54aae0 | ||
| 
						 | 
					4e96489e35 | ||
| 
						 | 
					65017da5ac | 
							
								
								
									
										24
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										24
									
								
								Makefile
									
									
									
									
									
								
							@@ -23,8 +23,8 @@ CUVID ?= 0
 | 
			
		||||
DRM ?= 0
 | 
			
		||||
 | 
			
		||||
# use libplacebo -
 | 
			
		||||
# available for all decoders but for DRM you need LIBPLACEBO_GL
 | 
			
		||||
LIBPLACEBO ?= 1
 | 
			
		||||
# available for all decoders but for DRM and VAAPI you need LIBPLACEBO_GL
 | 
			
		||||
LIBPLACEBO ?= 0
 | 
			
		||||
LIBPLACEBO_GL ?= 0
 | 
			
		||||
 | 
			
		||||
# use YADIF deint - only available with cuvid
 | 
			
		||||
@@ -35,7 +35,6 @@ YADIF = 1
 | 
			
		||||
 | 
			
		||||
CONFIG := -DDEBUG 		# remove '#' to enable debug output
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#--------------------- no more config needed past this point--------------------------------
 | 
			
		||||
 | 
			
		||||
# sanitize selections --------
 | 
			
		||||
@@ -114,8 +113,8 @@ TMPDIR ?= /tmp
 | 
			
		||||
 | 
			
		||||
### The compiler options:
 | 
			
		||||
 | 
			
		||||
export CFLAGS	= $(call PKGCFG,cflags)
 | 
			
		||||
export CXXFLAGS = $(call PKGCFG,cxxflags)
 | 
			
		||||
export CFLAGS	= $(call PKGCFG,cflags) -fpermissive
 | 
			
		||||
export CXXFLAGS = $(call PKGCFG,cxxflags) -fpermissive
 | 
			
		||||
 | 
			
		||||
ifeq ($(CFLAGS),)
 | 
			
		||||
$(warning CFLAGS not set)
 | 
			
		||||
@@ -159,29 +158,29 @@ endif
 | 
			
		||||
 | 
			
		||||
ifeq ($(LIBPLACEBO_GL),1)
 | 
			
		||||
CONFIG += -DPLACEBO_GL -DPLACEBO
 | 
			
		||||
LIBS += -lepoxy
 | 
			
		||||
LIBS += -lplacebo
 | 
			
		||||
_CFLAGS += $(shell pkg-config --cflags libplacebo)
 | 
			
		||||
LIBS += $(shell pkg-config --libs epoxy libplacebo)
 | 
			
		||||
else
 | 
			
		||||
LIBS += -lEGL
 | 
			
		||||
LIBS += $(shell pkg-config --libs egl)
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
ifeq ($(LIBPLACEBO),1)
 | 
			
		||||
CONFIG += -DPLACEBO
 | 
			
		||||
LIBS += -lEGL
 | 
			
		||||
LIBS += -lplacebo
 | 
			
		||||
_CFLAGS += $(shell pkg-config --cflags libplacebo)
 | 
			
		||||
LIBS += $(shell pkg-config --libs egl libplacebo)
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
ifeq ($(DRM),1)
 | 
			
		||||
PLUGIN = softhddrm
 | 
			
		||||
CONFIG += -DUSE_DRM -DVAAPI
 | 
			
		||||
_CFLAGS += $(shell pkg-config --cflags libdrm)
 | 
			
		||||
LIBS += -lgbm -ldrm -lEGL
 | 
			
		||||
LIBS += $(shell pkg-config --libs egl gbm libdrm)
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
ifeq ($(CUVID),1)
 | 
			
		||||
#CONFIG += -DUSE_PIP			# PIP support
 | 
			
		||||
CONFIG += -DCUVID			# enable CUVID decoder
 | 
			
		||||
LIBS += -lEGL -lGL
 | 
			
		||||
LIBS += $(shell pkg-config --libs egl gl)
 | 
			
		||||
ifeq ($(YADIF),1)
 | 
			
		||||
CONFIG += -DYADIF			# Yadif only with CUVID
 | 
			
		||||
endif
 | 
			
		||||
@@ -274,6 +273,7 @@ LIBS += -lcuda -lnvcuvid
 | 
			
		||||
endif
 | 
			
		||||
 | 
			
		||||
LIBS += -lGLEW -lGLU  -ldl -lglut
 | 
			
		||||
#LIBS += -ldl $(shell pkg-config --libs glew glu glut)
 | 
			
		||||
 | 
			
		||||
### Includes and Defines (add further entries here):
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -251,8 +251,8 @@ Setup: /etc/vdr/setup.conf
 | 
			
		||||
	(Red * 65536 +  Green * 256 + Blue)
 | 
			
		||||
 | 
			
		||||
	softhddevice.StudioLevels = 0
 | 
			
		||||
		0 use PC levels (0-255) with vdpau.
 | 
			
		||||
		1 use studio levels (16-235) with vdpau.
 | 
			
		||||
	0 use limited RGB (16-235) with placebo.
 | 
			
		||||
	1 use full RGB (0-255) with placebo.
 | 
			
		||||
 | 
			
		||||
	softhddevice.Suspend.Close = 0
 | 
			
		||||
	1 suspend closes x11 window, connection and audio device.
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										5
									
								
								audio.c
									
									
									
									
									
								
							
							
						
						
									
										5
									
								
								audio.c
									
									
									
									
									
								
							@@ -2283,26 +2283,31 @@ found:
 | 
			
		||||
                                AudioChannelMatrix[u][chan] = 4;
 | 
			
		||||
                                break;
 | 
			
		||||
                            }
 | 
			
		||||
                            __attribute__ ((fallthrough));
 | 
			
		||||
                        case 4:
 | 
			
		||||
                            if (AudioChannelsInHw[5]) {
 | 
			
		||||
                                AudioChannelMatrix[u][chan] = 5;
 | 
			
		||||
                                break;
 | 
			
		||||
                            }
 | 
			
		||||
                            __attribute__ ((fallthrough));
 | 
			
		||||
                        case 5:
 | 
			
		||||
                            if (AudioChannelsInHw[6]) {
 | 
			
		||||
                                AudioChannelMatrix[u][chan] = 6;
 | 
			
		||||
                                break;
 | 
			
		||||
                            }
 | 
			
		||||
                            __attribute__ ((fallthrough));
 | 
			
		||||
                        case 6:
 | 
			
		||||
                            if (AudioChannelsInHw[7]) {
 | 
			
		||||
                                AudioChannelMatrix[u][chan] = 7;
 | 
			
		||||
                                break;
 | 
			
		||||
                            }
 | 
			
		||||
                            __attribute__ ((fallthrough));
 | 
			
		||||
                        case 7:
 | 
			
		||||
                            if (AudioChannelsInHw[8]) {
 | 
			
		||||
                                AudioChannelMatrix[u][chan] = 8;
 | 
			
		||||
                                break;
 | 
			
		||||
                            }
 | 
			
		||||
                            __attribute__ ((fallthrough));
 | 
			
		||||
                        case 8:
 | 
			
		||||
                            if (AudioChannelsInHw[6]) {
 | 
			
		||||
                                AudioChannelMatrix[u][chan] = 6;
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										136
									
								
								codec.c
									
									
									
									
									
								
							
							
						
						
									
										136
									
								
								codec.c
									
									
									
									
									
								
							@@ -125,7 +125,7 @@ struct _video_decoder_
 | 
			
		||||
*/
 | 
			
		||||
static enum AVPixelFormat Codec_get_format(AVCodecContext *video_ctx, const enum AVPixelFormat *fmt) {
 | 
			
		||||
    VideoDecoder *decoder;
 | 
			
		||||
    enum AVPixelFormat fmt1;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    decoder = video_ctx->opaque;
 | 
			
		||||
    // bug in ffmpeg 1.1.1, called with zero width or height
 | 
			
		||||
@@ -208,9 +208,13 @@ void CodecVideoDelDecoder(VideoDecoder *decoder) { free(decoder); }
 | 
			
		||||
**  @param codec_id video codec id
 | 
			
		||||
*/
 | 
			
		||||
void CodecVideoOpen(VideoDecoder *decoder, int codec_id) {
 | 
			
		||||
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59,0,100)
 | 
			
		||||
    AVCodec *video_codec;
 | 
			
		||||
#else
 | 
			
		||||
    const AVCodec *video_codec;
 | 
			
		||||
#endif
 | 
			
		||||
    const char *name;
 | 
			
		||||
    int ret, deint = 2;
 | 
			
		||||
    int ret;
 | 
			
		||||
 | 
			
		||||
    Debug(3, "***************codec: Video Open using video codec ID %#06x (%s)\n", codec_id,
 | 
			
		||||
          avcodec_get_name(codec_id));
 | 
			
		||||
@@ -265,9 +269,7 @@ void CodecVideoOpen(VideoDecoder *decoder, int codec_id) {
 | 
			
		||||
 | 
			
		||||
    pthread_mutex_lock(&CodecLockMutex);
 | 
			
		||||
    // open codec
 | 
			
		||||
#ifdef YADIF
 | 
			
		||||
    deint = 2;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#if defined VAAPI
 | 
			
		||||
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59,8,100)
 | 
			
		||||
@@ -305,6 +307,7 @@ void CodecVideoOpen(VideoDecoder *decoder, int codec_id) {
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifdef CUVID
 | 
			
		||||
    int deint = 2;
 | 
			
		||||
    if (strcmp(decoder->VideoCodec->long_name,
 | 
			
		||||
               "Nvidia CUVID MPEG2VIDEO decoder") == 0) { // deinterlace for mpeg2 is somehow broken
 | 
			
		||||
        if (av_opt_set_int(decoder->VideoCtx->priv_data, "deint", deint, 0) < 0) { // adaptive
 | 
			
		||||
@@ -389,15 +392,19 @@ void CodecVideoClose(VideoDecoder *video_decoder) {
 | 
			
		||||
    Debug(3, "CodecVideoClose\n");
 | 
			
		||||
    if (video_decoder->VideoCtx) {
 | 
			
		||||
        pthread_mutex_lock(&CodecLockMutex);
 | 
			
		||||
#if 1
 | 
			
		||||
 | 
			
		||||
        frame = av_frame_alloc();
 | 
			
		||||
        avcodec_send_packet(video_decoder->VideoCtx, NULL);
 | 
			
		||||
        while (avcodec_receive_frame(video_decoder->VideoCtx, frame) >= 0)
 | 
			
		||||
            ;
 | 
			
		||||
        av_frame_free(&frame);
 | 
			
		||||
 | 
			
		||||
#if LIBAVUTIL_VERSION_INT < AV_VERSION_INT(55,63,100)
 | 
			
		||||
	    avcodec_close(video_decoder->VideoCtx);
 | 
			
		||||
	    av_freep(&video_decoder->VideoCtx);
 | 
			
		||||
#else
 | 
			
		||||
	    avcodec_free_context(&video_decoder->VideoCtx);
 | 
			
		||||
#endif
 | 
			
		||||
        avcodec_close(video_decoder->VideoCtx);
 | 
			
		||||
        av_freep(&video_decoder->VideoCtx);
 | 
			
		||||
        pthread_mutex_unlock(&CodecLockMutex);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -462,6 +469,7 @@ void CodecVideoDecode(VideoDecoder *decoder, const AVPacket *avpkt) {
 | 
			
		||||
 | 
			
		||||
        *pkt = *avpkt; // use copy
 | 
			
		||||
        ret = avcodec_send_packet(video_ctx, pkt);
 | 
			
		||||
        //printf("send packet %x\n",ret);
 | 
			
		||||
        if (ret < 0) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
@@ -480,7 +488,8 @@ void CodecVideoDecode(VideoDecoder *decoder, const AVPacket *avpkt) {
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
            if (ret >= 0) {
 | 
			
		||||
                if (decoder->filter) {
 | 
			
		||||
                //printf("Videosize %d:%d ttf %d\n",frame->width,frame->height,frame->interlaced_frame);
 | 
			
		||||
                if ((frame->flags & AV_FRAME_FLAG_INTERLACED) && decoder->filter) {
 | 
			
		||||
                    if (decoder->filter == 1) {
 | 
			
		||||
                        if (init_filters(video_ctx, decoder->HwDecoder, frame) < 0) {
 | 
			
		||||
                            Debug(3, "video: Init of VAAPI deint Filter failed\n");
 | 
			
		||||
@@ -513,7 +522,7 @@ void CodecVideoDecode(VideoDecoder *decoder, const AVPacket *avpkt) {
 | 
			
		||||
    int ret, ret1;
 | 
			
		||||
    int got_frame;
 | 
			
		||||
    int consumed = 0;
 | 
			
		||||
    static uint64_t first_time = 0;
 | 
			
		||||
    //static uint64_t first_time = 0;
 | 
			
		||||
    const AVPacket *pkt;
 | 
			
		||||
 | 
			
		||||
next_part:
 | 
			
		||||
@@ -541,7 +550,7 @@ next_part:
 | 
			
		||||
            frame = av_frame_alloc();
 | 
			
		||||
            ret = avcodec_receive_frame(video_ctx, frame); // get new frame
 | 
			
		||||
            if (ret >= 0) {                                // one is avail.
 | 
			
		||||
            first_time = frame->pts;
 | 
			
		||||
                //first_time = frame->pts;
 | 
			
		||||
                got_frame = 1;
 | 
			
		||||
            } else {
 | 
			
		||||
                got_frame = 0;
 | 
			
		||||
@@ -551,7 +560,7 @@ next_part:
 | 
			
		||||
//		printf("video frame pts %#012" PRIx64 "
 | 
			
		||||
//%dms\n",frame->pts,(int)(apts - frame->pts) / 90);
 | 
			
		||||
#ifdef YADIF
 | 
			
		||||
                if (decoder->filter) {
 | 
			
		||||
                if ((frame->flags & AV_FRAME_FLAG_INTERLACED) && decoder->filter) {
 | 
			
		||||
                    if (decoder->filter == 1) {
 | 
			
		||||
                        if (init_filters(video_ctx, decoder->HwDecoder, frame) < 0) {
 | 
			
		||||
                            Debug(3,"video: Init of YADIF Filter failed\n");
 | 
			
		||||
@@ -615,7 +624,11 @@ typedef struct _audio_decoder_ AudioDecoder;
 | 
			
		||||
/// Audio decoder structure.
 | 
			
		||||
///
 | 
			
		||||
struct _audio_decoder_ {
 | 
			
		||||
    AVCodec *AudioCodec;      ///< audio codec
 | 
			
		||||
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59,0,100)
 | 
			
		||||
    AVCodec *AudioCodec;		///< audio codec
 | 
			
		||||
#else
 | 
			
		||||
    const AVCodec *AudioCodec;		///< audio codec
 | 
			
		||||
#endif
 | 
			
		||||
    AVCodecContext *AudioCtx; ///< audio codec context
 | 
			
		||||
 | 
			
		||||
    char Passthrough; ///< current pass-through flags
 | 
			
		||||
@@ -702,8 +715,11 @@ void CodecAudioDelDecoder(AudioDecoder *decoder) {
 | 
			
		||||
**  @param codec_id audio   codec id
 | 
			
		||||
*/
 | 
			
		||||
void CodecAudioOpen(AudioDecoder *audio_decoder, int codec_id) {
 | 
			
		||||
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59,0,100)
 | 
			
		||||
    AVCodec *audio_codec;
 | 
			
		||||
 | 
			
		||||
#else
 | 
			
		||||
    const AVCodec *audio_codec;
 | 
			
		||||
#endif
 | 
			
		||||
    Debug(3, "codec: using audio codec ID %#06x (%s)\n", codec_id, avcodec_get_name(codec_id));
 | 
			
		||||
    if (!(audio_codec = avcodec_find_decoder(codec_id))) {
 | 
			
		||||
        // if (!(audio_codec = avcodec_find_decoder(codec_id))) {
 | 
			
		||||
@@ -716,9 +732,6 @@ void CodecAudioOpen(AudioDecoder *audio_decoder, int codec_id) {
 | 
			
		||||
        Fatal(_("codec: can't allocate audio codec context\n"));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (CodecDownmix) {
 | 
			
		||||
        audio_decoder->AudioCtx->request_channel_layout = AV_CH_LAYOUT_STEREO;
 | 
			
		||||
    }
 | 
			
		||||
    pthread_mutex_lock(&CodecLockMutex);
 | 
			
		||||
    // open codec
 | 
			
		||||
    if (1) {
 | 
			
		||||
@@ -758,8 +771,12 @@ void CodecAudioClose(AudioDecoder *audio_decoder) {
 | 
			
		||||
    }
 | 
			
		||||
    if (audio_decoder->AudioCtx) {
 | 
			
		||||
        pthread_mutex_lock(&CodecLockMutex);
 | 
			
		||||
        avcodec_close(audio_decoder->AudioCtx);
 | 
			
		||||
        av_freep(&audio_decoder->AudioCtx);
 | 
			
		||||
#if LIBAVUTIL_VERSION_INT < AV_VERSION_INT(55,63,100)
 | 
			
		||||
	    avcodec_close(audio_decoder->AudioCtx);
 | 
			
		||||
	    av_freep(&audio_decoder->AudioCtx);
 | 
			
		||||
#else
 | 
			
		||||
	    avcodec_free_context(&audio_decoder->AudioCtx);
 | 
			
		||||
#endif
 | 
			
		||||
        pthread_mutex_unlock(&CodecLockMutex);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -871,19 +888,35 @@ static int CodecAudioUpdateHelper(AudioDecoder *audio_decoder, int *passthrough)
 | 
			
		||||
    int err;
 | 
			
		||||
 | 
			
		||||
    audio_ctx = audio_decoder->AudioCtx;
 | 
			
		||||
    Debug(3, "codec/audio: Chanlayout %lx format change %s %dHz *%d channels%s%s%s%s%s\n",audio_ctx->channel_layout,
 | 
			
		||||
          av_get_sample_fmt_name(audio_ctx->sample_fmt), audio_ctx->sample_rate, audio_ctx->channels,
 | 
			
		||||
          CodecPassthrough & CodecPCM ? " PCM" : "", CodecPassthrough & CodecMPA ? " MPA" : "",
 | 
			
		||||
          CodecPassthrough & CodecAC3 ? " AC-3" : "", CodecPassthrough & CodecEAC3 ? " E-AC-3" : "",
 | 
			
		||||
          CodecPassthrough ? " pass-through" : "");
 | 
			
		||||
    
 | 
			
		||||
 
 | 
			
		||||
    Debug(3, "codec/audio: format change %s %dHz *%d channels%s%s%s%s%s%s\n",
 | 
			
		||||
	av_get_sample_fmt_name(audio_ctx->sample_fmt), audio_ctx->sample_rate,
 | 
			
		||||
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59,24,100)
 | 
			
		||||
	audio_ctx->channels, CodecPassthrough & CodecPCM ? " PCM" : "",
 | 
			
		||||
#else
 | 
			
		||||
	audio_ctx->ch_layout.nb_channels, CodecPassthrough & CodecPCM ? " PCM" : "",
 | 
			
		||||
#endif
 | 
			
		||||
	CodecPassthrough & CodecMPA ? " MPA" : "",
 | 
			
		||||
	CodecPassthrough & CodecAC3 ? " AC-3" : "",
 | 
			
		||||
	CodecPassthrough & CodecEAC3 ? " E-AC-3" : "",
 | 
			
		||||
	CodecPassthrough & CodecDTS ? " DTS" : "",
 | 
			
		||||
	CodecPassthrough ? " pass-through" : "");
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    *passthrough = 0;
 | 
			
		||||
    audio_decoder->SampleRate = audio_ctx->sample_rate;
 | 
			
		||||
    audio_decoder->HwSampleRate = audio_ctx->sample_rate;
 | 
			
		||||
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59,24,100)
 | 
			
		||||
    audio_decoder->Channels = audio_ctx->channels;
 | 
			
		||||
    audio_decoder->HwChannels = audio_ctx->channels;
 | 
			
		||||
    audio_decoder->Passthrough = CodecPassthrough;
 | 
			
		||||
#else
 | 
			
		||||
    audio_decoder->Channels = audio_ctx->ch_layout.nb_channels;
 | 
			
		||||
    audio_decoder->HwChannels = audio_ctx->ch_layout.nb_channels;
 | 
			
		||||
#endif
 | 
			
		||||
    if (CodecDownmix && !CodecPassthrough) audio_decoder->HwChannels = 2;
 | 
			
		||||
 | 
			
		||||
    audio_decoder->Passthrough = CodecPassthrough;
 | 
			
		||||
    // SPDIF/HDMI pass-through
 | 
			
		||||
    if ((CodecPassthrough & CodecAC3 && audio_ctx->codec_id == AV_CODEC_ID_AC3) ||
 | 
			
		||||
        (CodecPassthrough & CodecEAC3 && audio_ctx->codec_id == AV_CODEC_ID_EAC3)) {
 | 
			
		||||
@@ -912,9 +945,15 @@ static int CodecAudioUpdateHelper(AudioDecoder *audio_decoder, int *passthrough)
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    Debug(3, "codec/audio: resample %s %dHz *%d -> %s %dHz *%d\n", av_get_sample_fmt_name(audio_ctx->sample_fmt),
 | 
			
		||||
          audio_ctx->sample_rate, audio_ctx->channels, av_get_sample_fmt_name(AV_SAMPLE_FMT_S16),
 | 
			
		||||
          audio_decoder->HwSampleRate, audio_decoder->HwChannels);
 | 
			
		||||
    Debug(3, "codec/audio: resample %s %dHz *%d -> %s %dHz *%d\n",
 | 
			
		||||
	    av_get_sample_fmt_name(audio_ctx->sample_fmt), audio_ctx->sample_rate,
 | 
			
		||||
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59,24,100)
 | 
			
		||||
	    audio_ctx->channels, av_get_sample_fmt_name(AV_SAMPLE_FMT_S16),
 | 
			
		||||
#else
 | 
			
		||||
	    audio_ctx->ch_layout.nb_channels, av_get_sample_fmt_name(AV_SAMPLE_FMT_S16),
 | 
			
		||||
#endif
 | 
			
		||||
	    audio_decoder->HwSampleRate, audio_decoder->HwChannels);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
@@ -1143,6 +1182,12 @@ static void CodecAudioUpdateFormat(AudioDecoder *audio_decoder) {
 | 
			
		||||
    int passthrough;
 | 
			
		||||
    const AVCodecContext *audio_ctx;
 | 
			
		||||
 | 
			
		||||
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59,24,100)
 | 
			
		||||
    int64_t dmlayout = AV_CH_LAYOUT_STEREO;
 | 
			
		||||
#else
 | 
			
		||||
    AVChannelLayout dmlayout = AV_CHANNEL_LAYOUT_STEREO;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
    if (CodecAudioUpdateHelper(audio_decoder, &passthrough)) {
 | 
			
		||||
        // FIXME: handle swresample format conversions.
 | 
			
		||||
        return;
 | 
			
		||||
@@ -1153,6 +1198,12 @@ static void CodecAudioUpdateFormat(AudioDecoder *audio_decoder) {
 | 
			
		||||
 | 
			
		||||
    audio_ctx = audio_decoder->AudioCtx;
 | 
			
		||||
 | 
			
		||||
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59,24,100)
 | 
			
		||||
    if (!CodecDownmix || CodecPassthrough) dmlayout = audio_ctx->channel_layout;
 | 
			
		||||
#else
 | 
			
		||||
    if (!CodecDownmix || CodecPassthrough) dmlayout = audio_ctx->ch_layout;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifdef DEBUG
 | 
			
		||||
    if (audio_ctx->sample_fmt == AV_SAMPLE_FMT_S16 && audio_ctx->sample_rate == audio_decoder->HwSampleRate &&
 | 
			
		||||
        !CodecAudioDrift) {
 | 
			
		||||
@@ -1161,14 +1212,25 @@ static void CodecAudioUpdateFormat(AudioDecoder *audio_decoder) {
 | 
			
		||||
    }
 | 
			
		||||
#endif
 | 
			
		||||
    
 | 
			
		||||
    audio_decoder->Resample = swr_alloc_set_opts(audio_decoder->Resample, audio_ctx->channel_layout, AV_SAMPLE_FMT_S16,
 | 
			
		||||
                                                 audio_decoder->HwSampleRate, audio_ctx->channel_layout,
 | 
			
		||||
                                                 audio_ctx->sample_fmt, audio_ctx->sample_rate, 0, NULL);
 | 
			
		||||
#if LIBSWRESAMPLE_VERSION_INT < AV_VERSION_INT(4,5,100)
 | 
			
		||||
    audio_decoder->Resample =
 | 
			
		||||
        swr_alloc_set_opts(audio_decoder->Resample, dmlayout,
 | 
			
		||||
        AV_SAMPLE_FMT_S16, audio_decoder->HwSampleRate,
 | 
			
		||||
        audio_ctx->channel_layout, audio_ctx->sample_fmt,
 | 
			
		||||
#else
 | 
			
		||||
        swr_alloc_set_opts2(&audio_decoder->Resample, &dmlayout,
 | 
			
		||||
        AV_SAMPLE_FMT_S16, audio_decoder->HwSampleRate,
 | 
			
		||||
        &audio_ctx->ch_layout, audio_ctx->sample_fmt,
 | 
			
		||||
#endif
 | 
			
		||||
	   audio_ctx->sample_rate, 0, NULL); 
 | 
			
		||||
 | 
			
		||||
    if (audio_decoder->Resample) {
 | 
			
		||||
        swr_init(audio_decoder->Resample);
 | 
			
		||||
	swr_init(audio_decoder->Resample);
 | 
			
		||||
    } else {
 | 
			
		||||
        Error(_("codec/audio: can't setup resample\n"));
 | 
			
		||||
	Error(_("codec/audio: can't setup resample\n"));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
@@ -1211,7 +1273,11 @@ void CodecAudioDecode(AudioDecoder *audio_decoder, const AVPacket *avpkt) {
 | 
			
		||||
            // format change
 | 
			
		||||
            if (audio_decoder->Passthrough != CodecPassthrough ||
 | 
			
		||||
                audio_decoder->SampleRate != audio_ctx->sample_rate ||
 | 
			
		||||
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59,24,100)
 | 
			
		||||
                audio_decoder->Channels != audio_ctx->channels) {
 | 
			
		||||
#else
 | 
			
		||||
                audio_decoder->Channels != audio_ctx->ch_layout.nb_channels) {
 | 
			
		||||
#endif
 | 
			
		||||
                CodecAudioUpdateFormat(audio_decoder);
 | 
			
		||||
            }
 | 
			
		||||
            if (!audio_decoder->HwSampleRate || !audio_decoder->HwChannels) {
 | 
			
		||||
@@ -1220,13 +1286,15 @@ void CodecAudioDecode(AudioDecoder *audio_decoder, const AVPacket *avpkt) {
 | 
			
		||||
            if (CodecAudioPassthroughHelper(audio_decoder, avpkt)) {
 | 
			
		||||
                return;
 | 
			
		||||
            }
 | 
			
		||||
            
 | 
			
		||||
            if (audio_decoder->Resample) {
 | 
			
		||||
                uint8_t outbuf[8192 * 2 * 8];
 | 
			
		||||
                uint8_t outbuf[8192  * 2 * 8];
 | 
			
		||||
                uint8_t *out[1];
 | 
			
		||||
 | 
			
		||||
                out[0] = outbuf;
 | 
			
		||||
                ret = swr_convert(audio_decoder->Resample, out, sizeof(outbuf) / (2 * audio_decoder->HwChannels),
 | 
			
		||||
                                  (const uint8_t **)frame->extended_data, frame->nb_samples);
 | 
			
		||||
                                  
 | 
			
		||||
                if (ret > 0) {
 | 
			
		||||
                    if (!(audio_decoder->Passthrough & CodecPCM)) {
 | 
			
		||||
                        CodecReorderAudioFrame((int16_t *)outbuf, ret * 2 * audio_decoder->HwChannels,
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										6
									
								
								codec.h
									
									
									
									
									
								
							
							
						
						
									
										6
									
								
								codec.h
									
									
									
									
									
								
							@@ -56,7 +56,11 @@ struct _video_decoder_ {
 | 
			
		||||
    VideoHwDecoder *HwDecoder; ///< video hardware decoder
 | 
			
		||||
 | 
			
		||||
    int GetFormatDone;        ///< flag get format called!
 | 
			
		||||
    AVCodec *VideoCodec;      ///< video codec
 | 
			
		||||
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59,0,100)
 | 
			
		||||
     AVCodec *VideoCodec;                ///< video codec
 | 
			
		||||
#else
 | 
			
		||||
     const AVCodec *VideoCodec;          ///< video codec
 | 
			
		||||
#endif
 | 
			
		||||
    AVCodecContext *VideoCtx; ///< video codec context
 | 
			
		||||
    // #ifdef FFMPEG_WORKAROUND_ARTIFACTS
 | 
			
		||||
    int FirstKeyFrame; ///< flag first frame
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										38
									
								
								drm.c
									
									
									
									
									
								
							
							
						
						
									
										38
									
								
								drm.c
									
									
									
									
									
								
							@@ -209,8 +209,11 @@ static int FindDevice(VideoRender *render) {
 | 
			
		||||
    int found = 0;
 | 
			
		||||
    render->fd_drm = open("/dev/dri/card0", O_RDWR);
 | 
			
		||||
    if (render->fd_drm < 0) {
 | 
			
		||||
        fprintf(stderr, "FindDevice: cannot open /dev/dri/card0: %m\n");
 | 
			
		||||
        return -errno;
 | 
			
		||||
        render->fd_drm = open("/dev/dri/card1", O_RDWR);
 | 
			
		||||
        if (render->fd_drm < 0) {
 | 
			
		||||
            fprintf(stderr, "FindDevice: cannot open /dev/dri/card0 or card1: %m\n");
 | 
			
		||||
            return -errno;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    int ret = drmSetMaster(render->fd_drm);
 | 
			
		||||
@@ -545,6 +548,7 @@ static void drm_swap_buffers() {
 | 
			
		||||
        m_need_modeset = 0;
 | 
			
		||||
        has_modeset = 1;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    drmModeSetCrtc(render->fd_drm, render->crtc_id, fb, 0, 0, &render->connector_id, 1, &render->mode);
 | 
			
		||||
 | 
			
		||||
    if (previous_bo) {
 | 
			
		||||
@@ -562,15 +566,16 @@ static void drm_clean_up() {
 | 
			
		||||
        return;
 | 
			
		||||
    Debug(3, "drm clean up\n");
 | 
			
		||||
 | 
			
		||||
    if (previous_bo) {
 | 
			
		||||
        drmModeRmFB(render->fd_drm, previous_fb);
 | 
			
		||||
        gbm_surface_release_buffer(gbm.surface, previous_bo);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    drmModeSetCrtc(render->fd_drm, render->saved_crtc->crtc_id, render->saved_crtc->buffer_id, render->saved_crtc->x,
 | 
			
		||||
                   render->saved_crtc->y, &render->connector_id, 1, &render->saved_crtc->mode);
 | 
			
		||||
    drmModeFreeCrtc(render->saved_crtc);
 | 
			
		||||
 | 
			
		||||
    if (previous_bo) {
 | 
			
		||||
        drmModeRmFB(render->fd_drm, previous_fb);
 | 
			
		||||
        gbm_surface_release_buffer(gbm.surface, previous_bo);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (has_modeset) {
 | 
			
		||||
        drmModeAtomicReqPtr ModeReq;
 | 
			
		||||
        const uint32_t flags = DRM_MODE_ATOMIC_ALLOW_MODESET;
 | 
			
		||||
@@ -613,22 +618,29 @@ static void drm_clean_up() {
 | 
			
		||||
    if (render->hdr_blob_id)
 | 
			
		||||
        drmModeDestroyPropertyBlob(render->fd_drm, render->hdr_blob_id);
 | 
			
		||||
    render->hdr_blob_id = 0;
 | 
			
		||||
 | 
			
		||||
#if 0
 | 
			
		||||
    eglMakeCurrent(eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
 | 
			
		||||
    eglDestroySurface(eglDisplay, eglSurface);
 | 
			
		||||
    EglCheck();
 | 
			
		||||
    gbm_surface_destroy(gbm.surface);
 | 
			
		||||
    eglDestroyContext(eglDisplay, eglContext);
 | 
			
		||||
    EglCheck();
 | 
			
		||||
    eglDestroyContext(eglDisplay, eglSharedContext);
 | 
			
		||||
    EglCheck();
 | 
			
		||||
    eglDestroyContext(eglDisplay, eglContext);
 | 
			
		||||
    EglCheck();
 | 
			
		||||
    eglSharedContext = NULL;
 | 
			
		||||
 | 
			
		||||
    eglContext = NULL;
 | 
			
		||||
    eglTerminate(eglDisplay);
 | 
			
		||||
    EglCheck();
 | 
			
		||||
 | 
			
		||||
    eglDisplay = NULL;
 | 
			
		||||
#endif
 | 
			
		||||
    eglMakeCurrent(eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
 | 
			
		||||
    eglDestroySurface(eglDisplay, eglSurface);
 | 
			
		||||
    EglCheck();
 | 
			
		||||
    eglSurface = NULL;
 | 
			
		||||
    gbm_surface_destroy(gbm.surface);
 | 
			
		||||
    gbm_device_destroy(gbm.dev);
 | 
			
		||||
    drmDropMaster(render->fd_drm);
 | 
			
		||||
    close(render->fd_drm);
 | 
			
		||||
    eglDisplay = NULL;
 | 
			
		||||
    free(render);
 | 
			
		||||
    render = NULL;
 | 
			
		||||
    Debug(3, "nach drm clean up\n");
 | 
			
		||||
}
 | 
			
		||||
@@ -126,7 +126,7 @@ void pl_shader_append_v(const char *fmt, ...) {
 | 
			
		||||
        Fatal(_("Shaderlenght fault\n"));
 | 
			
		||||
    strcat(shv, temp);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#ifndef PLACEBO
 | 
			
		||||
static void compile_attach_shader(GLuint program, GLenum type, const char *source) {
 | 
			
		||||
    GLuint shader;
 | 
			
		||||
    GLint status = 1234, log_length;
 | 
			
		||||
@@ -159,6 +159,7 @@ static void link_shader(GLuint program) {
 | 
			
		||||
    Debug(3, "Link Status %d loglen %d\n", status, log_length);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
static GLuint sc_generate_osd(GLuint gl_prog) {
 | 
			
		||||
 | 
			
		||||
    Debug(3, "vor create osd\n");
 | 
			
		||||
@@ -209,7 +210,7 @@ static GLuint sc_generate(GLuint gl_prog, enum AVColorSpace colorspace) {
 | 
			
		||||
    int n;
 | 
			
		||||
    GLint cmsLoc;
 | 
			
		||||
    float *m, *c, *cms;
 | 
			
		||||
    char *frag;
 | 
			
		||||
    //char *frag;
 | 
			
		||||
 | 
			
		||||
    GL_init();
 | 
			
		||||
    GLSL("%s\n", gl_version);
 | 
			
		||||
@@ -446,3 +447,4 @@ static void render_pass_quad(int flip, float xcrop, float ycrop) {
 | 
			
		||||
    for (n = 0; vertex_vao[n].name; n++)
 | 
			
		||||
        glDisableVertexAttribArray(n);
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
 
 | 
			
		||||
@@ -61,7 +61,7 @@ extern void ToggleLUT();
 | 
			
		||||
/// vdr-plugin version number.
 | 
			
		||||
/// Makefile extracts the version number for generating the file name
 | 
			
		||||
/// for the distribution archive.
 | 
			
		||||
static const char *const VERSION = "3.16"
 | 
			
		||||
static const char *const VERSION = "3.28"
 | 
			
		||||
#ifdef GIT_REV
 | 
			
		||||
                                   "-GIT" GIT_REV
 | 
			
		||||
#endif
 | 
			
		||||
@@ -1226,7 +1226,7 @@ void cMenuSetupSoft::Create(void) {
 | 
			
		||||
	Add(new cMenuEditIntItem(tr("Video background color (Alpha)"), (int *)&BackgroundAlpha, 0, 0xFF));
 | 
			
		||||
#endif
 | 
			
		||||
#ifdef PLACEBO
 | 
			
		||||
        Add(new cMenuEditBoolItem(tr("Use studio levels"), &StudioLevels, trVDR("no"), trVDR("yes")));
 | 
			
		||||
        Add(new cMenuEditBoolItem(tr("Color Range"), &StudioLevels, trVDR("limited RGB"), trVDR("Full RGB")));
 | 
			
		||||
#endif
 | 
			
		||||
        Add(new cMenuEditBoolItem(tr("60hz display mode"), &_60HzMode, trVDR("no"), trVDR("yes")));
 | 
			
		||||
        Add(new cMenuEditBoolItem(tr("Soft start a/v sync"), &SoftStartSync, trVDR("no"), trVDR("yes")));
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										31
									
								
								softhddev.c
									
									
									
									
									
								
							
							
						
						
									
										31
									
								
								softhddev.c
									
									
									
									
									
								
							@@ -60,7 +60,7 @@
 | 
			
		||||
#include "codec.h"
 | 
			
		||||
// clang-format on
 | 
			
		||||
 | 
			
		||||
#ifdef DEBUG
 | 
			
		||||
#if 0
 | 
			
		||||
static int DumpH264(const uint8_t *data, int size);
 | 
			
		||||
static void DumpMpeg(const uint8_t *data, int size);
 | 
			
		||||
#endif
 | 
			
		||||
@@ -662,7 +662,13 @@ static void PesParse(PesDemux *pesdx, const uint8_t *data, int size, int is_star
 | 
			
		||||
                        break;
 | 
			
		||||
                    }
 | 
			
		||||
                    if (r > 0) {
 | 
			
		||||
                        AVPacket avpkt[1];
 | 
			
		||||
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(58,33,100)
 | 
			
		||||
				        AVPacket avpkt[1];
 | 
			
		||||
				        av_init_packet(avpkt);
 | 
			
		||||
#else
 | 
			
		||||
                        AVPacket * avpkt;
 | 
			
		||||
				        avpkt = av_packet_alloc();
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
                        // new codec id, close and open new
 | 
			
		||||
                        if (AudioCodecID != codec_id) {
 | 
			
		||||
@@ -671,13 +677,15 @@ static void PesParse(PesDemux *pesdx, const uint8_t *data, int size, int is_star
 | 
			
		||||
                            CodecAudioOpen(MyAudioDecoder, codec_id);
 | 
			
		||||
                            AudioCodecID = codec_id;
 | 
			
		||||
                        }
 | 
			
		||||
                        av_init_packet(avpkt);
 | 
			
		||||
                        avpkt->data = (void *)q;
 | 
			
		||||
                        avpkt->size = r;
 | 
			
		||||
                        avpkt->pts = pesdx->PTS;
 | 
			
		||||
                        avpkt->dts = pesdx->DTS;
 | 
			
		||||
                        // FIXME: not aligned for ffmpeg
 | 
			
		||||
                        CodecAudioDecode(MyAudioDecoder, avpkt);
 | 
			
		||||
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(58,33,100)
 | 
			
		||||
				        av_packet_free(&avpkt);
 | 
			
		||||
#endif
 | 
			
		||||
                        pesdx->PTS = AV_NOPTS_VALUE;
 | 
			
		||||
                        pesdx->DTS = AV_NOPTS_VALUE;
 | 
			
		||||
                        pesdx->Skip += r;
 | 
			
		||||
@@ -1147,21 +1155,28 @@ int PlayAudio(const uint8_t *data, int size, uint8_t id) {
 | 
			
		||||
            break;
 | 
			
		||||
        }
 | 
			
		||||
        if (r > 0) {
 | 
			
		||||
            AVPacket avpkt[1];
 | 
			
		||||
 | 
			
		||||
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(58,33,100)
 | 
			
		||||
	        AVPacket avpkt[1];
 | 
			
		||||
	        av_init_packet(avpkt);
 | 
			
		||||
#else
 | 
			
		||||
	        AVPacket * avpkt;
 | 
			
		||||
	        avpkt = av_packet_alloc();
 | 
			
		||||
#endif
 | 
			
		||||
            // new codec id, close and open new
 | 
			
		||||
            if (AudioCodecID != codec_id) {
 | 
			
		||||
                CodecAudioClose(MyAudioDecoder);
 | 
			
		||||
                CodecAudioOpen(MyAudioDecoder, codec_id);
 | 
			
		||||
                AudioCodecID = codec_id;
 | 
			
		||||
            }
 | 
			
		||||
            av_init_packet(avpkt);
 | 
			
		||||
            avpkt->data = (void *)p;
 | 
			
		||||
            avpkt->size = r;
 | 
			
		||||
            avpkt->pts = AudioAvPkt->pts;
 | 
			
		||||
            avpkt->dts = AudioAvPkt->dts;
 | 
			
		||||
            // FIXME: not aligned for ffmpeg
 | 
			
		||||
            CodecAudioDecode(MyAudioDecoder, avpkt);
 | 
			
		||||
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(58,33,100)
 | 
			
		||||
	        av_packet_free(&avpkt);
 | 
			
		||||
#endif
 | 
			
		||||
            AudioAvPkt->pts = AV_NOPTS_VALUE;
 | 
			
		||||
            AudioAvPkt->dts = AV_NOPTS_VALUE;
 | 
			
		||||
            p += r;
 | 
			
		||||
@@ -1625,7 +1640,7 @@ static void VideoMpegEnqueue(VideoStream *stream, int64_t pts, int64_t dts, cons
 | 
			
		||||
**  @param avpkt    ffmpeg a/v packet
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
#ifndef USE_PIP
 | 
			
		||||
#if !defined USE_PIP &&  !defined VAAPI
 | 
			
		||||
static void FixPacketForFFMpeg(VideoDecoder *vdecoder, AVPacket *avpkt) {
 | 
			
		||||
    uint8_t *p;
 | 
			
		||||
    int n;
 | 
			
		||||
@@ -1993,7 +2008,7 @@ static void StopVideo(void) {
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#ifdef DEBUG
 | 
			
		||||
#if 0
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
**  Dump mpeg video packet.
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										355
									
								
								video.c
									
									
									
									
									
								
							
							
						
						
									
										355
									
								
								video.c
									
									
									
									
									
								
							@@ -172,6 +172,7 @@ typedef enum {
 | 
			
		||||
#if !defined PLACEBO_GL
 | 
			
		||||
#include <EGL/egl.h>
 | 
			
		||||
#include <EGL/eglext.h>
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifndef GL_OES_EGL_image
 | 
			
		||||
@@ -183,6 +184,7 @@ typedef void *EGLImageKHR;
 | 
			
		||||
 | 
			
		||||
#ifdef PLACEBO
 | 
			
		||||
#ifdef PLACEBO_GL
 | 
			
		||||
GLenum glewInit(void);
 | 
			
		||||
#include <libplacebo/opengl.h>
 | 
			
		||||
#else
 | 
			
		||||
#define VK_USE_PLATFORM_XCB_KHR
 | 
			
		||||
@@ -380,18 +382,12 @@ signed char VideoHardwareDecoder = -1; ///< flag use hardware decoder
 | 
			
		||||
 | 
			
		||||
static char VideoSurfaceModesChanged; ///< flag surface modes changed
 | 
			
		||||
 | 
			
		||||
/// flag use transparent OSD.
 | 
			
		||||
static const char VideoTransparentOsd = 1;
 | 
			
		||||
 | 
			
		||||
static uint32_t VideoBackground; ///< video background color
 | 
			
		||||
char VideoStudioLevels;          ///< flag use studio levels
 | 
			
		||||
 | 
			
		||||
/// Default deinterlace mode.
 | 
			
		||||
static VideoDeinterlaceModes VideoDeinterlace[VideoResolutionMax];
 | 
			
		||||
 | 
			
		||||
/// Default number of deinterlace surfaces
 | 
			
		||||
static const int VideoDeinterlaceSurfaces = 4;
 | 
			
		||||
 | 
			
		||||
/// Default skip chroma deinterlace flag (CUVID only).
 | 
			
		||||
static char VideoSkipChromaDeinterlace[VideoResolutionMax];
 | 
			
		||||
 | 
			
		||||
@@ -430,7 +426,7 @@ static int DRMRefresh = 50;
 | 
			
		||||
 | 
			
		||||
static char Video60HzMode;                   ///< handle 60hz displays
 | 
			
		||||
static char VideoSoftStartSync;              ///< soft start sync audio/video
 | 
			
		||||
static const int VideoSoftStartFrames = 100; ///< soft start frames
 | 
			
		||||
//static const int VideoSoftStartFrames = 100; ///< soft start frames
 | 
			
		||||
static char VideoShowBlackPicture;           ///< flag show black picture
 | 
			
		||||
 | 
			
		||||
static float VideoBrightness = 0.0f;
 | 
			
		||||
@@ -442,11 +438,14 @@ static float VideoTemperature = 0.0f;
 | 
			
		||||
static int VulkanTargetColorSpace = 0;
 | 
			
		||||
static int VideoScalerTest = 0;
 | 
			
		||||
static int VideoColorBlindness = 0;
 | 
			
		||||
static float VideoColorBlindnessFaktor = 1.0f;
 | 
			
		||||
static float VideoColorBlindnessFaktor = 1.0;
 | 
			
		||||
 | 
			
		||||
#ifdef PLACEBO
 | 
			
		||||
static char *shadersp[NUM_SHADERS];
 | 
			
		||||
char MyConfigDir[200];
 | 
			
		||||
static int num_shaders = 0;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
static int LUTon = -1;
 | 
			
		||||
 | 
			
		||||
static xcb_atom_t WmDeleteWindowAtom;   ///< WM delete message atom
 | 
			
		||||
@@ -494,11 +493,11 @@ static char DPMSDisabled;            ///< flag we have disabled dpms
 | 
			
		||||
static char EnableDPMSatBlackScreen; ///< flag we should enable dpms at black screen
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
static unsigned int Count;
 | 
			
		||||
static int EglEnabled;          ///< use EGL
 | 
			
		||||
static int GlxVSyncEnabled = 1; ///< enable/disable v-sync
 | 
			
		||||
 | 
			
		||||
#ifdef CUVID
 | 
			
		||||
static int GlxVSyncEnabled = 1; ///< enable/disable v-sync
 | 
			
		||||
static unsigned int Count;
 | 
			
		||||
static GLXContext glxSharedContext; ///< shared gl context
 | 
			
		||||
static GLXContext glxContext;       ///< our gl context
 | 
			
		||||
 | 
			
		||||
@@ -509,11 +508,13 @@ static void GlxSetupWindow(xcb_window_t window, int width, int height, GLXContex
 | 
			
		||||
GLXContext OSDcontext;
 | 
			
		||||
#else
 | 
			
		||||
static EGLContext eglSharedContext;     ///< shared gl context
 | 
			
		||||
#ifdef USE_DRM
 | 
			
		||||
static EGLContext eglOSDContext = NULL; ///< our gl context for the thread
 | 
			
		||||
#endif
 | 
			
		||||
static EGLContext eglContext;           ///< our gl context
 | 
			
		||||
static EGLConfig eglConfig;
 | 
			
		||||
static EGLDisplay eglDisplay;
 | 
			
		||||
static EGLSurface eglSurface, eglOSDSurface;
 | 
			
		||||
static EGLSurface eglSurface;
 | 
			
		||||
static EGLint eglAttrs[10];
 | 
			
		||||
static int eglVersion = 2;
 | 
			
		||||
static EGLImageKHR(EGLAPIENTRY *CreateImageKHR)(EGLDisplay, EGLContext, EGLenum, EGLClientBuffer, const EGLint *);
 | 
			
		||||
@@ -531,9 +532,6 @@ static void GlxSetupWindow(xcb_window_t window, int width, int height, EGLContex
 | 
			
		||||
EGLContext OSDcontext;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
static GLuint OsdGlTextures[2]; ///< gl texture for OSD
 | 
			
		||||
static int OsdIndex = 0;        ///< index into OsdGlTextures
 | 
			
		||||
 | 
			
		||||
//----------------------------------------------------------------------------
 | 
			
		||||
//  Common Functions
 | 
			
		||||
//----------------------------------------------------------------------------
 | 
			
		||||
@@ -630,8 +628,8 @@ static void VideoSetPts(int64_t *pts_p, int interlaced, const AVCodecContext *vi
 | 
			
		||||
    // } else {
 | 
			
		||||
    duration = interlaced ? 40 : 20; // 50Hz -> 20ms default
 | 
			
		||||
    // }
 | 
			
		||||
    // Debug(4, "video: %d/%d %" PRIx64 " -> %d\n", video_ctx->framerate.den,
 | 
			
		||||
    // video_ctx->framerate.num, av_frame_get_pkt_duration(frame), duration);
 | 
			
		||||
    Debug(4, "video: Framerate %d/%d \n", video_ctx->framerate.den,
 | 
			
		||||
     video_ctx->framerate.num);
 | 
			
		||||
 | 
			
		||||
    // update video clock
 | 
			
		||||
    if (*pts_p != (int64_t)AV_NOPTS_VALUE) {
 | 
			
		||||
@@ -793,7 +791,7 @@ video_none:
 | 
			
		||||
    return;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static uint64_t test_time = 0;
 | 
			
		||||
//static uint64_t test_time = 0;
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// Lock video thread.
 | 
			
		||||
@@ -871,18 +869,7 @@ static uint64_t test_time = 0;
 | 
			
		||||
 | 
			
		||||
#ifdef USE_GLX
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// GLX extension functions
 | 
			
		||||
///@{
 | 
			
		||||
#ifdef GLX_MESA_swap_control
 | 
			
		||||
static PFNGLXSWAPINTERVALMESAPROC GlxSwapIntervalMESA;
 | 
			
		||||
#endif
 | 
			
		||||
#ifdef GLX_SGI_video_sync
 | 
			
		||||
static PFNGLXGETVIDEOSYNCSGIPROC GlxGetVideoSyncSGI;
 | 
			
		||||
#endif
 | 
			
		||||
#ifdef GLX_SGI_swap_control
 | 
			
		||||
static PFNGLXSWAPINTERVALSGIPROC GlxSwapIntervalSGI;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// GLX check error.
 | 
			
		||||
@@ -896,6 +883,21 @@ static PFNGLXSWAPINTERVALSGIPROC GlxSwapIntervalSGI;
 | 
			
		||||
        }                                                                                                             \
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#ifdef CUVID
 | 
			
		||||
///
 | 
			
		||||
/// GLX extension functions
 | 
			
		||||
///@{
 | 
			
		||||
#ifdef GLX_MESA_swap_control
 | 
			
		||||
static PFNGLXSWAPINTERVALMESAPROC GlxSwapIntervalMESA;
 | 
			
		||||
#endif
 | 
			
		||||
#ifdef GLX_SGI_video_sync
 | 
			
		||||
static PFNGLXGETVIDEOSYNCSGIPROC GlxGetVideoSyncSGI;
 | 
			
		||||
#endif
 | 
			
		||||
#ifdef GLX_SGI_swap_control
 | 
			
		||||
static PFNGLXSWAPINTERVALSGIPROC GlxSwapIntervalSGI;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// GLX check if a GLX extension is supported.
 | 
			
		||||
///
 | 
			
		||||
@@ -915,6 +917,7 @@ static int GlxIsExtensionSupported(const char *ext) {
 | 
			
		||||
    }
 | 
			
		||||
    return 0;
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
///
 | 
			
		||||
/// Setup GLX window.
 | 
			
		||||
@@ -930,11 +933,12 @@ static void GlxSetupWindow(xcb_window_t window, int width, int height, GLXContex
 | 
			
		||||
static void GlxSetupWindow(xcb_window_t window, int width, int height, EGLContext context)
 | 
			
		||||
#endif
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
#ifdef CUVID
 | 
			
		||||
    uint32_t start;
 | 
			
		||||
    uint32_t end;
 | 
			
		||||
    int i;
 | 
			
		||||
    unsigned count;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifdef PLACEBO_
 | 
			
		||||
    return;
 | 
			
		||||
@@ -1170,6 +1174,7 @@ static void EglInit(void) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#else // VAAPI
 | 
			
		||||
extern void make_egl(void);
 | 
			
		||||
static void EglInit(void) {
 | 
			
		||||
    int redSize, greenSize, blueSize, alphaSize;
 | 
			
		||||
    static int glewdone = 0;
 | 
			
		||||
@@ -1185,7 +1190,8 @@ static void EglInit(void) {
 | 
			
		||||
    make_egl();
 | 
			
		||||
 | 
			
		||||
    if (!glewdone) {
 | 
			
		||||
        GLenum err = glewInit();
 | 
			
		||||
        //GLenum err = glewInit();
 | 
			
		||||
        glewInit();
 | 
			
		||||
 | 
			
		||||
        glewdone = 1;
 | 
			
		||||
        //	  if (err != GLEW_OK) {
 | 
			
		||||
@@ -1246,14 +1252,22 @@ static void EglExit(void) {
 | 
			
		||||
        glxSharedContext = NULL;
 | 
			
		||||
    }
 | 
			
		||||
#else
 | 
			
		||||
    if (eglGetCurrentContext() == eglContext) {
 | 
			
		||||
        // if currently used, set to none
 | 
			
		||||
        eglMakeCurrent(eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
 | 
			
		||||
#ifdef USE_DRM
 | 
			
		||||
    drm_clean_up();
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
    
 | 
			
		||||
    eglMakeCurrent(eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
 | 
			
		||||
 | 
			
		||||
    if (eglSurface) {
 | 
			
		||||
        eglDestroySurface(eglDisplay, eglSurface);
 | 
			
		||||
        EglCheck();
 | 
			
		||||
        eglSurface = NULL;
 | 
			
		||||
    }
 | 
			
		||||
#ifndef USE_DRM
 | 
			
		||||
    if (eglSharedContext) {
 | 
			
		||||
        eglDestroyContext(eglDisplay, eglSharedContext);
 | 
			
		||||
        EglCheck();
 | 
			
		||||
        eglSharedContext = NULL;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (eglContext) {
 | 
			
		||||
@@ -1261,13 +1275,8 @@ static void EglExit(void) {
 | 
			
		||||
        EglCheck();
 | 
			
		||||
        eglContext = NULL;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    eglTerminate(eglDisplay);
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifdef USE_DRM
 | 
			
		||||
    drm_clean_up();
 | 
			
		||||
#endif
 | 
			
		||||
    eglDisplay = NULL;
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
@@ -1453,11 +1462,11 @@ typedef struct priv {
 | 
			
		||||
    const struct pl_vulkan *vk;
 | 
			
		||||
    const struct pl_vk_inst *vk_inst;
 | 
			
		||||
#endif
 | 
			
		||||
    struct pl_context *ctx;
 | 
			
		||||
    const struct pl_log_t *ctx;
 | 
			
		||||
    struct pl_custom_lut *lut;
 | 
			
		||||
    struct pl_renderer *renderer;
 | 
			
		||||
    struct pl_renderer *renderertest;
 | 
			
		||||
    const struct pl_swapchain *swapchain;
 | 
			
		||||
    struct pl_renderer_t *renderer;
 | 
			
		||||
    struct pl_renderer_t *renderertest;
 | 
			
		||||
    const struct pl_swapchain_t *swapchain;
 | 
			
		||||
    struct pl_log_params context;
 | 
			
		||||
#ifndef PLACEBO_GL
 | 
			
		||||
    VkSurfaceKHR pSurface;
 | 
			
		||||
@@ -1465,7 +1474,7 @@ typedef struct priv {
 | 
			
		||||
    int has_dma_buf;
 | 
			
		||||
#ifdef PLACEBO_GL
 | 
			
		||||
#if PL_API_VER >= 229
 | 
			
		||||
    struct pl_opengl_t *gl;
 | 
			
		||||
    const struct pl_opengl_t *gl;
 | 
			
		||||
#else
 | 
			
		||||
    struct pl_opengl *gl;
 | 
			
		||||
#endif
 | 
			
		||||
@@ -1481,7 +1490,6 @@ static struct pl_overlay osdoverlay;
 | 
			
		||||
static struct pl_overlay_part part;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
static int semid;
 | 
			
		||||
struct itimerval itimer;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
@@ -1813,11 +1821,6 @@ struct mp_egl_config_attr {
 | 
			
		||||
#define MP_EGL_ATTRIB(id)                                                                                             \
 | 
			
		||||
    { id, #id }
 | 
			
		||||
 | 
			
		||||
static const struct mp_egl_config_attr mp_egl_attribs[] = {
 | 
			
		||||
    MP_EGL_ATTRIB(EGL_CONFIG_ID),     MP_EGL_ATTRIB(EGL_RED_SIZE),   MP_EGL_ATTRIB(EGL_GREEN_SIZE),
 | 
			
		||||
    MP_EGL_ATTRIB(EGL_BLUE_SIZE),     MP_EGL_ATTRIB(EGL_ALPHA_SIZE), MP_EGL_ATTRIB(EGL_COLOR_BUFFER_TYPE),
 | 
			
		||||
    MP_EGL_ATTRIB(EGL_CONFIG_CAVEAT), MP_EGL_ATTRIB(EGL_CONFORMANT),
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
const int mpgl_preferred_gl_versions[] = {460, 440, 430, 400, 330, 320, 310, 300, 210, 0};
 | 
			
		||||
 | 
			
		||||
@@ -1949,7 +1952,7 @@ static bool create_context_cb(EGLDisplay display, int es_version, EGLContext *ou
 | 
			
		||||
    return true;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
make_egl() {
 | 
			
		||||
void make_egl(void) {
 | 
			
		||||
    int bpp;
 | 
			
		||||
 | 
			
		||||
    CreateImageKHR = (void *)eglGetProcAddress("eglCreateImageKHR");
 | 
			
		||||
@@ -1973,7 +1976,7 @@ make_egl() {
 | 
			
		||||
    if (!create_context_cb(eglDisplay, 0, &eglContext, &eglConfig, &bpp)) {
 | 
			
		||||
        Fatal(_("Could not create EGL Context\n"));
 | 
			
		||||
    }
 | 
			
		||||
    int vID, n;
 | 
			
		||||
    int vID;
 | 
			
		||||
 | 
			
		||||
    eglGetConfigAttrib(eglDisplay, eglConfig, EGL_NATIVE_VISUAL_ID, &vID);
 | 
			
		||||
    Debug(3, "chose visual 0x%x bpp %d\n", vID, bpp);
 | 
			
		||||
@@ -1990,6 +1993,9 @@ make_egl() {
 | 
			
		||||
        Fatal(_("Could not make context current!\n"));
 | 
			
		||||
    }
 | 
			
		||||
    EglEnabled = 1;
 | 
			
		||||
#ifdef USE_DRM
 | 
			
		||||
    drm_swap_buffers();
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
@@ -2243,9 +2249,9 @@ void generateCUDAImage(CuvidDecoder *decoder, int index, const AVFrame *frame, i
 | 
			
		||||
#ifdef PLACEBO
 | 
			
		||||
void createTextureDst(CuvidDecoder *decoder, int anz, unsigned int size_x, unsigned int size_y,
 | 
			
		||||
                      enum AVPixelFormat PixFmt) {
 | 
			
		||||
    int n, i, size = 1, fd;
 | 
			
		||||
    const struct pl_fmt *fmt;
 | 
			
		||||
    struct pl_tex *tex;
 | 
			
		||||
    int n, i; 
 | 
			
		||||
    const struct pl_fmt_t *fmt;
 | 
			
		||||
    //struct pl_tex *tex;
 | 
			
		||||
    struct pl_frame *img;
 | 
			
		||||
    struct pl_plane *pl;
 | 
			
		||||
 | 
			
		||||
@@ -2264,10 +2270,8 @@ void createTextureDst(CuvidDecoder *decoder, int anz, unsigned int size_x, unsig
 | 
			
		||||
 | 
			
		||||
            if (PixFmt == AV_PIX_FMT_NV12) {
 | 
			
		||||
                fmt = pl_find_named_fmt(p->gpu, n == 0 ? "r8" : "rg8"); // 8 Bit YUV
 | 
			
		||||
                size = 1;
 | 
			
		||||
            } else {
 | 
			
		||||
                fmt = pl_find_named_fmt(p->gpu, n == 0 ? "r16" : "rg16"); // 10 Bit YUV
 | 
			
		||||
                size = 2;
 | 
			
		||||
            }
 | 
			
		||||
            if (decoder->pl_frames[i].planes[n].texture) {
 | 
			
		||||
                // #ifdef VAAPI
 | 
			
		||||
@@ -2314,7 +2318,7 @@ void createTextureDst(CuvidDecoder *decoder, int anz, unsigned int size_x, unsig
 | 
			
		||||
                Fatal(_("Unable to create placebo textures"));
 | 
			
		||||
            }
 | 
			
		||||
#ifdef CUVID
 | 
			
		||||
            fd = dup(decoder->pl_frames[i].planes[n].texture->shared_mem.handle.fd);
 | 
			
		||||
            int fd = dup(decoder->pl_frames[i].planes[n].texture->shared_mem.handle.fd);
 | 
			
		||||
            CUDA_EXTERNAL_MEMORY_HANDLE_DESC ext_desc = {
 | 
			
		||||
                .type = CU_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD,
 | 
			
		||||
                .handle.fd = fd,
 | 
			
		||||
@@ -2366,8 +2370,6 @@ void createTextureDst(CuvidDecoder *decoder, int anz, unsigned int size_x, unsig
 | 
			
		||||
void generateVAAPIImage(CuvidDecoder *decoder, int index, const AVFrame *frame, int image_width, int image_height) {
 | 
			
		||||
    int n;
 | 
			
		||||
    VAStatus status;
 | 
			
		||||
    int toggle = 0;
 | 
			
		||||
    uint64_t first_time;
 | 
			
		||||
    VADRMPRIMESurfaceDescriptor desc;
 | 
			
		||||
    
 | 
			
		||||
    vaSyncSurface(decoder->VaDisplay, (unsigned int)frame->data[3]);
 | 
			
		||||
@@ -2388,11 +2390,8 @@ void generateVAAPIImage(CuvidDecoder *decoder, int index, const AVFrame *frame,
 | 
			
		||||
        int fd = desc.objects[id].fd;
 | 
			
		||||
        uint32_t size = desc.objects[id].size;
 | 
			
		||||
        uint32_t offset = desc.layers[n].offset[0];
 | 
			
		||||
#if PL_API_VER < 229
 | 
			
		||||
        struct pl_fmt *fmt;
 | 
			
		||||
#else
 | 
			
		||||
 | 
			
		||||
        struct pl_fmt_t *fmt;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
        if (fd == -1) {
 | 
			
		||||
            printf("Fehler beim Import von Surface %d\n", index);
 | 
			
		||||
@@ -2403,15 +2402,14 @@ void generateVAAPIImage(CuvidDecoder *decoder, int index, const AVFrame *frame,
 | 
			
		||||
            size = n == 0 ? desc.width * desc.height : desc.width * desc.height / 2;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //	fmt = pl_find_fourcc(p->gpu,desc.layers[n].drm_format);
 | 
			
		||||
#if 1
 | 
			
		||||
        //	fmt = pl_find_fourcc(p->gpu,desc.lsayers[n].drm_format);
 | 
			
		||||
 | 
			
		||||
        if (decoder->PixFmt == AV_PIX_FMT_NV12) {
 | 
			
		||||
            fmt = pl_find_named_fmt(p->gpu, n == 0 ? "r8" : "rg8"); // 8 Bit YUV
 | 
			
		||||
        } else {
 | 
			
		||||
            fmt = pl_find_fourcc(p->gpu,
 | 
			
		||||
                                 n == 0 ? 0x20363152 : 0x32335247); // 10 Bit YUV
 | 
			
		||||
        }
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
        assert(fmt != NULL);
 | 
			
		||||
#ifdef PLACEBO_GL
 | 
			
		||||
@@ -2564,8 +2562,6 @@ void generateVAAPIImage(CuvidDecoder *decoder, VASurfaceID index, const AVFrame
 | 
			
		||||
                        int image_height) {
 | 
			
		||||
    VAStatus status;
 | 
			
		||||
 | 
			
		||||
    uint64_t first_time;
 | 
			
		||||
 | 
			
		||||
#if defined(VAAPI)
 | 
			
		||||
    VADRMPRIMESurfaceDescriptor desc;
 | 
			
		||||
 | 
			
		||||
@@ -2834,7 +2830,7 @@ static int init_generic_hwaccel(CuvidDecoder *decoder, enum AVPixelFormat hw_fmt
 | 
			
		||||
    if (decoder->cached_hw_frames_ctx) {
 | 
			
		||||
        AVHWFramesContext *old_fctx = (void *)decoder->cached_hw_frames_ctx->data;
 | 
			
		||||
 | 
			
		||||
        Debug(3, "CMP %d:%d %d:%d %d:%d %d:%d %d:%d\,", new_fctx->format, old_fctx->format, new_fctx->sw_format,
 | 
			
		||||
        Debug(3, "CMP %d:%d %d:%d %d:%d %d:%d %d:%d\n,", new_fctx->format, old_fctx->format, new_fctx->sw_format,
 | 
			
		||||
              old_fctx->sw_format, new_fctx->width, old_fctx->width, new_fctx->height, old_fctx->height,
 | 
			
		||||
              new_fctx->initial_pool_size, old_fctx->initial_pool_size);
 | 
			
		||||
        if (new_fctx->format != old_fctx->format || new_fctx->sw_format != old_fctx->sw_format ||
 | 
			
		||||
@@ -2883,7 +2879,7 @@ error:
 | 
			
		||||
static enum AVPixelFormat Cuvid_get_format(CuvidDecoder *decoder, AVCodecContext *video_ctx,
 | 
			
		||||
                                           const enum AVPixelFormat *fmt) {
 | 
			
		||||
    const enum AVPixelFormat *fmt_idx;
 | 
			
		||||
    int bitformat16 = 0, deint = 0;
 | 
			
		||||
    int bitformat16 = 0;
 | 
			
		||||
 | 
			
		||||
    VideoDecoder *ist = video_ctx->opaque;
 | 
			
		||||
 | 
			
		||||
@@ -2980,6 +2976,7 @@ static enum AVPixelFormat Cuvid_get_format(CuvidDecoder *decoder, AVCodecContext
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
#if defined YADIF && defined CUVID
 | 
			
		||||
        int deint;
 | 
			
		||||
        if (VideoDeinterlace[decoder->Resolution] == VideoDeinterlaceYadif) {
 | 
			
		||||
            deint = 0;
 | 
			
		||||
            ist->filter = 1; // init yadif_cuda
 | 
			
		||||
@@ -2998,10 +2995,15 @@ static enum AVPixelFormat Cuvid_get_format(CuvidDecoder *decoder, AVCodecContext
 | 
			
		||||
#ifdef CUVID
 | 
			
		||||
        ist->active_hwaccel_id = HWACCEL_CUVID;
 | 
			
		||||
#else
 | 
			
		||||
        if (VideoDeinterlace[decoder->Resolution]) // need deinterlace
 | 
			
		||||
            ist->filter = 1;                       // init deint vaapi
 | 
			
		||||
        else
 | 
			
		||||
        if (video_ctx->codec_id == AV_CODEC_ID_HEVC) {
 | 
			
		||||
            ist->filter = 0;
 | 
			
		||||
        }
 | 
			
		||||
        else if (VideoDeinterlace[decoder->Resolution]) {// need deinterlace
 | 
			
		||||
            ist->filter = 1;                       // init deint vaapi
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
            ist->filter = 0;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        ist->active_hwaccel_id = HWACCEL_VAAPI;
 | 
			
		||||
#endif
 | 
			
		||||
@@ -3029,18 +3031,18 @@ int get_RGB(CuvidDecoder *decoder) {
 | 
			
		||||
#ifdef PLACEBO
 | 
			
		||||
    struct pl_render_params render_params = pl_render_default_params;
 | 
			
		||||
    struct pl_frame target = {0};
 | 
			
		||||
    const struct pl_fmt *fmt;
 | 
			
		||||
    const struct pl_fmt_t *fmt;
 | 
			
		||||
 | 
			
		||||
    int offset, x1, y1, x0, y0;
 | 
			
		||||
    int  x1=0, y1=0, x0=0, y0=0;
 | 
			
		||||
    float faktorx, faktory;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
    uint8_t *base;
 | 
			
		||||
    int width;
 | 
			
		||||
    int height;
 | 
			
		||||
    GLuint fb, texture;
 | 
			
		||||
    
 | 
			
		||||
    int current;
 | 
			
		||||
    GLint texLoc;
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    base = decoder->grabbase;
 | 
			
		||||
    width = decoder->grabwidth;
 | 
			
		||||
@@ -3049,7 +3051,8 @@ int get_RGB(CuvidDecoder *decoder) {
 | 
			
		||||
    current = decoder->SurfacesRb[decoder->SurfaceRead];
 | 
			
		||||
 | 
			
		||||
#ifndef PLACEBO
 | 
			
		||||
 | 
			
		||||
    GLint texLoc;
 | 
			
		||||
    GLuint fb, texture;
 | 
			
		||||
    glGenTextures(1, &texture);
 | 
			
		||||
    GlxCheck();
 | 
			
		||||
    glBindTexture(GL_TEXTURE_2D, texture);
 | 
			
		||||
@@ -3488,7 +3491,6 @@ extern void cudaLaunchNV12toARGBDrv(uint32_t * d_srcNV12, size_t nSourcePitch, u
 | 
			
		||||
/// @param frame    frame to display
 | 
			
		||||
///
 | 
			
		||||
static void CuvidRenderFrame(CuvidDecoder *decoder, const AVCodecContext *video_ctx, AVFrame *frame) {
 | 
			
		||||
    uint64_t first_time;
 | 
			
		||||
    int surface;
 | 
			
		||||
    enum AVColorSpace color;
 | 
			
		||||
 | 
			
		||||
@@ -3501,6 +3503,18 @@ static void CuvidRenderFrame(CuvidDecoder *decoder, const AVCodecContext *video_
 | 
			
		||||
        VideoSetPts(&decoder->PTS, decoder->Interlaced, video_ctx, frame);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if  ((decoder->InputWidth != frame->width) || (decoder->InputHeight != frame->height)) {
 | 
			
		||||
        printf("Framesize change\n");
 | 
			
		||||
        CuvidCleanup(decoder);
 | 
			
		||||
        decoder->InputAspect = frame->sample_aspect_ratio;
 | 
			
		||||
        decoder->InputWidth = frame->width;
 | 
			
		||||
        decoder->InputHeight = frame->height;
 | 
			
		||||
        decoder->Interlaced = 0;
 | 
			
		||||
        decoder->SurfacesNeeded = VIDEO_SURFACES_MAX + 1;
 | 
			
		||||
        CuvidSetupOutput(decoder);
 | 
			
		||||
        
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // update aspect ratio changes
 | 
			
		||||
    if (decoder->InputWidth && decoder->InputHeight && av_cmp_q(decoder->InputAspect, frame->sample_aspect_ratio)) {
 | 
			
		||||
        Debug(3, "video/cuvid: aspect ratio changed\n");
 | 
			
		||||
@@ -3516,33 +3530,40 @@ static void CuvidRenderFrame(CuvidDecoder *decoder, const AVCodecContext *video_
 | 
			
		||||
 | 
			
		||||
    // Fix libav colorspace failure
 | 
			
		||||
    color = frame->colorspace;
 | 
			
		||||
    if (color == AVCOL_SPC_UNSPECIFIED) // failure with RTL HD and all SD channels
 | 
			
		||||
    if (color == AVCOL_SPC_UNSPECIFIED) { // failure with RTL HD and all SD channels
 | 
			
		||||
                                        // with vaapi
 | 
			
		||||
        if (frame->width > 720)
 | 
			
		||||
        if (frame->width > 720) {
 | 
			
		||||
            color = AVCOL_SPC_BT709;
 | 
			
		||||
        else
 | 
			
		||||
        } else {
 | 
			
		||||
            color = AVCOL_SPC_BT470BG;
 | 
			
		||||
    if (color == AVCOL_SPC_RGB) // Cuvid decoder failure with SD channels
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    if (color == AVCOL_SPC_RGB) { // Cuvid decoder failure with SD channels
 | 
			
		||||
        color = AVCOL_SPC_BT470BG;
 | 
			
		||||
    }
 | 
			
		||||
    frame->colorspace = color;
 | 
			
		||||
 | 
			
		||||
    // Fix libav Color primaries failures
 | 
			
		||||
    if (frame->color_primaries == AVCOL_PRI_UNSPECIFIED) // failure with RTL HD and all SD channels with
 | 
			
		||||
    if (frame->color_primaries == AVCOL_PRI_UNSPECIFIED) { // failure with RTL HD and all SD channels with
 | 
			
		||||
                                                         // vaapi
 | 
			
		||||
        if (frame->width > 720)
 | 
			
		||||
        if (frame->width > 720) {
 | 
			
		||||
            frame->color_primaries = AVCOL_PRI_BT709;
 | 
			
		||||
        else
 | 
			
		||||
        } else {
 | 
			
		||||
            frame->color_primaries = AVCOL_PRI_BT470BG;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    if (frame->color_primaries == AVCOL_PRI_RESERVED0) // cuvid decoder failure with SD channels
 | 
			
		||||
        frame->color_primaries = AVCOL_PRI_BT470BG;
 | 
			
		||||
 | 
			
		||||
    // Fix libav Color TRC failures
 | 
			
		||||
    if (frame->color_trc == AVCOL_TRC_UNSPECIFIED) // failure with RTL HD and all
 | 
			
		||||
    if (frame->color_trc == AVCOL_TRC_UNSPECIFIED) { // failure with RTL HD and all
 | 
			
		||||
                                                   // SD channels with vaapi
 | 
			
		||||
        if (frame->width > 720)
 | 
			
		||||
        if (frame->width > 720) {
 | 
			
		||||
            frame->color_trc = AVCOL_TRC_BT709;
 | 
			
		||||
        else
 | 
			
		||||
        } else {
 | 
			
		||||
            frame->color_trc = AVCOL_TRC_SMPTE170M;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    if (frame->color_trc == AVCOL_TRC_RESERVED0) // cuvid decoder failure with SD channels
 | 
			
		||||
        frame->color_trc = AVCOL_TRC_SMPTE170M;
 | 
			
		||||
 | 
			
		||||
@@ -3637,10 +3658,10 @@ static void CuvidRenderFrame(CuvidDecoder *decoder, const AVCodecContext *video_
 | 
			
		||||
/// @param decoder  CUVID hw decoder
 | 
			
		||||
///
 | 
			
		||||
static void *CuvidGetHwAccelContext(CuvidDecoder *decoder) {
 | 
			
		||||
    unsigned int version, ret;
 | 
			
		||||
    
 | 
			
		||||
    (void)decoder;
 | 
			
		||||
    Debug(3, "Initializing cuvid hwaccel thread ID:%ld\n", (long int)syscall(186));
 | 
			
		||||
    // turn NULL;
 | 
			
		||||
    
 | 
			
		||||
#ifdef CUVID
 | 
			
		||||
    if (decoder->cuda_ctx) {
 | 
			
		||||
        Debug(3, "schon passiert\n");
 | 
			
		||||
@@ -3648,7 +3669,7 @@ static void *CuvidGetHwAccelContext(CuvidDecoder *decoder) {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (!cu) {
 | 
			
		||||
        ret = cuda_load_functions(&cu, NULL);
 | 
			
		||||
        int ret = cuda_load_functions(&cu, NULL);
 | 
			
		||||
        if (ret < 0) {
 | 
			
		||||
            Error(_("Could not dynamically load CUDA\n"));
 | 
			
		||||
            return 0;
 | 
			
		||||
@@ -3660,7 +3681,7 @@ static void *CuvidGetHwAccelContext(CuvidDecoder *decoder) {
 | 
			
		||||
 | 
			
		||||
    if (decoder->cuda_ctx == NULL)
 | 
			
		||||
        Fatal(_("Kein Cuda device gefunden"));
 | 
			
		||||
 | 
			
		||||
//    unsigned int version;
 | 
			
		||||
//    cu->cuCtxGetApiVersion(decoder->cuda_ctx, &version);
 | 
			
		||||
//    Debug(3, "***********CUDA API Version %d\n", version);
 | 
			
		||||
#endif
 | 
			
		||||
@@ -3719,7 +3740,7 @@ static void CuvidAdvanceDecoderFrame(CuvidDecoder *decoder) {
 | 
			
		||||
#if defined PLACEBO && PL_API_VER >= 58
 | 
			
		||||
 | 
			
		||||
static const struct pl_hook *parse_user_shader(char *shader) {
 | 
			
		||||
    char tmp[200];
 | 
			
		||||
    char tmp[400];
 | 
			
		||||
 | 
			
		||||
    if (!shader)
 | 
			
		||||
        return NULL;
 | 
			
		||||
@@ -3782,26 +3803,23 @@ static void CuvidMixVideo(CuvidDecoder *decoder, __attribute__((unused)) int lev
 | 
			
		||||
    struct pl_deband_params deband;
 | 
			
		||||
    struct pl_color_adjustment colors;
 | 
			
		||||
    struct pl_cone_params cone;
 | 
			
		||||
    struct pl_tex_vk *vkp;
 | 
			
		||||
    //struct pl_tex_vk *vkp;
 | 
			
		||||
    struct pl_plane *pl;
 | 
			
		||||
    struct pl_tex *tex0, *tex1;
 | 
			
		||||
    //struct pl_tex *tex0, *tex1;
 | 
			
		||||
 | 
			
		||||
    struct pl_frame *img;
 | 
			
		||||
    bool ok;
 | 
			
		||||
    //bool ok;
 | 
			
		||||
    VdpRect video_src_rect;
 | 
			
		||||
    VdpRect dst_rect;
 | 
			
		||||
    //VdpRect dst_rect;
 | 
			
		||||
    VdpRect dst_video_rect;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
    int current;
 | 
			
		||||
    int y;
 | 
			
		||||
    float xcropf, ycropf;
 | 
			
		||||
    GLint texLoc;
 | 
			
		||||
    AVFrame *frame;
 | 
			
		||||
    AVFrameSideData *sd, *sd1 = NULL, *sd2 = NULL;
 | 
			
		||||
 | 
			
		||||
#ifdef PLACEBO
 | 
			
		||||
    
 | 
			
		||||
 
 | 
			
		||||
#if 0
 | 
			
		||||
    if (level) {
 | 
			
		||||
        dst_rect.x0 = decoder->VideoX; // video window output (clip)
 | 
			
		||||
        dst_rect.y0 = decoder->VideoY;
 | 
			
		||||
@@ -3813,7 +3831,7 @@ static void CuvidMixVideo(CuvidDecoder *decoder, __attribute__((unused)) int lev
 | 
			
		||||
        dst_rect.x1 = VideoWindowWidth;
 | 
			
		||||
        dst_rect.y1 = VideoWindowHeight;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
#endif
 | 
			
		||||
    video_src_rect.x0 = decoder->CropX; // video source (crop)
 | 
			
		||||
    video_src_rect.y0 = decoder->CropY;
 | 
			
		||||
    video_src_rect.x1 = decoder->CropX + decoder->CropWidth;
 | 
			
		||||
@@ -3825,12 +3843,13 @@ static void CuvidMixVideo(CuvidDecoder *decoder, __attribute__((unused)) int lev
 | 
			
		||||
    dst_video_rect.y1 = decoder->OutputY + decoder->OutputHeight;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
    xcropf = (float)decoder->CropX / (float)decoder->InputWidth;
 | 
			
		||||
    ycropf = (float)decoder->CropY / (float)decoder->InputHeight;
 | 
			
		||||
   
 | 
			
		||||
 | 
			
		||||
    current = decoder->SurfacesRb[decoder->SurfaceRead];
 | 
			
		||||
 | 
			
		||||
#ifdef USE_DRM
 | 
			
		||||
    AVFrame *frame;
 | 
			
		||||
    AVFrameSideData *sd, *sd1 = NULL, *sd2 = NULL;
 | 
			
		||||
    if (!decoder->Closing) {
 | 
			
		||||
        frame = decoder->frames[current];
 | 
			
		||||
        sd1 = av_frame_get_side_data(frame, AV_FRAME_DATA_MASTERING_DISPLAY_METADATA);
 | 
			
		||||
@@ -3842,6 +3861,14 @@ static void CuvidMixVideo(CuvidDecoder *decoder, __attribute__((unused)) int lev
 | 
			
		||||
 | 
			
		||||
    // Render Progressive frame
 | 
			
		||||
#ifndef PLACEBO
 | 
			
		||||
    
 | 
			
		||||
    GLint texLoc;
 | 
			
		||||
    int y; 
 | 
			
		||||
    float xcropf, ycropf;
 | 
			
		||||
 | 
			
		||||
    xcropf = (float)decoder->CropX / (float)decoder->InputWidth;
 | 
			
		||||
    ycropf = (float)decoder->CropY / (float)decoder->InputHeight;
 | 
			
		||||
 | 
			
		||||
    y = VideoWindowHeight - decoder->OutputY - decoder->OutputHeight;
 | 
			
		||||
    if (y < 0)
 | 
			
		||||
        y = 0;
 | 
			
		||||
@@ -3880,7 +3907,6 @@ static void CuvidMixVideo(CuvidDecoder *decoder, __attribute__((unused)) int lev
 | 
			
		||||
    else
 | 
			
		||||
        render_params.lut = NULL;
 | 
			
		||||
        
 | 
			
		||||
    frame = decoder->frames[current];
 | 
			
		||||
   
 | 
			
		||||
    // Fix Color Parameters
 | 
			
		||||
 | 
			
		||||
@@ -3964,6 +3990,9 @@ static void CuvidMixVideo(CuvidDecoder *decoder, __attribute__((unused)) int lev
 | 
			
		||||
    // target.repr.bits.bit_shift =0;
 | 
			
		||||
 | 
			
		||||
#if USE_DRM
 | 
			
		||||
    
 | 
			
		||||
    frame = decoder->frames[current];
 | 
			
		||||
 | 
			
		||||
    switch (VulkanTargetColorSpace) {
 | 
			
		||||
        case 0: // Monitor
 | 
			
		||||
            memcpy(&target->color, &pl_color_space_monitor, sizeof(struct pl_color_space));
 | 
			
		||||
@@ -4092,7 +4121,11 @@ static void CuvidMixVideo(CuvidDecoder *decoder, __attribute__((unused)) int lev
 | 
			
		||||
    render_params.downscaler = pl_filter_presets[VideoScaling[decoder->Resolution]].filter;
 | 
			
		||||
 | 
			
		||||
    if (level)
 | 
			
		||||
#if PL_API_VER < 346
 | 
			
		||||
        render_params.skip_target_clearing = 1;
 | 
			
		||||
#else
 | 
			
		||||
        render_params.border = PL_CLEAR_SKIP;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
    render_params.color_adjustment = &colors;
 | 
			
		||||
 | 
			
		||||
@@ -4188,7 +4221,11 @@ static void CuvidMixVideo(CuvidDecoder *decoder, __attribute__((unused)) int lev
 | 
			
		||||
 | 
			
		||||
        //	render_params.lut = NULL;
 | 
			
		||||
        render_params.num_hooks = 0;
 | 
			
		||||
#if PL_API_VER < 346
 | 
			
		||||
        render_params.skip_target_clearing = 1;
 | 
			
		||||
#else
 | 
			
		||||
        render_params.border = PL_CLEAR_SKIP;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
        if (!p->renderertest)
 | 
			
		||||
            p->renderertest = pl_renderer_create(p->ctx, p->gpu);
 | 
			
		||||
@@ -4201,7 +4238,7 @@ static void CuvidMixVideo(CuvidDecoder *decoder, __attribute__((unused)) int lev
 | 
			
		||||
        p->renderertest = NULL;
 | 
			
		||||
    }
 | 
			
		||||
#endif
 | 
			
		||||
    Debug(4, "video/cuvid: yy video surface %p displayed\n", current, decoder->SurfaceRead);
 | 
			
		||||
    
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#ifdef PLACEBO
 | 
			
		||||
@@ -4209,7 +4246,7 @@ void make_osd_overlay(int x, int y, int width, int height) {
 | 
			
		||||
    const struct pl_fmt *fmt;
 | 
			
		||||
    struct pl_overlay *pl;
 | 
			
		||||
 | 
			
		||||
    int offset = VideoWindowHeight - (VideoWindowHeight - height - y) - (VideoWindowHeight - y);
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    fmt = pl_find_named_fmt(p->gpu, "rgba8"); // 8 Bit RGB
 | 
			
		||||
 | 
			
		||||
@@ -4274,7 +4311,7 @@ void make_osd_overlay(int x, int y, int width, int height) {
 | 
			
		||||
    pl->rect.x1 = x + width;
 | 
			
		||||
    pl->rect.y0 = VideoWindowHeight - height - y;
 | 
			
		||||
#else
 | 
			
		||||
 | 
			
		||||
    int offset = VideoWindowHeight - (VideoWindowHeight - height - y) - (VideoWindowHeight - y);
 | 
			
		||||
    pl->rect.x0 = x;
 | 
			
		||||
    pl->rect.y0 = VideoWindowHeight - y + offset; // Boden von oben
 | 
			
		||||
    pl->rect.x1 = x + width;
 | 
			
		||||
@@ -4289,6 +4326,7 @@ void make_osd_overlay(int x, int y, int width, int height) {
 | 
			
		||||
    part.dst.x1 = x + width;
 | 
			
		||||
    part.dst.y0 = VideoWindowHeight - height - y;
 | 
			
		||||
#else
 | 
			
		||||
    int offset = VideoWindowHeight - (VideoWindowHeight - height - y) - (VideoWindowHeight - y);
 | 
			
		||||
    part.dst.x0 = x;
 | 
			
		||||
    part.dst.y0 = VideoWindowHeight - y + offset; // Boden von oben
 | 
			
		||||
    part.dst.x1 = x + width;
 | 
			
		||||
@@ -4303,30 +4341,33 @@ void make_osd_overlay(int x, int y, int width, int height) {
 | 
			
		||||
 | 
			
		||||
static void CuvidDisplayFrame(void) {
 | 
			
		||||
 | 
			
		||||
    static uint64_t first_time = 0, round_time = 0;
 | 
			
		||||
    static uint64_t last_time = 0;
 | 
			
		||||
    
 | 
			
		||||
    
 | 
			
		||||
    int i;
 | 
			
		||||
 | 
			
		||||
#if defined PLACEBO_GL || defined CUVID
 | 
			
		||||
    static uint64_t round_time = 0;
 | 
			
		||||
    //static uint64_t first_time = 0;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
    int filled;
 | 
			
		||||
    CuvidDecoder *decoder;
 | 
			
		||||
    int RTS_flag;
 | 
			
		||||
    int valid_frame = 0;
 | 
			
		||||
    float ldiff;
 | 
			
		||||
    float turnaround;
 | 
			
		||||
    
 | 
			
		||||
#ifdef PLACEBO
 | 
			
		||||
    uint64_t diff;
 | 
			
		||||
    static float fdiff = 23000.0;
 | 
			
		||||
    //uint64_t diff;
 | 
			
		||||
    //static float fdiff = 23000.0;
 | 
			
		||||
    struct pl_swapchain_frame frame;
 | 
			
		||||
    struct pl_frame target;
 | 
			
		||||
    bool ok;
 | 
			
		||||
    //bool ok;
 | 
			
		||||
 | 
			
		||||
    const struct pl_fmt *fmt;
 | 
			
		||||
    const float black[4] = {0.0f, 0.0f, 0.0f, 1.0f};
 | 
			
		||||
    //const struct pl_fmt *fmt;
 | 
			
		||||
    //const float black[4] = {0.0f, 0.0f, 0.0f, 1.0f};
 | 
			
		||||
#else
 | 
			
		||||
    int valid_frame = 0;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifndef PLACEBO
 | 
			
		||||
 | 
			
		||||
    static uint64_t last_time = 0;
 | 
			
		||||
    if (CuvidDecoderN)
 | 
			
		||||
        CuvidDecoders[0]->Frameproc = (float)(GetusTicks() - last_time) / 1000000.0;
 | 
			
		||||
 | 
			
		||||
@@ -4362,7 +4403,7 @@ static void CuvidDisplayFrame(void) {
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
    if (CuvidDecoderN) {
 | 
			
		||||
        ldiff = (float)(GetusTicks() - round_time) / 1000000.0;
 | 
			
		||||
        float ldiff = (float)(GetusTicks() - round_time) / 1000000.0;
 | 
			
		||||
        if (ldiff < 100.0 && ldiff > 0.0)
 | 
			
		||||
            CuvidDecoders[0]->Frameproc = (CuvidDecoders[0]->Frameproc + ldiff + ldiff) / 3.0;
 | 
			
		||||
    }
 | 
			
		||||
@@ -4376,7 +4417,7 @@ static void CuvidDisplayFrame(void) {
 | 
			
		||||
    VideoThreadLock();
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
    last_time = GetusTicks();
 | 
			
		||||
    //last_time = GetusTicks();
 | 
			
		||||
 | 
			
		||||
    while (!pl_swapchain_start_frame(p->swapchain, &frame)) { // get new frame wait for previous to swap
 | 
			
		||||
        usleep(5);
 | 
			
		||||
@@ -4431,7 +4472,7 @@ static void CuvidDisplayFrame(void) {
 | 
			
		||||
            }
 | 
			
		||||
            continue;
 | 
			
		||||
        }
 | 
			
		||||
        valid_frame = 1;
 | 
			
		||||
        
 | 
			
		||||
#ifdef PLACEBO
 | 
			
		||||
        //pthread_mutex_lock(&OSDMutex);
 | 
			
		||||
        if (OsdShown == 1) { // New OSD opened
 | 
			
		||||
@@ -4459,6 +4500,7 @@ static void CuvidDisplayFrame(void) {
 | 
			
		||||
        }
 | 
			
		||||
        //pthread_mutex_unlock(&OSDMutex);
 | 
			
		||||
#else
 | 
			
		||||
        valid_frame = 1;
 | 
			
		||||
        CuvidMixVideo(decoder, i);
 | 
			
		||||
#endif
 | 
			
		||||
        if (i == 0 && decoder->grab) { // Grab frame
 | 
			
		||||
@@ -4575,7 +4617,7 @@ static void CuvidDisplayFrame(void) {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#ifdef PLACEBO_GL
 | 
			
		||||
CuvidSwapBuffer() {
 | 
			
		||||
void CuvidSwapBuffer() {
 | 
			
		||||
#ifndef USE_DRM
 | 
			
		||||
    eglSwapBuffers(eglDisplay, eglSurface);
 | 
			
		||||
//    eglMakeCurrent(eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE,
 | 
			
		||||
@@ -4691,7 +4733,6 @@ static void CuvidSyncDecoder(CuvidDecoder *decoder) {
 | 
			
		||||
    int filled;
 | 
			
		||||
    int64_t audio_clock;
 | 
			
		||||
    int64_t video_clock;
 | 
			
		||||
    int err = 0;
 | 
			
		||||
    static int speedup = 3;
 | 
			
		||||
 | 
			
		||||
#ifdef GAMMA
 | 
			
		||||
@@ -4759,14 +4800,14 @@ static void CuvidSyncDecoder(CuvidDecoder *decoder) {
 | 
			
		||||
	}
 | 
			
		||||
#endif
 | 
			
		||||
        if (abs(diff) > 5000 * 90) { // more than 5s
 | 
			
		||||
            err = CuvidMessage(2, "video: audio/video difference too big %d\n", diff / 90);
 | 
			
		||||
            CuvidMessage(2, "video: audio/video difference too big %d\n", diff / 90);
 | 
			
		||||
            // decoder->SyncCounter = 1;
 | 
			
		||||
            // usleep(10);
 | 
			
		||||
            goto skip_sync;
 | 
			
		||||
 | 
			
		||||
        } else if (diff > 100 * 90) {
 | 
			
		||||
 | 
			
		||||
            err = CuvidMessage(4, "video: slow down video, duping frame %d\n", diff / 90);
 | 
			
		||||
            CuvidMessage(4, "video: slow down video, duping frame %d\n", diff / 90);
 | 
			
		||||
            ++decoder->FramesDuped;
 | 
			
		||||
            if ((speedup && --speedup) || VideoSoftStartSync)
 | 
			
		||||
                decoder->SyncCounter = 1;
 | 
			
		||||
@@ -4775,13 +4816,13 @@ static void CuvidSyncDecoder(CuvidDecoder *decoder) {
 | 
			
		||||
            goto out;
 | 
			
		||||
 | 
			
		||||
        } else if (diff > 25 * 90) {
 | 
			
		||||
            err = CuvidMessage(3, "video: slow down video, duping frame %d \n", diff / 90);
 | 
			
		||||
            CuvidMessage(3, "video: slow down video, duping frame %d \n", diff / 90);
 | 
			
		||||
            ++decoder->FramesDuped;
 | 
			
		||||
            decoder->SyncCounter = 1;
 | 
			
		||||
            goto out;
 | 
			
		||||
        } else if ((diff < -100 * 90)) {
 | 
			
		||||
            if (filled > 2) {
 | 
			
		||||
                err = CuvidMessage(3, "video: speed up video, droping frame %d\n", diff / 90);
 | 
			
		||||
                CuvidMessage(3, "video: speed up video, droping frame %d\n", diff / 90);
 | 
			
		||||
                ++decoder->FramesDropped;
 | 
			
		||||
                CuvidAdvanceDecoderFrame(decoder);
 | 
			
		||||
            } else if ((diff < -100 * 90)) { // give it some time to get frames to drop
 | 
			
		||||
@@ -5271,7 +5312,7 @@ void VideoOsdDrawARGB(int xi, int yi, int width, int height, int pitch, const ui
 | 
			
		||||
    }
 | 
			
		||||
    Debug(3, "video: osd dirty %dx%d%+d%+d -> %dx%d%+d%+d\n", width, height, x, y, OsdDirtyWidth, OsdDirtyHeight,
 | 
			
		||||
          OsdDirtyX, OsdDirtyY);
 | 
			
		||||
 | 
			
		||||
    Debug(4," dummy print %d %d %d %s",xi,yi,pitch,argb);
 | 
			
		||||
    VideoThreadUnlock();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -5575,7 +5616,7 @@ void pl_log_intern(void *stream, enum pl_log_level level, const char *msg) {
 | 
			
		||||
        [PL_LOG_FATAL] = "fatal", [PL_LOG_ERR] = "error",   [PL_LOG_WARN] = "warn",
 | 
			
		||||
        [PL_LOG_INFO] = "info",   [PL_LOG_DEBUG] = "debug", [PL_LOG_TRACE] = "trace",
 | 
			
		||||
    };
 | 
			
		||||
 | 
			
		||||
    (void)stream;
 | 
			
		||||
    printf("%5s: %s\n", prefix[level], msg);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -5686,6 +5727,7 @@ void InitPlacebo() {
 | 
			
		||||
        Fatal(_("Failed creating vulkan swapchain!"));
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
#ifdef VAAPI
 | 
			
		||||
    if (!(p->gpu->import_caps.tex & PL_HANDLE_DMA_BUF)) {
 | 
			
		||||
        p->has_dma_buf = 0;
 | 
			
		||||
        Debug(3, "No support for dma_buf import \n");
 | 
			
		||||
@@ -5693,16 +5735,20 @@ void InitPlacebo() {
 | 
			
		||||
        p->has_dma_buf = 1;
 | 
			
		||||
        Debug(3, "dma_buf support available\n");
 | 
			
		||||
    }
 | 
			
		||||
#else
 | 
			
		||||
    p->has_dma_buf = 0;
 | 
			
		||||
    Debug(3, "No support for dma_buf import \n");
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifdef PLACEBO_GL
 | 
			
		||||
    if (!pl_swapchain_resize(p->swapchain, &VideoWindowWidth, &VideoWindowHeight)) {
 | 
			
		||||
    if (!pl_swapchain_resize(p->swapchain, (int *)&VideoWindowWidth, (int *)&VideoWindowHeight)) {
 | 
			
		||||
        Fatal(_("libplacebo: failed initializing swapchain\n"));
 | 
			
		||||
    }
 | 
			
		||||
#endif
 | 
			
		||||
#if PL_API_VER >= 113
 | 
			
		||||
    // load LUT File
 | 
			
		||||
    struct file lutf;
 | 
			
		||||
    char tmp[200];
 | 
			
		||||
    char tmp[400];
 | 
			
		||||
 | 
			
		||||
    sprintf(tmp, "%s/%s", MyConfigDir, lut_file);
 | 
			
		||||
    if (open_file(tmp, &lutf) && lutf.size) {
 | 
			
		||||
@@ -5808,10 +5854,9 @@ void exit_display() {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void *VideoHandlerThread(void *dummy) {
 | 
			
		||||
#ifdef VAAPI
 | 
			
		||||
#if defined VAAPI && !defined PLACEBO_GL
 | 
			
		||||
    EGLint contextAttrs[] = {EGL_CONTEXT_CLIENT_VERSION, 3, EGL_NONE};
 | 
			
		||||
#endif
 | 
			
		||||
    int redSize, greenSize, blueSize, alphaSize;
 | 
			
		||||
 | 
			
		||||
    prctl(PR_SET_NAME, "video display", 0, 0, 0);
 | 
			
		||||
 | 
			
		||||
@@ -6575,13 +6620,13 @@ int VideoSetShader(char *s) {
 | 
			
		||||
#if defined PLACEBO && PL_API_VER >= 58
 | 
			
		||||
    if (num_shaders == NUM_SHADERS)
 | 
			
		||||
        return -1;
 | 
			
		||||
    p = malloc(strlen(s) + 1);
 | 
			
		||||
    char *p = malloc(strlen(s) + 1);
 | 
			
		||||
    memcpy(p, s, strlen(s) + 1);
 | 
			
		||||
    shadersp[num_shaders++] = p;
 | 
			
		||||
    CuvidMessage(2, "Use Shader %s\n", s);
 | 
			
		||||
    return 0;
 | 
			
		||||
#else
 | 
			
		||||
    printf("Shaders are only support with placebo\n");
 | 
			
		||||
    printf("Shaders are only support with placebo (%s)\n",s);
 | 
			
		||||
    return -1;
 | 
			
		||||
#endif
 | 
			
		||||
}
 | 
			
		||||
@@ -6897,7 +6942,8 @@ void VideoSetAbove() {
 | 
			
		||||
///
 | 
			
		||||
/// Set deinterlace mode.
 | 
			
		||||
///
 | 
			
		||||
void VideoSetDeinterlace(int mode[VideoResolutionMax]) {
 | 
			
		||||
void VideoSetDeinterlace(int mode[]) {
 | 
			
		||||
    
 | 
			
		||||
#ifdef CUVID
 | 
			
		||||
    VideoDeinterlace[0] = mode[0]; // 576i
 | 
			
		||||
    VideoDeinterlace[1] = 0;       // mode[1];  // 720p
 | 
			
		||||
@@ -6905,6 +6951,7 @@ void VideoSetDeinterlace(int mode[VideoResolutionMax]) {
 | 
			
		||||
    VideoDeinterlace[3] = mode[3]; // 1080
 | 
			
		||||
    VideoDeinterlace[4] = 0;       // mode[4];  2160p
 | 
			
		||||
#else
 | 
			
		||||
    (void)mode;
 | 
			
		||||
    VideoDeinterlace[0] = 1; // 576i
 | 
			
		||||
    VideoDeinterlace[1] = 0; // mode[1];  // 720p
 | 
			
		||||
    VideoDeinterlace[2] = 1; // fake 1080
 | 
			
		||||
@@ -6917,7 +6964,7 @@ void VideoSetDeinterlace(int mode[VideoResolutionMax]) {
 | 
			
		||||
///
 | 
			
		||||
/// Set skip chroma deinterlace on/off.
 | 
			
		||||
///
 | 
			
		||||
void VideoSetSkipChromaDeinterlace(int onoff[VideoResolutionMax]) {
 | 
			
		||||
void VideoSetSkipChromaDeinterlace(int onoff[]) {
 | 
			
		||||
    VideoSkipChromaDeinterlace[0] = onoff[0];
 | 
			
		||||
    VideoSkipChromaDeinterlace[1] = onoff[1];
 | 
			
		||||
    VideoSkipChromaDeinterlace[2] = onoff[2];
 | 
			
		||||
@@ -6929,7 +6976,7 @@ void VideoSetSkipChromaDeinterlace(int onoff[VideoResolutionMax]) {
 | 
			
		||||
///
 | 
			
		||||
/// Set inverse telecine on/off.
 | 
			
		||||
///
 | 
			
		||||
void VideoSetInverseTelecine(int onoff[VideoResolutionMax]) {
 | 
			
		||||
void VideoSetInverseTelecine(int onoff[]) {
 | 
			
		||||
    VideoInverseTelecine[0] = onoff[0];
 | 
			
		||||
    VideoInverseTelecine[1] = onoff[1];
 | 
			
		||||
    VideoInverseTelecine[2] = onoff[2];
 | 
			
		||||
@@ -6941,7 +6988,7 @@ void VideoSetInverseTelecine(int onoff[VideoResolutionMax]) {
 | 
			
		||||
///
 | 
			
		||||
/// Set denoise level (0 .. 1000).
 | 
			
		||||
///
 | 
			
		||||
void VideoSetDenoise(int level[VideoResolutionMax]) {
 | 
			
		||||
void VideoSetDenoise(int level[]) {
 | 
			
		||||
    VideoDenoise[0] = level[0];
 | 
			
		||||
    VideoDenoise[1] = level[1];
 | 
			
		||||
    VideoDenoise[2] = level[2];
 | 
			
		||||
@@ -6953,7 +7000,7 @@ void VideoSetDenoise(int level[VideoResolutionMax]) {
 | 
			
		||||
///
 | 
			
		||||
/// Set sharpness level (-1000 .. 1000).
 | 
			
		||||
///
 | 
			
		||||
void VideoSetSharpen(int level[VideoResolutionMax]) {
 | 
			
		||||
void VideoSetSharpen(int level[]) {
 | 
			
		||||
    VideoSharpen[0] = level[0];
 | 
			
		||||
    VideoSharpen[1] = level[1];
 | 
			
		||||
    VideoSharpen[2] = level[2];
 | 
			
		||||
@@ -6967,7 +7014,7 @@ void VideoSetSharpen(int level[VideoResolutionMax]) {
 | 
			
		||||
///
 | 
			
		||||
/// @param mode table with VideoResolutionMax values
 | 
			
		||||
///
 | 
			
		||||
void VideoSetScaling(int mode[VideoResolutionMax]) {
 | 
			
		||||
void VideoSetScaling(int mode[]) {
 | 
			
		||||
    VideoScaling[0] = mode[0];
 | 
			
		||||
    VideoScaling[1] = mode[1];
 | 
			
		||||
    VideoScaling[2] = mode[2];
 | 
			
		||||
@@ -6981,7 +7028,7 @@ void VideoSetScaling(int mode[VideoResolutionMax]) {
 | 
			
		||||
///
 | 
			
		||||
/// @param pixels table with VideoResolutionMax values
 | 
			
		||||
///
 | 
			
		||||
void VideoSetCutTopBottom(int pixels[VideoResolutionMax]) {
 | 
			
		||||
void VideoSetCutTopBottom(int pixels[]) {
 | 
			
		||||
    VideoCutTopBottom[0] = pixels[0];
 | 
			
		||||
    VideoCutTopBottom[1] = pixels[1];
 | 
			
		||||
    VideoCutTopBottom[2] = pixels[2];
 | 
			
		||||
@@ -6995,7 +7042,7 @@ void VideoSetCutTopBottom(int pixels[VideoResolutionMax]) {
 | 
			
		||||
///
 | 
			
		||||
/// @param pixels   table with VideoResolutionMax values
 | 
			
		||||
///
 | 
			
		||||
void VideoSetCutLeftRight(int pixels[VideoResolutionMax]) {
 | 
			
		||||
void VideoSetCutLeftRight(int pixels[]) {
 | 
			
		||||
    VideoCutLeftRight[0] = pixels[0];
 | 
			
		||||
    VideoCutLeftRight[1] = pixels[1];
 | 
			
		||||
    VideoCutLeftRight[2] = pixels[2];
 | 
			
		||||
@@ -7091,6 +7138,14 @@ void VideoInit(const char *display_name) {
 | 
			
		||||
    xcb_screen_iterator_t screen_iter;
 | 
			
		||||
    xcb_screen_t const *screen;
 | 
			
		||||
 | 
			
		||||
#ifdef VAAPI
 | 
			
		||||
    VideoDeinterlace[0] = 1; // 576i
 | 
			
		||||
    VideoDeinterlace[1] = 0; // mode[1];  // 720p
 | 
			
		||||
    VideoDeinterlace[2] = 1; // fake 1080
 | 
			
		||||
    VideoDeinterlace[3] = 1; // 1080
 | 
			
		||||
    VideoDeinterlace[4] = 0; // mode[4];  2160p
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#ifdef USE_DRM
 | 
			
		||||
    VideoInitDrm();
 | 
			
		||||
#else
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user