Skip to content

Commit

Permalink
Add support for the VP9 codec in the IVF container
Browse files Browse the repository at this point in the history
  • Loading branch information
DrinkyBird authored and RicardoLuis0 committed Mar 31, 2024
1 parent 7a43d7f commit 4012dd2
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/common/cutscenes/movieplayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ class VpxPlayer : public MoviePlayer
unsigned width, height;
TArray<uint8_t> Pic;
TArray<uint8_t> readBuf;
vpx_codec_iface_t *iface;
vpx_codec_ctx_t codec{};
vpx_codec_iter_t iter = nullptr;

Expand Down Expand Up @@ -365,7 +366,7 @@ class VpxPlayer : public MoviePlayer

// Todo: Support VP9 as well?
vpx_codec_dec_cfg_t cfg = { 1, width, height };
if (vpx_codec_dec_init(&codec, &vpx_codec_vp8_dx_algo, &cfg, 0))
if (vpx_codec_dec_init(&codec, iface, &cfg, 0))
{
error.Format("Error initializing VPX codec.\n");
failed = true;
Expand All @@ -388,7 +389,16 @@ class VpxPlayer : public MoviePlayer
uint16_t length = fr.ReadUInt16();
if (length != 32) return false;
fr.Read(&magic, 4);
if (magic != MAKE_ID('V', 'P', '8', '0')) return false;

switch (magic)
{
case MAKE_ID('V', 'P', '8', '0'):
iface = &vpx_codec_vp8_dx_algo; break;
case MAKE_ID('V', 'P', '9', '0'):
iface = &vpx_codec_vp9_dx_algo; break;
default:
return false;
}

width = fr.ReadUInt16();
height = fr.ReadUInt16();
Expand Down Expand Up @@ -895,7 +905,7 @@ MoviePlayer* OpenMovie(const char* filename, TArray<int>& ans, const int* framet
}
return anm;
}
else if (!memcmp(id, "DKIF\0\0 \0VP80", 12))
else if (!memcmp(id, "DKIF\0\0 \0VP80", 12) || !memcmp(id, "DKIF\0\0 \0VP90", 12))
{
auto anm = new VpxPlayer(fr, ans, frameticks ? frameticks[1] : 0, flags, error);
if (!anm->isvalid())
Expand Down

0 comments on commit 4012dd2

Please sign in to comment.