summaryrefslogtreecommitdiff
path: root/modules/webm
diff options
context:
space:
mode:
Diffstat (limited to 'modules/webm')
-rw-r--r--modules/webm/SCsub14
-rw-r--r--modules/webm/config.py1
-rw-r--r--modules/webm/doc_classes/VideoStreamWebm.xml2
-rw-r--r--modules/webm/libvpx/SCsub10
-rw-r--r--modules/webm/video_stream_webm.cpp45
-rw-r--r--modules/webm/video_stream_webm.h5
6 files changed, 44 insertions, 33 deletions
diff --git a/modules/webm/SCsub b/modules/webm/SCsub
index cb35b926ab..32e6727656 100644
--- a/modules/webm/SCsub
+++ b/modules/webm/SCsub
@@ -15,22 +15,18 @@ thirdparty_sources = [
]
thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources]
-env_webm.Append(CPPPATH=[thirdparty_dir, thirdparty_dir + "libwebm/"])
-
-# upstream uses c++11
-if (not env_webm.msvc):
- env_webm.Append(CCFLAGS="-std=c++11")
+env_webm.Prepend(CPPPATH=[thirdparty_dir, thirdparty_dir + "libwebm/"])
# also requires libogg, libvorbis and libopus
if env['builtin_libogg']:
- env_webm.Append(CPPPATH=["#thirdparty/libogg"])
+ env_webm.Prepend(CPPPATH=["#thirdparty/libogg"])
if env['builtin_libvorbis']:
- env_webm.Append(CPPPATH=["#thirdparty/libvorbis"])
+ env_webm.Prepend(CPPPATH=["#thirdparty/libvorbis"])
if env['builtin_opus']:
- env_webm.Append(CPPPATH=["#thirdparty/opus"])
+ env_webm.Prepend(CPPPATH=["#thirdparty/opus"])
if env['builtin_libvpx']:
- env_webm.Append(CPPPATH=["#thirdparty/libvpx"])
+ env_webm.Prepend(CPPPATH=["#thirdparty/libvpx"])
SConscript("libvpx/SCsub")
env_thirdparty = env_webm.Clone()
diff --git a/modules/webm/config.py b/modules/webm/config.py
index 72a4073423..ba4dcce2f5 100644
--- a/modules/webm/config.py
+++ b/modules/webm/config.py
@@ -6,7 +6,6 @@ def configure(env):
def get_doc_classes():
return [
- "ResourceImporterWebm",
"VideoStreamWebm",
]
diff --git a/modules/webm/doc_classes/VideoStreamWebm.xml b/modules/webm/doc_classes/VideoStreamWebm.xml
index 33dff0e93b..ff11bbb37d 100644
--- a/modules/webm/doc_classes/VideoStreamWebm.xml
+++ b/modules/webm/doc_classes/VideoStreamWebm.xml
@@ -6,8 +6,6 @@
</description>
<tutorials>
</tutorials>
- <demos>
- </demos>
<methods>
<method name="get_file">
<return type="String">
diff --git a/modules/webm/libvpx/SCsub b/modules/webm/libvpx/SCsub
index 2639d20620..14fa6c1268 100644
--- a/modules/webm/libvpx/SCsub
+++ b/modules/webm/libvpx/SCsub
@@ -256,7 +256,7 @@ libvpx_sources_arm_neon_gas_apple = [libvpx_dir + file for file in libvpx_source
env_libvpx = env_modules.Clone()
env_libvpx.disable_warnings()
-env_libvpx.Append(CPPPATH=[libvpx_dir])
+env_libvpx.Prepend(CPPPATH=[libvpx_dir])
webm_multithread = env["platform"] != 'javascript'
@@ -323,7 +323,7 @@ if webm_cpu_x86:
elif cpu_bits == '64':
env_libvpx["ASCPU"] = 'X86_64'
- env_libvpx.Append(CCFLAGS=['-DWEBM_X86ASM'])
+ env_libvpx.Append(CPPDEFINES=['WEBM_X86ASM'])
webm_simd_optimizations = True
@@ -337,7 +337,7 @@ if webm_cpu_arm:
env_libvpx["ASFLAGS"] = ''
env_libvpx["ASCOM"] = '$AS $ASFLAGS -o $TARGET $SOURCES'
- env_libvpx.Append(CCFLAGS=['-DWEBM_ARMASM'])
+ env_libvpx.Append(CPPDEFINES=['WEBM_ARMASM'])
webm_simd_optimizations = True
@@ -380,12 +380,10 @@ if webm_cpu_x86:
elif webm_cpu_arm:
env_libvpx.add_source_files(env.modules_sources, libvpx_sources_arm)
if env["platform"] == 'android':
- env_libvpx.Append(CPPPATH=[libvpx_dir + "third_party/android"])
+ env_libvpx.Prepend(CPPPATH=[libvpx_dir + "third_party/android"])
env_libvpx.add_source_files(env.modules_sources, [libvpx_dir + "third_party/android/cpu-features.c"])
env_libvpx_neon = env_libvpx.Clone()
- if env["platform"] == 'android' and env["android_arch"] == 'armv6':
- env_libvpx_neon.Append(CCFLAGS=['-mfpu=neon'])
env_libvpx_neon.add_source_files(env.modules_sources, libvpx_sources_arm_neon)
if env["platform"] == 'uwp':
diff --git a/modules/webm/video_stream_webm.cpp b/modules/webm/video_stream_webm.cpp
index 06f9e39dc7..54b284f939 100644
--- a/modules/webm/video_stream_webm.cpp
+++ b/modules/webm/video_stream_webm.cpp
@@ -32,6 +32,7 @@
#include "OpusVorbisDecoder.hpp"
#include "VPXDecoder.hpp"
+#include <vpx/vpx_image.h>
#include "mkvparser/mkvparser.h"
@@ -52,8 +53,7 @@ public:
file = FileAccess::open(p_file, FileAccess::READ);
- ERR_EXPLAIN("Failed loading resource: '" + p_file + "';");
- ERR_FAIL_COND(!file);
+ ERR_FAIL_COND_MSG(!file, "Failed loading resource: '" + p_file + "'.");
}
~MkvReader() {
@@ -230,7 +230,7 @@ void VideoStreamPlaybackWebm::set_audio_track(int p_idx) {
audio_track = p_idx;
}
-Ref<Texture> VideoStreamPlaybackWebm::get_texture() {
+Ref<Texture> VideoStreamPlaybackWebm::get_texture() const {
return texture;
}
@@ -314,19 +314,37 @@ void VideoStreamPlaybackWebm::update(float p_delta) {
PoolVector<uint8_t>::Write w = frame_data.write();
bool converted = false;
- if (image.chromaShiftW == 1 && image.chromaShiftH == 1) {
+ if (image.chromaShiftW == 0 && image.chromaShiftH == 0 && image.cs == VPX_CS_SRGB) {
+
+ uint8_t *wp = w.ptr();
+ unsigned char *rRow = image.planes[2];
+ unsigned char *gRow = image.planes[0];
+ unsigned char *bRow = image.planes[1];
+ for (int i = 0; i < image.h; i++) {
+ for (int j = 0; j < image.w; j++) {
+ *wp++ = rRow[j];
+ *wp++ = gRow[j];
+ *wp++ = bRow[j];
+ *wp++ = 255;
+ }
+ rRow += image.linesize[2];
+ gRow += image.linesize[0];
+ bRow += image.linesize[1];
+ }
+ converted = true;
+ } else if (image.chromaShiftW == 1 && image.chromaShiftH == 1) {
- yuv420_2_rgb8888(w.ptr(), image.planes[0], image.planes[2], image.planes[1], image.w, image.h, image.linesize[0], image.linesize[1], image.w << 2, 0);
+ yuv420_2_rgb8888(w.ptr(), image.planes[0], image.planes[1], image.planes[2], image.w, image.h, image.linesize[0], image.linesize[1], image.w << 2);
// libyuv::I420ToARGB(image.planes[0], image.linesize[0], image.planes[2], image.linesize[2], image.planes[1], image.linesize[1], w.ptr(), image.w << 2, image.w, image.h);
converted = true;
} else if (image.chromaShiftW == 1 && image.chromaShiftH == 0) {
- yuv422_2_rgb8888(w.ptr(), image.planes[0], image.planes[2], image.planes[1], image.w, image.h, image.linesize[0], image.linesize[1], image.w << 2, 0);
+ yuv422_2_rgb8888(w.ptr(), image.planes[0], image.planes[1], image.planes[2], image.w, image.h, image.linesize[0], image.linesize[1], image.w << 2);
// libyuv::I422ToARGB(image.planes[0], image.linesize[0], image.planes[2], image.linesize[2], image.planes[1], image.linesize[1], w.ptr(), image.w << 2, image.w, image.h);
converted = true;
} else if (image.chromaShiftW == 0 && image.chromaShiftH == 0) {
- yuv444_2_rgb8888(w.ptr(), image.planes[0], image.planes[2], image.planes[1], image.w, image.h, image.linesize[0], image.linesize[1], image.w << 2, 0);
+ yuv444_2_rgb8888(w.ptr(), image.planes[0], image.planes[1], image.planes[2], image.w, image.h, image.linesize[0], image.linesize[1], image.w << 2);
// libyuv::I444ToARGB(image.planes[0], image.linesize[0], image.planes[2], image.linesize[2], image.planes[1], image.linesize[1], w.ptr(), image.w << 2, image.w, image.h);
converted = true;
} else if (image.chromaShiftW == 2 && image.chromaShiftH == 0) {
@@ -375,7 +393,7 @@ int VideoStreamPlaybackWebm::get_mix_rate() const {
inline bool VideoStreamPlaybackWebm::has_enough_video_frames() const {
if (video_frames_pos > 0) {
- const double audio_delay = AudioServer::get_singleton()->get_output_delay();
+ const double audio_delay = AudioServer::get_singleton()->get_output_latency();
const double video_time = video_frames[video_frames_pos - 1]->time;
return video_time >= time + audio_delay + delay_compensation;
}
@@ -383,7 +401,7 @@ inline bool VideoStreamPlaybackWebm::has_enough_video_frames() const {
}
bool VideoStreamPlaybackWebm::should_process(WebMFrame &video_frame) {
- const double audio_delay = AudioServer::get_singleton()->get_output_delay();
+ const double audio_delay = AudioServer::get_singleton()->get_output_latency();
return video_frame.time >= time + audio_delay + delay_compensation;
}
@@ -394,10 +412,11 @@ void VideoStreamPlaybackWebm::delete_pointers() {
if (audio_frame)
memdelete(audio_frame);
- for (int i = 0; i < video_frames_capacity; ++i)
- memdelete(video_frames[i]);
- if (video_frames)
+ if (video_frames) {
+ for (int i = 0; i < video_frames_capacity; ++i)
+ memdelete(video_frames[i]);
memfree(video_frames);
+ }
if (video)
memdelete(video);
@@ -465,6 +484,8 @@ RES ResourceFormatLoaderWebm::load(const String &p_path, const String &p_origina
*r_error = OK;
}
+ f->close();
+ memdelete(f);
return webm_stream;
}
diff --git a/modules/webm/video_stream_webm.h b/modules/webm/video_stream_webm.h
index 992095ba4c..4f79d46cce 100644
--- a/modules/webm/video_stream_webm.h
+++ b/modules/webm/video_stream_webm.h
@@ -41,7 +41,7 @@ class OpusVorbisDecoder;
class VideoStreamPlaybackWebm : public VideoStreamPlayback {
- GDCLASS(VideoStreamPlaybackWebm, VideoStreamPlayback)
+ GDCLASS(VideoStreamPlaybackWebm, VideoStreamPlayback);
String file_name;
int audio_track;
@@ -90,7 +90,7 @@ public:
virtual void set_audio_track(int p_idx);
- virtual Ref<Texture> get_texture();
+ virtual Ref<Texture> get_texture() const;
virtual void update(float p_delta);
virtual void set_mix_callback(AudioMixCallback p_callback, void *p_userdata);
@@ -127,7 +127,6 @@ public:
};
class ResourceFormatLoaderWebm : public ResourceFormatLoader {
- GDCLASS(ResourceFormatLoaderWebm, ResourceFormatLoader)
public:
virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL);
virtual void get_recognized_extensions(List<String> *p_extensions) const;