mirror of
https://github.com/vcmi/vcmi.git
synced 2025-02-03 13:01:33 +02:00
Use scaling
(*) into - fullscreen (*) spellbook - no scaling
This commit is contained in:
parent
61b31e5c60
commit
0efb6e2890
@ -165,23 +165,36 @@ bool CVideoPlayer::open(std::string fname, bool loop, bool useOverlay)
|
|||||||
// Allocate video frame
|
// Allocate video frame
|
||||||
frame = avcodec_alloc_frame();
|
frame = avcodec_alloc_frame();
|
||||||
|
|
||||||
|
//setup scaling
|
||||||
|
|
||||||
|
if(doScale)
|
||||||
|
{
|
||||||
|
pos.w = screen->w;
|
||||||
|
pos.h = screen->h;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pos.w = codecContext->width;
|
||||||
|
pos.h = codecContext->height;
|
||||||
|
}
|
||||||
|
|
||||||
// Allocate a place to put our YUV image on that screen
|
// Allocate a place to put our YUV image on that screen
|
||||||
if (useOverlay)
|
if (useOverlay)
|
||||||
{
|
{
|
||||||
#ifdef VCMI_SDL1
|
#ifdef VCMI_SDL1
|
||||||
overlay = SDL_CreateYUVOverlay(codecContext->width, codecContext->height,
|
overlay = SDL_CreateYUVOverlay(pos.w, pos.h,
|
||||||
SDL_YV12_OVERLAY, screen);
|
SDL_YV12_OVERLAY, screen);
|
||||||
#else
|
#else
|
||||||
texture = SDL_CreateTexture( mainRenderer, SDL_PIXELFORMAT_IYUV, SDL_TEXTUREACCESS_STATIC, codecContext->width, codecContext->height);
|
texture = SDL_CreateTexture( mainRenderer, SDL_PIXELFORMAT_IYUV, SDL_TEXTUREACCESS_STATIC, pos.w, pos.h);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dest = CSDL_Ext::newSurface(codecContext->width, codecContext->height);
|
dest = CSDL_Ext::newSurface(pos.w, pos.h);
|
||||||
destRect.x = destRect.y = 0;
|
destRect.x = destRect.y = 0;
|
||||||
destRect.w = codecContext->width;
|
destRect.w = pos.w;
|
||||||
destRect.h = codecContext->height;
|
destRect.h = pos.h;
|
||||||
}
|
}
|
||||||
#ifdef VCMI_SDL1
|
#ifdef VCMI_SDL1
|
||||||
if (overlay == nullptr && dest == nullptr)
|
if (overlay == nullptr && dest == nullptr)
|
||||||
@ -195,9 +208,9 @@ bool CVideoPlayer::open(std::string fname, bool loop, bool useOverlay)
|
|||||||
if (texture)
|
if (texture)
|
||||||
#endif
|
#endif
|
||||||
{ // Convert the image into YUV format that SDL uses
|
{ // Convert the image into YUV format that SDL uses
|
||||||
sws = sws_getContext(codecContext->width, codecContext->height,
|
sws = sws_getContext(codecContext->width, codecContext->height, codecContext->pix_fmt,
|
||||||
codecContext->pix_fmt, codecContext->width, codecContext->height,
|
pos.w, pos.h, PIX_FMT_YUV420P,
|
||||||
PIX_FMT_YUV420P, SWS_BICUBIC, nullptr, nullptr, nullptr);
|
SWS_BICUBIC, nullptr, nullptr, nullptr);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -226,17 +239,14 @@ bool CVideoPlayer::open(std::string fname, bool loop, bool useOverlay)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sws = sws_getContext(codecContext->width, codecContext->height,
|
sws = sws_getContext(codecContext->width, codecContext->height, codecContext->pix_fmt,
|
||||||
codecContext->pix_fmt, codecContext->width, codecContext->height,
|
pos.w, pos.h, screenFormat,
|
||||||
screenFormat, SWS_BICUBIC, nullptr, nullptr, nullptr);
|
SWS_BICUBIC, nullptr, nullptr, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sws == nullptr)
|
if (sws == nullptr)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
pos.w = codecContext->width;
|
|
||||||
pos.h = codecContext->height;
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -300,7 +310,7 @@ bool CVideoPlayer::nextFrame()
|
|||||||
SDL_UnlockYUVOverlay(overlay);
|
SDL_UnlockYUVOverlay(overlay);
|
||||||
#else
|
#else
|
||||||
if (texture) {
|
if (texture) {
|
||||||
avpicture_alloc(&pict, AV_PIX_FMT_YUV420P, codecContext->width, codecContext->height);
|
avpicture_alloc(&pict, AV_PIX_FMT_YUV420P, pos.w, pos.h);
|
||||||
|
|
||||||
sws_scale(sws, frame->data, frame->linesize,
|
sws_scale(sws, frame->data, frame->linesize,
|
||||||
0, codecContext->height, pict.data, pict.linesize);
|
0, codecContext->height, pict.data, pict.linesize);
|
||||||
@ -456,7 +466,7 @@ bool CVideoPlayer::playVideo(int x, int y, SDL_Surface *dst, bool stopOnKey)
|
|||||||
#ifdef VCMI_SDL1
|
#ifdef VCMI_SDL1
|
||||||
SDL_DisplayYUVOverlay(overlay, &pos);
|
SDL_DisplayYUVOverlay(overlay, &pos);
|
||||||
#else
|
#else
|
||||||
SDL_RenderCopy(mainRenderer, texture, NULL, NULL);
|
SDL_RenderCopy(mainRenderer, texture, NULL, &pos);
|
||||||
SDL_RenderPresent(mainRenderer);
|
SDL_RenderPresent(mainRenderer);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user