Create new utility function for scaling with aspect ratio and use it for DXVA2
This commit is contained in:
parent
b076744f00
commit
5cbb38091b
4 changed files with 49 additions and 18 deletions
20
app/streaming/streamutils.cpp
Normal file
20
app/streaming/streamutils.cpp
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
#include "streamutils.h"
|
||||
|
||||
void StreamUtils::scaleSourceToDestinationSurface(SDL_Rect* src, SDL_Rect* dst)
|
||||
{
|
||||
int dstH = dst->w * src->h / src->w;
|
||||
int dstW = dst->h * src->w / src->h;
|
||||
|
||||
if (dstH > dst->h) {
|
||||
dst->y = 0;
|
||||
dst->x = (dst->w - dstW) / 2;
|
||||
dst->w = dstW;
|
||||
SDL_assert(dst->w * src->h / src->w <= dst->h);
|
||||
}
|
||||
else {
|
||||
dst->x = 0;
|
||||
dst->y = (dst->h - dstH) / 2;
|
||||
dst->h = dstH;
|
||||
SDL_assert(dst->h * src->w / src->h <= dst->w);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue