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

Fixes for drm Aspectratio and UHD HDR

This commit is contained in:
jojo61 2020-01-15 18:01:27 +01:00
parent 269c396a2c
commit 1674600882
3 changed files with 78 additions and 65 deletions

13
codec.c
View File

@ -502,6 +502,7 @@ extern int CuvidTestSurfaces();
extern int init_filters(AVCodecContext * dec_ctx, void *decoder, AVFrame * frame); extern int init_filters(AVCodecContext * dec_ctx, void *decoder, AVFrame * frame);
extern int push_filters(AVCodecContext * dec_ctx, void *decoder, AVFrame * frame); extern int push_filters(AVCodecContext * dec_ctx, void *decoder, AVFrame * frame);
#endif #endif
#ifdef VAAPI #ifdef VAAPI
void CodecVideoDecode(VideoDecoder * decoder, const AVPacket * avpkt) void CodecVideoDecode(VideoDecoder * decoder, const AVPacket * avpkt)
{ {
@ -522,8 +523,11 @@ void CodecVideoDecode(VideoDecoder * decoder, const AVPacket * avpkt)
if (!CuvidTestSurfaces()) if (!CuvidTestSurfaces())
usleep(1000); usleep(1000);
ret = 0;
while (ret >= 0) {
frame = av_frame_alloc(); frame = av_frame_alloc();
ret = avcodec_receive_frame(video_ctx, frame); ret = avcodec_receive_frame(video_ctx, frame);
if (ret < 0 && ret != AVERROR(EAGAIN) && ret != AVERROR_EOF) { if (ret < 0 && ret != AVERROR(EAGAIN) && ret != AVERROR_EOF) {
Debug(4, "codec: receiving video frame failed"); Debug(4, "codec: receiving video frame failed");
av_frame_free(&frame); av_frame_free(&frame);
@ -541,17 +545,20 @@ void CodecVideoDecode(VideoDecoder * decoder, const AVPacket * avpkt)
} }
} }
if (frame->interlaced_frame && decoder->filter == 2 && (frame->height != 720)) { // broken ZDF sends Interlaced flag if (frame->interlaced_frame && decoder->filter == 2 && (frame->height != 720)) { // broken ZDF sends Interlaced flag
ret = push_filters(video_ctx, decoder->HwDecoder, frame); push_filters(video_ctx, decoder->HwDecoder, frame);
return; continue;
} }
} }
VideoRenderFrame(decoder->HwDecoder, video_ctx, frame); VideoRenderFrame(decoder->HwDecoder, video_ctx, frame);
} else { } else {
av_frame_free(&frame); av_frame_free(&frame);
return;
}
} }
} }
} }
#endif #endif
#ifdef CUVID #ifdef CUVID
void CodecVideoDecode(VideoDecoder * decoder, const AVPacket * avpkt) void CodecVideoDecode(VideoDecoder * decoder, const AVPacket * avpkt)
@ -582,7 +589,7 @@ void CodecVideoDecode(VideoDecoder * decoder, const AVPacket * avpkt)
if (!CuvidTestSurfaces()) if (!CuvidTestSurfaces())
usleep(1000); usleep(1000);
// printf("send packet to decode %s\n",consumed?"ok":"Full"); // printf("send packet to decode %s %04x\n",consumed?"ok":"Full",ret1);
if ((ret1 == AVERROR(EAGAIN) || ret1 == AVERROR_EOF || ret1 >= 0) && CuvidTestSurfaces()) { if ((ret1 == AVERROR(EAGAIN) || ret1 == AVERROR_EOF || ret1 >= 0) && CuvidTestSurfaces()) {
ret = 0; ret = 0;

9
drm.c
View File

@ -257,10 +257,15 @@ static int FindDevice(VideoRender * render)
continue; continue;
if (connector->connection == DRM_MODE_CONNECTED && connector->count_modes > 0) { if (connector->connection == DRM_MODE_CONNECTED && connector->count_modes > 0) {
render->connector_id = connector->connector_id; float aspect = (float)connector->mmWidth / (float)connector->mmHeight;
if ((aspect > 1.70) && (aspect < 1.85)) {
render->mmHeight = 90;
render->mmWidth = 160;
} else {
render->mmHeight = connector->mmHeight; render->mmHeight = connector->mmHeight;
render->mmWidth = connector->mmWidth; render->mmWidth = connector->mmWidth;
}
render->connector_id = connector->connector_id;
// FIXME: use default encoder/crtc pair // FIXME: use default encoder/crtc pair
if ((encoder = drmModeGetEncoder(render->fd_drm, connector->encoder_id)) == NULL){ if ((encoder = drmModeGetEncoder(render->fd_drm, connector->encoder_id)) == NULL){
fprintf(stderr, "FindDevice: cannot retrieve encoder (%d): %m\n", errno); fprintf(stderr, "FindDevice: cannot retrieve encoder (%d): %m\n", errno);

View File

@ -1168,6 +1168,7 @@ static void EglInit(void)
// create egl context // create egl context
setenv("MESA_GL_VERSION_OVERRIDE","3.3",0); setenv("MESA_GL_VERSION_OVERRIDE","3.3",0);
setenv("V3D_DOUBLE_BUFFER","1",0);
make_egl(); make_egl();
if (!glewdone) { if (!glewdone) {
@ -1700,7 +1701,7 @@ static void CuvidReleaseSurface(CuvidDecoder * decoder, int surface)
#endif #endif
if (decoder->fds[surface*Planes]) { if (decoder->fds[surface*Planes]) {
close(decoder->fds[surface*Planes]); close(decoder->fds[surface*Planes]);
close(decoder->fds[surface*Planes+1]); // close(decoder->fds[surface*Planes+1]);
#ifdef RASPI #ifdef RASPI
close(decoder->fds[surface*Planes+2]); close(decoder->fds[surface*Planes+2]);
#endif #endif
@ -2550,10 +2551,9 @@ void generateVAAPIImage(CuvidDecoder * decoder, int index, const AVFrame * frame
EGLImageTargetTexture2DOES(GL_TEXTURE_2D, decoder->images[index * Planes + n]); EGLImageTargetTexture2DOES(GL_TEXTURE_2D, decoder->images[index * Planes + n]);
#ifdef RASPI #ifdef RASPI
decoder->fds[index*Planes+n] = fd; decoder->fds[index*Planes+n] = fd;
#else
decoder->fds[index*Planes+n] = desc.objects[desc.layers[n].object_index[0]].fd;
#endif #endif
} }
decoder->fds[index*Planes+n] = desc.objects[0].fd;
glBindTexture(GL_TEXTURE_2D, 0); glBindTexture(GL_TEXTURE_2D, 0);
eglMakeCurrent(eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); eglMakeCurrent(eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
EglCheck(); EglCheck();
@ -5255,6 +5255,7 @@ void exit_display()
} }
#endif #endif
Debug(3,"display thread exit\n"); Debug(3,"display thread exit\n");
} }
static void *VideoHandlerThread(void *dummy) static void *VideoHandlerThread(void *dummy)