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

fixed SURFACES full

This commit is contained in:
jojo61 2018-10-08 17:02:12 +02:00
parent 92333441bd
commit f03dde19ed
3 changed files with 41 additions and 36 deletions

View File

@ -457,6 +457,8 @@ void DisplayPts(AVCodecContext * video_ctx, AVFrame * frame)
** @param decoder video decoder data ** @param decoder video decoder data
** @param avpkt video packet ** @param avpkt video packet
*/ */
extern int CuvidTestSurfaces();
void CodecVideoDecode(VideoDecoder * decoder, const AVPacket * avpkt) void CodecVideoDecode(VideoDecoder * decoder, const AVPacket * avpkt)
{ {
AVCodecContext *video_ctx; AVCodecContext *video_ctx;
@ -478,9 +480,9 @@ next_part:
if (ret1 >= 0) { if (ret1 >= 0) {
consumed = 1; consumed = 1;
} }
if (ret1 == AVERROR(EAGAIN) || ret1 == AVERROR_EOF || ret1 >= 0) { // decoder is full if ((ret1 == AVERROR(EAGAIN) || ret1 == AVERROR_EOF || ret1 >= 0) && CuvidTestSurfaces()) {
ret = 0; ret = 0;
while (ret >= 0) { // get frames until empty while ((ret >= 0) && CuvidTestSurfaces()) { // get frames until empty snd Surfaces avail.
ret = avcodec_receive_frame(video_ctx, frame); // get new frame ret = avcodec_receive_frame(video_ctx, frame); // get new frame
if (ret >= 0) { // one is avail. if (ret >= 0) { // one is avail.
@ -515,7 +517,7 @@ next_part:
} }
} }
} else { } else {
consumed = 1; // consumed = 1;
} }
if (!consumed) { if (!consumed) {

View File

@ -2588,7 +2588,7 @@ void cSoftHdDevice::TrickSpeed(int speed)
*/ */
void cSoftHdDevice::Clear(void) void cSoftHdDevice::Clear(void)
{ {
dsyslog("[softhddev]%s:\n", __FUNCTION__); dsyslog("[softhddev] vom VDR kommt %s:\n", __FUNCTION__);
cDevice::Clear(); cDevice::Clear();
::Clear(); ::Clear();

67
video.c
View File

@ -1353,7 +1353,7 @@ static VideoResolutions VideoResolutionGroup(int width, int height,
if (height <= 720) { if (height <= 720) {
return VideoResolution720p; return VideoResolution720p;
} }
if (height < 1080) { if (height <= 1080) {
return VideoResolutionFake1080i; return VideoResolutionFake1080i;
} }
if (width < 1920) { if (width < 1920) {
@ -1864,7 +1864,11 @@ static void CuvidPrintFrames(const CuvidDecoder * decoder)
#endif #endif
} }
int CuvidTestSurfaces() {
if (atomic_read(&CuvidDecoders[0]->SurfacesFilled) < VIDEO_SURFACES_MAX)
return 1;
return 0;
}
/// ///
/// Allocate new CUVID decoder. /// Allocate new CUVID decoder.
@ -2296,7 +2300,7 @@ static enum AVPixelFormat Cuvid_get_format(CuvidDecoder * decoder,
Fatal(_("CUVID Init failed\n")); Fatal(_("CUVID Init failed\n"));
} }
#endif #endif
CuvidMessage(2,"no CUVID Init ok %dx%d\n",video_ctx->width,video_ctx->height); CuvidMessage(2,"CUVID Init ok %dx%d\n",video_ctx->width,video_ctx->height);
ist->active_hwaccel_id = HWACCEL_CUVID; ist->active_hwaccel_id = HWACCEL_CUVID;
ist->hwaccel_pix_fmt = AV_PIX_FMT_CUDA; ist->hwaccel_pix_fmt = AV_PIX_FMT_CUDA;
decoder->InputWidth = video_ctx->width; decoder->InputWidth = video_ctx->width;
@ -2637,35 +2641,35 @@ static void CuvidAutoCrop(CuvidDecoder * decoder)
decoder->AutoCrop->State = next_state; decoder->AutoCrop->State = next_state;
if (next_state) { if (next_state) {
decoder->CropX = VideoCutLeftRight[decoder->Resolution]; decoder->CropX = VideoCutLeftRight[decoder->Resolution];
decoder->CropY = decoder->CropY =
(next_state == (next_state ==
16 ? crop16 : crop14) + VideoCutTopBottom[decoder->Resolution]; 16 ? crop16 : crop14) + VideoCutTopBottom[decoder->Resolution];
decoder->CropWidth = decoder->InputWidth - decoder->CropX * 2; decoder->CropWidth = decoder->InputWidth - decoder->CropX * 2;
decoder->CropHeight = decoder->InputHeight - decoder->CropY * 2; decoder->CropHeight = decoder->InputHeight - decoder->CropY * 2;
// FIXME: this overwrites user choosen output position // FIXME: this overwrites user choosen output position
// FIXME: resize kills the auto crop values // FIXME: resize kills the auto crop values
// FIXME: support other 4:3 zoom modes // FIXME: support other 4:3 zoom modes
decoder->OutputX = decoder->VideoX; decoder->OutputX = decoder->VideoX;
decoder->OutputY = decoder->VideoY; decoder->OutputY = decoder->VideoY;
decoder->OutputWidth = (decoder->VideoHeight * next_state) / 9; decoder->OutputWidth = (decoder->VideoHeight * next_state) / 9;
decoder->OutputHeight = (decoder->VideoWidth * 9) / next_state; decoder->OutputHeight = (decoder->VideoWidth * 9) / next_state;
if (decoder->OutputWidth > decoder->VideoWidth) { if (decoder->OutputWidth > decoder->VideoWidth) {
decoder->OutputWidth = decoder->VideoWidth; decoder->OutputWidth = decoder->VideoWidth;
decoder->OutputY = decoder->OutputY =
(decoder->VideoHeight - decoder->OutputHeight) / 2; (decoder->VideoHeight - decoder->OutputHeight) / 2;
} else if (decoder->OutputHeight > decoder->VideoHeight) { } else if (decoder->OutputHeight > decoder->VideoHeight) {
decoder->OutputHeight = decoder->VideoHeight; decoder->OutputHeight = decoder->VideoHeight;
decoder->OutputX = decoder->OutputX =
(decoder->VideoWidth - decoder->OutputWidth) / 2; (decoder->VideoWidth - decoder->OutputWidth) / 2;
} }
Debug(3, "video: aspect output %dx%d %dx%d%+d%+d\n", Debug(3, "video: aspect output %dx%d %dx%d%+d%+d\n",
decoder->InputWidth, decoder->InputHeight, decoder->OutputWidth, decoder->InputWidth, decoder->InputHeight, decoder->OutputWidth,
decoder->OutputHeight, decoder->OutputX, decoder->OutputY); decoder->OutputHeight, decoder->OutputX, decoder->OutputY);
} else { } else {
// sets AutoCrop->Count // sets AutoCrop->Count
CuvidUpdateOutput(decoder); CuvidUpdateOutput(decoder);
} }
decoder->AutoCrop->Count = 0; decoder->AutoCrop->Count = 0;
} }
@ -4388,8 +4392,7 @@ void VideoRenderFrame(VideoHwDecoder * hw_decoder,
Timestamp2String(frame->pkt_pts), hw_decoder->Cuvid.Closing); Timestamp2String(frame->pkt_pts), hw_decoder->Cuvid.Closing);
#endif #endif
if (frame->repeat_pict && !VideoIgnoreRepeatPict) { if (frame->repeat_pict && !VideoIgnoreRepeatPict) {
Warning(_("video: repeated pict %d found, but not handled\n"), Warning(_("video: repeated pict %d found, but not handled\n"), frame->repeat_pict);
frame->repeat_pict);
} }
VideoUsedModule->RenderFrame(hw_decoder, video_ctx, frame); VideoUsedModule->RenderFrame(hw_decoder, video_ctx, frame);
} }