diff --git a/thirdparty/README.md b/thirdparty/README.md index 738835c70a7..f36b53f1e33 100644 --- a/thirdparty/README.md +++ b/thirdparty/README.md @@ -178,18 +178,21 @@ Files extracted from upstream source: ## libsimplewebm - Upstream: https://github.com/zaps166/libsimplewebm -- Version: git (05cfdc2, 2016) -- License: MIT, BSD-3-Clause +- Version: git (fe57fd3, 2019) +- License: MIT (main), BSD-3-Clause (libwebm) + +This contains libwebm, but the version in use is updated from the one used by libsimplewebm, +and may have *unmarked* alterations from that. Files extracted from upstream source: -TODO. +- all the .cpp, .hpp files in the main folder except `example.cpp` +- LICENSE Important: Some files have Godot-made changes. They are marked with `// -- GODOT start --` and `// -- GODOT end --` comments. - ## libtheora - Upstream: https://www.theora.org diff --git a/thirdparty/libsimplewebm/OpusVorbisDecoder.cpp b/thirdparty/libsimplewebm/OpusVorbisDecoder.cpp index c9e71eb733e..b5824b17be8 100644 --- a/thirdparty/libsimplewebm/OpusVorbisDecoder.cpp +++ b/thirdparty/libsimplewebm/OpusVorbisDecoder.cpp @@ -122,6 +122,7 @@ bool OpusVorbisDecoder::getPCMS16(WebMFrame &frame, short *buffer, int &numOutSa return false; } +// -- GODOT begin -- bool OpusVorbisDecoder::getPCMF(WebMFrame &frame, float *buffer, int &numOutSamples) { if (m_vorbis) { m_vorbis->op.packet = frame.buffer; @@ -158,6 +159,7 @@ bool OpusVorbisDecoder::getPCMF(WebMFrame &frame, float *buffer, int &numOutSamp } return false; } +// -- GODOT end -- bool OpusVorbisDecoder::openVorbis(const WebMDemuxer &demuxer) { diff --git a/thirdparty/libsimplewebm/OpusVorbisDecoder.hpp b/thirdparty/libsimplewebm/OpusVorbisDecoder.hpp index b7619d6a251..f285b3fbd61 100644 --- a/thirdparty/libsimplewebm/OpusVorbisDecoder.hpp +++ b/thirdparty/libsimplewebm/OpusVorbisDecoder.hpp @@ -44,8 +44,10 @@ public: { return m_numSamples; } - bool getPCMF(WebMFrame &frame, float *buffer, int &numOutSamples); bool getPCMS16(WebMFrame &frame, short *buffer, int &numOutSamples); +// -- GODOT begin -- + bool getPCMF(WebMFrame &frame, float *buffer, int &numOutSamples); +// -- GODOT end -- private: bool openVorbis(const WebMDemuxer &demuxer); diff --git a/thirdparty/libsimplewebm/VPXDecoder.cpp b/thirdparty/libsimplewebm/VPXDecoder.cpp index 3f77b8f5cd6..e2606f83ba0 100644 --- a/thirdparty/libsimplewebm/VPXDecoder.cpp +++ b/thirdparty/libsimplewebm/VPXDecoder.cpp @@ -33,7 +33,8 @@ VPXDecoder::VPXDecoder(const WebMDemuxer &demuxer, unsigned threads) : m_ctx(NULL), m_iter(NULL), - m_delay(0) + m_delay(0), + m_last_space(VPX_CS_UNKNOWN) { if (threads > 8) threads = 8; @@ -86,6 +87,11 @@ VPXDecoder::IMAGE_ERROR VPXDecoder::getImage(Image &image) IMAGE_ERROR err = NO_FRAME; if (vpx_image_t *img = vpx_codec_get_frame(m_ctx, &m_iter)) { + // It seems to be a common problem that UNKNOWN comes up a lot, yet FFMPEG is somehow getting accurate colour-space information. + // After checking FFMPEG code, *they're* getting colour-space information, so I'm assuming something like this is going on. + // It appears to work, at least. + if (img->cs != VPX_CS_UNKNOWN) + m_last_space = img->cs; if ((img->fmt & VPX_IMG_FMT_PLANAR) && !(img->fmt & (VPX_IMG_FMT_HAS_ALPHA | VPX_IMG_FMT_HIGHBITDEPTH))) { if (img->stride[0] && img->stride[1] && img->stride[2]) @@ -95,6 +101,7 @@ VPXDecoder::IMAGE_ERROR VPXDecoder::getImage(Image &image) image.w = img->d_w; image.h = img->d_h; + image.cs = m_last_space; image.chromaShiftW = img->x_chroma_shift; image.chromaShiftH = img->y_chroma_shift; @@ -119,7 +126,9 @@ VPXDecoder::IMAGE_ERROR VPXDecoder::getImage(Image &image) /**/ +// -- GODOT begin -- #if 0 +// -- GODOT end -- static inline int ceilRshift(int val, int shift) { @@ -139,4 +148,7 @@ int VPXDecoder::Image::getHeight(int plane) const return ceilRshift(h, chromaShiftH); } +// -- GODOT begin -- #endif +// -- GODOT end -- + diff --git a/thirdparty/libsimplewebm/VPXDecoder.hpp b/thirdparty/libsimplewebm/VPXDecoder.hpp index 61083958710..5071b069cb1 100644 --- a/thirdparty/libsimplewebm/VPXDecoder.hpp +++ b/thirdparty/libsimplewebm/VPXDecoder.hpp @@ -37,12 +37,17 @@ public: class Image { public: +// -- GODOT begin -- #if 0 +// -- GODOT end -- int getWidth(int plane) const; int getHeight(int plane) const; +// -- GODOT begin -- #endif +// -- GODOT end -- int w, h; + int cs; int chromaShiftW, chromaShiftH; unsigned char *planes[3]; int linesize[3]; @@ -75,6 +80,7 @@ private: vpx_codec_ctx *m_ctx; const void *m_iter; int m_delay; + int m_last_space; }; #endif // VPXDECODER_HPP