diff --git a/Sources/Plasma/FeatureLib/pfMoviePlayer/plMoviePlayer.cpp b/Sources/Plasma/FeatureLib/pfMoviePlayer/plMoviePlayer.cpp index 782dc71b..be33308b 100644 --- a/Sources/Plasma/FeatureLib/pfMoviePlayer/plMoviePlayer.cpp +++ b/Sources/Plasma/FeatureLib/pfMoviePlayer/plMoviePlayer.cpp @@ -48,6 +48,9 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com # include # define iface (vpx_codec_vp9_dx()) # include + +# define WEBM_CODECID_VP9 "V_VP9" +# define WEBM_CODECID_OPUS "A_OPUS" #endif #include "plGImage/plMipmap.h" @@ -94,6 +97,7 @@ public: if(vpx_codec_dec_init(&instance->codec, iface, nullptr, 0)) { hsAssert(false, vpx_codec_error_detail(&instance->codec)); + delete instance; return nullptr; } return instance; @@ -320,6 +324,12 @@ bool plMoviePlayer::Start() hsAssert(fVideoTrack, "nil video track -- expect bad things to happen!"); // Initialize VPX + const mkvparser::VideoTrack* video = static_cast(fVideoTrack->GetTrack()); + if (strcmp(video->GetCodecId(), WEBM_CODECID_VP9) != 0) + { + hsAssert(false, "Not a VP9 video track!"); + return false; + } if (VPX* vpx = VPX::Create()) fVpx.reset(vpx); else @@ -327,7 +337,6 @@ bool plMoviePlayer::Start() // Need to figure out scaling based on pipe size. plPlateManager& plateMgr = plPlateManager::Instance(); - const mkvparser::VideoTrack* video = static_cast(fVideoTrack->GetTrack()); float plateWidth = video->GetWidth() * fScale.fX; float plateHeight = video->GetHeight() * fScale.fY; if (plateWidth > plateMgr.GetPipeWidth() || plateHeight > plateMgr.GetPipeHeight()) @@ -340,7 +349,7 @@ bool plMoviePlayer::Start() plateMgr.SetPlatePixelSize(fPlate, plateWidth, plateHeight); fTexture = fPlate->CreateMaterial(static_cast(video->GetWidth()), static_cast(video->GetHeight()), false); - //initialize opus + // Fetch audio track information const mkvparser::AudioTrack* audio = static_cast(fAudioTrack->GetTrack()); plWAVHeader header; header.fFormatTag = plWAVHeader::kPCMFormatTag; @@ -350,6 +359,13 @@ bool plMoviePlayer::Start() header.fBlockAlign = header.fNumChannels * header.fBitsPerSample / 8; header.fAvgBytesPerSec = header.fNumSamplesPerSec * header.fBlockAlign; fAudioSound.reset(new plWin32VideoSound(header)); + + // Initialize Opus + if (strcmp(audio->GetCodecId(), WEBM_CODECID_OPUS) != 0) + { + hsAssert(false, "Not an Opus audio track!"); + return false; + } int error; fOpusDecoder = opus_decoder_create(48000, audio->GetChannels(), &error); if (error != OPUS_OK)