1
0
mirror of https://github.com/jojo61/vdr-plugin-softhdcuvid.git synced 2023-10-10 13:37:41 +02:00

- Reindent all sources to common coding style again.

- Fix compile bug occurred with gcc10 (-fno-common is now default)
This commit is contained in:
Dirk Nehring 2020-04-10 16:17:23 +02:00
parent 5875e10479
commit 36c208967e
13 changed files with 1236 additions and 1076 deletions

View File

@ -1,6 +1,6 @@
# #
# Makefile for a Video Disk Recorder plugin # Makefile for a Video Disk Recorder plugin
# #
# $Id: 2a41981a57e5e83036463c6a08c84b86ed9d2be3 $ # $Id: 2a41981a57e5e83036463c6a08c84b86ed9d2be3 $
# The official name of this plugin. # The official name of this plugin.
@ -11,7 +11,7 @@
### Configuration (edit this for your needs) ### Configuration (edit this for your needs)
# config as needed # config as needed
# what kind of decoder do we make - # what kind of decoder do we make -
# if VAAPI is enabled the pluginname is softhdvaapi # if VAAPI is enabled the pluginname is softhdvaapi
# if CUVID is enabled the pluginname is softhdcuvid # if CUVID is enabled the pluginname is softhdcuvid
# if DRM is enabled the pluginname is softhddrm # if DRM is enabled the pluginname is softhddrm
@ -19,12 +19,12 @@ VAAPI ?= 0
CUVID ?= 0 CUVID ?= 0
# if you enable DRM then the plugin will only run without X server # if you enable DRM then the plugin will only run without X server
# only valid for VAAPI # only valid for VAAPI
# does not work with libplacebo # does not work with libplacebo
DRM ?= 0 DRM ?= 0
# use libplacebo - available for both decoders but not for DRM # use libplacebo - available for both decoders but not for DRM
LIBPLACEBO ?= 1 LIBPLACEBO ?= 1
# use YADIF deint - only available with cuvid # use YADIF deint - only available with cuvid
@ -124,7 +124,7 @@ TMPDIR ?= /tmp
### The compiler options: ### The compiler options:
export CFLAGS = $(call PKGCFG,cflags) export CFLAGS = $(call PKGCFG,cflags)
export CXXFLAGS = $(call PKGCFG,cxxflags) export CXXFLAGS = $(call PKGCFG,cxxflags)
ifeq ($(CFLAGS),) ifeq ($(CFLAGS),)
@ -146,10 +146,10 @@ APIVERSION = $(call PKGCFG,apiversion)
### Parse config ### Parse config
ifeq ($(VAAPI),1) ifeq ($(VAAPI),1)
CONFIG += -DVAAPI CONFIG += -DVAAPI
#LIBPLACEBO=1 #LIBPLACEBO=1
PLUGIN = softhdvaapi PLUGIN = softhdvaapi
LIBS += -lEGL LIBS += -lEGL
endif endif
@ -159,13 +159,13 @@ CONFIG += -DUSE_DRM -DVAAPI
LIBPLACEBO=0 LIBPLACEBO=0
_CFLAGS += $(shell pkg-config --cflags libdrm) _CFLAGS += $(shell pkg-config --cflags libdrm)
LIBS += -lgbm -ldrm LIBS += -lgbm -ldrm
LIBS += -lEGL LIBS += -lEGL
endif endif
ifeq ($(CUVID),1) ifeq ($(CUVID),1)
CONFIG += -DUSE_PIP # PIP support CONFIG += -DUSE_PIP # PIP support
CONFIG += -DCUVID # enable CUVID decoder CONFIG += -DCUVID # enable CUVID decoder
LIBS += -lEGL -lGL LIBS += -lEGL -lGL
ifeq ($(YADIF),1) ifeq ($(YADIF),1)
CONFIG += -DYADIF # Yadif only with CUVID CONFIG += -DYADIF # Yadif only with CUVID
endif endif
@ -213,7 +213,7 @@ SOFILE = libvdr-$(PLUGIN).so
# #
# Test that libswresample is available # Test that libswresample is available
# #
#ifneq (exists, $(shell pkg-config libswresample && echo exists)) #ifneq (exists, $(shell pkg-config libswresample && echo exists))
# $(warning ******************************************************************) # $(warning ******************************************************************)
@ -222,7 +222,7 @@ SOFILE = libvdr-$(PLUGIN).so
#endif #endif
# #
# Test and set config for libavutil # Test and set config for libavutil
# #
ifneq (exists, $(shell pkg-config libavutil && echo exists)) ifneq (exists, $(shell pkg-config libavutil && echo exists))
$(warning ******************************************************************) $(warning ******************************************************************)
@ -233,7 +233,7 @@ _CFLAGS += $(shell pkg-config --cflags libavutil)
LIBS += $(shell pkg-config --libs libavutil) LIBS += $(shell pkg-config --libs libavutil)
# #
# Test and set config for libswscale # Test and set config for libswscale
# #
ifneq (exists, $(shell pkg-config libswscale && echo exists)) ifneq (exists, $(shell pkg-config libswscale && echo exists))
$(warning ******************************************************************) $(warning ******************************************************************)
@ -281,14 +281,14 @@ _CFLAGS += -I./opengl -I./
LIBS += -L/usr/lib64 LIBS += -L/usr/lib64
ifeq ($(LIBPLACEBO),1) ifeq ($(LIBPLACEBO),1)
LIBS += -lplacebo LIBS += -lplacebo
endif endif
ifeq ($(CUVID),1) ifeq ($(CUVID),1)
LIBS += -lcuda -lnvcuvid LIBS += -lcuda -lnvcuvid
endif endif
LIBS += -lGLEW -lGLU -ldl -lglut LIBS += -lGLEW -lGLU -ldl -lglut
### Includes and Defines (add further entries here): ### Includes and Defines (add further entries here):
INCLUDES += INCLUDES +=
@ -299,16 +299,16 @@ DEFINES += -DPLUGIN_NAME_I18N='"$(PLUGIN)"' -D_GNU_SOURCE $(CONFIG) \
### Make it standard ### Make it standard
override CXXFLAGS += $(_CFLAGS) $(DEFINES) $(INCLUDES) \ override CXXFLAGS += $(_CFLAGS) $(DEFINES) $(INCLUDES) \
-g -W -Wextra -Winit-self -Werror=overloaded-virtual -Wno-unused-parameter -g -W -Wextra -Winit-self -Werror=overloaded-virtual -Wno-unused-parameter
override CFLAGS += $(_CFLAGS) $(DEFINES) $(INCLUDES) \ override CFLAGS += $(_CFLAGS) $(DEFINES) $(INCLUDES) \
-g -W -Wextra -Winit-self -Wdeclaration-after-statement -g -W -Wextra -Winit-self -Wdeclaration-after-statement
### The object files (add further files here): ### The object files (add further files here):
OBJS = softhdcuvid.o softhddev.o video.o audio.o codec.o ringbuffer.o OBJS = softhdcuvid.o softhddev.o video.o audio.o codec.o ringbuffer.o
ifeq ($(OPENGLOSD),1) ifeq ($(OPENGLOSD),1)
OBJS += openglosd.o OBJS += openglosd.o
endif endif
SRCS = $(wildcard $(OBJS:.o=.c)) *.cpp SRCS = $(wildcard $(OBJS:.o=.c)) *.cpp
@ -385,9 +385,7 @@ HDRS= $(wildcard *.h)
indent: indent:
for i in $(SRCS) $(HDRS); do \ for i in $(SRCS) $(HDRS); do \
indent $$i; \ VERSION_CONTROL=none indent $$i; \
unexpand -a $$i | sed -e s/constconst/const/ > $$i.up; \
mv $$i.up $$i; \
done done
video_test: video.c Makefile video_test: video.c Makefile

19
audio.c
View File

@ -146,7 +146,6 @@ static volatile char AudioRunning; ///< thread running / stopped
static volatile char AudioPaused; ///< audio paused static volatile char AudioPaused; ///< audio paused
static volatile char AudioVideoIsReady; ///< video ready start early static volatile char AudioVideoIsReady; ///< video ready start early
static int AudioSkip; ///< skip audio to sync to video static int AudioSkip; ///< skip audio to sync to video
int AudioDelay; /// delay audio to sync to video
static const int AudioBytesProSample = 2; ///< number of bytes per sample static const int AudioBytesProSample = 2; ///< number of bytes per sample
@ -2005,7 +2004,7 @@ static void *AudioPlayHandlerThread(void *dummy)
{ {
Debug(3, "audio: play thread started\n"); Debug(3, "audio: play thread started\n");
prctl(PR_SET_NAME, "cuvid audio", 0, 0, 0); prctl(PR_SET_NAME, "cuvid audio", 0, 0, 0);
for (;;) { for (;;) {
// check if we should stop the thread // check if we should stop the thread
if (AudioThreadStop) { if (AudioThreadStop) {
@ -2024,7 +2023,8 @@ static void *AudioPlayHandlerThread(void *dummy)
Debug(3, "audio: ----> %dms %d start\n", (AudioUsedBytes() * 1000) Debug(3, "audio: ----> %dms %d start\n", (AudioUsedBytes() * 1000)
/ (!AudioRing[AudioRingWrite].HwSampleRate + !AudioRing[AudioRingWrite].HwChannels + / (!AudioRing[AudioRingWrite].HwSampleRate + !AudioRing[AudioRingWrite].HwChannels +
AudioRing[AudioRingWrite].HwSampleRate * AudioRing[AudioRingWrite].HwChannels * AudioBytesProSample),AudioUsedBytes()); AudioRing[AudioRingWrite].HwSampleRate * AudioRing[AudioRingWrite].HwChannels * AudioBytesProSample),
AudioUsedBytes());
do { do {
int filled; int filled;
@ -2252,7 +2252,7 @@ void AudioEnqueue(const void *samples, int count)
AudioNormalizer(buffer, count); AudioNormalizer(buffer, count);
} }
} }
n = RingBufferWrite(AudioRing[AudioRingWrite].RingBuffer, buffer, count); n = RingBufferWrite(AudioRing[AudioRingWrite].RingBuffer, buffer, count);
if (n != (size_t)count) { if (n != (size_t)count) {
Error(_("audio: can't place %d samples in ring buffer\n"), count); Error(_("audio: can't place %d samples in ring buffer\n"), count);
@ -2291,7 +2291,7 @@ void AudioEnqueue(const void *samples, int count)
// no lock needed, can wakeup next time // no lock needed, can wakeup next time
AudioRunning = 1; AudioRunning = 1;
pthread_cond_signal(&AudioStartCond); pthread_cond_signal(&AudioStartCond);
Debug(3, "Start on AudioEnque Threshold %d n %d\n",AudioStartThreshold,n); Debug(3, "Start on AudioEnque Threshold %d n %d\n", AudioStartThreshold, n);
} }
} }
// Update audio clock (stupid gcc developers thinks INT64_C is unsigned) // Update audio clock (stupid gcc developers thinks INT64_C is unsigned)
@ -2325,7 +2325,7 @@ void AudioVideoReady(int64_t pts)
// Audio.PTS = next written sample time stamp // Audio.PTS = next written sample time stamp
used = RingBufferUsedBytes(AudioRing[AudioRingWrite].RingBuffer); used = RingBufferUsedBytes(AudioRing[AudioRingWrite].RingBuffer);
audio_pts = audio_pts =
AudioRing[AudioRingWrite].PTS - AudioRing[AudioRingWrite].PTS -
(used * 90 * 1000) / (AudioRing[AudioRingWrite].HwSampleRate * AudioRing[AudioRingWrite].HwChannels * (used * 90 * 1000) / (AudioRing[AudioRingWrite].HwSampleRate * AudioRing[AudioRingWrite].HwChannels *
AudioBytesProSample); AudioBytesProSample);
@ -2337,11 +2337,12 @@ void AudioVideoReady(int64_t pts)
if (!AudioRunning) { if (!AudioRunning) {
int skip; int skip;
// buffer ~15 video frames // buffer ~15 video frames
// FIXME: HDTV can use smaller video buffer // FIXME: HDTV can use smaller video buffer
skip = pts - 0 * 20 * 90 - AudioBufferTime * 90 - audio_pts + VideoAudioDelay; skip = pts - 0 * 20 * 90 - AudioBufferTime * 90 - audio_pts + VideoAudioDelay;
#ifdef DEBUG #ifdef DEBUG
// fprintf(stderr, "a/v-diff %dms a/v-delay %dms skip %dms Audiobuffer %d\n", (int)(pts - audio_pts) / 90, VideoAudioDelay / 90, skip / 90,AudioBufferTime); // fprintf(stderr, "a/v-diff %dms a/v-delay %dms skip %dms Audiobuffer %d\n", (int)(pts - audio_pts) / 90, VideoAudioDelay / 90, skip / 90,AudioBufferTime);
#endif #endif
// guard against old PTS // guard against old PTS
if (skip > 0 && skip < 4000 * 90) { if (skip > 0 && skip < 4000 * 90) {
@ -2479,7 +2480,7 @@ int64_t AudioGetDelay(void)
pts += ((int64_t) RingBufferUsedBytes(AudioRing[AudioRingRead].RingBuffer) pts += ((int64_t) RingBufferUsedBytes(AudioRing[AudioRingRead].RingBuffer)
* 90 * 1000) / (AudioRing[AudioRingRead].HwSampleRate * AudioRing[AudioRingRead].HwChannels * * 90 * 1000) / (AudioRing[AudioRingRead].HwSampleRate * AudioRing[AudioRingRead].HwChannels *
AudioBytesProSample); AudioBytesProSample);
Debug(4,"audio: hw+sw delay %zd %" PRId64 "ms\n", RingBufferUsedBytes(AudioRing[AudioRingRead].RingBuffer), Debug(4, "audio: hw+sw delay %zd %" PRId64 "ms\n", RingBufferUsedBytes(AudioRing[AudioRingRead].RingBuffer),
pts / 90); pts / 90);
return pts; return pts;
@ -2496,7 +2497,7 @@ void AudioSetClock(int64_t pts)
Debug(4, "audio: set clock %s -> %s pts\n", Timestamp2String(AudioRing[AudioRingWrite].PTS), Debug(4, "audio: set clock %s -> %s pts\n", Timestamp2String(AudioRing[AudioRingWrite].PTS),
Timestamp2String(pts)); Timestamp2String(pts));
} }
// printf("Audiosetclock pts %#012" PRIx64 " %d\n",pts,RingBufferUsedBytes(AudioRing[AudioRingWrite].RingBuffer)); // printf("Audiosetclock pts %#012" PRIx64 " %d\n",pts,RingBufferUsedBytes(AudioRing[AudioRingWrite].RingBuffer));
AudioRing[AudioRingWrite].PTS = pts; AudioRing[AudioRingWrite].PTS = pts;
} }

56
codec.c
View File

@ -96,6 +96,7 @@ static pthread_mutex_t CodecLockMutex;
/// Flag prefer fast channel switch /// Flag prefer fast channel switch
char CodecUsePossibleDefectFrames; char CodecUsePossibleDefectFrames;
AVBufferRef *hw_device_ctx; AVBufferRef *hw_device_ctx;
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// Video // Video
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -255,18 +256,18 @@ void CodecVideoOpen(VideoDecoder * decoder, int codec_id)
#endif #endif
#ifdef RASPI #ifdef RASPI
switch (codec_id) { switch (codec_id) {
case AV_CODEC_ID_MPEG2VIDEO: case AV_CODEC_ID_MPEG2VIDEO:
name = "mpeg2_v4l2m2m"; name = "mpeg2_v4l2m2m";
break; break;
case AV_CODEC_ID_H264: case AV_CODEC_ID_H264:
name = "h264_v4l2m2m"; name = "h264_v4l2m2m";
// name = "h264_mmal"; // name = "h264_mmal";
break; break;
case AV_CODEC_ID_HEVC: case AV_CODEC_ID_HEVC:
name = "hevc_v4l2m2m"; name = "hevc_v4l2m2m";
break; 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");
} else if ((video_codec = avcodec_find_decoder(codec_id)) == NULL) { } else if ((video_codec = avcodec_find_decoder(codec_id)) == NULL) {
@ -281,15 +282,15 @@ void CodecVideoOpen(VideoDecoder * decoder, int codec_id)
if (!(decoder->VideoCtx = avcodec_alloc_context3(video_codec))) { if (!(decoder->VideoCtx = avcodec_alloc_context3(video_codec))) {
Fatal(_("codec: can't allocate video codec context\n")); Fatal(_("codec: can't allocate video codec context\n"));
} }
#ifndef RASPI #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 #else
decoder->VideoCtx->pix_fmt = AV_PIX_FMT_DRM_PRIME; /* request a DRM frame 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 */ // decoder->VideoCtx->pix_fmt = AV_PIX_FMT_MMAL; /* request a DRM frame */
#endif #endif
// FIXME: for software decoder use all cpus, otherwise 1 // FIXME: for software decoder use all cpus, otherwise 1
@ -310,7 +311,7 @@ void CodecVideoOpen(VideoDecoder * decoder, int codec_id)
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");
// decoder->VideoCtx->thread_count = 0; // decoder->VideoCtx->thread_count = 0;
} }
if (video_codec->capabilities & AV_CODEC_CAP_TRUNCATED) { if (video_codec->capabilities & AV_CODEC_CAP_TRUNCATED) {
Debug(3, "codec: supports truncated packets"); Debug(3, "codec: supports truncated packets");
@ -333,9 +334,9 @@ 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"));
decoder->VideoCtx->thread_safe_callbacks = 0; decoder->VideoCtx->thread_safe_callbacks = 0;
#endif #endif
#ifdef RASPI #ifdef RASPI
decoder->VideoCtx->codec_id = codec_id; decoder->VideoCtx->codec_id = codec_id;
decoder->VideoCtx->flags |= AV_CODEC_FLAG_BITEXACT; decoder->VideoCtx->flags |= AV_CODEC_FLAG_BITEXACT;
@ -508,18 +509,18 @@ void CodecVideoDecode(VideoDecoder * decoder, const AVPacket * avpkt)
int ret; int ret;
AVPacket pkt[1]; AVPacket pkt[1];
AVFrame *frame; AVFrame *frame;
*pkt = *avpkt; // use copy *pkt = *avpkt; // use copy
ret = avcodec_send_packet(video_ctx, pkt); ret = avcodec_send_packet(video_ctx, pkt);
if (ret < 0) { if (ret < 0) {
return; return;
} }
if (!CuvidTestSurfaces()) if (!CuvidTestSurfaces())
usleep(1000); usleep(1000);
ret = 0; ret = 0;
while (ret >= 0 && CuvidTestSurfaces()) { while (ret >= 0 && CuvidTestSurfaces()) {
frame = av_frame_alloc(); frame = av_frame_alloc();
ret = avcodec_receive_frame(video_ctx, frame); ret = avcodec_receive_frame(video_ctx, frame);
@ -549,7 +550,7 @@ void CodecVideoDecode(VideoDecoder * decoder, const AVPacket * avpkt)
av_frame_free(&frame); av_frame_free(&frame);
return; return;
} }
} }
} }
} }
#endif #endif
@ -596,9 +597,9 @@ void CodecVideoDecode(VideoDecoder * decoder, const AVPacket * avpkt)
} else { } else {
got_frame = 0; got_frame = 0;
} }
// printf("got %s packet from decoder\n",got_frame?"1":"no"); // printf("got %s packet from decoder\n",got_frame?"1":"no");
if (got_frame) { // frame completed if (got_frame) { // frame completed
// printf("video frame pts %#012" PRIx64 " %dms\n",frame->pts,(int)(apts - frame->pts) / 90); // printf("video frame pts %#012" PRIx64 " %dms\n",frame->pts,(int)(apts - frame->pts) / 90);
#ifdef YADIF #ifdef YADIF
if (decoder->filter) { if (decoder->filter) {
if (decoder->filter == 1) { if (decoder->filter == 1) {
@ -647,7 +648,7 @@ void CodecVideoDecode(VideoDecoder * decoder, const AVPacket * avpkt)
void CodecVideoFlushBuffers(VideoDecoder * decoder) void CodecVideoFlushBuffers(VideoDecoder * decoder)
{ {
if (decoder->VideoCtx) { if (decoder->VideoCtx) {
avcodec_flush_buffers(decoder->VideoCtx); avcodec_flush_buffers(decoder->VideoCtx);
} }
} }
@ -819,7 +820,7 @@ void CodecAudioOpen(AudioDecoder * audio_decoder, int codec_id)
void CodecAudioClose(AudioDecoder * audio_decoder) void CodecAudioClose(AudioDecoder * audio_decoder)
{ {
// FIXME: output any buffered data // FIXME: output any buffered data
#ifdef USE_SWRESAMPLE #ifdef USE_SWRESAMPLE
if (audio_decoder->Resample) { if (audio_decoder->Resample) {
swr_free(&audio_decoder->Resample); swr_free(&audio_decoder->Resample);
@ -1111,8 +1112,6 @@ static int CodecAudioPassthroughHelper(AudioDecoder * audio_decoder, const AVPac
return 0; return 0;
} }
#if defined(USE_SWRESAMPLE) || defined(USE_AVRESAMPLE) #if defined(USE_SWRESAMPLE) || defined(USE_AVRESAMPLE)
/** /**
@ -1346,6 +1345,7 @@ void CodecAudioDecode(AudioDecoder * audio_decoder, const AVPacket * avpkt)
if (audio_decoder->Resample) { if (audio_decoder->Resample) {
uint8_t outbuf[8192 * 2 * 8]; uint8_t outbuf[8192 * 2 * 8];
uint8_t *out[1]; uint8_t *out[1];
out[0] = outbuf; out[0] = outbuf;
ret = ret =
swr_convert(audio_decoder->Resample, out, sizeof(outbuf) / (2 * audio_decoder->HwChannels), swr_convert(audio_decoder->Resample, out, sizeof(outbuf) / (2 * audio_decoder->HwChannels),

View File

@ -1,4 +1,3 @@
/* /*
* This file is part of mpv. * This file is part of mpv.
* *

View File

@ -1,4 +1,3 @@
/* /*
* This file is part of libplacebo. * This file is part of libplacebo.
* *

104
drm.c
View File

@ -18,13 +18,13 @@ struct _Drm_Render_
int fd_drm; int fd_drm;
drmModeModeInfo mode; drmModeModeInfo mode;
drmModeCrtc *saved_crtc; drmModeCrtc *saved_crtc;
// drmEventContext ev; // drmEventContext ev;
int bpp; int bpp;
uint32_t connector_id, crtc_id, video_plane; uint32_t connector_id, crtc_id, video_plane;
uint32_t hdr_metadata; uint32_t hdr_metadata;
uint32_t mmWidth,mmHeight; // Size in mm uint32_t mmWidth,mmHeight; // Size in mm
uint32_t hdr_blob_id; uint32_t hdr_blob_id;
}; };
typedef struct _Drm_Render_ VideoRender; typedef struct _Drm_Render_ VideoRender;
@ -193,12 +193,12 @@ void set_video_mode(int width, int height)
return; return;
connector = drmModeGetConnector(render->fd_drm, render->connector_id); connector = drmModeGetConnector(render->fd_drm, render->connector_id);
for (ii = 0; ii < connector->count_modes; ii++) { for (ii = 0; ii < connector->count_modes; ii++) {
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);
if (width == mode->hdisplay && if (width == mode->hdisplay &&
height == mode->vdisplay && height == mode->vdisplay &&
mode->vrefresh == DRMRefresh && mode->vrefresh == DRMRefresh &&
render->mode.hdisplay != width && render->mode.hdisplay != width &&
render->mode.vdisplay != height && render->mode.vdisplay != height &&
!(mode->flags & DRM_MODE_FLAG_INTERLACE)) { !(mode->flags & DRM_MODE_FLAG_INTERLACE)) {
memcpy(&render->mode, mode, sizeof(drmModeModeInfo)); memcpy(&render->mode, mode, sizeof(drmModeModeInfo));
@ -211,7 +211,7 @@ void set_video_mode(int width, int height)
CuvidSetVideoMode(); CuvidSetVideoMode();
Debug(3,"Set new mode %d:%d\n",mode->hdisplay,mode->vdisplay); Debug(3,"Set new mode %d:%d\n",mode->hdisplay,mode->vdisplay);
break; break;
} }
} }
} }
@ -241,10 +241,10 @@ static int FindDevice(VideoRender * render)
return -errno; return -errno;
} }
drmSetMaster(render->fd_drm); drmSetMaster(render->fd_drm);
version = drmGetVersion(render->fd_drm); version = drmGetVersion(render->fd_drm);
fprintf(stderr, "FindDevice: open /dev/dri/card0: %s\n", version->name); fprintf(stderr, "FindDevice: open /dev/dri/card0: %s\n", version->name);
// check capability // check capability
if (drmGetCap(render->fd_drm, DRM_CAP_DUMB_BUFFER, &has_dumb) < 0 || has_dumb == 0) if (drmGetCap(render->fd_drm, DRM_CAP_DUMB_BUFFER, &has_dumb) < 0 || has_dumb == 0)
fprintf(stderr, "FindDevice: drmGetCap DRM_CAP_DUMB_BUFFER failed or doesn't have dumb buffer\n"); fprintf(stderr, "FindDevice: drmGetCap DRM_CAP_DUMB_BUFFER failed or doesn't have dumb buffer\n");
@ -263,7 +263,7 @@ static int FindDevice(VideoRender * render)
if (drmGetCap(render->fd_drm, DRM_PRIME_CAP_IMPORT, &has_prime) < 0) if (drmGetCap(render->fd_drm, DRM_PRIME_CAP_IMPORT, &has_prime) < 0)
fprintf(stderr, "FindDevice: DRM_PRIME_CAP_IMPORT not available.\n"); fprintf(stderr, "FindDevice: DRM_PRIME_CAP_IMPORT not available.\n");
if ((resources = drmModeGetResources(render->fd_drm)) == NULL){ if ((resources = drmModeGetResources(render->fd_drm)) == NULL){
fprintf(stderr, "FindDevice: cannot retrieve DRM resources (%d): %m\n", errno); fprintf(stderr, "FindDevice: cannot retrieve DRM resources (%d): %m\n", errno);
return -errno; return -errno;
@ -282,18 +282,18 @@ static int FindDevice(VideoRender * render)
fprintf(stderr, "FindDevice: cannot retrieve DRM connector (%d): %m\n", errno); fprintf(stderr, "FindDevice: cannot retrieve DRM connector (%d): %m\n", errno);
return -errno; return -errno;
} }
sprintf(connectorstr,"%s-%u",util_lookup_connector_type_name(connector->connector_type),connector->connector_type_id); sprintf(connectorstr,"%s-%u",util_lookup_connector_type_name(connector->connector_type),connector->connector_type_id);
printf("Connector >%s< is %sconnected\n",connectorstr,connector->connection == DRM_MODE_CONNECTED?"":"not "); printf("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;
render->mmWidth = 160; render->mmWidth = 160;
} else { } else {
render->mmHeight = connector->mmHeight; render->mmHeight = connector->mmHeight;
render->mmWidth = connector->mmWidth; render->mmWidth = connector->mmWidth;
} }
@ -304,27 +304,27 @@ static int FindDevice(VideoRender * render)
return -errno; return -errno;
} }
render->crtc_id = encoder->crtc_id; render->crtc_id = encoder->crtc_id;
render->hdr_metadata = GetPropertyID(render->fd_drm, connector->connector_id, render->hdr_metadata = GetPropertyID(render->fd_drm, connector->connector_id,
DRM_MODE_OBJECT_CONNECTOR, "HDR_OUTPUT_METADATA"); DRM_MODE_OBJECT_CONNECTOR, "HDR_OUTPUT_METADATA");
printf("ID %d of METADATA in Connector %d connected %d\n",render->hdr_metadata,connector->connector_id,connector->connection); printf("ID %d of METADATA in Connector %d connected %d\n",render->hdr_metadata,connector->connector_id,connector->connection);
memcpy(&render->mode, &connector->modes[0], sizeof(drmModeModeInfo)); // set fallback memcpy(&render->mode, &connector->modes[0], sizeof(drmModeModeInfo)); // set fallback
// search Modes for Connector // search Modes for Connector
for (ii = 0; ii < connector->count_modes; ii++) { for (ii = 0; ii < connector->count_modes; ii++) {
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);
if (VideoWindowWidth && VideoWindowHeight) { // preset by command line if (VideoWindowWidth && VideoWindowHeight) { // preset by command line
if (VideoWindowWidth == mode->hdisplay && if (VideoWindowWidth == mode->hdisplay &&
VideoWindowHeight == mode->vdisplay && VideoWindowHeight == mode->vdisplay &&
mode->vrefresh == DRMRefresh && mode->vrefresh == DRMRefresh &&
!(mode->flags & DRM_MODE_FLAG_INTERLACE)) { !(mode->flags & DRM_MODE_FLAG_INTERLACE)) {
memcpy(&render->mode, mode, sizeof(drmModeModeInfo)); memcpy(&render->mode, mode, sizeof(drmModeModeInfo));
break; break;
} }
} }
else { else {
if (!(mode->flags & DRM_MODE_FLAG_INTERLACE)) { if (!(mode->flags & DRM_MODE_FLAG_INTERLACE)) {
memcpy(&render->mode, mode, sizeof(drmModeModeInfo)); memcpy(&render->mode, mode, sizeof(drmModeModeInfo));
@ -335,7 +335,7 @@ static int FindDevice(VideoRender * render)
} }
} }
found = 1; found = 1;
i = resources->count_connectors; // uuuuhh i = resources->count_connectors; // uuuuhh
} }
VideoWindowWidth = render->mode.hdisplay; VideoWindowWidth = render->mode.hdisplay;
VideoWindowHeight = render->mode.vdisplay; VideoWindowHeight = render->mode.vdisplay;
@ -348,7 +348,7 @@ static int FindDevice(VideoRender * render)
printf("Requested Connector not found or not connected\n"); printf("Requested Connector not found or not connected\n");
return -1; return -1;
} }
// find first plane // find first plane
if ((plane_res = drmModeGetPlaneResources(render->fd_drm)) == NULL) if ((plane_res = drmModeGetPlaneResources(render->fd_drm)) == NULL)
fprintf(stderr, "FindDevice: cannot retrieve PlaneResources (%d): %m\n", errno); fprintf(stderr, "FindDevice: cannot retrieve PlaneResources (%d): %m\n", errno);
@ -366,7 +366,7 @@ static int FindDevice(VideoRender * render)
uint64_t type = GetPropertyValue(render->fd_drm, plane_res->planes[j], uint64_t type = GetPropertyValue(render->fd_drm, plane_res->planes[j],
DRM_MODE_OBJECT_PLANE, "type"); DRM_MODE_OBJECT_PLANE, "type");
uint64_t zpos = 0; uint64_t zpos = 0;
#ifdef DRM_DEBUG // If more then 2 crtcs this must rewriten!!! #ifdef DRM_DEBUG // If more then 2 crtcs this must rewriten!!!
printf("[FindDevice] Plane id %i crtc_id %i possible_crtcs %i possible CRTC %i type %s\n", printf("[FindDevice] Plane id %i crtc_id %i possible_crtcs %i possible CRTC %i type %s\n",
@ -384,7 +384,7 @@ static int FindDevice(VideoRender * render)
case DRM_FORMAT_ARGB8888: case DRM_FORMAT_ARGB8888:
#else #else
case DRM_FORMAT_XRGB2101010: case DRM_FORMAT_XRGB2101010:
#endif #endif
if (!render->video_plane) { if (!render->video_plane) {
render->video_plane = plane->plane_id; render->video_plane = plane->plane_id;
} }
@ -419,25 +419,25 @@ static int FindDevice(VideoRender * render)
void VideoInitDrm() void VideoInitDrm()
{ {
int i; int i;
if (!(render = calloc(1, sizeof(*render)))) { if (!(render = calloc(1, sizeof(*render)))) {
Fatal(_("video/DRM: out of memory\n")); Fatal(_("video/DRM: out of memory\n"));
return; return;
} }
if (FindDevice(render)){ if (FindDevice(render)){
Fatal(_( "VideoInit: FindDevice() failed\n")); Fatal(_( "VideoInit: FindDevice() failed\n"));
} }
gbm.dev = gbm_create_device (render->fd_drm); gbm.dev = gbm_create_device (render->fd_drm);
assert (gbm.dev != NULL); assert (gbm.dev != NULL);
PFNEGLGETPLATFORMDISPLAYEXTPROC get_platform_display = NULL; PFNEGLGETPLATFORMDISPLAYEXTPROC get_platform_display = NULL;
get_platform_display = get_platform_display =
(void *) eglGetProcAddress("eglGetPlatformDisplay"); (void *) eglGetProcAddress("eglGetPlatformDisplay");
assert(get_platform_display != NULL); assert(get_platform_display != NULL);
eglDisplay = get_platform_display(EGL_PLATFORM_GBM_KHR, gbm.dev, NULL); eglDisplay = get_platform_display(EGL_PLATFORM_GBM_KHR, gbm.dev, NULL);
assert (eglDisplay != NULL); assert (eglDisplay != NULL);
@ -462,13 +462,13 @@ void VideoInitDrm()
DRM_MODE_OBJECT_CONNECTOR, "CRTC_ID", render->crtc_id); DRM_MODE_OBJECT_CONNECTOR, "CRTC_ID", render->crtc_id);
SetPropertyRequest(ModeReq, render->fd_drm, render->crtc_id, SetPropertyRequest(ModeReq, render->fd_drm, render->crtc_id,
DRM_MODE_OBJECT_CRTC, "ACTIVE", 1); DRM_MODE_OBJECT_CRTC, "ACTIVE", 1);
if (drmModeAtomicCommit(render->fd_drm, ModeReq, flags, NULL) != 0) if (drmModeAtomicCommit(render->fd_drm, ModeReq, flags, NULL) != 0)
fprintf(stderr, "cannot set atomic mode (%d): %m\n", errno); fprintf(stderr, "cannot set atomic mode (%d): %m\n", errno);
if (drmModeDestroyPropertyBlob(render->fd_drm, modeID) != 0) if (drmModeDestroyPropertyBlob(render->fd_drm, modeID) != 0)
fprintf(stderr, "cannot destroy property blob (%d): %m\n", errno); fprintf(stderr, "cannot destroy property blob (%d): %m\n", errno);
drmModeAtomicFree(ModeReq); drmModeAtomicFree(ModeReq);
} }
@ -488,8 +488,8 @@ static int old_color=-1,old_trc=-1;
void InitBo(int bpp) { void InitBo(int bpp) {
// create the GBM and EGL surface // create the GBM and EGL surface
render->bpp = bpp; render->bpp = bpp;
gbm.surface = gbm_surface_create (gbm.dev, VideoWindowWidth,VideoWindowHeight, gbm.surface = gbm_surface_create (gbm.dev, VideoWindowWidth,VideoWindowHeight,
bpp==10?GBM_FORMAT_XRGB2101010:GBM_FORMAT_ARGB8888, bpp==10?GBM_FORMAT_XRGB2101010:GBM_FORMAT_ARGB8888,
GBM_BO_USE_SCANOUT|GBM_BO_USE_RENDERING); GBM_BO_USE_SCANOUT|GBM_BO_USE_RENDERING);
assert(gbm.surface != NULL); assert(gbm.surface != NULL);
eglSurface = eglCreateWindowSurface (eglDisplay, eglConfig, gbm.surface, NULL); eglSurface = eglCreateWindowSurface (eglDisplay, eglConfig, gbm.surface, NULL);
@ -501,10 +501,10 @@ static struct gbm_bo *previous_bo = NULL;
static uint32_t previous_fb; static uint32_t previous_fb;
static void drm_swap_buffers () { static void drm_swap_buffers () {
uint32_t fb; uint32_t fb;
eglSwapBuffers (eglDisplay, eglSurface); eglSwapBuffers (eglDisplay, eglSurface);
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)
@ -517,7 +517,7 @@ static void drm_swap_buffers () {
drmModeAddFB (render->fd_drm, VideoWindowWidth,VideoWindowHeight,render->bpp==10? 30:24, 32, pitch, handle, &fb); drmModeAddFB (render->fd_drm, VideoWindowWidth,VideoWindowHeight,render->bpp==10? 30:24, 32, pitch, handle, &fb);
// drmModeSetCrtc (render->fd_drm, render->crtc_id, fb, 0, 0, &render->connector_id, 1, &render->mode); // drmModeSetCrtc (render->fd_drm, render->crtc_id, fb, 0, 0, &render->connector_id, 1, &render->mode);
if (m_need_modeset) { if (m_need_modeset) {
drmModeAtomicReqPtr ModeReq; drmModeAtomicReqPtr ModeReq;
const uint32_t flags = DRM_MODE_ATOMIC_ALLOW_MODESET; const uint32_t flags = DRM_MODE_ATOMIC_ALLOW_MODESET;
@ -531,14 +531,14 @@ static void drm_swap_buffers () {
fprintf(stderr, "cannot allocate atomic request (%d): %m\n", errno); fprintf(stderr, "cannot allocate atomic request (%d): %m\n", errno);
return; return;
} }
// Need to disable the CRTC in order to submit the HDR data.... // Need to disable the CRTC in order to submit the HDR data....
SetPropertyRequest(ModeReq, render->fd_drm, render->crtc_id, SetPropertyRequest(ModeReq, render->fd_drm, render->crtc_id,
DRM_MODE_OBJECT_CRTC, "ACTIVE", 0); DRM_MODE_OBJECT_CRTC, "ACTIVE", 0);
if (drmModeAtomicCommit(render->fd_drm, ModeReq, flags, NULL) != 0) if (drmModeAtomicCommit(render->fd_drm, ModeReq, flags, NULL) != 0)
fprintf(stderr, "cannot set atomic mode (%d): %m\n", errno); fprintf(stderr, "cannot set atomic mode (%d): %m\n", errno);
sleep(2); sleep(2);
SetPropertyRequest(ModeReq, render->fd_drm, render->connector_id, SetPropertyRequest(ModeReq, render->fd_drm, render->connector_id,
DRM_MODE_OBJECT_CONNECTOR, "Colorspace",old_color==AVCOL_PRI_BT2020?9:2 ); DRM_MODE_OBJECT_CONNECTOR, "Colorspace",old_color==AVCOL_PRI_BT2020?9:2 );
SetPropertyRequest(ModeReq, render->fd_drm, render->crtc_id, SetPropertyRequest(ModeReq, render->fd_drm, render->crtc_id,
@ -547,7 +547,7 @@ static void drm_swap_buffers () {
DRM_MODE_OBJECT_CONNECTOR, "CRTC_ID", render->crtc_id); DRM_MODE_OBJECT_CONNECTOR, "CRTC_ID", render->crtc_id);
SetPropertyRequest(ModeReq, render->fd_drm, render->crtc_id, SetPropertyRequest(ModeReq, render->fd_drm, render->crtc_id,
DRM_MODE_OBJECT_CRTC, "ACTIVE", 1); DRM_MODE_OBJECT_CRTC, "ACTIVE", 1);
if (drmModeAtomicCommit(render->fd_drm, ModeReq, flags, NULL) != 0) if (drmModeAtomicCommit(render->fd_drm, ModeReq, flags, NULL) != 0)
fprintf(stderr, "cannot set atomic mode (%d): %m\n", errno); fprintf(stderr, "cannot set atomic mode (%d): %m\n", errno);
@ -558,7 +558,7 @@ static void drm_swap_buffers () {
m_need_modeset = 0; m_need_modeset = 0;
} }
drmModeSetCrtc (render->fd_drm, render->crtc_id, fb, 0, 0, &render->connector_id, 1, &render->mode); drmModeSetCrtc (render->fd_drm, render->crtc_id, fb, 0, 0, &render->connector_id, 1, &render->mode);
if (previous_bo) { if (previous_bo) {
drmModeRmFB (render->fd_drm, previous_fb); drmModeRmFB (render->fd_drm, previous_fb);
gbm_surface_release_buffer (gbm.surface, previous_bo); gbm_surface_release_buffer (gbm.surface, previous_bo);
@ -579,15 +579,15 @@ static void drm_clean_up () {
drmModeRmFB (render->fd_drm, previous_fb); drmModeRmFB (render->fd_drm, previous_fb);
gbm_surface_release_buffer (gbm.surface, previous_bo); gbm_surface_release_buffer (gbm.surface, previous_bo);
} }
drmModeSetCrtc (render->fd_drm, render->saved_crtc->crtc_id, render->saved_crtc->buffer_id, drmModeSetCrtc (render->fd_drm, render->saved_crtc->crtc_id, render->saved_crtc->buffer_id,
render->saved_crtc->x, render->saved_crtc->y, &render->connector_id, 1, &render->saved_crtc->mode); render->saved_crtc->x, render->saved_crtc->y, &render->connector_id, 1, &render->saved_crtc->mode);
drmModeFreeCrtc (render->saved_crtc); drmModeFreeCrtc (render->saved_crtc);
if (render->hdr_blob_id) if (render->hdr_blob_id)
drmModeDestroyPropertyBlob(render->fd_drm, render->hdr_blob_id); drmModeDestroyPropertyBlob(render->fd_drm, render->hdr_blob_id);
render->hdr_blob_id = 0; render->hdr_blob_id = 0;
eglDestroySurface (eglDisplay, eglSurface); eglDestroySurface (eglDisplay, eglSurface);
EglCheck(); EglCheck();
gbm_surface_destroy (gbm.surface); gbm_surface_destroy (gbm.surface);
@ -597,9 +597,9 @@ static void drm_clean_up () {
EglCheck(); EglCheck();
eglSharedContext = NULL; eglSharedContext = NULL;
eglTerminate (eglDisplay); eglTerminate (eglDisplay);
EglCheck(); EglCheck();
gbm_device_destroy (gbm.dev); gbm_device_destroy (gbm.dev);
drmDropMaster(render->fd_drm); drmDropMaster(render->fd_drm);
close (render->fd_drm); close (render->fd_drm);

View File

@ -1,4 +1,3 @@
/* /*
* Copyright 1993-2013 NVIDIA Corporation. All rights reserved. * Copyright 1993-2013 NVIDIA Corporation. All rights reserved.
* *

41
hdr.c
View File

@ -334,11 +334,11 @@ static void set_hdr_metadata(int color,int trc, AVFrameSideData *sd1, AVFrameSid
int max_lum=4000,min_lum=0050; int max_lum=4000,min_lum=0050;
struct AVMasteringDisplayMetadata *md = NULL; struct AVMasteringDisplayMetadata *md = NULL;
struct AVContentLightMetadata *ld = NULL; struct AVContentLightMetadata *ld = NULL;
if (render->hdr_metadata == -1) { // Metadata not supported if (render->hdr_metadata == -1) { // Metadata not supported
return; return;
} }
// clean up FFMEPG stuff // clean up FFMEPG stuff
if (trc == AVCOL_TRC_BT2020_10) if (trc == AVCOL_TRC_BT2020_10)
trc = AVCOL_TRC_ARIB_STD_B67; trc = AVCOL_TRC_ARIB_STD_B67;
@ -346,16 +346,16 @@ static void set_hdr_metadata(int color,int trc, AVFrameSideData *sd1, AVFrameSid
trc = AVCOL_TRC_BT709; trc = AVCOL_TRC_BT709;
if (color == AVCOL_PRI_UNSPECIFIED) if (color == AVCOL_PRI_UNSPECIFIED)
color = AVCOL_PRI_BT709; color = AVCOL_PRI_BT709;
if ((old_color == color && old_trc == trc && !sd1 && !sd2) || !render->hdr_metadata) if ((old_color == color && old_trc == trc && !sd1 && !sd2) || !render->hdr_metadata)
return; // nothing to do return; // nothing to do
if (sd1) if (sd1)
md = sd1->data; md = sd1->data;
if (sd2) if (sd2)
ld = sd2->data; ld = sd2->data;
if (md && !memcmp(md,&md_save,sizeof(md_save))) if (md && !memcmp(md,&md_save,sizeof(md_save)))
if (ld && !memcmp(ld,&ld_save,sizeof(ld_save))) { if (ld && !memcmp(ld,&ld_save,sizeof(ld_save))) {
return; return;
@ -363,23 +363,23 @@ static void set_hdr_metadata(int color,int trc, AVFrameSideData *sd1, AVFrameSid
else if (ld && !memcmp(ld,&ld_save,sizeof(ld_save))) { else if (ld && !memcmp(ld,&ld_save,sizeof(ld_save))) {
return; return;
} }
if (ld) if (ld)
memcpy(&ld_save,ld,sizeof(ld_save)); memcpy(&ld_save,ld,sizeof(ld_save));
if (md) if (md)
memcpy(&md_save,md,sizeof(md_save)); memcpy(&md_save,md,sizeof(md_save));
Debug(3,"Update HDR to TRC %d color %d\n",trc,color); Debug(3,"Update HDR to TRC %d color %d\n",trc,color);
if (trc == AVCOL_TRC_BT2020_10) if (trc == AVCOL_TRC_BT2020_10)
trc = AVCOL_TRC_ARIB_STD_B67; trc = AVCOL_TRC_ARIB_STD_B67;
old_color = color; old_color = color;
old_trc = trc; old_trc = trc;
if (render->hdr_blob_id) if (render->hdr_blob_id)
drmModeDestroyPropertyBlob(render->fd_drm, render->hdr_blob_id); drmModeDestroyPropertyBlob(render->fd_drm, render->hdr_blob_id);
switch(trc) { switch(trc) {
case AVCOL_TRC_BT709: // 1 case AVCOL_TRC_BT709: // 1
case AVCOL_TRC_UNSPECIFIED: // 2 case AVCOL_TRC_UNSPECIFIED: // 2
@ -387,7 +387,7 @@ static void set_hdr_metadata(int color,int trc, AVFrameSideData *sd1, AVFrameSid
break; break;
case AVCOL_TRC_BT2020_10: // 14 case AVCOL_TRC_BT2020_10: // 14
case AVCOL_TRC_BT2020_12: case AVCOL_TRC_BT2020_12:
case AVCOL_TRC_ARIB_STD_B67: // 18 HLG case AVCOL_TRC_ARIB_STD_B67: // 18 HLG
eotf = EOTF_HLG; eotf = EOTF_HLG;
break; break;
case AVCOL_TRC_SMPTE2084: // 16 case AVCOL_TRC_SMPTE2084: // 16
@ -397,7 +397,7 @@ static void set_hdr_metadata(int color,int trc, AVFrameSideData *sd1, AVFrameSid
eotf = EOTF_TRADITIONAL_GAMMA_SDR; eotf = EOTF_TRADITIONAL_GAMMA_SDR;
break; break;
} }
switch (color) { switch (color) {
case AVCOL_PRI_BT709: // 1 case AVCOL_PRI_BT709: // 1
case AVCOL_PRI_UNSPECIFIED: // 2 case AVCOL_PRI_UNSPECIFIED: // 2
@ -413,7 +413,7 @@ static void set_hdr_metadata(int color,int trc, AVFrameSideData *sd1, AVFrameSid
cs = weston_colorspace_lookup("BT.709"); cs = weston_colorspace_lookup("BT.709");
break; break;
} }
if (md) { // we got Metadata if (md) { // we got Metadata
if (md->has_primaries) { if (md->has_primaries) {
Debug(3,"Mastering Display Metadata,\n has_primaries:%d has_luminance:%d \n" Debug(3,"Mastering Display Metadata,\n has_primaries:%d has_luminance:%d \n"
@ -465,9 +465,9 @@ static void set_hdr_metadata(int color,int trc, AVFrameSideData *sd1, AVFrameSid
MaxCLL, // Maximum Content Light Level (MaxCLL) MaxCLL, // Maximum Content Light Level (MaxCLL)
MaxFALL, // Maximum Frame-Average Light Level (MaxFALL) MaxFALL, // Maximum Frame-Average Light Level (MaxFALL)
eotf); eotf);
ret = drmModeCreatePropertyBlob(render->fd_drm, &data, sizeof(data), &render->hdr_blob_id); ret = drmModeCreatePropertyBlob(render->fd_drm, &data, sizeof(data), &render->hdr_blob_id);
if (ret) { if (ret) {
printf("DRM: HDR metadata: failed blob create \n"); printf("DRM: HDR metadata: failed blob create \n");
@ -479,15 +479,14 @@ static void set_hdr_metadata(int color,int trc, AVFrameSideData *sd1, AVFrameSid
render->hdr_metadata, render->hdr_blob_id); render->hdr_metadata, render->hdr_blob_id);
if (ret) { if (ret) {
printf("DRM: HDR metadata: failed property set %d\n",ret); printf("DRM: HDR metadata: failed property set %d\n",ret);
if (render->hdr_blob_id) if (render->hdr_blob_id)
drmModeDestroyPropertyBlob(render->fd_drm, render->hdr_blob_id); drmModeDestroyPropertyBlob(render->fd_drm, render->hdr_blob_id);
render->hdr_blob_id = 0; render->hdr_blob_id = 0;
return; return;
} }
m_need_modeset = 1; m_need_modeset = 1;
Debug(3,"DRM: HDR metadata: prop set\n");
}
Debug(3,"DRM: HDR metadata: prop set\n");
}

File diff suppressed because it is too large Load Diff

315
shaders.h
View File

@ -11,7 +11,6 @@ const char *gl_version = "#version 300 es ";
#endif #endif
#endif #endif
/* Color conversion matrix: RGB = m * YUV + c /* Color conversion matrix: RGB = m * YUV + c
* m is in row-major matrix, with m[row][col], e.g.: * m is in row-major matrix, with m[row][col], e.g.:
* [ a11 a12 a13 ] float m[3][3] = { { a11, a12, a13 }, * [ a11 a12 a13 ] float m[3][3] = { { a11, a12, a13 },
@ -71,16 +70,11 @@ float cms_matrix[3][3] = { {1.660497, -0.124547, -0.018154},
}; };
// Common constants for SMPTE ST.2084 (PQ) // Common constants for SMPTE ST.2084 (PQ)
static const float PQ_M1 = 2610./4096 * 1./4, static const float PQ_M1 = 2610. / 4096 * 1. / 4, PQ_M2 = 2523. / 4096 * 128, PQ_C1 = 3424. / 4096, PQ_C2 =
PQ_M2 = 2523./4096 * 128, 2413. / 4096 * 32, PQ_C3 = 2392. / 4096 * 32;
PQ_C1 = 3424./4096,
PQ_C2 = 2413./4096 * 32,
PQ_C3 = 2392./4096 * 32;
// Common constants for ARIB STD-B67 (HLG) // Common constants for ARIB STD-B67 (HLG)
static const float HLG_A = 0.17883277, static const float HLG_A = 0.17883277, HLG_B = 0.28466892, HLG_C = 0.55991073;
HLG_B = 0.28466892,
HLG_C = 0.55991073;
struct gl_vao_entry struct gl_vao_entry
{ {
@ -124,48 +118,55 @@ static const struct gl_vao_entry vertex_vao[] = {
char sh[SHADER_LENGTH]; char sh[SHADER_LENGTH];
char shv[SHADER_LENGTH]; char shv[SHADER_LENGTH];
GL_init() { GL_init()
sh[0] = 0; {
sh[0] = 0;
} }
GLV_init() {
shv[0] = 0; GLV_init()
{
shv[0] = 0;
} }
pl_shader_append(const char *fmt, ...) {
char temp[1000]; pl_shader_append(const char *fmt, ...)
va_list ap; {
char temp[1000];
va_list ap;
va_start(ap, fmt); va_start(ap, fmt);
vsprintf(temp,fmt,ap); vsprintf(temp, fmt, ap);
va_end(ap); va_end(ap);
if (strlen(sh) + strlen(temp) > SHADER_LENGTH) if (strlen(sh) + strlen(temp) > SHADER_LENGTH)
Fatal(_("Shaderlenght fault\n")); Fatal(_("Shaderlenght fault\n"));
strcat(sh,temp); strcat(sh, temp);
} }
pl_shader_append_v(const char *fmt, ...) { pl_shader_append_v(const char *fmt, ...)
char temp[1000]; {
va_list ap; char temp[1000];
va_list ap;
va_start(ap, fmt); va_start(ap, fmt);
vsprintf(temp,fmt,ap); vsprintf(temp, fmt, ap);
va_end(ap); va_end(ap);
if (strlen(shv) + strlen(temp) > SHADER_LENGTH) if (strlen(shv) + strlen(temp) > SHADER_LENGTH)
Fatal(_("Shaderlenght fault\n")); Fatal(_("Shaderlenght fault\n"));
strcat(shv,temp); strcat(shv, temp);
} }
static void compile_attach_shader(GLuint program, GLenum type, const char *source) static void compile_attach_shader(GLuint program, GLenum type, const char *source)
{ {
GLuint shader; GLuint shader;
GLint status=1234, log_length; GLint status = 1234, log_length;
char log[4000]; char log[4000];
GLsizei len; GLsizei len;
shader = glCreateShader(type); shader = glCreateShader(type);
glShaderSource(shader, 1, (const GLchar **)&source, NULL); // &buffer, NULL); glShaderSource(shader, 1, (const GLchar **)&source, NULL); // &buffer, NULL);
glCompileShader(shader); glCompileShader(shader);
status = 0; status = 0;
glGetShaderiv(shader, GL_COMPILE_STATUS, &status); glGetShaderiv(shader, GL_COMPILE_STATUS, &status);
@ -198,42 +199,42 @@ static GLuint sc_generate_osd(GLuint gl_prog)
Debug(3, "vor create osd\n"); Debug(3, "vor create osd\n");
gl_prog = glCreateProgram(); gl_prog = glCreateProgram();
GL_init(); GL_init();
GLSL("%s\n",gl_version); GLSL("%s\n", gl_version);
GLSL("in vec2 vertex_position;\n"); GLSL("in vec2 vertex_position;\n");
GLSL("in vec2 vertex_texcoord0;\n"); GLSL("in vec2 vertex_texcoord0;\n");
GLSL("out vec2 texcoord0;\n"); GLSL("out vec2 texcoord0;\n");
GLSL("void main() {\n"); GLSL("void main() {\n");
GLSL("gl_Position = vec4(vertex_position, 1.0, 1.0);\n"); GLSL("gl_Position = vec4(vertex_position, 1.0, 1.0);\n");
GLSL("texcoord0 = vertex_texcoord0;\n"); GLSL("texcoord0 = vertex_texcoord0;\n");
GLSL("}\n"); GLSL("}\n");
Debug(3, "vor compile vertex osd\n"); Debug(3, "vor compile vertex osd\n");
compile_attach_shader(gl_prog, GL_VERTEX_SHADER, sh); // vertex_osd); compile_attach_shader(gl_prog, GL_VERTEX_SHADER, sh); // vertex_osd);
GL_init(); GL_init();
GLSL("%s\n",gl_version); GLSL("%s\n", gl_version);
GLSL("#define texture1D texture\n"); GLSL("#define texture1D texture\n");
GLSL("precision mediump float; \n"); GLSL("precision mediump float; \n");
GLSL("layout(location = 0) out vec4 out_color;\n"); GLSL("layout(location = 0) out vec4 out_color;\n");
GLSL("in vec2 texcoord0;\n"); GLSL("in vec2 texcoord0;\n");
GLSL("uniform sampler2D texture0;\n"); GLSL("uniform sampler2D texture0;\n");
GLSL("void main() {\n"); GLSL("void main() {\n");
GLSL("vec4 color; \n"); GLSL("vec4 color; \n");
GLSL("color = vec4(texture(texture0, texcoord0));\n"); GLSL("color = vec4(texture(texture0, texcoord0));\n");
#ifdef GAMMA #ifdef GAMMA
GLSL("// delinearize gamma \n"); GLSL("// delinearize gamma \n");
GLSL("color.rgb = clamp(color.rgb, 0.0, 1.0); \n"); // delinearize gamma GLSL("color.rgb = clamp(color.rgb, 0.0, 1.0); \n"); // delinearize gamma
GLSL("color.rgb = pow(color.rgb, vec3(2.4)); \n"); GLSL("color.rgb = pow(color.rgb, vec3(2.4)); \n");
#endif #endif
GLSL("out_color = color;\n"); GLSL("out_color = color;\n");
GLSL("}\n"); GLSL("}\n");
Debug(3, "vor compile fragment osd \n"); Debug(3, "vor compile fragment osd \n");
compile_attach_shader(gl_prog, GL_FRAGMENT_SHADER, sh); //fragment_osd); compile_attach_shader(gl_prog, GL_FRAGMENT_SHADER, sh); //fragment_osd);
glBindAttribLocation(gl_prog, 0, "vertex_position"); glBindAttribLocation(gl_prog, 0, "vertex_position");
glBindAttribLocation(gl_prog, 1, "vertex_texcoord0"); glBindAttribLocation(gl_prog, 1, "vertex_texcoord0");
link_shader(gl_prog); link_shader(gl_prog);
return gl_prog; return gl_prog;
} }
@ -245,34 +246,33 @@ static GLuint sc_generate(GLuint gl_prog, enum AVColorSpace colorspace)
GLint cmsLoc; GLint cmsLoc;
float *m, *c, *cms; float *m, *c, *cms;
char *frag; char *frag;
GL_init(); GL_init();
GLSL("%s\n",gl_version); GLSL("%s\n", gl_version);
GLSL("in vec2 vertex_position; \n"); GLSL("in vec2 vertex_position; \n");
GLSL("in vec2 vertex_texcoord0; \n"); GLSL("in vec2 vertex_texcoord0; \n");
GLSL("out vec2 texcoord0; \n"); GLSL("out vec2 texcoord0; \n");
GLSL("in vec2 vertex_texcoord1; \n"); GLSL("in vec2 vertex_texcoord1; \n");
GLSL("out vec2 texcoord1; \n"); GLSL("out vec2 texcoord1; \n");
if (Planes == 3) { if (Planes == 3) {
GLSL("in vec2 vertex_texcoord2; \n"); GLSL("in vec2 vertex_texcoord2; \n");
GLSL("out vec2 texcoord2; \n"); GLSL("out vec2 texcoord2; \n");
} }
GLSL("void main() { \n"); GLSL("void main() { \n");
GLSL("gl_Position = vec4(vertex_position, 1.0, 1.0);\n"); GLSL("gl_Position = vec4(vertex_position, 1.0, 1.0);\n");
GLSL("texcoord0 = vertex_texcoord0; \n"); GLSL("texcoord0 = vertex_texcoord0; \n");
GLSL("texcoord1 = vertex_texcoord1; \n"); GLSL("texcoord1 = vertex_texcoord1; \n");
if (Planes == 3) { if (Planes == 3) {
GLSL("texcoord2 = vertex_texcoord1; \n"); // texcoord1 ist hier richtig GLSL("texcoord2 = vertex_texcoord1; \n"); // texcoord1 ist hier richtig
} }
GLSL("} \n"); GLSL("} \n");
Debug(3, "vor create\n"); Debug(3, "vor create\n");
gl_prog = glCreateProgram(); gl_prog = glCreateProgram();
Debug(3, "vor compile vertex\n"); Debug(3, "vor compile vertex\n");
// printf("%s",sh); // printf("%s",sh);
compile_attach_shader(gl_prog, GL_VERTEX_SHADER, sh ); compile_attach_shader(gl_prog, GL_VERTEX_SHADER, sh);
switch (colorspace) { switch (colorspace) {
case AVCOL_SPC_RGB: case AVCOL_SPC_RGB:
m = &yuv_bt601.m[0][0]; m = &yuv_bt601.m[0][0];
@ -297,86 +297,85 @@ static GLuint sc_generate(GLuint gl_prog, enum AVColorSpace colorspace)
Debug(3, "default BT709 Colorspace used %d\n", colorspace); Debug(3, "default BT709 Colorspace used %d\n", colorspace);
break; break;
} }
GL_init();
GLSL("%s\n",gl_version);
GLSL("precision mediump float; \n");
GLSL("layout(location = 0) out vec4 out_color;\n");
GLSL("in vec2 texcoord0; \n");
GLSL("in vec2 texcoord1; \n");
if (Planes == 3)
GLSL("in vec2 texcoord2; \n");
GLSL("uniform mat3 colormatrix; \n");
GLSL("uniform vec3 colormatrix_c; \n");
if (colorspace == AVCOL_SPC_BT2020_NCL)
GLSL("uniform mat3 cms_matrix;\n");
GLSL("uniform sampler2D texture0; \n");
GLSL("uniform sampler2D texture1; \n");
if (Planes == 3)
GLSL("uniform sampler2D texture2; \n");
GLSL("void main() { \n");
GLSL("vec4 color; \n");
if (colorspace == AVCOL_SPC_BT2020_NCL) {
GLSL("color.r = 1.003906 * vec4(texture(texture0, texcoord0)).r; \n");
if (Planes == 3) {
GLSL("color.g = 1.003906 * vec4(texture(texture1, texcoord1)).r; \n");
GLSL("color.b = 1.003906 * vec4(texture(texture2, texcoord2)).r; \n");
} else {
GLSL("color.gb = 1.003906 * vec4(texture(texture1, texcoord1)).rg;\n");
}
GLSL("// color conversion\n");
GLSL("color.rgb = mat3(colormatrix) * color.rgb + colormatrix_c; \n");
GLSL("color.a = 1.0; \n");
GLSL("// pl_shader_linearize \n"); GL_init();
GLSL("%s\n", gl_version);
GLSL("precision mediump float; \n");
GLSL("layout(location = 0) out vec4 out_color;\n");
GLSL("in vec2 texcoord0; \n");
GLSL("in vec2 texcoord1; \n");
if (Planes == 3)
GLSL("in vec2 texcoord2; \n");
GLSL("uniform mat3 colormatrix; \n");
GLSL("uniform vec3 colormatrix_c; \n");
if (colorspace == AVCOL_SPC_BT2020_NCL)
GLSL("uniform mat3 cms_matrix;\n");
GLSL("uniform sampler2D texture0; \n");
GLSL("uniform sampler2D texture1; \n");
if (Planes == 3)
GLSL("uniform sampler2D texture2; \n");
GLSL("void main() { \n");
GLSL("vec4 color; \n");
if (colorspace == AVCOL_SPC_BT2020_NCL) {
GLSL("color.r = 1.003906 * vec4(texture(texture0, texcoord0)).r; \n");
if (Planes == 3) {
GLSL("color.g = 1.003906 * vec4(texture(texture1, texcoord1)).r; \n");
GLSL("color.b = 1.003906 * vec4(texture(texture2, texcoord2)).r; \n");
} else {
GLSL("color.gb = 1.003906 * vec4(texture(texture1, texcoord1)).rg;\n");
}
GLSL("// color conversion\n");
GLSL("color.rgb = mat3(colormatrix) * color.rgb + colormatrix_c; \n");
GLSL("color.a = 1.0; \n");
GLSL("// pl_shader_linearize \n");
GLSL("color.rgb = max(color.rgb, 0.0); \n"); GLSL("color.rgb = max(color.rgb, 0.0); \n");
// GLSL("color.rgb = clamp(color.rgb, 0.0, 1.0); \n"); // GLSL("color.rgb = clamp(color.rgb, 0.0, 1.0); \n");
// GLSL("color.rgb = pow(color.rgb, vec3(2.4)); \n"); // GLSL("color.rgb = pow(color.rgb, vec3(2.4)); \n");
// GLSL("color.rgb = mix(vec3(4.0) * color.rgb * color.rgb,exp((color.rgb - vec3(%f)) * vec3(1.0/%f)) + vec3(%f),bvec3(lessThan(vec3(0.5), color.rgb)));\n",HLG_C, HLG_A, HLG_B); // GLSL("color.rgb = mix(vec3(4.0) * color.rgb * color.rgb,exp((color.rgb - vec3(%f)) * vec3(1.0/%f)) + vec3(%f),bvec3(lessThan(vec3(0.5), color.rgb)));\n",HLG_C, HLG_A, HLG_B);
GLSL("color.rgb = mix(vec3(4.0) * color.rgb * color.rgb,exp((color.rgb - vec3(0.55991073)) * vec3(1.0/0.17883277)) + vec3(0.28466892), bvec3(lessThan(vec3(0.5), color.rgb)));\n"); GLSL("color.rgb = mix(vec3(4.0) * color.rgb * color.rgb,exp((color.rgb - vec3(0.55991073)) * vec3(1.0/0.17883277)) + vec3(0.28466892), bvec3(lessThan(vec3(0.5), color.rgb)));\n");
GLSL("// color mapping \n"); GLSL("// color mapping \n");
GLSL("color.rgb = cms_matrix * color.rgb; \n"); GLSL("color.rgb = cms_matrix * color.rgb; \n");
#ifndef GAMMA #ifndef GAMMA
GLSL("// pl_shader_delinearize \n"); GLSL("// pl_shader_delinearize \n");
GLSL("color.rgb = max(color.rgb, 0.0); \n"); GLSL("color.rgb = max(color.rgb, 0.0); \n");
// GLSL("color.rgb = clamp(color.rgb, 0.0, 1.0); \n"); // GLSL("color.rgb = clamp(color.rgb, 0.0, 1.0); \n");
// GLSL("color.rgb = pow(color.rgb, vec3(1.0/2.4)); \n"); // GLSL("color.rgb = pow(color.rgb, vec3(1.0/2.4)); \n");
GLSL("color.rgb = mix(vec3(0.5) * sqrt(color.rgb), vec3(0.17883277) * log(color.rgb - vec3(0.28466892)) + vec3(0.55991073), bvec3(lessThan(vec3(1.0), color.rgb))); \n"); GLSL("color.rgb = mix(vec3(0.5) * sqrt(color.rgb), vec3(0.17883277) * log(color.rgb - vec3(0.28466892)) + vec3(0.55991073), bvec3(lessThan(vec3(1.0), color.rgb))); \n");
#endif #endif
GLSL("out_color = color; \n"); GLSL("out_color = color; \n");
GLSL("} \n"); GLSL("} \n");
} } else {
else {
GLSL("color.r = 1.000000 * vec4(texture(texture0, texcoord0)).r; \n"); GLSL("color.r = 1.000000 * vec4(texture(texture0, texcoord0)).r; \n");
if (Planes == 3) { if (Planes == 3) {
GLSL("color.g = 1.000000 * vec4(texture(texture1, texcoord1)).r;\n"); GLSL("color.g = 1.000000 * vec4(texture(texture1, texcoord1)).r;\n");
GLSL("color.b = 1.000000 * vec4(texture(texture2, texcoord2)).r;\n"); GLSL("color.b = 1.000000 * vec4(texture(texture2, texcoord2)).r;\n");
} else { } else {
GLSL("color.gb = 1.000000 * vec4(texture(texture1, texcoord1)).rg; \n"); GLSL("color.gb = 1.000000 * vec4(texture(texture1, texcoord1)).rg; \n");
} }
GLSL("// color conversion \n"); GLSL("// color conversion \n");
GLSL("color.rgb = mat3(colormatrix) * color.rgb + colormatrix_c; \n"); GLSL("color.rgb = mat3(colormatrix) * color.rgb + colormatrix_c; \n");
GLSL("color.a = 1.0; \n"); GLSL("color.a = 1.0; \n");
GLSL("// linearize gamma \n"); GLSL("// linearize gamma \n");
GLSL("color.rgb = clamp(color.rgb, 0.0, 1.0); \n"); // linearize gamma GLSL("color.rgb = clamp(color.rgb, 0.0, 1.0); \n"); // linearize gamma
GLSL("color.rgb = pow(color.rgb, vec3(2.4)); \n"); GLSL("color.rgb = pow(color.rgb, vec3(2.4)); \n");
#ifndef GAMMA #ifndef GAMMA
GLSL("// delinearize gamma to sRGB \n"); GLSL("// delinearize gamma to sRGB \n");
GLSL("color.rgb = max(color.rgb, 0.0); \n"); GLSL("color.rgb = max(color.rgb, 0.0); \n");
GLSL("color.rgb = mix(color.rgb * vec3(12.92), vec3(1.055) * pow(color.rgb, vec3(1.0/2.4)) - vec3(0.055), bvec3(lessThanEqual(vec3(0.0031308), color.rgb))); \n"); GLSL("color.rgb = mix(color.rgb * vec3(12.92), vec3(1.055) * pow(color.rgb, vec3(1.0/2.4)) - vec3(0.055), bvec3(lessThanEqual(vec3(0.0031308), color.rgb))); \n");
#endif #endif
GLSL("// color mapping \n"); GLSL("// color mapping \n");
GLSL("out_color = color; \n"); GLSL("out_color = color; \n");
GLSL("} \n"); GLSL("} \n");
} }
//printf(">%s<",sh); //printf(">%s<",sh);
Debug(3, "vor compile fragment\n"); Debug(3, "vor compile fragment\n");
compile_attach_shader(gl_prog, GL_FRAGMENT_SHADER, sh); compile_attach_shader(gl_prog, GL_FRAGMENT_SHADER, sh);
glBindAttribLocation(gl_prog, 0, "vertex_position"); glBindAttribLocation(gl_prog, 0, "vertex_position");
for (n = 0; n < 6; n++) { for (n = 0; n < 6; n++) {

View File

@ -1133,7 +1133,7 @@ void cMenuSetupSoft::Create(void)
static char *scalingtest[100]; static char *scalingtest[100];
if (scalers == 0) { if (scalers == 0) {
scalingtest[0] = (char *) "Off"; scalingtest[0] = (char *)"Off";
for (scalers = 0; pl_named_filters[scalers].filter != NULL; scalers++) { for (scalers = 0; pl_named_filters[scalers].filter != NULL; scalers++) {
scaling[scalers] = (char *)pl_named_filters[scalers].name; scaling[scalers] = (char *)pl_named_filters[scalers].name;
scalingtest[scalers + 1] = (char *)pl_named_filters[scalers].name; scalingtest[scalers + 1] = (char *)pl_named_filters[scalers].name;
@ -2153,10 +2153,10 @@ void cSoftHdMenu::Create(void)
int dropped; int dropped;
int counter; int counter;
float frametime; float frametime;
int width,height; int width, height;
int color; int color;
int eotf; int eotf;
char *colorstr, *eotfstr; char *colorstr, *eotfstr;
current = Current(); // get current menu item index current = Current(); // get current menu item index
Clear(); // clear the menu Clear(); // clear the menu
@ -2191,8 +2191,8 @@ void cSoftHdMenu::Create(void)
#endif #endif
Add(new cOsdItem(NULL, osUnknown, false)); Add(new cOsdItem(NULL, osUnknown, false));
Add(new cOsdItem(NULL, osUnknown, false)); Add(new cOsdItem(NULL, osUnknown, false));
GetStats(&missed, &duped, &dropped, &counter, &frametime, &width, &height, &color,&eotf); GetStats(&missed, &duped, &dropped, &counter, &frametime, &width, &height, &color, &eotf);
switch (color) { switch (color) {
case AVCOL_SPC_RGB: case AVCOL_SPC_RGB:
colorstr = strdup("BT 601"); colorstr = strdup("BT 601");
eotfstr = strdup("BT 1886"); eotfstr = strdup("BT 1886");
@ -2213,8 +2213,9 @@ void cSoftHdMenu::Create(void)
} }
Add(new cOsdItem(cString::sprintf(tr(" Frames missed(%d) duped(%d) dropped(%d) total(%d)"), missed, duped, dropped, Add(new cOsdItem(cString::sprintf(tr(" Frames missed(%d) duped(%d) dropped(%d) total(%d)"), missed, duped, dropped,
counter), osUnknown, false)); counter), osUnknown, false));
Add(new cOsdItem(cString::sprintf(tr(" Video %dx%d Color: %s Gamma: %s"), width, height, colorstr, eotfstr), osUnknown, false)); Add(new cOsdItem(cString::sprintf(tr(" Video %dx%d Color: %s Gamma: %s"), width, height, colorstr, eotfstr),
// Add(new cOsdItem(cString::sprintf(tr(" Frame Process time %2.2fms"), frametime), osUnknown, false)); osUnknown, false));
// Add(new cOsdItem(cString::sprintf(tr(" Frame Process time %2.2fms"), frametime), osUnknown, false));
SetCurrent(Get(current)); // restore selected menu entry SetCurrent(Get(current)); // restore selected menu entry
Display(); // display build menu Display(); // display build menu
} }

View File

@ -645,7 +645,7 @@ static void PesParse(PesDemux * pesdx, const uint8_t * data, int size, int is_st
q = pesdx->Buffer + pesdx->Skip; q = pesdx->Buffer + pesdx->Skip;
n = pesdx->Index - pesdx->Skip; n = pesdx->Index - pesdx->Skip;
while (n >= 5) { while (n >= 5) {
int r=0; int r = 0;
unsigned codec_id = AV_CODEC_ID_NONE; unsigned codec_id = AV_CODEC_ID_NONE;
// 4 bytes 0xFFExxxxx Mpeg audio // 4 bytes 0xFFExxxxx Mpeg audio
@ -2871,11 +2871,10 @@ const char *CommandLineHelp(void)
" -p device\taudio device for pass-through (hw:0,1 or /dev/dsp1)\n" " -p device\taudio device for pass-through (hw:0,1 or /dev/dsp1)\n"
" -c channel\taudio mixer channel name (fe. PCM)\n" " -d display\tdisplay of x11 server (fe. :0.0)\n" " -c channel\taudio mixer channel name (fe. PCM)\n" " -d display\tdisplay of x11 server (fe. :0.0)\n"
" -f\t\tstart with fullscreen window (only with window manager)\n" " -f\t\tstart with fullscreen window (only with window manager)\n"
" -g geometry\tx11 window geometry wxh+x+y\n" " -g geometry\tx11 window geometry wxh+x+y\n" " -r Refresh\tRefreshrate for DRM (default is 50 Hz)\n"
" -r Refresh\tRefreshrate for DRM (default is 50 Hz)\n" " -C Connector\tConnector for DRM (default is current Connector)\n"
" -C Connector\tConnector for DRM (default is current Connector)\n" " -v device\tvideo driver device (cuvid)\n" " -s\t\tstart in suspended mode\n"
" -v device\tvideo driver device (cuvid)\n" " -x\t\tstart x11 server, with -xx try to connect, if this fails\n"
" -s\t\tstart in suspended mode\n" " -x\t\tstart x11 server, with -xx try to connect, if this fails\n"
" -X args\tX11 server arguments (f.e. -nocursor)\n" " -w workaround\tenable/disable workarounds\n" " -X args\tX11 server arguments (f.e. -nocursor)\n" " -w workaround\tenable/disable workarounds\n"
"\tno-hw-decoder\t\tdisable hw decoder, use software decoder only\n" "\tno-hw-decoder\t\tdisable hw decoder, use software decoder only\n"
"\tno-mpeg-hw-decoder\tdisable hw decoder for mpeg only\n" "\tno-mpeg-hw-decoder\tdisable hw decoder for mpeg only\n"
@ -2916,10 +2915,10 @@ int ProcessArgs(int argc, char *const argv[])
continue; continue;
case 'C': // Connector for DRM case 'C': // Connector for DRM
VideoSetConnector(optarg); VideoSetConnector(optarg);
continue; continue;
case 'r': // Connector for DRM case 'r': // Connector for DRM
VideoSetRefresh(optarg); VideoSetRefresh(optarg);
continue; continue;
case 'p': // pass-through audio device case 'p': // pass-through audio device
AudioSetPassthroughDevice(optarg); AudioSetPassthroughDevice(optarg);
continue; continue;
@ -3369,19 +3368,21 @@ void Resume(void)
** @param[out] dropped dropped frames ** @param[out] dropped dropped frames
** @param[out] count number of decoded frames ** @param[out] count number of decoded frames
*/ */
void GetStats(int *missed, int *duped, int *dropped, int *counter, float *frametime, int *width, int *height, int *color, int *eotf) void GetStats(int *missed, int *duped, int *dropped, int *counter, float *frametime, int *width, int *height,
int *color, int *eotf)
{ {
*missed = 0; *missed = 0;
*duped = 0; *duped = 0;
*dropped = 0; *dropped = 0;
*counter = 0; *counter = 0;
*frametime = 0.0f; *frametime = 0.0f;
*width = 0; *width = 0;
*height = 0; *height = 0;
*color = NULL; *color = NULL;
*eotf = NULL; *eotf = NULL;
if (MyVideoStream->HwDecoder) { if (MyVideoStream->HwDecoder) {
VideoGetStats(MyVideoStream->HwDecoder, missed, duped, dropped, counter, frametime, width, height, color, eotf); VideoGetStats(MyVideoStream->HwDecoder, missed, duped, dropped, counter, frametime, width, height, color,
eotf);
} }
} }

675
video.c

File diff suppressed because it is too large Load Diff