mirror of
https://github.com/vcmi/vcmi.git
synced 2025-02-03 13:01:33 +02:00
Formatting
This commit is contained in:
parent
e39461165a
commit
02da800151
@ -216,10 +216,10 @@ void FFMpegStream::decodeNextFrame()
|
||||
{
|
||||
AVPacket packet;
|
||||
|
||||
for (;;)
|
||||
for(;;)
|
||||
{
|
||||
int rc = avcodec_receive_frame(codecContext, frame);
|
||||
if (rc == AVERROR(EAGAIN))
|
||||
if(rc == AVERROR(EAGAIN))
|
||||
break;
|
||||
|
||||
if(rc < 0)
|
||||
@ -252,7 +252,7 @@ void FFMpegStream::decodeNextFrame()
|
||||
throwFFmpegError(rc);
|
||||
|
||||
rc = avcodec_receive_frame(codecContext, frame);
|
||||
if (rc == AVERROR(EAGAIN))
|
||||
if(rc == AVERROR(EAGAIN))
|
||||
{
|
||||
av_packet_unref(&packet);
|
||||
continue;
|
||||
@ -272,7 +272,7 @@ bool CVideoInstance::loadNextFrame()
|
||||
decodeNextFrame();
|
||||
const AVFrame * frame = getCurrentFrame();
|
||||
|
||||
if (!frame)
|
||||
if(!frame)
|
||||
return false;
|
||||
|
||||
uint8_t * data[4] = {};
|
||||
@ -292,7 +292,7 @@ bool CVideoInstance::loadNextFrame()
|
||||
SDL_UpdateTexture(textureRGB, nullptr, data[0], linesize[0]);
|
||||
av_freep(&data[0]);
|
||||
}
|
||||
if (surface)
|
||||
if(surface)
|
||||
{
|
||||
// Avoid buffer overflow caused by sws_scale():
|
||||
// http://trac.ffmpeg.org/ticket/9254
|
||||
@ -357,21 +357,21 @@ void CVideoInstance::show(const Point & position, Canvas & canvas)
|
||||
|
||||
double FFMpegStream::getCurrentFrameEndTime()
|
||||
{
|
||||
# if(LIBAVUTIL_VERSION_MAJOR < 58)
|
||||
#if(LIBAVUTIL_VERSION_MAJOR < 58)
|
||||
auto packet_duration = frame->pkt_duration;
|
||||
# else
|
||||
#else
|
||||
auto packet_duration = frame->duration;
|
||||
# endif
|
||||
#endif
|
||||
return (frame->pts + packet_duration) * av_q2d(formatContext->streams[streamIndex]->time_base);
|
||||
}
|
||||
|
||||
double FFMpegStream::getCurrentFrameDuration()
|
||||
{
|
||||
# if(LIBAVUTIL_VERSION_MAJOR < 58)
|
||||
#if(LIBAVUTIL_VERSION_MAJOR < 58)
|
||||
auto packet_duration = frame->pkt_duration;
|
||||
# else
|
||||
#else
|
||||
auto packet_duration = frame->duration;
|
||||
# endif
|
||||
#endif
|
||||
return (packet_duration) * av_q2d(formatContext->streams[streamIndex]->time_base);
|
||||
}
|
||||
|
||||
@ -552,7 +552,7 @@ bool CVideoPlayer::openAndPlayVideoImpl(const VideoPath & name, const Point & po
|
||||
else
|
||||
SDL_RenderClear(mainRenderer);
|
||||
|
||||
if (instance.textureYUV)
|
||||
if(instance.textureYUV)
|
||||
SDL_RenderCopy(mainRenderer, instance.textureYUV, nullptr, &rect);
|
||||
else
|
||||
SDL_RenderCopy(mainRenderer, instance.textureRGB, nullptr, &rect);
|
||||
@ -567,7 +567,7 @@ bool CVideoPlayer::openAndPlayVideoImpl(const VideoPath & name, const Point & po
|
||||
auto timeSpentBusy = boost::chrono::duration_cast<boost::chrono::milliseconds>(timePointAfterPresent - lastTimePoint);
|
||||
|
||||
logGlobal->info("Sleeping for %d", (targetFrameTime - timeSpentBusy).count());
|
||||
if (targetFrameTime > timeSpentBusy)
|
||||
if(targetFrameTime > timeSpentBusy)
|
||||
boost::this_thread::sleep_for(targetFrameTime - timeSpentBusy);
|
||||
|
||||
lastTimePoint = boost::chrono::steady_clock::now();
|
||||
@ -577,7 +577,7 @@ bool CVideoPlayer::openAndPlayVideoImpl(const VideoPath & name, const Point & po
|
||||
|
||||
bool CVideoPlayer::playIntroVideo(const VideoPath & name)
|
||||
{
|
||||
return openAndPlayVideoImpl(name, Point(0,0), true, true, true);
|
||||
return openAndPlayVideoImpl(name, Point(0, 0), true, true, true);
|
||||
}
|
||||
|
||||
void CVideoPlayer::playSpellbookAnimation(const VideoPath & name, const Point & position)
|
||||
@ -596,7 +596,7 @@ std::unique_ptr<IVideoInstance> CVideoPlayer::open(const VideoPath & name, bool
|
||||
return result;
|
||||
}
|
||||
|
||||
std::pair<std::unique_ptr<ui8 []>, si64> CVideoPlayer::getAudio(const VideoPath & videoToOpen)
|
||||
std::pair<std::unique_ptr<ui8[]>, si64> CVideoPlayer::getAudio(const VideoPath & videoToOpen)
|
||||
{
|
||||
CAudioInstance audio;
|
||||
return audio.extractAudio(videoToOpen);
|
||||
|
@ -12,7 +12,6 @@
|
||||
#ifndef DISABLE_VIDEO
|
||||
|
||||
# include "IVideoPlayer.h"
|
||||
|
||||
# include "../lib/Rect.h"
|
||||
|
||||
struct SDL_Surface;
|
||||
@ -64,14 +63,13 @@ public:
|
||||
class CAudioInstance final : public FFMpegStream
|
||||
{
|
||||
public:
|
||||
std::pair<std::unique_ptr<ui8 []>, si64> extractAudio(const VideoPath & videoToOpen);
|
||||
std::pair<std::unique_ptr<ui8[]>, si64> extractAudio(const VideoPath & videoToOpen);
|
||||
};
|
||||
|
||||
class CVideoInstance final : public IVideoInstance, public FFMpegStream
|
||||
{
|
||||
friend class CVideoPlayer;
|
||||
|
||||
|
||||
struct SwsContext * sws = nullptr;
|
||||
SDL_Texture * textureRGB = nullptr;
|
||||
SDL_Texture * textureYUV = nullptr;
|
||||
@ -105,7 +103,7 @@ public:
|
||||
bool playIntroVideo(const VideoPath & name) final;
|
||||
void playSpellbookAnimation(const VideoPath & name, const Point & position) final;
|
||||
std::unique_ptr<IVideoInstance> open(const VideoPath & name, bool scaleToScreen) final;
|
||||
std::pair<std::unique_ptr<ui8 []>, si64> getAudio(const VideoPath & videoToOpen) final;
|
||||
std::pair<std::unique_ptr<ui8[]>, si64> getAudio(const VideoPath & videoToOpen) final;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user