8 Commits
V3.19 ... V3.23

Author SHA1 Message Date
jojo61
9dd936df86 Support for ffmpeg 7.0.x 2024-08-05 17:00:56 +02:00
jojo61
4e5529efcf Make compiler happy 2024-06-04 06:32:44 +02:00
jojo61
20f1bd45e6 Update Version 2024-03-12 09:11:40 +01:00
jojo61
7a7e09ff7a For drm try card1 if card0 fails. 2024-03-12 09:09:51 +01:00
jojo61
c4a660ede2 Update Version 2024-02-15 09:24:30 +01:00
jojo61
8e495266e2 Changes for egl exit 2024-02-15 09:23:09 +01:00
jojo61
f27e4fb35f Set Deinterlace Table for vaapi
Clean up exit on softhddrm
2024-02-05 10:50:19 +01:00
jojo61
e14ea73a00 Fix typo 2024-02-04 17:45:54 +01:00
5 changed files with 121 additions and 56 deletions

86
codec.c
View File

@@ -868,19 +868,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 = CodecDownmix ? 2 : audio_ctx->channels;
audio_decoder->Passthrough = CodecPassthrough;
audio_decoder->HwChannels = audio_ctx->channels;
#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)) {
@@ -909,9 +925,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;
}
@@ -1140,6 +1162,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;
@@ -1150,6 +1178,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) {
@@ -1157,27 +1191,23 @@ static void CodecAudioUpdateFormat(AudioDecoder *audio_decoder) {
fprintf(stderr, "no resample needed\n");
}
#endif
#if LIBSWRESAMPLE_VERSION_INT < AV_VERSION_INT(4,5,100)
audio_decoder->Resample = swr_alloc_set_opts(audio_decoder->Resample,
CodecDownMix ? AV_CH_LAYOUT_STEREO : 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);
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
//printf("last ressort downmix Layout in %lx Lyout out: %llx \n",audio_ctx->channel_layout,AV_CH_LAYOUT_STEREO);
audio_decoder->Resample = swr_alloc();
av_opt_set_channel_layout(audio_decoder->Resample, "in_channel_layout",audio_ctx->channel_layout, 0);
av_opt_set_channel_layout(audio_decoder->Resample, "out_channel_layout", CodecDownmix ? AV_CH_LAYOUT_STEREO : audio_ctx->channel_layout , 0);
av_opt_set_int(audio_decoder->Resample, "in_sample_rate", audio_ctx->sample_rate, 0);
av_opt_set_int(audio_decoder->Resample, "out_sample_rate", audio_ctx->sample_rate, 0);
av_opt_set_sample_fmt(audio_decoder->Resample, "in_sample_fmt", audio_ctx->sample_fmt, 0);
av_opt_set_sample_fmt(audio_decoder->Resample, "out_sample_fmt", AV_SAMPLE_FMT_S16, 0);
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"));
}
@@ -1223,7 +1253,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) {

38
drm.c
View File

@@ -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");
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);
}
drmModeSetCrtc(render->fd_drm, render->saved_crtc->crtc_id, render->saved_crtc->buffer_id, render->saved_crtc->x,
render->saved_crtc->y, &render->connector_id, 1, &render->saved_crtc->mode);
drmModeFreeCrtc(render->saved_crtc);
if (has_modeset) {
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");
}

View File

@@ -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.19"
static const char *const VERSION = "3.23"
#ifdef GIT_REV
"-GIT" GIT_REV
#endif

47
video.c
View File

@@ -1246,28 +1246,33 @@ 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);
}
#ifndef USE_DRM
if (eglSharedContext) {
eglDestroyContext(eglDisplay, eglSharedContext);
EglCheck();
}
#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;
}
if (eglContext) {
eglDestroyContext(eglDisplay, eglContext);
EglCheck();
eglContext = NULL;
}
if (eglSharedContext) {
eglDestroyContext(eglDisplay, eglSharedContext);
EglCheck();
eglSharedContext = NULL;
}
eglTerminate(eglDisplay);
#endif
#ifdef USE_DRM
drm_clean_up();
#endif
eglDisplay = NULL;
#endif
}
@@ -3001,10 +3006,12 @@ static enum AVPixelFormat Cuvid_get_format(CuvidDecoder *decoder, AVCodecContext
#ifdef CUVID
ist->active_hwaccel_id = HWACCEL_CUVID;
#else
if (VideoDeinterlace[decoder->Resolution]) // need deinterlace
if (VideoDeinterlace[decoder->Resolution]) {// need deinterlace
ist->filter = 1; // init deint vaapi
else
}
else {
ist->filter = 0;
}
ist->active_hwaccel_id = HWACCEL_VAAPI;
#endif
@@ -7094,6 +7101,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

View File

@@ -249,6 +249,10 @@ extern int VideoRaiseWindow(void);
/// Set Shaders
extern int VideoSetShader(char *);
extern void VideoSetRefresh(char *);
extern void VideoSetConnector(char *);
#ifdef USE_OPENGLOSD
extern void ActivateOsd(GLuint, int, int, int, int);
#endif