mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-26 09:35:28 +00:00
use sample_aspect_ratio if available
This commit is contained in:
parent
5ed04ae53e
commit
63e86555b6
@ -1045,15 +1045,16 @@ void VideoPlayer::update ()
|
||||
mVideoMaterial->getTechnique(0)->getPass(0)->getTextureUnitState(0)->setTextureName("VideoTexture");
|
||||
|
||||
// Correct aspect ratio by adding black bars
|
||||
int width = (mState->video_st->codec->width);
|
||||
int height = (mState->video_st->codec->height);
|
||||
double videoaspect = static_cast<double>(mState->video_st->codec->width) / mState->video_st->codec->height;
|
||||
|
||||
float screenaspect = static_cast<float>(mWidth) / mHeight;
|
||||
float videoaspect = static_cast<float>(width) / height;
|
||||
float aspect_correction = videoaspect / screenaspect;
|
||||
if (av_q2d(mState->video_st->codec->sample_aspect_ratio) != 0)
|
||||
videoaspect *= av_q2d(mState->video_st->codec->sample_aspect_ratio);
|
||||
|
||||
mRectangle->setCorners (std::max(-1.f, -1.f * aspect_correction), std::min(1.f, 1.f / aspect_correction),
|
||||
std::min(1.f, 1.f * aspect_correction), std::max(-1.f, -1.f / aspect_correction));
|
||||
double screenaspect = static_cast<double>(mWidth) / mHeight;
|
||||
double aspect_correction = videoaspect / screenaspect;
|
||||
|
||||
mRectangle->setCorners (std::max(-1.0, -1.0 * aspect_correction), std::min(1.0, 1.0 / aspect_correction),
|
||||
std::min(1.0, 1.0 * aspect_correction), std::max(-1.0, -1.0 / aspect_correction));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user