summaryrefslogtreecommitdiff
path: root/media
diff options
context:
space:
mode:
authorMoonchild <moonchild@palemoon.org>2022-11-07 13:49:11 +0000
committerMoonchild <moonchild@palemoon.org>2022-11-07 13:49:11 +0000
commitd19fb35c6abab93a22d08f8c7fc850ddcc2cbba6 (patch)
treee63daaac8b9dd59a88f4a7d9a55e6f9c0724cddf /media
parent10a37f462e7b4357feda9284dac608c0da0a416e (diff)
parent94554142e9f2aafdae0f2152537e8e2bee89313c (diff)
downloaduxp-d19fb35c6abab93a22d08f8c7fc850ddcc2cbba6.tar.gz
Merge branch 'master' into 1769-take2
Diffstat (limited to 'media')
-rw-r--r--media/ffvpx/changes.patch231
-rw-r--r--media/ffvpx/libavcodec/h264pred.c9
-rw-r--r--media/ffvpx/libavcodec/videodsp.c11
-rw-r--r--media/ffvpx/libavcodec/vp8dsp.c18
-rw-r--r--media/ffvpx/libavcodec/vp9dsp.c13
-rw-r--r--media/ffvpx/libavutil/cpu.c57
-rw-r--r--media/ffvpx/libavutil/float_dsp.c11
-rw-r--r--media/libaom/config/win/ia32/config/av1_rtcd.h24
-rw-r--r--media/libaom/moz.build13
-rw-r--r--media/libaom/src/aom_dsp/aom_simd.h3
-rw-r--r--media/libav/libavcodec/fft_template.c25
-rw-r--r--media/libav/libavutil/cpu.c9
-rw-r--r--media/libav/moz-libav.patch62
-rw-r--r--media/libnestegg/README.md2
-rw-r--r--media/libnestegg/README_MCP2
-rw-r--r--media/libnestegg/include/nestegg.h28
-rw-r--r--media/libnestegg/mcp-avcaacsupport.patch59
-rw-r--r--media/libnestegg/src/nestegg.c172
-rwxr-xr-xmedia/libnestegg/update.sh4
-rw-r--r--media/libogg/include/ogg/os_types.h1
-rw-r--r--media/libsoundtouch/AUTHORS2
-rw-r--r--media/libsoundtouch/LICENSE6
-rw-r--r--media/libsoundtouch/README_MCP (renamed from media/libsoundtouch/README_MOZILLA)4
-rw-r--r--media/libsoundtouch/mcp-disableexceptions.patch13
-rw-r--r--media/libsoundtouch/moz-libsoundtouch.patch33
-rw-r--r--media/libsoundtouch/src/AAFilter.cpp14
-rw-r--r--media/libsoundtouch/src/AAFilter.h7
-rw-r--r--media/libsoundtouch/src/FIFOSampleBuffer.cpp21
-rw-r--r--media/libsoundtouch/src/FIFOSampleBuffer.h12
-rw-r--r--media/libsoundtouch/src/FIFOSamplePipe.h28
-rw-r--r--media/libsoundtouch/src/FIRFilter.cpp103
-rw-r--r--media/libsoundtouch/src/FIRFilter.h8
-rw-r--r--media/libsoundtouch/src/InterpolateCubic.cpp4
-rw-r--r--media/libsoundtouch/src/InterpolateCubic.h14
-rw-r--r--media/libsoundtouch/src/InterpolateLinear.cpp19
-rw-r--r--media/libsoundtouch/src/InterpolateLinear.h30
-rw-r--r--media/libsoundtouch/src/InterpolateShannon.cpp4
-rw-r--r--media/libsoundtouch/src/InterpolateShannon.h14
-rw-r--r--media/libsoundtouch/src/RateTransposer.cpp55
-rw-r--r--media/libsoundtouch/src/RateTransposer.h33
-rw-r--r--media/libsoundtouch/src/STTypes.h47
-rw-r--r--media/libsoundtouch/src/SoundTouch.cpp208
-rw-r--r--media/libsoundtouch/src/SoundTouch.h141
-rw-r--r--media/libsoundtouch/src/SoundTouchFactory.cpp4
-rw-r--r--media/libsoundtouch/src/SoundTouchFactory.h4
-rw-r--r--media/libsoundtouch/src/TDStretch.cpp443
-rw-r--r--media/libsoundtouch/src/TDStretch.h59
-rw-r--r--media/libsoundtouch/src/cpu_detect.h7
-rw-r--r--media/libsoundtouch/src/cpu_detect_x86.cpp8
-rw-r--r--media/libsoundtouch/src/mmx_optimized.cpp43
-rw-r--r--media/libsoundtouch/src/moz.build3
-rw-r--r--media/libsoundtouch/src/sse_optimized.cpp13
-rwxr-xr-xmedia/libsoundtouch/update.sh2
-rw-r--r--media/libtheora/AUTHORS14
-rw-r--r--media/libtheora/LICENSE8
-rw-r--r--media/libtheora/README.md (renamed from media/libtheora/README)110
-rw-r--r--media/libtheora/README_MCP7
-rw-r--r--media/libtheora/README_MOZILLA5
-rw-r--r--media/libtheora/bug468275-r18219.patch22
-rw-r--r--media/libtheora/bug625773-r17780.patch23
-rw-r--r--media/libtheora/bug752139-r18031.patch53
-rw-r--r--media/libtheora/bug752668-r18268.patch28
-rw-r--r--media/libtheora/bug920992.patch103
-rw-r--r--media/libtheora/include/theora/codec.h77
-rw-r--r--media/libtheora/include/theora/theora.h112
-rw-r--r--media/libtheora/include/theora/theoradec.h19
-rw-r--r--media/libtheora/include/theora/theoraenc.h540
-rw-r--r--media/libtheora/lib/apiwrapper.c166
-rw-r--r--media/libtheora/lib/apiwrapper.h54
-rwxr-xr-x[-rw-r--r--]media/libtheora/lib/arm/arm2gnu.pl55
-rw-r--r--media/libtheora/lib/arm/armbits.s8
-rw-r--r--media/libtheora/lib/arm/armcpu.c40
-rw-r--r--media/libtheora/lib/arm/armfrag.s11
-rw-r--r--media/libtheora/lib/arm/armidct.s177
-rw-r--r--media/libtheora/lib/arm/armloop.s8
-rw-r--r--media/libtheora/lib/arm/armopts.s2
-rw-r--r--media/libtheora/lib/bitpack.c2
-rw-r--r--media/libtheora/lib/config.h41
-rw-r--r--media/libtheora/lib/dct.h2
-rw-r--r--media/libtheora/lib/decapiwrapper.c193
-rw-r--r--media/libtheora/lib/decinfo.c36
-rw-r--r--media/libtheora/lib/decint.h3
-rw-r--r--media/libtheora/lib/decode.c1349
-rw-r--r--media/libtheora/lib/dequant.c2
-rw-r--r--media/libtheora/lib/dequant.h2
-rw-r--r--media/libtheora/lib/fragment.c2
-rw-r--r--media/libtheora/lib/huffdec.c2
-rw-r--r--media/libtheora/lib/huffdec.h2
-rw-r--r--media/libtheora/lib/huffman.h4
-rw-r--r--media/libtheora/lib/idct.c13
-rw-r--r--media/libtheora/lib/info.c10
-rw-r--r--media/libtheora/lib/internal.c4
-rw-r--r--media/libtheora/lib/internal.h2
-rw-r--r--media/libtheora/lib/ocintrin.h2
-rw-r--r--media/libtheora/lib/quant.c2
-rw-r--r--media/libtheora/lib/quant.h2
-rw-r--r--media/libtheora/lib/state.c19
-rw-r--r--media/libtheora/lib/x86/mmxfrag.c4
-rw-r--r--media/libtheora/lib/x86/mmxidct.c42
-rw-r--r--media/libtheora/lib/x86/mmxstate.c2
-rw-r--r--media/libtheora/lib/x86/sse2idct.c44
-rw-r--r--media/libtheora/lib/x86/x86cpu.c2
-rw-r--r--media/libtheora/lib/x86/x86cpu.h2
-rw-r--r--media/libtheora/lib/x86/x86int.h2
-rw-r--r--media/libtheora/lib/x86/x86state.c4
-rw-r--r--media/libtheora/lib/x86_vc/mmxfrag.c2
-rw-r--r--media/libtheora/lib/x86_vc/mmxidct.c45
-rw-r--r--media/libtheora/lib/x86_vc/mmxstate.c2
-rw-r--r--media/libtheora/lib/x86_vc/x86cpu.c2
-rw-r--r--media/libtheora/lib/x86_vc/x86cpu.h2
-rw-r--r--media/libtheora/lib/x86_vc/x86int.h2
-rw-r--r--media/libtheora/lib/x86_vc/x86state.c2
-rw-r--r--media/libtheora/moz.build36
-rwxr-xr-x[-rw-r--r--]media/libtheora/update.sh14
-rw-r--r--media/libtremor/README_MCP7
-rw-r--r--media/libtremor/README_MOZILLA7
-rw-r--r--media/libtremor/bug1117571-r19420.patch18
-rw-r--r--media/libtremor/bug719612.patch21
-rw-r--r--media/libtremor/lib/misc.h4
-rw-r--r--media/libtremor/lib/moz.build3
-rw-r--r--media/libtremor/lib/tremor_floor0.c1
-rw-r--r--media/libtremor/lib/tremor_floor1.c5
-rw-r--r--media/libtremor/lib/tremor_info.c13
-rw-r--r--media/libtremor/lib/tremor_mdct.c2
-rw-r--r--media/libtremor/lib/tremor_synthesis.c2
-rwxr-xr-xmedia/libtremor/update.sh4
-rw-r--r--media/mtransport/nr_socket_prsock.cpp34
-rw-r--r--media/mtransport/nr_socket_prsock.h3
-rw-r--r--media/mtransport/nricectx.cpp9
-rw-r--r--media/mtransport/nricectx.h1
-rw-r--r--media/mtransport/test_nr_socket.cpp55
-rw-r--r--media/mtransport/test_nr_socket.h3
-rw-r--r--media/mtransport/third_party/nICEr/src/ice/ice_candidate.c8
-rw-r--r--media/mtransport/third_party/nICEr/src/ice/ice_ctx.h1
-rw-r--r--media/mtransport/third_party/nICEr/src/net/transport_addr.h1
-rw-r--r--media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp24
-rw-r--r--media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.h1
-rw-r--r--media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.cpp11
-rw-r--r--media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.h3
-rw-r--r--media/webrtc/trunk/webrtc/modules/audio_coding/neteq/audio_classifier.cc2
-rw-r--r--media/webrtc/trunk/webrtc/system_wrappers/source/tick_util.cc2
141 files changed, 2853 insertions, 3097 deletions
diff --git a/media/ffvpx/changes.patch b/media/ffvpx/changes.patch
index 49a49b26b7..b3a1125dc0 100644
--- a/media/ffvpx/changes.patch
+++ b/media/ffvpx/changes.patch
@@ -50,3 +50,234 @@ index 9fb8d0a..97ad3b9 100644
rgba_color[0] = rgba >> 24;
rgba_color[1] = rgba >> 16;
rgba_color[2] = rgba >> 8;
+
+
+diff --git a/media/ffvpx/libavcodec/h264pred.c b/media/ffvpx/libavcodec/h264pred.c
+index 5632a58fd..f9f3af50e 100644
+--- a/media/ffvpx/libavcodec/h264pred.c
++++ b/media/ffvpx/libavcodec/h264pred.c
+@@ -592,12 +592,13 @@ av_cold void ff_h264_pred_init(H264PredContext *h, int codec_id,
+ break;
+ }
+
+- if (ARCH_AARCH64)
++ #if ARCH_AARCH64 == 1
+ ff_h264_pred_init_aarch64(h, codec_id, bit_depth, chroma_format_idc);
+- if (ARCH_ARM)
++ #elif ARCH_ARM == 1
+ ff_h264_pred_init_arm(h, codec_id, bit_depth, chroma_format_idc);
+- if (ARCH_X86)
++ #elif ARCH_X86 == 1
+ ff_h264_pred_init_x86(h, codec_id, bit_depth, chroma_format_idc);
+- if (ARCH_MIPS)
++ #elif ARCH_MIPS == 1
+ ff_h264_pred_init_mips(h, codec_id, bit_depth, chroma_format_idc);
++ #endif
+ }
+diff --git a/media/ffvpx/libavcodec/videodsp.c b/media/ffvpx/libavcodec/videodsp.c
+index ce9e9eb14..4f082a426 100644
+--- a/media/ffvpx/libavcodec/videodsp.c
++++ b/media/ffvpx/libavcodec/videodsp.c
+@@ -44,14 +44,15 @@ av_cold void ff_videodsp_init(VideoDSPContext *ctx, int bpc)
+ ctx->emulated_edge_mc = ff_emulated_edge_mc_16;
+ }
+
+- if (ARCH_AARCH64)
++ #if ARCH_AARCH64 == 1
+ ff_videodsp_init_aarch64(ctx, bpc);
+- if (ARCH_ARM)
++ #elif ARCH_ARM == 1
+ ff_videodsp_init_arm(ctx, bpc);
+- if (ARCH_PPC)
++ #elif ARCH_PPC == 1
+ ff_videodsp_init_ppc(ctx, bpc);
+- if (ARCH_X86)
++ #elif ARCH_X86 == 1
+ ff_videodsp_init_x86(ctx, bpc);
+- if (ARCH_MIPS)
++ #elif ARCH_MIPS == 1
+ ff_videodsp_init_mips(ctx, bpc);
++ #endif
+ }
+diff --git a/media/ffvpx/libavcodec/vp8dsp.c b/media/ffvpx/libavcodec/vp8dsp.c
+index 4ff63d078..efaf3e71a 100644
+--- a/media/ffvpx/libavcodec/vp8dsp.c
++++ b/media/ffvpx/libavcodec/vp8dsp.c
+@@ -673,14 +673,15 @@ av_cold void ff_vp78dsp_init(VP8DSPContext *dsp)
+ VP78_BILINEAR_MC_FUNC(1, 8);
+ VP78_BILINEAR_MC_FUNC(2, 4);
+
+- if (ARCH_AARCH64)
++ #if ARCH_AARCH64 == 1
+ ff_vp78dsp_init_aarch64(dsp);
+- if (ARCH_ARM)
++ #elif ARCH_ARM == 1
+ ff_vp78dsp_init_arm(dsp);
+- if (ARCH_PPC)
++ #elif ARCH_PPC == 1
+ ff_vp78dsp_init_ppc(dsp);
+- if (ARCH_X86)
++ #elif ARCH_X86 == 1
+ ff_vp78dsp_init_x86(dsp);
++ #endif
+ }
+
+ #if CONFIG_VP7_DECODER
+@@ -735,13 +736,14 @@ av_cold void ff_vp8dsp_init(VP8DSPContext *dsp)
+ dsp->vp8_v_loop_filter_simple = vp8_v_loop_filter_simple_c;
+ dsp->vp8_h_loop_filter_simple = vp8_h_loop_filter_simple_c;
+
+- if (ARCH_AARCH64)
++ #if ARCH_AARCH64 == 1
+ ff_vp8dsp_init_aarch64(dsp);
+- if (ARCH_ARM)
++ #elif ARCH_ARM == 1
+ ff_vp8dsp_init_arm(dsp);
+- if (ARCH_X86)
++ #elif ARCH_X86 == 1
+ ff_vp8dsp_init_x86(dsp);
+- if (ARCH_MIPS)
++ #elif ARCH_MIPS == 1
+ ff_vp8dsp_init_mips(dsp);
++ #endif
+ }
+ #endif /* CONFIG_VP8_DECODER */
+diff --git a/media/ffvpx/libavcodec/vp9dsp.c b/media/ffvpx/libavcodec/vp9dsp.c
+index f6d73f73c..b8fa3be36 100644
+--- a/media/ffvpx/libavcodec/vp9dsp.c
++++ b/media/ffvpx/libavcodec/vp9dsp.c
+@@ -92,8 +92,13 @@ av_cold void ff_vp9dsp_init(VP9DSPContext *dsp, int bpp, int bitexact)
+ ff_vp9dsp_init_12(dsp);
+ }
+
+- if (ARCH_AARCH64) ff_vp9dsp_init_aarch64(dsp, bpp);
+- if (ARCH_ARM) ff_vp9dsp_init_arm(dsp, bpp);
+- if (ARCH_X86) ff_vp9dsp_init_x86(dsp, bpp, bitexact);
+- if (ARCH_MIPS) ff_vp9dsp_init_mips(dsp, bpp);
++ #if ARCH_AARCH64 == 1
++ ff_vp9dsp_init_aarch64(dsp, bpp);
++ #elif ARCH_ARM == 1
++ ff_vp9dsp_init_arm(dsp, bpp);
++ #elif ARCH_X86 == 1
++ ff_vp9dsp_init_x86(dsp, bpp, bitexact);
++ #elif ARCH_MIPS == 1
++ ff_vp9dsp_init_mips(dsp, bpp);
++ #endif
+ }
+diff --git a/media/ffvpx/libavutil/cpu.c b/media/ffvpx/libavutil/cpu.c
+index 6548cc304..2cf1a3829 100644
+--- a/media/ffvpx/libavutil/cpu.c
++++ b/media/ffvpx/libavutil/cpu.c
+@@ -51,41 +51,43 @@ static atomic_int cpu_flags = ATOMIC_VAR_INIT(-1);
+
+ static int get_cpu_flags(void)
+ {
+- if (ARCH_AARCH64)
++ #if ARCH_AARCH64 == 1
+ return ff_get_cpu_flags_aarch64();
+- if (ARCH_ARM)
++ #elif ARCH_ARM == 1
+ return ff_get_cpu_flags_arm();
+- if (ARCH_PPC)
++ #elif ARCH_PPC == 1
+ return ff_get_cpu_flags_ppc();
+- if (ARCH_X86)
++ #elif ARCH_X86 == 1
+ return ff_get_cpu_flags_x86();
++ #endif
+ return 0;
+ }
+
+ void av_force_cpu_flags(int arg){
+- if (ARCH_X86 &&
+- (arg & ( AV_CPU_FLAG_3DNOW |
+- AV_CPU_FLAG_3DNOWEXT |
+- AV_CPU_FLAG_MMXEXT |
+- AV_CPU_FLAG_SSE |
+- AV_CPU_FLAG_SSE2 |
+- AV_CPU_FLAG_SSE2SLOW |
+- AV_CPU_FLAG_SSE3 |
+- AV_CPU_FLAG_SSE3SLOW |
+- AV_CPU_FLAG_SSSE3 |
+- AV_CPU_FLAG_SSE4 |
+- AV_CPU_FLAG_SSE42 |
+- AV_CPU_FLAG_AVX |
+- AV_CPU_FLAG_AVXSLOW |
+- AV_CPU_FLAG_XOP |
+- AV_CPU_FLAG_FMA3 |
+- AV_CPU_FLAG_FMA4 |
+- AV_CPU_FLAG_AVX2 |
+- AV_CPU_FLAG_AVX512 ))
++ #if ARCH_X86 == 1
++ if ((arg & (AV_CPU_FLAG_3DNOW |
++ AV_CPU_FLAG_3DNOWEXT |
++ AV_CPU_FLAG_MMXEXT |
++ AV_CPU_FLAG_SSE |
++ AV_CPU_FLAG_SSE2 |
++ AV_CPU_FLAG_SSE2SLOW |
++ AV_CPU_FLAG_SSE3 |
++ AV_CPU_FLAG_SSE3SLOW |
++ AV_CPU_FLAG_SSSE3 |
++ AV_CPU_FLAG_SSE4 |
++ AV_CPU_FLAG_SSE42 |
++ AV_CPU_FLAG_AVX |
++ AV_CPU_FLAG_AVXSLOW |
++ AV_CPU_FLAG_XOP |
++ AV_CPU_FLAG_FMA3 |
++ AV_CPU_FLAG_FMA4 |
++ AV_CPU_FLAG_AVX2 |
++ AV_CPU_FLAG_AVX512 ))
+ && !(arg & AV_CPU_FLAG_MMX)) {
+ av_log(NULL, AV_LOG_WARNING, "MMX implied by specified flags\n");
+ arg |= AV_CPU_FLAG_MMX;
+ }
++ #endif
+
+ atomic_store_explicit(&cpu_flags, arg, memory_order_relaxed);
+ }
+@@ -308,14 +310,15 @@ int av_cpu_count(void)
+
+ size_t av_cpu_max_align(void)
+ {
+- if (ARCH_AARCH64)
++ #if ARCH_AARCH64 == 1
+ return ff_get_cpu_max_align_aarch64();
+- if (ARCH_ARM)
++ #elif ARCH_ARM == 1
+ return ff_get_cpu_max_align_arm();
+- if (ARCH_PPC)
++ #elif ARCH_PPC == 1
+ return ff_get_cpu_max_align_ppc();
+- if (ARCH_X86)
++ #elif ARCH_X86 == 1
+ return ff_get_cpu_max_align_x86();
++ #endif
+
+ return 8;
+ }
+diff --git a/media/ffvpx/libavutil/float_dsp.c b/media/ffvpx/libavutil/float_dsp.c
+index 6e28d71b5..6c30dafc5 100644
+--- a/media/ffvpx/libavutil/float_dsp.c
++++ b/media/ffvpx/libavutil/float_dsp.c
+@@ -150,15 +150,16 @@ av_cold AVFloatDSPContext *avpriv_float_dsp_alloc(int bit_exact)
+ fdsp->butterflies_float = butterflies_float_c;
+ fdsp->scalarproduct_float = avpriv_scalarproduct_float_c;
+
+- if (ARCH_AARCH64)
++ #if ARCH_AARCH64 == 1
+ ff_float_dsp_init_aarch64(fdsp);
+- if (ARCH_ARM)
++ #elif ARCH_ARM == 1
+ ff_float_dsp_init_arm(fdsp);
+- if (ARCH_PPC)
++ #elif ARCH_PPC == 1
+ ff_float_dsp_init_ppc(fdsp, bit_exact);
+- if (ARCH_X86)
++ #elif ARCH_X86 == 1
+ ff_float_dsp_init_x86(fdsp);
+- if (ARCH_MIPS)
++ #elif ARCH_MIPS == 1
+ ff_float_dsp_init_mips(fdsp);
++ #endif
+ return fdsp;
+ } \ No newline at end of file
diff --git a/media/ffvpx/libavcodec/h264pred.c b/media/ffvpx/libavcodec/h264pred.c
index 5632a58fd7..f9f3af50e2 100644
--- a/media/ffvpx/libavcodec/h264pred.c
+++ b/media/ffvpx/libavcodec/h264pred.c
@@ -592,12 +592,13 @@ av_cold void ff_h264_pred_init(H264PredContext *h, int codec_id,
break;
}
- if (ARCH_AARCH64)
+ #if ARCH_AARCH64 == 1
ff_h264_pred_init_aarch64(h, codec_id, bit_depth, chroma_format_idc);
- if (ARCH_ARM)
+ #elif ARCH_ARM == 1
ff_h264_pred_init_arm(h, codec_id, bit_depth, chroma_format_idc);
- if (ARCH_X86)
+ #elif ARCH_X86 == 1
ff_h264_pred_init_x86(h, codec_id, bit_depth, chroma_format_idc);
- if (ARCH_MIPS)
+ #elif ARCH_MIPS == 1
ff_h264_pred_init_mips(h, codec_id, bit_depth, chroma_format_idc);
+ #endif
}
diff --git a/media/ffvpx/libavcodec/videodsp.c b/media/ffvpx/libavcodec/videodsp.c
index ce9e9eb143..4f082a4267 100644
--- a/media/ffvpx/libavcodec/videodsp.c
+++ b/media/ffvpx/libavcodec/videodsp.c
@@ -44,14 +44,15 @@ av_cold void ff_videodsp_init(VideoDSPContext *ctx, int bpc)
ctx->emulated_edge_mc = ff_emulated_edge_mc_16;
}
- if (ARCH_AARCH64)
+ #if ARCH_AARCH64 == 1
ff_videodsp_init_aarch64(ctx, bpc);
- if (ARCH_ARM)
+ #elif ARCH_ARM == 1
ff_videodsp_init_arm(ctx, bpc);
- if (ARCH_PPC)
+ #elif ARCH_PPC == 1
ff_videodsp_init_ppc(ctx, bpc);
- if (ARCH_X86)
+ #elif ARCH_X86 == 1
ff_videodsp_init_x86(ctx, bpc);
- if (ARCH_MIPS)
+ #elif ARCH_MIPS == 1
ff_videodsp_init_mips(ctx, bpc);
+ #endif
}
diff --git a/media/ffvpx/libavcodec/vp8dsp.c b/media/ffvpx/libavcodec/vp8dsp.c
index 4ff63d0784..efaf3e71a7 100644
--- a/media/ffvpx/libavcodec/vp8dsp.c
+++ b/media/ffvpx/libavcodec/vp8dsp.c
@@ -673,14 +673,15 @@ av_cold void ff_vp78dsp_init(VP8DSPContext *dsp)
VP78_BILINEAR_MC_FUNC(1, 8);
VP78_BILINEAR_MC_FUNC(2, 4);
- if (ARCH_AARCH64)
+ #if ARCH_AARCH64 == 1
ff_vp78dsp_init_aarch64(dsp);
- if (ARCH_ARM)
+ #elif ARCH_ARM == 1
ff_vp78dsp_init_arm(dsp);
- if (ARCH_PPC)
+ #elif ARCH_PPC == 1
ff_vp78dsp_init_ppc(dsp);
- if (ARCH_X86)
+ #elif ARCH_X86 == 1
ff_vp78dsp_init_x86(dsp);
+ #endif
}
#if CONFIG_VP7_DECODER
@@ -735,13 +736,14 @@ av_cold void ff_vp8dsp_init(VP8DSPContext *dsp)
dsp->vp8_v_loop_filter_simple = vp8_v_loop_filter_simple_c;
dsp->vp8_h_loop_filter_simple = vp8_h_loop_filter_simple_c;
- if (ARCH_AARCH64)
+ #if ARCH_AARCH64 == 1
ff_vp8dsp_init_aarch64(dsp);
- if (ARCH_ARM)
+ #elif ARCH_ARM == 1
ff_vp8dsp_init_arm(dsp);
- if (ARCH_X86)
+ #elif ARCH_X86 == 1
ff_vp8dsp_init_x86(dsp);
- if (ARCH_MIPS)
+ #elif ARCH_MIPS == 1
ff_vp8dsp_init_mips(dsp);
+ #endif
}
#endif /* CONFIG_VP8_DECODER */
diff --git a/media/ffvpx/libavcodec/vp9dsp.c b/media/ffvpx/libavcodec/vp9dsp.c
index f6d73f73cd..b8fa3be36d 100644
--- a/media/ffvpx/libavcodec/vp9dsp.c
+++ b/media/ffvpx/libavcodec/vp9dsp.c
@@ -92,8 +92,13 @@ av_cold void ff_vp9dsp_init(VP9DSPContext *dsp, int bpp, int bitexact)
ff_vp9dsp_init_12(dsp);
}
- if (ARCH_AARCH64) ff_vp9dsp_init_aarch64(dsp, bpp);
- if (ARCH_ARM) ff_vp9dsp_init_arm(dsp, bpp);
- if (ARCH_X86) ff_vp9dsp_init_x86(dsp, bpp, bitexact);
- if (ARCH_MIPS) ff_vp9dsp_init_mips(dsp, bpp);
+ #if ARCH_AARCH64 == 1
+ ff_vp9dsp_init_aarch64(dsp, bpp);
+ #elif ARCH_ARM == 1
+ ff_vp9dsp_init_arm(dsp, bpp);
+ #elif ARCH_X86 == 1
+ ff_vp9dsp_init_x86(dsp, bpp, bitexact);
+ #elif ARCH_MIPS == 1
+ ff_vp9dsp_init_mips(dsp, bpp);
+ #endif
}
diff --git a/media/ffvpx/libavutil/cpu.c b/media/ffvpx/libavutil/cpu.c
index 6548cc3042..2cf1a38297 100644
--- a/media/ffvpx/libavutil/cpu.c
+++ b/media/ffvpx/libavutil/cpu.c
@@ -51,41 +51,43 @@ static atomic_int cpu_flags = ATOMIC_VAR_INIT(-1);
static int get_cpu_flags(void)
{
- if (ARCH_AARCH64)
+ #if ARCH_AARCH64 == 1
return ff_get_cpu_flags_aarch64();
- if (ARCH_ARM)
+ #elif ARCH_ARM == 1
return ff_get_cpu_flags_arm();
- if (ARCH_PPC)
+ #elif ARCH_PPC == 1
return ff_get_cpu_flags_ppc();
- if (ARCH_X86)
+ #elif ARCH_X86 == 1
return ff_get_cpu_flags_x86();
+ #endif
return 0;
}
void av_force_cpu_flags(int arg){
- if (ARCH_X86 &&
- (arg & ( AV_CPU_FLAG_3DNOW |
- AV_CPU_FLAG_3DNOWEXT |
- AV_CPU_FLAG_MMXEXT |
- AV_CPU_FLAG_SSE |
- AV_CPU_FLAG_SSE2 |
- AV_CPU_FLAG_SSE2SLOW |
- AV_CPU_FLAG_SSE3 |
- AV_CPU_FLAG_SSE3SLOW |
- AV_CPU_FLAG_SSSE3 |
- AV_CPU_FLAG_SSE4 |
- AV_CPU_FLAG_SSE42 |
- AV_CPU_FLAG_AVX |
- AV_CPU_FLAG_AVXSLOW |
- AV_CPU_FLAG_XOP |
- AV_CPU_FLAG_FMA3 |
- AV_CPU_FLAG_FMA4 |
- AV_CPU_FLAG_AVX2 |
- AV_CPU_FLAG_AVX512 ))
+ #if ARCH_X86 == 1
+ if ((arg & (AV_CPU_FLAG_3DNOW |
+ AV_CPU_FLAG_3DNOWEXT |
+ AV_CPU_FLAG_MMXEXT |
+ AV_CPU_FLAG_SSE |
+ AV_CPU_FLAG_SSE2 |
+ AV_CPU_FLAG_SSE2SLOW |
+ AV_CPU_FLAG_SSE3 |
+ AV_CPU_FLAG_SSE3SLOW |
+ AV_CPU_FLAG_SSSE3 |
+ AV_CPU_FLAG_SSE4 |
+ AV_CPU_FLAG_SSE42 |
+ AV_CPU_FLAG_AVX |
+ AV_CPU_FLAG_AVXSLOW |
+ AV_CPU_FLAG_XOP |
+ AV_CPU_FLAG_FMA3 |
+ AV_CPU_FLAG_FMA4 |
+ AV_CPU_FLAG_AVX2 |
+ AV_CPU_FLAG_AVX512 ))
&& !(arg & AV_CPU_FLAG_MMX)) {
av_log(NULL, AV_LOG_WARNING, "MMX implied by specified flags\n");
arg |= AV_CPU_FLAG_MMX;
}
+ #endif
atomic_store_explicit(&cpu_flags, arg, memory_order_relaxed);
}
@@ -308,14 +310,15 @@ int av_cpu_count(void)
size_t av_cpu_max_align(void)
{
- if (ARCH_AARCH64)
+ #if ARCH_AARCH64 == 1
return ff_get_cpu_max_align_aarch64();
- if (ARCH_ARM)
+ #elif ARCH_ARM == 1
return ff_get_cpu_max_align_arm();
- if (ARCH_PPC)
+ #elif ARCH_PPC == 1
return ff_get_cpu_max_align_ppc();
- if (ARCH_X86)
+ #elif ARCH_X86 == 1
return ff_get_cpu_max_align_x86();
+ #endif
return 8;
}
diff --git a/media/ffvpx/libavutil/float_dsp.c b/media/ffvpx/libavutil/float_dsp.c
index 6e28d71b57..6c30dafc56 100644
--- a/media/ffvpx/libavutil/float_dsp.c
+++ b/media/ffvpx/libavutil/float_dsp.c
@@ -150,15 +150,16 @@ av_cold AVFloatDSPContext *avpriv_float_dsp_alloc(int bit_exact)
fdsp->butterflies_float = butterflies_float_c;
fdsp->scalarproduct_float = avpriv_scalarproduct_float_c;
- if (ARCH_AARCH64)
+ #if ARCH_AARCH64 == 1
ff_float_dsp_init_aarch64(fdsp);
- if (ARCH_ARM)
+ #elif ARCH_ARM == 1
ff_float_dsp_init_arm(fdsp);
- if (ARCH_PPC)
+ #elif ARCH_PPC == 1
ff_float_dsp_init_ppc(fdsp, bit_exact);
- if (ARCH_X86)
+ #elif ARCH_X86 == 1
ff_float_dsp_init_x86(fdsp);
- if (ARCH_MIPS)
+ #elif ARCH_MIPS == 1
ff_float_dsp_init_mips(fdsp);
+ #endif
return fdsp;
}
diff --git a/media/libaom/config/win/ia32/config/av1_rtcd.h b/media/libaom/config/win/ia32/config/av1_rtcd.h
index 14c816a8a9..4a86760ce0 100644
--- a/media/libaom/config/win/ia32/config/av1_rtcd.h
+++ b/media/libaom/config/win/ia32/config/av1_rtcd.h
@@ -701,65 +701,89 @@ static void setup_rtcd_internal(void)
if (flags & HAS_SSE2) av1_wiener_convolve_add_src = av1_wiener_convolve_add_src_sse2;
if (flags & HAS_AVX2) av1_wiener_convolve_add_src = av1_wiener_convolve_add_src_avx2;
cdef_copy_rect8_16bit_to_16bit = cdef_copy_rect8_16bit_to_16bit_c;
+ if (_MSC_VER <= 1900) {
if (flags & HAS_SSE2) cdef_copy_rect8_16bit_to_16bit = cdef_copy_rect8_16bit_to_16bit_sse2;
if (flags & HAS_SSSE3) cdef_copy_rect8_16bit_to_16bit = cdef_copy_rect8_16bit_to_16bit_ssse3;
if (flags & HAS_SSE4_1) cdef_copy_rect8_16bit_to_16bit = cdef_copy_rect8_16bit_to_16bit_sse4_1;
if (flags & HAS_AVX2) cdef_copy_rect8_16bit_to_16bit = cdef_copy_rect8_16bit_to_16bit_avx2;
+ }
cdef_copy_rect8_8bit_to_16bit = cdef_copy_rect8_8bit_to_16bit_c;
+ if (_MSC_VER <= 1900) {
if (flags & HAS_SSE2) cdef_copy_rect8_8bit_to_16bit = cdef_copy_rect8_8bit_to_16bit_sse2;
if (flags & HAS_SSSE3) cdef_copy_rect8_8bit_to_16bit = cdef_copy_rect8_8bit_to_16bit_ssse3;
if (flags & HAS_SSE4_1) cdef_copy_rect8_8bit_to_16bit = cdef_copy_rect8_8bit_to_16bit_sse4_1;
if (flags & HAS_AVX2) cdef_copy_rect8_8bit_to_16bit = cdef_copy_rect8_8bit_to_16bit_avx2;
+ }
cdef_filter_16_0 = cdef_filter_16_0_c;
+ if (_MSC_VER <= 1900) {
if (flags & HAS_SSE2) cdef_filter_16_0 = cdef_filter_16_0_sse2;
if (flags & HAS_SSSE3) cdef_filter_16_0 = cdef_filter_16_0_ssse3;
if (flags & HAS_SSE4_1) cdef_filter_16_0 = cdef_filter_16_0_sse4_1;
if (flags & HAS_AVX2) cdef_filter_16_0 = cdef_filter_16_0_avx2;
+ }
cdef_filter_16_1 = cdef_filter_16_1_c;
+ if (_MSC_VER <= 1900) {
if (flags & HAS_SSE2) cdef_filter_16_1 = cdef_filter_16_1_sse2;
if (flags & HAS_SSSE3) cdef_filter_16_1 = cdef_filter_16_1_ssse3;
if (flags & HAS_SSE4_1) cdef_filter_16_1 = cdef_filter_16_1_sse4_1;
if (flags & HAS_AVX2) cdef_filter_16_1 = cdef_filter_16_1_avx2;
+ }
cdef_filter_16_2 = cdef_filter_16_2_c;
+ if (_MSC_VER <= 1900) {
if (flags & HAS_SSE2) cdef_filter_16_2 = cdef_filter_16_2_sse2;
if (flags & HAS_SSSE3) cdef_filter_16_2 = cdef_filter_16_2_ssse3;
if (flags & HAS_SSE4_1) cdef_filter_16_2 = cdef_filter_16_2_sse4_1;
if (flags & HAS_AVX2) cdef_filter_16_2 = cdef_filter_16_2_avx2;
+ }
cdef_filter_16_3 = cdef_filter_16_3_c;
+ if (_MSC_VER <= 1900) {
if (flags & HAS_SSE2) cdef_filter_16_3 = cdef_filter_16_3_sse2;
if (flags & HAS_SSSE3) cdef_filter_16_3 = cdef_filter_16_3_ssse3;
if (flags & HAS_SSE4_1) cdef_filter_16_3 = cdef_filter_16_3_sse4_1;
if (flags & HAS_AVX2) cdef_filter_16_3 = cdef_filter_16_3_avx2;
+ }
cdef_filter_8_0 = cdef_filter_8_0_c;
+ if (_MSC_VER <= 1900) {
if (flags & HAS_SSE2) cdef_filter_8_0 = cdef_filter_8_0_sse2;
if (flags & HAS_SSSE3) cdef_filter_8_0 = cdef_filter_8_0_ssse3;
if (flags & HAS_SSE4_1) cdef_filter_8_0 = cdef_filter_8_0_sse4_1;
if (flags & HAS_AVX2) cdef_filter_8_0 = cdef_filter_8_0_avx2;
+ }
cdef_filter_8_1 = cdef_filter_8_1_c;
+ if (_MSC_VER <= 1900) {
if (flags & HAS_SSE2) cdef_filter_8_1 = cdef_filter_8_1_sse2;
if (flags & HAS_SSSE3) cdef_filter_8_1 = cdef_filter_8_1_ssse3;
if (flags & HAS_SSE4_1) cdef_filter_8_1 = cdef_filter_8_1_sse4_1;
if (flags & HAS_AVX2) cdef_filter_8_1 = cdef_filter_8_1_avx2;
+ }
cdef_filter_8_2 = cdef_filter_8_2_c;
+ if (_MSC_VER <= 1900) {
if (flags & HAS_SSE2) cdef_filter_8_2 = cdef_filter_8_2_sse2;
if (flags & HAS_SSSE3) cdef_filter_8_2 = cdef_filter_8_2_ssse3;
if (flags & HAS_SSE4_1) cdef_filter_8_2 = cdef_filter_8_2_sse4_1;
if (flags & HAS_AVX2) cdef_filter_8_2 = cdef_filter_8_2_avx2;
+ }
cdef_filter_8_3 = cdef_filter_8_3_c;
+ if (_MSC_VER <= 1900) {
if (flags & HAS_SSE2) cdef_filter_8_3 = cdef_filter_8_3_sse2;
if (flags & HAS_SSSE3) cdef_filter_8_3 = cdef_filter_8_3_ssse3;
if (flags & HAS_SSE4_1) cdef_filter_8_3 = cdef_filter_8_3_sse4_1;
if (flags & HAS_AVX2) cdef_filter_8_3 = cdef_filter_8_3_avx2;
+ }
cdef_find_dir = cdef_find_dir_c;
+ if (_MSC_VER <= 1900) {
if (flags & HAS_SSE2) cdef_find_dir = cdef_find_dir_sse2;
if (flags & HAS_SSSE3) cdef_find_dir = cdef_find_dir_ssse3;
if (flags & HAS_SSE4_1) cdef_find_dir = cdef_find_dir_sse4_1;
if (flags & HAS_AVX2) cdef_find_dir = cdef_find_dir_avx2;
+ }
cdef_find_dir_dual = cdef_find_dir_dual_c;
+ if (_MSC_VER <= 1900) {
if (flags & HAS_SSE2) cdef_find_dir_dual = cdef_find_dir_dual_sse2;
if (flags & HAS_SSSE3) cdef_find_dir_dual = cdef_find_dir_dual_ssse3;
if (flags & HAS_SSE4_1) cdef_find_dir_dual = cdef_find_dir_dual_sse4_1;
if (flags & HAS_AVX2) cdef_find_dir_dual = cdef_find_dir_dual_avx2;
+ }
cfl_get_luma_subsampling_420_hbd = cfl_get_luma_subsampling_420_hbd_c;
if (flags & HAS_SSSE3) cfl_get_luma_subsampling_420_hbd = cfl_get_luma_subsampling_420_hbd_ssse3;
if (flags & HAS_AVX2) cfl_get_luma_subsampling_420_hbd = cfl_get_luma_subsampling_420_hbd_avx2;
diff --git a/media/libaom/moz.build b/media/libaom/moz.build
index 68da0406c0..adc5892f37 100644
--- a/media/libaom/moz.build
+++ b/media/libaom/moz.build
@@ -105,7 +105,18 @@ if CONFIG['CLANG_CL'] or not CONFIG['_MSC_VER']:
SOURCES[f].flags += ['-mavx']
elif f.endswith('avx2.c'):
SOURCES[f].flags += ['-mavx2']
-
+if CONFIG['_MSC_VER']:
+ for f in SOURCES:
+ # MSVC massively chokes on inlining these SIMD sources, so disable inlining for them.
+ if f.endswith('cdef_block_sse2.c'):
+ SOURCES[f].flags += ['-Ob0']
+ elif f.endswith('cdef_block_ssse3.c'):
+ SOURCES[f].flags += ['-Ob0']
+ elif f.endswith('cdef_block_sse4.c'):
+ SOURCES[f].flags += ['-Ob0']
+ elif f.endswith('cdef_block_avx2.c'):
+ SOURCES[f].flags += ['-Ob0']
+
# Suppress warnings in third-party code.
if CONFIG['GNU_CC'] or CONFIG['CLANG_CL']:
CFLAGS += [
diff --git a/media/libaom/src/aom_dsp/aom_simd.h b/media/libaom/src/aom_dsp/aom_simd.h
index ab950ca55b..4c435aa7c0 100644
--- a/media/libaom/src/aom_dsp/aom_simd.h
+++ b/media/libaom/src/aom_dsp/aom_simd.h
@@ -29,7 +29,8 @@
// VS compiling for 32 bit targets does not support vector types in
// structs as arguments, which makes the v256 type of the intrinsics
// hard to support, so optimizations for this target are disabled.
-#elif HAVE_SSE2 && (defined(_WIN64) || !defined(_MSC_VER) || defined(__clang__))
+// Disabling optimizations and falling back to plain C here causes problems on newer MSVC.
+#elif HAVE_SSE2 && (defined(_WIN64) || !defined(_MSC_VER) || _MSC_VER > 1900 || defined(__clang__))
#include "simd/v256_intrinsics_x86.h"
#else
#include "simd/v256_intrinsics.h"
diff --git a/media/libav/libavcodec/fft_template.c b/media/libav/libavcodec/fft_template.c
index 808f317c17..9d21ffa6b5 100644
--- a/media/libav/libavcodec/fft_template.c
+++ b/media/libav/libavcodec/fft_template.c
@@ -158,14 +158,25 @@ av_cold int ff_fft_init(FFTContext *s, int nbits, int inverse)
#endif
#if FFT_FLOAT
- if (ARCH_AARCH64) ff_fft_init_aarch64(s);
- if (ARCH_ARM) ff_fft_init_arm(s);
- if (ARCH_PPC) ff_fft_init_ppc(s);
- if (ARCH_X86) ff_fft_init_x86(s);
- if (CONFIG_MDCT) s->mdct_calcw = s->mdct_calc;
+ #if ARCH_AARCH64 == 1
+ ff_fft_init_aarch64(s);
+ #elif ARCH_ARM == 1
+ ff_fft_init_arm(s);
+ #elif ARCH_PPC == 1
+ ff_fft_init_ppc(s);
+ #elif ARCH_X86 == 1
+ ff_fft_init_x86(s);
+ #endif
+ #if CONFIG_MDCT
+ s->mdct_calcw = s->mdct_calc;
+ #endif
#else
- if (CONFIG_MDCT) s->mdct_calcw = ff_mdct_calcw_c;
- if (ARCH_ARM) ff_fft_fixed_init_arm(s);
+ #if CONFIG_MDCT
+ s->mdct_calcw = ff_mdct_calcw_c;
+ #endif
+ #if ARCH_ARM == 1
+ ff_fft_fixed_init_arm(s);
+ #endif
#endif
for(j=4; j<=nbits; j++) {
diff --git a/media/libav/libavutil/cpu.c b/media/libav/libavutil/cpu.c
index 354d21e76f..6d100e95c1 100644
--- a/media/libav/libavutil/cpu.c
+++ b/media/libav/libavutil/cpu.c
@@ -51,14 +51,15 @@ int av_get_cpu_flags(void)
if (checked)
return flags;
- if (ARCH_AARCH64)
+ #if ARCH_AARCH64 == 1
flags = ff_get_cpu_flags_aarch64();
- if (ARCH_ARM)
+ #elif ARCH_ARM == 1
flags = ff_get_cpu_flags_arm();
- if (ARCH_PPC)
+ #elif ARCH_PPC == 1
flags = ff_get_cpu_flags_ppc();
- if (ARCH_X86)
+ #elif ARCH_X86 == 1
flags = ff_get_cpu_flags_x86();
+ #endif
flags &= cpuflags_mask;
checked = 1;
diff --git a/media/libav/moz-libav.patch b/media/libav/moz-libav.patch
index 5179e777cc..bdde7dad8e 100644
--- a/media/libav/moz-libav.patch
+++ b/media/libav/moz-libav.patch
@@ -11,3 +11,65 @@ index aed9925..03ee543 100644
#pragma comment(linker, "/include:"EXTERN_PREFIX"avpriv_strtod")
#pragma comment(linker, "/include:"EXTERN_PREFIX"avpriv_snprintf")
#endif
+
+diff --git a/media/libav/libavcodec/fft_template.c b/media/libav/libavcodec/fft_template.c
+index 808f317c1..9d21ffa6b 100644
+--- a/media/libav/libavcodec/fft_template.c
++++ b/media/libav/libavcodec/fft_template.c
+@@ -158,14 +158,25 @@ av_cold int ff_fft_init(FFTContext *s, int nbits, int inverse)
+ #endif
+
+ #if FFT_FLOAT
+- if (ARCH_AARCH64) ff_fft_init_aarch64(s);
+- if (ARCH_ARM) ff_fft_init_arm(s);
+- if (ARCH_PPC) ff_fft_init_ppc(s);
+- if (ARCH_X86) ff_fft_init_x86(s);
+- if (CONFIG_MDCT) s->mdct_calcw = s->mdct_calc;
++ #if ARCH_AARCH64 == 1
++ ff_fft_init_aarch64(s);
++ #elif ARCH_ARM == 1
++ ff_fft_init_arm(s);
++ #elif ARCH_PPC == 1
++ ff_fft_init_ppc(s);
++ #elif ARCH_X86 == 1
++ ff_fft_init_x86(s);
++ #endif
++ #if CONFIG_MDCT
++ s->mdct_calcw = s->mdct_calc;
++ #endif
+ #else
+- if (CONFIG_MDCT) s->mdct_calcw = ff_mdct_calcw_c;
+- if (ARCH_ARM) ff_fft_fixed_init_arm(s);
++ #if CONFIG_MDCT
++ s->mdct_calcw = ff_mdct_calcw_c;
++ #endif
++ #if ARCH_ARM == 1
++ ff_fft_fixed_init_arm(s);
++ #endif
+ #endif
+
+ for(j=4; j<=nbits; j++) {
+diff --git a/media/libav/libavutil/cpu.c b/media/libav/libavutil/cpu.c
+index 354d21e76..6d100e95c 100644
+--- a/media/libav/libavutil/cpu.c
++++ b/media/libav/libavutil/cpu.c
+@@ -51,14 +51,15 @@ int av_get_cpu_flags(void)
+ if (checked)
+ return flags;
+
+- if (ARCH_AARCH64)
++ #if ARCH_AARCH64 == 1
+ flags = ff_get_cpu_flags_aarch64();
+- if (ARCH_ARM)
++ #elif ARCH_ARM == 1
+ flags = ff_get_cpu_flags_arm();
+- if (ARCH_PPC)
++ #elif ARCH_PPC == 1
+ flags = ff_get_cpu_flags_ppc();
+- if (ARCH_X86)
++ #elif ARCH_X86 == 1
+ flags = ff_get_cpu_flags_x86();
++ #endif
+
+ flags &= cpuflags_mask;
+ checked = 1; \ No newline at end of file
diff --git a/media/libnestegg/README.md b/media/libnestegg/README.md
index ce9bd76ff7..2d64a65cc7 100644
--- a/media/libnestegg/README.md
+++ b/media/libnestegg/README.md
@@ -1,4 +1,4 @@
-[![Build Status](https://travis-ci.org/kinetiknz/nestegg.svg?branch=master)](https://travis-ci.org/kinetiknz/nestegg)
+[![Build Status](https://github.com/mozilla/nestegg/actions/workflows/build.yml/badge.svg)](https://github.com/mozilla/nestegg/actions/workflows/build.yml)
See INSTALL for build instructions.
diff --git a/media/libnestegg/README_MCP b/media/libnestegg/README_MCP
index e738fd920b..e799e2bfc2 100644
--- a/media/libnestegg/README_MCP
+++ b/media/libnestegg/README_MCP
@@ -5,4 +5,4 @@ Makefile.in build files for the Mozilla build system.
The nestegg git repository is: https://github.com/kinetiknz/nestegg
-The git commit ID used was f7a0b7cedc893b6683cf15cb210b1656c086d964.
+The git commit ID used was ec6adfbbf979678e3058cc4695257366f39e290b.
diff --git a/media/libnestegg/include/nestegg.h b/media/libnestegg/include/nestegg.h
index 2a9f08f5d7..ede90fdac5 100644
--- a/media/libnestegg/include/nestegg.h
+++ b/media/libnestegg/include/nestegg.h
@@ -72,8 +72,8 @@ extern "C" {
#define NESTEGG_CODEC_VP9 2 /**< Track uses Google On2 VP9 codec. */
#define NESTEGG_CODEC_OPUS 3 /**< Track uses Xiph Opus codec. */
#define NESTEGG_CODEC_AV1 4 /**< Track uses AOMedia AV1 codec. */
-#define NESTEGG_CODEC_AVC1 5 /**< Track uses AVC1 'h264' */
-#define NESTEGG_CODEC_AAC 6 /**< Track uses AAC 'mp4a' */
+#define NESTEGG_CODEC_AVC1 5 /**< Track uses AVC1 'h264' codec. */
+#define NESTEGG_CODEC_AAC 6 /**< Track uses AAC 'mp4a' codec. */
#define NESTEGG_CODEC_UNKNOWN INT_MAX /**< Track uses unknown codec. */
#define NESTEGG_VIDEO_MONO 0 /**< Track is mono video. */
@@ -152,6 +152,30 @@ typedef struct {
unsigned int crop_left; /**< Pixels to crop from the left of the frame. */
unsigned int crop_right; /**< Pixels to crop from the right of the frame. */
unsigned int alpha_mode; /**< 1 if an additional opacity stream is available, otherwise 0. */
+ unsigned int matrix_coefficients; /**< See Table 4 of ISO/IEC 23001-8:2016. */
+ unsigned int range; /**< Clipping of color ranges. */
+ unsigned int transfer_characteristics; /**< See Table 3 of ISO/IEC 23091-4. */
+ unsigned int primaries; /**< See Table 2 of ISO/IEC 23091-4. */
+ double primary_r_chromacity_x; /**< Red X chromaticity coordinate per CIE 1931.
+ NaN means element not present. */
+ double primary_r_chromacity_y; /**< Red Y chromaticity coordinate per CIE 1931.
+ NaN means element not present. */
+ double primary_g_chromacity_x; /**< Green X chromaticity coordinate per CIE 1931.
+ NaN means element not present. */
+ double primary_g_chromacity_y; /**< Green Y chromaticity coordinate per CIE 1931.
+ NaN means element not present. */
+ double primary_b_chromacity_x; /**< Blue X chromaticity coordinate per CIE 1931.
+ NaN means element not present. */
+ double primary_b_chromacity_y; /**< Blue Y chromaticity coordinate per CIE 1931.
+ NaN means element not present. */
+ double white_point_chromaticity_x; /**< White X chromaticity coordinate per CIE 1931.
+ NaN means element not present. */
+ double white_point_chromaticity_y; /**< White Y chromaticity coordinate per CIE 1931.
+ NaN means element not present. */
+ double luminance_max; /**< Maximum luminance in cd/m2.
+ NaN means element not present. */
+ double luminance_min; /**< Minimum luminance in cd/m2.
+ NaN means element not present. */
} nestegg_video_params;
/** Parameters specific to an audio track. */
diff --git a/media/libnestegg/mcp-avcaacsupport.patch b/media/libnestegg/mcp-avcaacsupport.patch
new file mode 100644
index 0000000000..279af76820
--- /dev/null
+++ b/media/libnestegg/mcp-avcaacsupport.patch
@@ -0,0 +1,59 @@
+diff -u /include/nestegg.h /include/nestegg.h
+--- /include/nestegg.h
++++ /include/nestegg.h
+@@ -72,6 +72,8 @@
+ #define NESTEGG_CODEC_VP9 2 /**< Track uses Google On2 VP9 codec. */
+ #define NESTEGG_CODEC_OPUS 3 /**< Track uses Xiph Opus codec. */
+ #define NESTEGG_CODEC_AV1 4 /**< Track uses AOMedia AV1 codec. */
++#define NESTEGG_CODEC_AVC1 5 /**< Track uses AVC1 'h264' codec. */
++#define NESTEGG_CODEC_AAC 6 /**< Track uses AAC 'mp4a' codec. */
+ #define NESTEGG_CODEC_UNKNOWN INT_MAX /**< Track uses unknown codec. */
+
+ #define NESTEGG_VIDEO_MONO 0 /**< Track is mono video. */
+diff -u /src/nestegg.c /src/nestegg.c
+--- /src/nestegg.c
++++ /src/nestegg.c
+@@ -177,6 +177,8 @@
+ #define TRACK_ID_AV1 "V_AV1"
+ #define TRACK_ID_VORBIS "A_VORBIS"
+ #define TRACK_ID_OPUS "A_OPUS"
++#define TRACK_ID_AVC1 "V_MPEG4/ISO/AVC"
++#define TRACK_ID_AAC "A_AAC"
+
+ /* Track Encryption */
+ #define CONTENT_ENC_ALGO_AES 5
+@@ -2482,6 +2484,12 @@
+ if (strcmp(codec_id, TRACK_ID_OPUS) == 0)
+ return NESTEGG_CODEC_OPUS;
+
++ if (strcmp(codec_id, TRACK_ID_AVC1) == 0)
++ return NESTEGG_CODEC_AVC1;
++
++ if (strcmp(codec_id, TRACK_ID_AAC) == 0)
++ return NESTEGG_CODEC_AAC;
++
+ return NESTEGG_CODEC_UNKNOWN;
+ }
+
+@@ -2502,7 +2510,8 @@
+
+ codec_id = nestegg_track_codec_id(ctx, track);
+
+- if (codec_id == NESTEGG_CODEC_OPUS) {
++ if (codec_id == NESTEGG_CODEC_OPUS ||
++ codec_id == NESTEGG_CODEC_AAC) {
+ *count = 1;
+ return 0;
+ }
+@@ -2540,7 +2549,9 @@
+ return -1;
+
+ if (nestegg_track_codec_id(ctx, track) != NESTEGG_CODEC_VORBIS &&
+- nestegg_track_codec_id(ctx, track) != NESTEGG_CODEC_OPUS)
++ nestegg_track_codec_id(ctx, track) != NESTEGG_CODEC_OPUS &&
++ nestegg_track_codec_id(ctx, track) != NESTEGG_CODEC_AVC1 &&
++ nestegg_track_codec_id(ctx, track) != NESTEGG_CODEC_AAC)
+ return -1;
+
+ if (ne_get_binary(entry->codec_private, &codec_private) != 0)
+
diff --git a/media/libnestegg/src/nestegg.c b/media/libnestegg/src/nestegg.c
index 051bc50faf..ae7c73d9d2 100644
--- a/media/libnestegg/src/nestegg.c
+++ b/media/libnestegg/src/nestegg.c
@@ -88,6 +88,7 @@
#define ID_PIXEL_CROP_RIGHT 0x54dd
#define ID_DISPLAY_WIDTH 0x54b0
#define ID_DISPLAY_HEIGHT 0x54ba
+#define ID_COLOUR 0x55b0
/* Audio Elements */
#define ID_AUDIO 0xe1
@@ -116,6 +117,25 @@
#define ID_CONTENT_ENC_AES_SETTINGS 0x47e7
#define ID_AES_SETTINGS_CIPHER_MODE 0x47e8
+/* Colour Elements */
+#define ID_MATRIX_COEFFICIENTS 0x55b1
+#define ID_RANGE 0x55b9
+#define ID_TRANSFER_CHARACTERISTICS 0x55ba
+#define ID_PRIMARIES 0x55bb
+#define ID_MASTERING_METADATA 0x55d0
+
+/* MasteringMetadata Elements */
+#define ID_PRIMARY_R_CHROMATICITY_X 0x55d1
+#define ID_PRIMARY_R_CHROMATICITY_Y 0x55d2
+#define ID_PRIMARY_G_CHROMATICITY_X 0x55d3
+#define ID_PRIMARY_G_CHROMATICITY_Y 0x55d4
+#define ID_PRIMARY_B_CHROMATICITY_X 0x55d5
+#define ID_PRIMARY_B_CHROMATICITY_Y 0x55d6
+#define ID_WHITE_POINT_CHROMATICITY_X 0x55d7
+#define ID_WHITE_POINT_CHROMATICITY_Y 0x55d8
+#define ID_LUMINANCE_MAX 0x55d9
+#define ID_LUMINANCE_MIN 0x55da
+
/* EBML Types */
enum ebml_type_enum {
TYPE_UNKNOWN,
@@ -236,6 +256,27 @@ struct info {
struct ebml_type duration;
};
+struct mastering_metadata {
+ struct ebml_type primary_r_chromacity_x;
+ struct ebml_type primary_r_chromacity_y;
+ struct ebml_type primary_g_chromacity_x;
+ struct ebml_type primary_g_chromacity_y;
+ struct ebml_type primary_b_chromacity_x;
+ struct ebml_type primary_b_chromacity_y;
+ struct ebml_type white_point_chromaticity_x;
+ struct ebml_type white_point_chromaticity_y;
+ struct ebml_type luminance_max;
+ struct ebml_type luminance_min;
+};
+
+struct colour {
+ struct ebml_type matrix_coefficients;
+ struct ebml_type range;
+ struct ebml_type transfer_characteristics;
+ struct ebml_type primaries;
+ struct mastering_metadata mastering_metadata;
+};
+
struct video {
struct ebml_type stereo_mode;
struct ebml_type alpha_mode;
@@ -247,6 +288,7 @@ struct video {
struct ebml_type pixel_crop_right;
struct ebml_type display_width;
struct ebml_type display_height;
+ struct colour colour;
};
struct audio {
@@ -454,6 +496,29 @@ static struct ebml_element_desc ne_info_elements[] = {
E_LAST
};
+static struct ebml_element_desc ne_mastering_metadata_elements[] = {
+ E_FIELD(ID_PRIMARY_R_CHROMATICITY_X, TYPE_FLOAT, struct mastering_metadata, primary_r_chromacity_x),
+ E_FIELD(ID_PRIMARY_R_CHROMATICITY_Y, TYPE_FLOAT, struct mastering_metadata, primary_r_chromacity_y),
+ E_FIELD(ID_PRIMARY_G_CHROMATICITY_X, TYPE_FLOAT, struct mastering_metadata, primary_g_chromacity_x),
+ E_FIELD(ID_PRIMARY_G_CHROMATICITY_Y, TYPE_FLOAT, struct mastering_metadata, primary_g_chromacity_y),
+ E_FIELD(ID_PRIMARY_B_CHROMATICITY_X, TYPE_FLOAT, struct mastering_metadata, primary_b_chromacity_x),
+ E_FIELD(ID_PRIMARY_B_CHROMATICITY_Y, TYPE_FLOAT, struct mastering_metadata, primary_b_chromacity_y),
+ E_FIELD(ID_WHITE_POINT_CHROMATICITY_X, TYPE_FLOAT, struct mastering_metadata, white_point_chromaticity_x),
+ E_FIELD(ID_WHITE_POINT_CHROMATICITY_Y, TYPE_FLOAT, struct mastering_metadata, white_point_chromaticity_y),
+ E_FIELD(ID_LUMINANCE_MAX, TYPE_FLOAT, struct mastering_metadata, luminance_max),
+ E_FIELD(ID_LUMINANCE_MIN, TYPE_FLOAT, struct mastering_metadata, luminance_min),
+ E_LAST
+};
+
+static struct ebml_element_desc ne_colour_elements[] = {
+ E_FIELD(ID_MATRIX_COEFFICIENTS, TYPE_UINT, struct colour, matrix_coefficients),
+ E_FIELD(ID_RANGE, TYPE_UINT, struct colour, range),
+ E_FIELD(ID_TRANSFER_CHARACTERISTICS, TYPE_UINT, struct colour, transfer_characteristics),
+ E_FIELD(ID_PRIMARIES, TYPE_UINT, struct colour, primaries),
+ E_SINGLE_MASTER(ID_MASTERING_METADATA, TYPE_MASTER, struct colour, mastering_metadata),
+ E_LAST
+};
+
static struct ebml_element_desc ne_video_elements[] = {
E_FIELD(ID_STEREO_MODE, TYPE_UINT, struct video, stereo_mode),
E_FIELD(ID_ALPHA_MODE, TYPE_UINT, struct video, alpha_mode),
@@ -465,6 +530,7 @@ static struct ebml_element_desc ne_video_elements[] = {
E_FIELD(ID_PIXEL_CROP_RIGHT, TYPE_UINT, struct video, pixel_crop_right),
E_FIELD(ID_DISPLAY_WIDTH, TYPE_UINT, struct video, display_width),
E_FIELD(ID_DISPLAY_HEIGHT, TYPE_UINT, struct video, display_height),
+ E_SINGLE_MASTER(ID_COLOUR, TYPE_MASTER, struct video, colour),
E_LAST
};
@@ -770,7 +836,15 @@ ne_read_float(nestegg_io * io, double * val, uint64_t length)
{
union {
uint64_t u;
- float f;
+ struct {
+#if defined(__FLOAT_WORD_ORDER__) && __FLOAT_WORD_ORDER__ == __ORDER_BIG_ENDIAN__
+ uint32_t _pad;
+ float f;
+#else
+ float f;
+ uint32_t _pad;
+#endif
+ } f;
double d;
} value;
int r;
@@ -782,7 +856,7 @@ ne_read_float(nestegg_io * io, double * val, uint64_t length)
if (r != 1)
return r;
if (length == 4)
- *val = value.f;
+ *val = value.f.f;
else
*val = value.d;
return 1;
@@ -2062,7 +2136,10 @@ ne_match_webm(nestegg_io io, int64_t max_offset)
return 0;
}
- ne_ctx_push(ctx, ne_top_level_elements, ctx);
+ if (ne_ctx_push(ctx, ne_top_level_elements, ctx) < 0) {
+ nestegg_destroy(ctx);
+ return -1;
+ }
/* we don't check the return value of ne_parse, that might fail because
max_offset is not on a valid element end point. We only want to check
@@ -2118,7 +2195,10 @@ nestegg_init(nestegg ** context, nestegg_io io, nestegg_log callback, int64_t ma
ctx->log(ctx, NESTEGG_LOG_DEBUG, "ctx %p", ctx);
- ne_ctx_push(ctx, ne_top_level_elements, ctx);
+ if (ne_ctx_push(ctx, ne_top_level_elements, ctx) < 0) {
+ nestegg_destroy(ctx);
+ return -1;
+ }
r = ne_parse(ctx, NULL, max_offset);
while (ctx->ancestor)
@@ -2178,7 +2258,8 @@ void
nestegg_destroy(nestegg * ctx)
{
assert(ctx->ancestor == NULL);
- ne_pool_destroy(ctx->alloc_pool);
+ if (ctx->alloc_pool)
+ ne_pool_destroy(ctx->alloc_pool);
free(ctx->io);
free(ctx);
}
@@ -2366,10 +2447,10 @@ nestegg_track_type(nestegg * ctx, unsigned int track)
if (ne_get_uint(entry->type, &type) != 0)
return -1;
- if (type & TRACK_TYPE_VIDEO)
+ if (type == TRACK_TYPE_VIDEO)
return NESTEGG_TRACK_VIDEO;
- if (type & TRACK_TYPE_AUDIO)
+ if (type == TRACK_TYPE_AUDIO)
return NESTEGG_TRACK_AUDIO;
return NESTEGG_TRACK_UNKNOWN;
@@ -2537,6 +2618,7 @@ nestegg_track_video_params(nestegg * ctx, unsigned int track,
{
struct track_entry * entry;
uint64_t value;
+ double fvalue;
memset(params, 0, sizeof(*params));
@@ -2589,6 +2671,62 @@ nestegg_track_video_params(nestegg * ctx, unsigned int track,
ne_get_uint(entry->video.display_height, &value);
params->display_height = value;
+ value = 2;
+ ne_get_uint(entry->video.colour.matrix_coefficients, &value);
+ params->matrix_coefficients = value;
+
+ value = 0;
+ ne_get_uint(entry->video.colour.range, &value);
+ params->range = value;
+
+ value = 2;
+ ne_get_uint(entry->video.colour.transfer_characteristics, &value);
+ params->transfer_characteristics = value;
+
+ value = 2;
+ ne_get_uint(entry->video.colour.primaries, &value);
+ params->primaries = value;
+
+ fvalue = strtod("NaN", NULL);
+ ne_get_float(entry->video.colour.mastering_metadata.primary_r_chromacity_x, &fvalue);
+ params->primary_r_chromacity_x = fvalue;
+
+ fvalue = strtod("NaN", NULL);
+ ne_get_float(entry->video.colour.mastering_metadata.primary_r_chromacity_y, &fvalue);
+ params->primary_r_chromacity_y = fvalue;
+
+ fvalue = strtod("NaN", NULL);
+ ne_get_float(entry->video.colour.mastering_metadata.primary_g_chromacity_x, &fvalue);
+ params->primary_g_chromacity_x = fvalue;
+
+ fvalue = strtod("NaN", NULL);
+ ne_get_float(entry->video.colour.mastering_metadata.primary_g_chromacity_y, &fvalue);
+ params->primary_g_chromacity_y = fvalue;
+
+ fvalue = strtod("NaN", NULL);
+ ne_get_float(entry->video.colour.mastering_metadata.primary_b_chromacity_x, &fvalue);
+ params->primary_b_chromacity_x = fvalue;
+
+ fvalue = strtod("NaN", NULL);
+ ne_get_float(entry->video.colour.mastering_metadata.primary_b_chromacity_y, &fvalue);
+ params->primary_b_chromacity_y = fvalue;
+
+ fvalue = strtod("NaN", NULL);
+ ne_get_float(entry->video.colour.mastering_metadata.white_point_chromaticity_x, &fvalue);
+ params->white_point_chromaticity_x = fvalue;
+
+ fvalue = strtod("NaN", NULL);
+ ne_get_float(entry->video.colour.mastering_metadata.white_point_chromaticity_y, &fvalue);
+ params->white_point_chromaticity_y = fvalue;
+
+ fvalue = strtod("NaN", NULL);
+ ne_get_float(entry->video.colour.mastering_metadata.luminance_max, &fvalue);
+ params->luminance_max = fvalue;
+
+ fvalue = strtod("NaN", NULL);
+ ne_get_float(entry->video.colour.mastering_metadata.luminance_min, &fvalue);
+ params->luminance_min = fvalue;
+
return 0;
}
@@ -2783,20 +2921,18 @@ nestegg_read_packet(nestegg * ctx, nestegg_packet ** pkt)
if (r != 1)
return r;
- /* Some files have a crc32 element, since it also has to be first it
- conflicts with the timecode spec. Just ignore it */
+ /* Matroska may place a CRC32 before the Timecode. Skip and continue parsing. */
if (id == ID_CRC32) {
- ctx->log(ctx, NESTEGG_LOG_DEBUG,
- "read_packet: skipping crc element in a cluster");
- r = ne_io_read_skip(ctx->io, size);
- if (r != 1)
- return r;
- r = ne_read_element(ctx, &id, &size);
- if (r != 1)
- return r;
+ r = ne_io_read_skip(ctx->io, size);
+ if (r != 1)
+ return r;
+
+ r = ne_read_element(ctx, &id, &size);
+ if (r != 1)
+ return r;
}
- /* Timecode must be the first element in a Cluster, per spec. */
+ /* Timecode must be the first element in a Cluster, per WebM spec. */
if (id != ID_TIMECODE)
return -1;
diff --git a/media/libnestegg/update.sh b/media/libnestegg/update.sh
index 644408e094..dc3324c46b 100755
--- a/media/libnestegg/update.sh
+++ b/media/libnestegg/update.sh
@@ -4,6 +4,10 @@ cp $1/src/nestegg.c src
cp $1/LICENSE .
cp $1/README.md .
cp $1/AUTHORS .
+
+# Patch the imported files.
+patch -p1 < mcp-avcaacsupport.patch
+
if [ -d $1/.git ]; then
rev=$(cd $1 && git rev-parse --verify HEAD)
dirty=$(cd $1 && git diff-index --name-only HEAD)
diff --git a/media/libogg/include/ogg/os_types.h b/media/libogg/include/ogg/os_types.h
index a8d4600fb0..f67f0c0d98 100644
--- a/media/libogg/include/ogg/os_types.h
+++ b/media/libogg/include/ogg/os_types.h
@@ -108,6 +108,7 @@ extern ogg_free_function_type *ogg_free_func;
typedef int32_t ogg_int32_t;
typedef uint32_t ogg_uint32_t;
typedef int64_t ogg_int64_t;
+ typedef uint64_t ogg_uint64_t;
#elif defined(__HAIKU__)
diff --git a/media/libsoundtouch/AUTHORS b/media/libsoundtouch/AUTHORS
index 666081e195..56441f98fa 100644
--- a/media/libsoundtouch/AUTHORS
+++ b/media/libsoundtouch/AUTHORS
@@ -1,4 +1,4 @@
The SoundTouch Library
-Copyright © Olli Parviainen 2001-2012
+Copyright © Olli Parviainen 2001-2021
http://www.surina.net/soundtouch/
diff --git a/media/libsoundtouch/LICENSE b/media/libsoundtouch/LICENSE
index 5b2161be20..c04d4d8040 100644
--- a/media/libsoundtouch/LICENSE
+++ b/media/libsoundtouch/LICENSE
@@ -2,7 +2,7 @@
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
- 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
@@ -117,7 +117,7 @@ be combined with the library in order to run.
0. This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
-other authoried party saying it may be distributed under the terms of
+other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called "this License").
Each licensee is addressed as "you".
@@ -455,4 +455,4 @@ FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
- END OF TERMS AND CONDITIONS
+ END OF TERMS AND CONDITIONS \ No newline at end of file
diff --git a/media/libsoundtouch/README_MOZILLA b/media/libsoundtouch/README_MCP
index dc0dbe8f68..91da84390a 100644
--- a/media/libsoundtouch/README_MOZILLA
+++ b/media/libsoundtouch/README_MCP
@@ -1,6 +1,6 @@
These files are from the SoundTouch library (http://www.surina.net/soundtouch/),
-and are extracted from the revision r222 of the svn repository at
-https://soundtouch.svn.sourceforge.net/svnroot/soundtouch/trunk.
+and are extracted from tagged version 2.3.1 of the git repository at
+https://codeberg.org/soundtouch/soundtouch/.
The whole library is not used, only the relevant files are imported in the tree,
using the script `update.sh`. Some changes have been made to the files, using
diff --git a/media/libsoundtouch/mcp-disableexceptions.patch b/media/libsoundtouch/mcp-disableexceptions.patch
new file mode 100644
index 0000000000..c92d11a86c
--- /dev/null
+++ b/media/libsoundtouch/mcp-disableexceptions.patch
@@ -0,0 +1,13 @@
+diff -u /src/STTypes.h /src/STTypes.h
+--- /src/STTypes.h
++++ /src/STTypes.h
+@@ -174,7 +174,7 @@
+ }
+
+ // define ST_NO_EXCEPTION_HANDLING switch to disable throwing std exceptions:
+-// #define ST_NO_EXCEPTION_HANDLING 1
++#define ST_NO_EXCEPTION_HANDLING 1
+ #ifdef ST_NO_EXCEPTION_HANDLING
+ // Exceptions disabled. Throw asserts instead if enabled.
+ #include <assert.h>
+
diff --git a/media/libsoundtouch/moz-libsoundtouch.patch b/media/libsoundtouch/moz-libsoundtouch.patch
index 87629373e8..dc2ea63804 100644
--- a/media/libsoundtouch/moz-libsoundtouch.patch
+++ b/media/libsoundtouch/moz-libsoundtouch.patch
@@ -56,7 +56,7 @@ diff -u /src/cpu_detect_x86.cpp /src/cpu_detect_x86.cpp
diff -u /src/STTypes.h /src/STTypes.h
--- /src/STTypes.h
+++ /src/STTypes.h
-@@ -54,12 +54,13 @@
+@@ -54,12 +54,17 @@
#define SOUNDTOUCH_ALIGN_POINTER_16(x) ( ( (ulongptr)(x) + 15 ) & ~(ulongptr)15 )
@@ -68,9 +68,13 @@ diff -u /src/STTypes.h /src/STTypes.h
+#include "soundtouch_config.h"
+#if defined(WIN32)
-+#define EXPORT __declspec(dllexport)
++#if defined(BUILDING_SOUNDTOUCH)
++#define SOUNDTOUCH_API __declspec(dllexport)
+#else
-+#define EXPORT
++#define SOUNDTOUCH_API __declspec(dllimport)
++#endif
++#else
++#define SOUNDTOUCH_API
+#endif
namespace soundtouch
@@ -83,7 +87,7 @@ diff -u /src/SoundTouch.h /src/SoundTouch.h
#define SETTING_NOMINAL_OUTPUT_SEQUENCE 7
-class SoundTouch : public FIFOProcessor
-+class EXPORT SoundTouch : public FIFOProcessor
++class SOUNDTOUCH_API SoundTouch : public FIFOProcessor
{
private:
/// Rate transposer class instance
@@ -116,26 +120,17 @@ diff -u /src/TDStretch.cpp /src/TDStretch.cpp
+#endif
// Check if MMX/SSE instruction set extensions supported by CPU
-
-diff --git a/media/libsoundtouch/src/AAFilter.cpp b/media/libsoundtouch/src/AAFilter.cpp
---- a/media/libsoundtouch/src/AAFilter.cpp
-+++ b/media/libsoundtouch/src/AAFilter.cpp
-@@ -44,17 +44,17 @@
- #include <assert.h>
- #include <math.h>
- #include <stdlib.h>
- #include "AAFilter.h"
- #include "FIRFilter.h"
+
+diff -u /src/AAFilter.cpp /src/AAFilter.cpp
+--- /src/AAFilter.cpp
++++ /src/AAFilter.cpp
+@@ -42,7 +42,7 @@
using namespace soundtouch;
--#define PI 3.141592655357989
+-#define PI 3.14159265358979323846
+#define PI M_PI
#define TWOPI (2 * PI)
// define this to save AA filter coefficients to a file
- // #define _DEBUG_SAVE_AAFILTER_COEFFICIENTS 1
-
- #ifdef _DEBUG_SAVE_AAFILTER_COEFFICIENTS
- #include <stdio.h>
diff --git a/media/libsoundtouch/src/AAFilter.cpp b/media/libsoundtouch/src/AAFilter.cpp
index b98a6d63ee..3fd4e9fe6d 100644
--- a/media/libsoundtouch/src/AAFilter.cpp
+++ b/media/libsoundtouch/src/AAFilter.cpp
@@ -12,13 +12,6 @@
///
////////////////////////////////////////////////////////////////////////////////
//
-// Last changed : $Date: 2014-01-05 21:40:22 +0000 (Sun, 05 Jan 2014) $
-// File revision : $Revision: 4 $
-//
-// $Id: AAFilter.cpp 177 2014-01-05 21:40:22Z oparviai $
-//
-////////////////////////////////////////////////////////////////////////////////
-//
// License :
//
// SoundTouch audio processing library
@@ -75,7 +68,6 @@ using namespace soundtouch;
#define _DEBUG_SAVE_AAFIR_COEFFS(x, y)
#endif
-
/*****************************************************************************
*
* Implementation of the class 'AAFilter'
@@ -90,14 +82,12 @@ AAFilter::AAFilter(uint len)
}
-
AAFilter::~AAFilter()
{
delete pFIR;
}
-
// Sets new anti-alias filter cut-off edge frequency, scaled to
// sampling frequency (nyquist frequency = 0.5).
// The filter will cut frequencies higher than the given frequency.
@@ -108,7 +98,6 @@ void AAFilter::setCutoffFreq(double newCutoffFreq)
}
-
// Sets number of FIR filter taps
void AAFilter::setLength(uint newLength)
{
@@ -117,7 +106,6 @@ void AAFilter::setLength(uint newLength)
}
-
// Calculates coefficients for a low-pass FIR filter using Hamming window
void AAFilter::calculateCoeffs()
{
@@ -177,12 +165,10 @@ void AAFilter::calculateCoeffs()
for (i = 0; i < length; i ++)
{
temp = work[i] * scaleCoeff;
-//#if SOUNDTOUCH_INTEGER_SAMPLES
// scale & round to nearest integer
temp += (temp >= 0) ? 0.5 : -0.5;
// ensure no overfloods
assert(temp >= -32768 && temp <= 32767);
-//#endif
coeffs[i] = (SAMPLETYPE)temp;
}
diff --git a/media/libsoundtouch/src/AAFilter.h b/media/libsoundtouch/src/AAFilter.h
index f1b5f2a554..81d836b750 100644
--- a/media/libsoundtouch/src/AAFilter.h
+++ b/media/libsoundtouch/src/AAFilter.h
@@ -13,13 +13,6 @@
///
////////////////////////////////////////////////////////////////////////////////
//
-// Last changed : $Date: 2014-01-07 19:41:23 +0000 (Tue, 07 Jan 2014) $
-// File revision : $Revision: 4 $
-//
-// $Id: AAFilter.h 187 2014-01-07 19:41:23Z oparviai $
-//
-////////////////////////////////////////////////////////////////////////////////
-//
// License :
//
// SoundTouch audio processing library
diff --git a/media/libsoundtouch/src/FIFOSampleBuffer.cpp b/media/libsoundtouch/src/FIFOSampleBuffer.cpp
index 4e75c8a433..ad36875466 100644
--- a/media/libsoundtouch/src/FIFOSampleBuffer.cpp
+++ b/media/libsoundtouch/src/FIFOSampleBuffer.cpp
@@ -15,13 +15,6 @@
///
////////////////////////////////////////////////////////////////////////////////
//
-// Last changed : $Date: 2012-11-08 18:53:01 +0000 (Thu, 08 Nov 2012) $
-// File revision : $Revision: 4 $
-//
-// $Id: FIFOSampleBuffer.cpp 160 2012-11-08 18:53:01Z oparviai $
-//
-////////////////////////////////////////////////////////////////////////////////
-//
// License :
//
// SoundTouch audio processing library
@@ -80,7 +73,8 @@ void FIFOSampleBuffer::setChannels(int numChannels)
{
uint usedBytes;
- assert(numChannels > 0);
+ if (!verifyNumberOfChannels(numChannels)) return;
+
usedBytes = channels * samplesInBuffer;
channels = (uint)numChannels;
samplesInBuffer = usedBytes / channels;
@@ -131,7 +125,7 @@ void FIFOSampleBuffer::putSamples(uint nSamples)
//
// Parameter 'slackCapacity' tells the function how much free capacity (in
// terms of samples) there _at least_ should be, in order to the caller to
-// succesfully insert all the required samples to the buffer. When necessary,
+// successfully insert all the required samples to the buffer. When necessary,
// the function grows the buffer size to comply with this requirement.
//
// When using this function as means for inserting new samples, also remember
@@ -158,7 +152,7 @@ SAMPLETYPE *FIFOSampleBuffer::ptrBegin()
}
-// Ensures that the buffer has enought capacity, i.e. space for _at least_
+// Ensures that the buffer has enough capacity, i.e. space for _at least_
// 'capacityRequirement' number of samples. The buffer is grown in steps of
// 4 kilobytes to eliminate the need for frequently growing up the buffer,
// as well as to round the buffer size up to the virtual memory page size.
@@ -272,3 +266,10 @@ uint FIFOSampleBuffer::adjustAmountOfSamples(uint numSamples)
return samplesInBuffer;
}
+
+/// Add silence to end of buffer
+void FIFOSampleBuffer::addSilent(uint nSamples)
+{
+ memset(ptrEnd(nSamples), 0, sizeof(SAMPLETYPE) * nSamples * channels);
+ samplesInBuffer += nSamples;
+}
diff --git a/media/libsoundtouch/src/FIFOSampleBuffer.h b/media/libsoundtouch/src/FIFOSampleBuffer.h
index 6d2fd59f65..537a7b8722 100644
--- a/media/libsoundtouch/src/FIFOSampleBuffer.h
+++ b/media/libsoundtouch/src/FIFOSampleBuffer.h
@@ -15,13 +15,6 @@
///
////////////////////////////////////////////////////////////////////////////////
//
-// Last changed : $Date: 2014-01-05 21:40:22 +0000 (Sun, 05 Jan 2014) $
-// File revision : $Revision: 4 $
-//
-// $Id: FIFOSampleBuffer.h 177 2014-01-05 21:40:22Z oparviai $
-//
-////////////////////////////////////////////////////////////////////////////////
-//
// License :
//
// SoundTouch audio processing library
@@ -119,7 +112,7 @@ public:
/// 'putSamples(numSamples)' function.
SAMPLETYPE *ptrEnd(
uint slackCapacity ///< How much free capacity (in samples) there _at least_
- ///< should be so that the caller can succesfully insert the
+ ///< should be so that the caller can successfully insert the
///< desired samples to the buffer. If necessary, the function
///< grows the buffer size to comply with this requirement.
);
@@ -177,6 +170,9 @@ public:
/// allow trimming (downwards) amount of samples in pipeline.
/// Returns adjusted amount of samples
uint adjustAmountOfSamples(uint numSamples);
+
+ /// Add silence to end of buffer
+ void addSilent(uint nSamples);
};
}
diff --git a/media/libsoundtouch/src/FIFOSamplePipe.h b/media/libsoundtouch/src/FIFOSamplePipe.h
index cd3191c1af..3def42d1ab 100644
--- a/media/libsoundtouch/src/FIFOSamplePipe.h
+++ b/media/libsoundtouch/src/FIFOSamplePipe.h
@@ -17,13 +17,6 @@
///
////////////////////////////////////////////////////////////////////////////////
//
-// Last changed : $Date: 2012-06-13 19:29:53 +0000 (Wed, 13 Jun 2012) $
-// File revision : $Revision: 4 $
-//
-// $Id: FIFOSamplePipe.h 143 2012-06-13 19:29:53Z oparviai $
-//
-////////////////////////////////////////////////////////////////////////////////
-//
// License :
//
// SoundTouch audio processing library
@@ -58,6 +51,18 @@ namespace soundtouch
/// Abstract base class for FIFO (first-in-first-out) sample processing classes.
class FIFOSamplePipe
{
+protected:
+
+ bool verifyNumberOfChannels(int nChannels) const
+ {
+ if ((nChannels > 0) && (nChannels <= SOUNDTOUCH_MAX_CHANNELS))
+ {
+ return true;
+ }
+ ST_THROW_RT_ERROR("Error: Illegal number of channels");
+ return false;
+ }
+
public:
// virtual default destructor
virtual ~FIFOSamplePipe() {}
@@ -122,7 +127,6 @@ public:
};
-
/// Base-class for sound processing routines working in FIFO principle. With this base
/// class it's easy to implement sound processing stages that can be chained together,
/// so that samples that are fed into beginning of the pipe automatically go through
@@ -145,7 +149,6 @@ protected:
output = pOutput;
}
-
/// Constructor. Doesn't define output pipe; it has to be set be
/// 'setOutPipe' function.
FIFOProcessor()
@@ -153,7 +156,6 @@ protected:
output = NULL;
}
-
/// Constructor. Configures output pipe.
FIFOProcessor(FIFOSamplePipe *pOutput ///< Output pipe.
)
@@ -161,13 +163,11 @@ protected:
output = pOutput;
}
-
/// Destructor.
virtual ~FIFOProcessor()
{
}
-
/// Returns a pointer to the beginning of the output samples.
/// This function is provided for accessing the output samples directly.
/// Please be careful for not to corrupt the book-keeping!
@@ -194,7 +194,6 @@ public:
return output->receiveSamples(outBuffer, maxSamples);
}
-
/// Adjusts book-keeping so that given number of samples are removed from beginning of the
/// sample buffer without copying them anywhere.
///
@@ -206,14 +205,12 @@ public:
return output->receiveSamples(maxSamples);
}
-
/// Returns number of samples currently available.
virtual uint numSamples() const
{
return output->numSamples();
}
-
/// Returns nonzero if there aren't any samples available for outputting.
virtual int isEmpty() const
{
@@ -226,7 +223,6 @@ public:
{
return output->adjustAmountOfSamples(numSamples);
}
-
};
}
diff --git a/media/libsoundtouch/src/FIRFilter.cpp b/media/libsoundtouch/src/FIRFilter.cpp
index dc7c4aa0ba..201395bd51 100644
--- a/media/libsoundtouch/src/FIRFilter.cpp
+++ b/media/libsoundtouch/src/FIRFilter.cpp
@@ -2,22 +2,21 @@
///
/// General FIR digital filter routines with MMX optimization.
///
-/// Note : MMX optimized functions reside in a separate, platform-specific file,
+/// Notes : MMX optimized functions reside in a separate, platform-specific file,
/// e.g. 'mmx_win.cpp' or 'mmx_gcc.cpp'
///
+/// This source file contains OpenMP optimizations that allow speeding up the
+/// corss-correlation algorithm by executing it in several threads / CPU cores
+/// in parallel. See the following article link for more detailed discussion
+/// about SoundTouch OpenMP optimizations:
+/// http://www.softwarecoven.com/parallel-computing-in-embedded-mobile-devices
+///
/// Author : Copyright (c) Olli Parviainen
/// Author e-mail : oparviai 'at' iki.fi
/// SoundTouch WWW: http://www.surina.net/soundtouch
///
////////////////////////////////////////////////////////////////////////////////
//
-// Last changed : $Date: 2015-02-21 21:24:29 +0000 (Sat, 21 Feb 2015) $
-// File revision : $Revision: 4 $
-//
-// $Id: FIRFilter.cpp 202 2015-02-21 21:24:29Z oparviai $
-//
-////////////////////////////////////////////////////////////////////////////////
-//
// License :
//
// SoundTouch audio processing library
@@ -61,14 +60,17 @@ FIRFilter::FIRFilter()
length = 0;
lengthDiv8 = 0;
filterCoeffs = NULL;
+ filterCoeffsStereo = NULL;
}
FIRFilter::~FIRFilter()
{
delete[] filterCoeffs;
+ delete[] filterCoeffsStereo;
}
+
// Usual C-version of the filter routine for stereo sound
uint FIRFilter::evaluateFilterStereo(SAMPLETYPE *dest, const SAMPLETYPE *src, uint numSamples) const
{
@@ -78,35 +80,26 @@ uint FIRFilter::evaluateFilterStereo(SAMPLETYPE *dest, const SAMPLETYPE *src, ui
// because division is much slower operation than multiplying.
double dScaler = 1.0 / (double)resultDivider;
#endif
+ // hint compiler autovectorization that loop length is divisible by 8
+ int ilength = length & -8;
- assert(length != 0);
- assert(src != NULL);
- assert(dest != NULL);
- assert(filterCoeffs != NULL);
+ assert((length != 0) && (length == ilength) && (src != NULL) && (dest != NULL) && (filterCoeffs != NULL));
- end = 2 * (numSamples - length);
+ end = 2 * (numSamples - ilength);
#pragma omp parallel for
for (j = 0; j < end; j += 2)
{
const SAMPLETYPE *ptr;
LONG_SAMPLETYPE suml, sumr;
- uint i;
suml = sumr = 0;
ptr = src + j;
- for (i = 0; i < length; i += 4)
+ for (int i = 0; i < ilength; i ++)
{
- // loop is unrolled by factor of 4 here for efficiency
- suml += ptr[2 * i + 0] * filterCoeffs[i + 0] +
- ptr[2 * i + 2] * filterCoeffs[i + 1] +
- ptr[2 * i + 4] * filterCoeffs[i + 2] +
- ptr[2 * i + 6] * filterCoeffs[i + 3];
- sumr += ptr[2 * i + 1] * filterCoeffs[i + 0] +
- ptr[2 * i + 3] * filterCoeffs[i + 1] +
- ptr[2 * i + 5] * filterCoeffs[i + 2] +
- ptr[2 * i + 7] * filterCoeffs[i + 3];
+ suml += ptr[2 * i] * filterCoeffsStereo[2 * i];
+ sumr += ptr[2 * i + 1] * filterCoeffsStereo[2 * i + 1];
}
#ifdef SOUNDTOUCH_INTEGER_SAMPLES
@@ -116,19 +109,14 @@ uint FIRFilter::evaluateFilterStereo(SAMPLETYPE *dest, const SAMPLETYPE *src, ui
suml = (suml < -32768) ? -32768 : (suml > 32767) ? 32767 : suml;
// saturate to 16 bit integer limits
sumr = (sumr < -32768) ? -32768 : (sumr > 32767) ? 32767 : sumr;
-#else
- suml *= dScaler;
- sumr *= dScaler;
#endif // SOUNDTOUCH_INTEGER_SAMPLES
dest[j] = (SAMPLETYPE)suml;
dest[j + 1] = (SAMPLETYPE)sumr;
}
- return numSamples - length;
+ return numSamples - ilength;
}
-
-
// Usual C-version of the filter routine for mono sound
uint FIRFilter::evaluateFilterMono(SAMPLETYPE *dest, const SAMPLETYPE *src, uint numSamples) const
{
@@ -139,31 +127,28 @@ uint FIRFilter::evaluateFilterMono(SAMPLETYPE *dest, const SAMPLETYPE *src, uint
double dScaler = 1.0 / (double)resultDivider;
#endif
- assert(length != 0);
+ // hint compiler autovectorization that loop length is divisible by 8
+ int ilength = length & -8;
- end = numSamples - length;
+ assert(ilength != 0);
+
+ end = numSamples - ilength;
#pragma omp parallel for
- for (j = 0; j < end; j ++)
+ for (j = 0; j < end; j ++)
{
const SAMPLETYPE *pSrc = src + j;
LONG_SAMPLETYPE sum;
- uint i;
+ int i;
sum = 0;
- for (i = 0; i < length; i += 4)
+ for (i = 0; i < ilength; i ++)
{
- // loop is unrolled by factor of 4 here for efficiency
- sum += pSrc[i + 0] * filterCoeffs[i + 0] +
- pSrc[i + 1] * filterCoeffs[i + 1] +
- pSrc[i + 2] * filterCoeffs[i + 2] +
- pSrc[i + 3] * filterCoeffs[i + 3];
+ sum += pSrc[i] * filterCoeffs[i];
}
#ifdef SOUNDTOUCH_INTEGER_SAMPLES
sum >>= resultDivFactor;
// saturate to 16 bit integer limits
sum = (sum < -32768) ? -32768 : (sum > 32767) ? 32767 : sum;
-#else
- sum *= dScaler;
#endif // SOUNDTOUCH_INTEGER_SAMPLES
dest[j] = (SAMPLETYPE)sum;
}
@@ -187,14 +172,18 @@ uint FIRFilter::evaluateFilterMulti(SAMPLETYPE *dest, const SAMPLETYPE *src, uin
assert(filterCoeffs != NULL);
assert(numChannels < 16);
- end = numChannels * (numSamples - length);
+ // hint compiler autovectorization that loop length is divisible by 8
+ int ilength = length & -8;
+
+ end = numChannels * (numSamples - ilength);
#pragma omp parallel for
for (j = 0; j < end; j += numChannels)
{
const SAMPLETYPE *ptr;
LONG_SAMPLETYPE sums[16];
- uint c, i;
+ uint c;
+ int i;
for (c = 0; c < numChannels; c ++)
{
@@ -203,7 +192,7 @@ uint FIRFilter::evaluateFilterMulti(SAMPLETYPE *dest, const SAMPLETYPE *src, uin
ptr = src + j;
- for (i = 0; i < length; i ++)
+ for (i = 0; i < ilength; i ++)
{
SAMPLETYPE coef=filterCoeffs[i];
for (c = 0; c < numChannels; c ++)
@@ -217,13 +206,11 @@ uint FIRFilter::evaluateFilterMulti(SAMPLETYPE *dest, const SAMPLETYPE *src, uin
{
#ifdef SOUNDTOUCH_INTEGER_SAMPLES
sums[c] >>= resultDivFactor;
-#else
- sums[c] *= dScaler;
#endif // SOUNDTOUCH_INTEGER_SAMPLES
dest[j+c] = (SAMPLETYPE)sums[c];
}
}
- return numSamples - length;
+ return numSamples - ilength;
}
@@ -235,6 +222,13 @@ void FIRFilter::setCoefficients(const SAMPLETYPE *coeffs, uint newLength, uint u
assert(newLength > 0);
if (newLength % 8) ST_THROW_RT_ERROR("FIR filter length not divisible by 8");
+ #ifdef SOUNDTOUCH_FLOAT_SAMPLES
+ // scale coefficients already here if using floating samples
+ double scale = 1.0 / resultDivider;
+ #else
+ short scale = 1;
+ #endif
+
lengthDiv8 = newLength / 8;
length = lengthDiv8 * 8;
assert(length == newLength);
@@ -244,7 +238,16 @@ void FIRFilter::setCoefficients(const SAMPLETYPE *coeffs, uint newLength, uint u
delete[] filterCoeffs;
filterCoeffs = new SAMPLETYPE[length];
- memcpy(filterCoeffs, coeffs, length * sizeof(SAMPLETYPE));
+ delete[] filterCoeffsStereo;
+ filterCoeffsStereo = new SAMPLETYPE[length*2];
+ for (uint i = 0; i < length; i ++)
+ {
+ filterCoeffs[i] = (SAMPLETYPE)(coeffs[i] * scale);
+ // create also stereo set of filter coefficients: this allows compiler
+ // to autovectorize filter evaluation much more efficiently
+ filterCoeffsStereo[2 * i] = (SAMPLETYPE)(coeffs[i] * scale);
+ filterCoeffsStereo[2 * i + 1] = (SAMPLETYPE)(coeffs[i] * scale);
+ }
}
@@ -254,7 +257,6 @@ uint FIRFilter::getLength() const
}
-
// Applies the filter to the given sequence of samples.
//
// Note : The amount of outputted samples is by value of 'filter_length'
@@ -284,7 +286,6 @@ uint FIRFilter::evaluate(SAMPLETYPE *dest, const SAMPLETYPE *src, uint numSample
}
-
// Operator 'new' is overloaded so that it automatically creates a suitable instance
// depending on if we've a MMX-capable CPU available or not.
void * FIRFilter::operator new(size_t s)
diff --git a/media/libsoundtouch/src/FIRFilter.h b/media/libsoundtouch/src/FIRFilter.h
index 70ba97cfe5..39c2cc7542 100644
--- a/media/libsoundtouch/src/FIRFilter.h
+++ b/media/libsoundtouch/src/FIRFilter.h
@@ -11,13 +11,6 @@
///
////////////////////////////////////////////////////////////////////////////////
//
-// Last changed : $Date: 2015-02-21 21:24:29 +0000 (Sat, 21 Feb 2015) $
-// File revision : $Revision: 4 $
-//
-// $Id: FIRFilter.h 202 2015-02-21 21:24:29Z oparviai $
-//
-////////////////////////////////////////////////////////////////////////////////
-//
// License :
//
// SoundTouch audio processing library
@@ -64,6 +57,7 @@ protected:
// Memory for filter coefficients
SAMPLETYPE *filterCoeffs;
+ SAMPLETYPE *filterCoeffsStereo;
virtual uint evaluateFilterStereo(SAMPLETYPE *dest,
const SAMPLETYPE *src,
diff --git a/media/libsoundtouch/src/InterpolateCubic.cpp b/media/libsoundtouch/src/InterpolateCubic.cpp
index 8aa7374c74..b37b0fa801 100644
--- a/media/libsoundtouch/src/InterpolateCubic.cpp
+++ b/media/libsoundtouch/src/InterpolateCubic.cpp
@@ -8,10 +8,6 @@
///
////////////////////////////////////////////////////////////////////////////////
//
-// $Id: InterpolateCubic.cpp 179 2014-01-06 18:41:42Z oparviai $
-//
-////////////////////////////////////////////////////////////////////////////////
-//
// License :
//
// SoundTouch audio processing library
diff --git a/media/libsoundtouch/src/InterpolateCubic.h b/media/libsoundtouch/src/InterpolateCubic.h
index e0e302b233..481abd64bc 100644
--- a/media/libsoundtouch/src/InterpolateCubic.h
+++ b/media/libsoundtouch/src/InterpolateCubic.h
@@ -8,10 +8,6 @@
///
////////////////////////////////////////////////////////////////////////////////
//
-// $Id: InterpolateCubic.h 179 2014-01-06 18:41:42Z oparviai $
-//
-////////////////////////////////////////////////////////////////////////////////
-//
// License :
//
// SoundTouch audio processing library
@@ -45,7 +41,6 @@ namespace soundtouch
class InterpolateCubic : public TransposerBase
{
protected:
- virtual void resetRegisters();
virtual int transposeMono(SAMPLETYPE *dest,
const SAMPLETYPE *src,
int &srcSamples);
@@ -56,10 +51,17 @@ protected:
const SAMPLETYPE *src,
int &srcSamples);
- float fract;
+ double fract;
public:
InterpolateCubic();
+
+ virtual void resetRegisters();
+
+ int getLatency() const
+ {
+ return 1;
+ }
};
}
diff --git a/media/libsoundtouch/src/InterpolateLinear.cpp b/media/libsoundtouch/src/InterpolateLinear.cpp
index ae26e69a1e..9533e79b79 100644
--- a/media/libsoundtouch/src/InterpolateLinear.cpp
+++ b/media/libsoundtouch/src/InterpolateLinear.cpp
@@ -8,10 +8,6 @@
///
////////////////////////////////////////////////////////////////////////////////
//
-// $Id: InterpolateLinear.cpp 180 2014-01-06 19:16:02Z oparviai $
-//
-////////////////////////////////////////////////////////////////////////////////
-//
// License :
//
// SoundTouch audio processing library
@@ -146,7 +142,7 @@ int InterpolateLinearInteger::transposeMulti(SAMPLETYPE *dest, const SAMPLETYPE
LONG_SAMPLETYPE temp, vol1;
assert(iFract < SCALE);
- vol1 = (SCALE - iFract);
+ vol1 = (LONG_SAMPLETYPE)(SCALE - iFract);
for (int c = 0; c < numChannels; c ++)
{
temp = vol1 * src[c] + iFract * src[c + numChannels];
@@ -170,9 +166,9 @@ int InterpolateLinearInteger::transposeMulti(SAMPLETYPE *dest, const SAMPLETYPE
// Sets new target iRate. Normal iRate = 1.0, smaller values represent slower
// iRate, larger faster iRates.
-void InterpolateLinearInteger::setRate(float newRate)
+void InterpolateLinearInteger::setRate(double newRate)
{
- iRate = (int)(newRate * SCALE + 0.5f);
+ iRate = (int)(newRate * SCALE + 0.5);
TransposerBase::setRate(newRate);
}
@@ -190,7 +186,7 @@ InterpolateLinearFloat::InterpolateLinearFloat() : TransposerBase()
// Notice: use local function calling syntax for sake of clarity,
// to indicate the fact that C++ constructor can't call virtual functions.
resetRegisters();
- setRate(1.0f);
+ setRate(1.0);
}
@@ -275,12 +271,13 @@ int InterpolateLinearFloat::transposeMulti(SAMPLETYPE *dest, const SAMPLETYPE *s
i = 0;
while (srcCount < srcSampleEnd)
{
- float temp, vol1;
+ float temp, vol1, fract_float;
- vol1 = (1.0f- fract);
+ vol1 = (float)(1.0 - fract);
+ fract_float = (float)fract;
for (int c = 0; c < numChannels; c ++)
{
- temp = vol1 * src[c] + fract * src[c + numChannels];
+ temp = vol1 * src[c] + fract_float * src[c + numChannels];
*dest = (SAMPLETYPE)temp;
dest ++;
}
diff --git a/media/libsoundtouch/src/InterpolateLinear.h b/media/libsoundtouch/src/InterpolateLinear.h
index b76299f889..ff362e84b1 100644
--- a/media/libsoundtouch/src/InterpolateLinear.h
+++ b/media/libsoundtouch/src/InterpolateLinear.h
@@ -8,10 +8,6 @@
///
////////////////////////////////////////////////////////////////////////////////
//
-// $Id: InterpolateLinear.h 179 2014-01-06 18:41:42Z oparviai $
-//
-////////////////////////////////////////////////////////////////////////////////
-//
// License :
//
// SoundTouch audio processing library
@@ -42,15 +38,13 @@
namespace soundtouch
{
-/// Linear transposer class that uses integer arithmetics
+/// Linear transposer class that uses integer arithmetic
class InterpolateLinearInteger : public TransposerBase
{
protected:
int iFract;
int iRate;
- virtual void resetRegisters();
-
virtual int transposeMono(SAMPLETYPE *dest,
const SAMPLETYPE *src,
int &srcSamples);
@@ -63,17 +57,22 @@ public:
/// Sets new target rate. Normal rate = 1.0, smaller values represent slower
/// rate, larger faster rates.
- virtual void setRate(float newRate);
+ virtual void setRate(double newRate);
+
+ virtual void resetRegisters();
+
+ int getLatency() const
+ {
+ return 0;
+ }
};
-/// Linear transposer class that uses floating point arithmetics
+/// Linear transposer class that uses floating point arithmetic
class InterpolateLinearFloat : public TransposerBase
{
protected:
- float fract;
-
- virtual void resetRegisters();
+ double fract;
virtual int transposeMono(SAMPLETYPE *dest,
const SAMPLETYPE *src,
@@ -85,6 +84,13 @@ protected:
public:
InterpolateLinearFloat();
+
+ virtual void resetRegisters();
+
+ int getLatency() const
+ {
+ return 0;
+ }
};
}
diff --git a/media/libsoundtouch/src/InterpolateShannon.cpp b/media/libsoundtouch/src/InterpolateShannon.cpp
index 1085fd14cb..975d872ad6 100644
--- a/media/libsoundtouch/src/InterpolateShannon.cpp
+++ b/media/libsoundtouch/src/InterpolateShannon.cpp
@@ -13,10 +13,6 @@
///
////////////////////////////////////////////////////////////////////////////////
//
-// $Id: InterpolateShannon.cpp 195 2014-04-06 15:57:21Z oparviai $
-//
-////////////////////////////////////////////////////////////////////////////////
-//
// License :
//
// SoundTouch audio processing library
diff --git a/media/libsoundtouch/src/InterpolateShannon.h b/media/libsoundtouch/src/InterpolateShannon.h
index 701640f7db..72ab0b526d 100644
--- a/media/libsoundtouch/src/InterpolateShannon.h
+++ b/media/libsoundtouch/src/InterpolateShannon.h
@@ -13,10 +13,6 @@
///
////////////////////////////////////////////////////////////////////////////////
//
-// $Id: InterpolateShannon.h 179 2014-01-06 18:41:42Z oparviai $
-//
-////////////////////////////////////////////////////////////////////////////////
-//
// License :
//
// SoundTouch audio processing library
@@ -50,7 +46,6 @@ namespace soundtouch
class InterpolateShannon : public TransposerBase
{
protected:
- void resetRegisters();
int transposeMono(SAMPLETYPE *dest,
const SAMPLETYPE *src,
int &srcSamples);
@@ -61,10 +56,17 @@ protected:
const SAMPLETYPE *src,
int &srcSamples);
- float fract;
+ double fract;
public:
InterpolateShannon();
+
+ void resetRegisters();
+
+ int getLatency() const
+ {
+ return 3;
+ }
};
}
diff --git a/media/libsoundtouch/src/RateTransposer.cpp b/media/libsoundtouch/src/RateTransposer.cpp
index f1e3fd043b..4c202391e0 100644
--- a/media/libsoundtouch/src/RateTransposer.cpp
+++ b/media/libsoundtouch/src/RateTransposer.cpp
@@ -10,13 +10,6 @@
///
////////////////////////////////////////////////////////////////////////////////
//
-// Last changed : $Date: 2014-04-06 15:57:21 +0000 (Sun, 06 Apr 2014) $
-// File revision : $Revision: 4 $
-//
-// $Id: RateTransposer.cpp 195 2014-04-06 15:57:21Z oparviai $
-//
-////////////////////////////////////////////////////////////////////////////////
-//
// License :
//
// SoundTouch audio processing library
@@ -57,15 +50,21 @@ TransposerBase::ALGORITHM TransposerBase::algorithm = TransposerBase::CUBIC;
// Constructor
RateTransposer::RateTransposer() : FIFOProcessor(&outputBuffer)
{
- bUseAAFilter = true;
+ bUseAAFilter =
+#ifndef SOUNDTOUCH_PREVENT_CLICK_AT_RATE_CROSSOVER
+ true;
+#else
+ // Disable Anti-alias filter if desirable to avoid click at rate change zero value crossover
+ false;
+#endif
// Instantiates the anti-alias filter
pAAFilter = new AAFilter(64);
pTransposer = TransposerBase::newInstance();
+ clear();
}
-
RateTransposer::~RateTransposer()
{
delete pAAFilter;
@@ -73,11 +72,14 @@ RateTransposer::~RateTransposer()
}
-
/// Enables/disables the anti-alias filter. Zero to disable, nonzero to enable
void RateTransposer::enableAAFilter(bool newMode)
{
+#ifndef SOUNDTOUCH_PREVENT_CLICK_AT_RATE_CROSSOVER
+ // Disable Anti-alias filter if desirable to avoid click at rate change zero value crossover
bUseAAFilter = newMode;
+ clear();
+#endif
}
@@ -94,23 +96,22 @@ AAFilter *RateTransposer::getAAFilter()
}
-
// Sets new target iRate. Normal iRate = 1.0, smaller values represent slower
// iRate, larger faster iRates.
-void RateTransposer::setRate(float newRate)
+void RateTransposer::setRate(double newRate)
{
double fCutoff;
pTransposer->setRate(newRate);
// design a new anti-alias filter
- if (newRate > 1.0f)
+ if (newRate > 1.0)
{
- fCutoff = 0.5f / newRate;
+ fCutoff = 0.5 / newRate;
}
else
{
- fCutoff = 0.5f * newRate;
+ fCutoff = 0.5 * newRate;
}
pAAFilter->setCutoffFreq(fCutoff);
}
@@ -177,11 +178,10 @@ void RateTransposer::processSamples(const SAMPLETYPE *src, uint nSamples)
// Sets the number of channels, 1 = mono, 2 = stereo
void RateTransposer::setChannels(int nChannels)
{
- assert(nChannels > 0);
+ if (!verifyNumberOfChannels(nChannels) ||
+ (pTransposer->numChannels == nChannels)) return;
- if (pTransposer->numChannels == nChannels) return;
pTransposer->setChannels(nChannels);
-
inputBuffer.setChannels(nChannels);
midBuffer.setChannels(nChannels);
outputBuffer.setChannels(nChannels);
@@ -194,6 +194,11 @@ void RateTransposer::clear()
outputBuffer.clear();
midBuffer.clear();
inputBuffer.clear();
+ pTransposer->resetRegisters();
+
+ // prefill buffer to avoid losing first samples at beginning of stream
+ int prefill = getLatency();
+ inputBuffer.addSilent(prefill);
}
@@ -208,6 +213,14 @@ int RateTransposer::isEmpty() const
}
+/// Return approximate initial input-output latency
+int RateTransposer::getLatency() const
+{
+ return pTransposer->getLatency() +
+ ((bUseAAFilter) ? (pAAFilter->getLength() / 2) : 0);
+}
+
+
//////////////////////////////////////////////////////////////////////////////
//
// TransposerBase - Base class for interpolation
@@ -225,7 +238,7 @@ void TransposerBase::setAlgorithm(TransposerBase::ALGORITHM a)
int TransposerBase::transpose(FIFOSampleBuffer &dest, FIFOSampleBuffer &src)
{
int numSrcSamples = src.numSamples();
- int sizeDemand = (int)((float)numSrcSamples / rate) + 8;
+ int sizeDemand = (int)((double)numSrcSamples / rate) + 8;
int numOutput;
SAMPLETYPE *psrc = src.ptrBegin();
SAMPLETYPE *pdest = dest.ptrEnd(sizeDemand);
@@ -270,7 +283,7 @@ void TransposerBase::setChannels(int channels)
}
-void TransposerBase::setRate(float newRate)
+void TransposerBase::setRate(double newRate)
{
rate = newRate;
}
@@ -280,7 +293,7 @@ void TransposerBase::setRate(float newRate)
TransposerBase *TransposerBase::newInstance()
{
#ifdef SOUNDTOUCH_INTEGER_SAMPLES
- // Notice: For integer arithmetics support only linear algorithm (due to simplest calculus)
+ // Notice: For integer arithmetic support only linear algorithm (due to simplest calculus)
return ::new InterpolateLinearInteger;
#else
switch (algorithm)
diff --git a/media/libsoundtouch/src/RateTransposer.h b/media/libsoundtouch/src/RateTransposer.h
index fad6d65718..59381fab5f 100644
--- a/media/libsoundtouch/src/RateTransposer.h
+++ b/media/libsoundtouch/src/RateTransposer.h
@@ -14,13 +14,6 @@
///
////////////////////////////////////////////////////////////////////////////////
//
-// Last changed : $Date: 2014-04-06 15:57:21 +0000 (Sun, 06 Apr 2014) $
-// File revision : $Revision: 4 $
-//
-// $Id: RateTransposer.h 195 2014-04-06 15:57:21Z oparviai $
-//
-////////////////////////////////////////////////////////////////////////////////
-//
// License :
//
// SoundTouch audio processing library
@@ -66,8 +59,6 @@ public:
};
protected:
- virtual void resetRegisters() = 0;
-
virtual int transposeMono(SAMPLETYPE *dest,
const SAMPLETYPE *src,
int &srcSamples) = 0;
@@ -81,15 +72,18 @@ protected:
static ALGORITHM algorithm;
public:
- float rate;
+ double rate;
int numChannels;
TransposerBase();
virtual ~TransposerBase();
virtual int transpose(FIFOSampleBuffer &dest, FIFOSampleBuffer &src);
- virtual void setRate(float newRate);
+ virtual void setRate(double newRate);
virtual void setChannels(int channels);
+ virtual int getLatency() const = 0;
+
+ virtual void resetRegisters() = 0;
// static factory function
static TransposerBase *newInstance();
@@ -132,21 +126,9 @@ public:
RateTransposer();
virtual ~RateTransposer();
- /// Operator 'new' is overloaded so that it automatically creates a suitable instance
- /// depending on if we're to use integer or floating point arithmetics.
-// static void *operator new(size_t s);
-
- /// Use this function instead of "new" operator to create a new instance of this class.
- /// This function automatically chooses a correct implementation, depending on if
- /// integer ot floating point arithmetics are to be used.
-// static RateTransposer *newInstance();
-
/// Returns the output buffer object
FIFOSamplePipe *getOutput() { return &outputBuffer; };
- /// Returns the store buffer object
-// FIFOSamplePipe *getStore() { return &storeBuffer; };
-
/// Return anti-alias filter object
AAFilter *getAAFilter();
@@ -158,7 +140,7 @@ public:
/// Sets new target rate. Normal rate = 1.0, smaller values represent slower
/// rate, larger faster rates.
- virtual void setRate(float newRate);
+ virtual void setRate(double newRate);
/// Sets the number of channels, 1 = mono, 2 = stereo
void setChannels(int channels);
@@ -172,6 +154,9 @@ public:
/// Returns nonzero if there aren't any samples available for outputting.
int isEmpty() const;
+
+ /// Return approximate initial input-output latency
+ int getLatency() const;
};
}
diff --git a/media/libsoundtouch/src/STTypes.h b/media/libsoundtouch/src/STTypes.h
index ddd56d8080..c823fcfd23 100644
--- a/media/libsoundtouch/src/STTypes.h
+++ b/media/libsoundtouch/src/STTypes.h
@@ -8,13 +8,6 @@
///
////////////////////////////////////////////////////////////////////////////////
//
-// Last changed : $Date: 2015-05-18 15:25:07 +0000 (Mon, 18 May 2015) $
-// File revision : $Revision: 3 $
-//
-// $Id: STTypes.h 215 2015-05-18 15:25:07Z oparviai $
-//
-////////////////////////////////////////////////////////////////////////////////
-//
// License :
//
// SoundTouch audio processing library
@@ -57,13 +50,20 @@ typedef unsigned long ulong;
#include "soundtouch_config.h"
#if defined(WIN32)
-#define EXPORT __declspec(dllexport)
+#if defined(BUILDING_SOUNDTOUCH)
+#define SOUNDTOUCH_API __declspec(dllexport)
+#else
+#define SOUNDTOUCH_API __declspec(dllimport)
+#endif
#else
-#define EXPORT
+#define SOUNDTOUCH_API
#endif
namespace soundtouch
{
+ /// Max allowed number of channels
+ #define SOUNDTOUCH_MAX_CHANNELS 16
+
/// Activate these undef's to overrule the possible sampletype
/// setting inherited from some other header file:
//#undef SOUNDTOUCH_INTEGER_SAMPLES
@@ -126,10 +126,10 @@ namespace soundtouch
#endif
- // If defined, allows the SIMD-optimized routines to take minor shortcuts
- // for improved performance. Undefine to require faithfully similar SIMD
- // calculations as in normal C implementation.
- #define SOUNDTOUCH_ALLOW_NONEXACT_SIMD_OPTIMIZATION 1
+ // If defined, allows the SIMD-optimized routines to skip unevenly aligned
+ // memory offsets that can cause performance penalty in some SIMD implementations.
+ // Causes slight compromise in sound quality.
+ // #define SOUNDTOUCH_ALLOW_NONEXACT_SIMD_OPTIMIZATION 1
#ifdef SOUNDTOUCH_INTEGER_SAMPLES
@@ -144,16 +144,19 @@ namespace soundtouch
#endif // SOUNDTOUCH_FLOAT_SAMPLES
#ifdef SOUNDTOUCH_ALLOW_X86_OPTIMIZATIONS
- // Allow MMX optimizations
- #define SOUNDTOUCH_ALLOW_MMX 1
+ // Allow MMX optimizations (not available in X64 mode)
+ #if (!_M_X64)
+ #define SOUNDTOUCH_ALLOW_MMX 1
+ #endif
#endif
#else
// floating point samples
typedef float SAMPLETYPE;
- // data type for sample accumulation: Use double to utilize full precision.
- typedef double LONG_SAMPLETYPE;
+ // data type for sample accumulation: Use float also here to enable
+ // efficient autovectorization
+ typedef float LONG_SAMPLETYPE;
#ifdef SOUNDTOUCH_ALLOW_X86_OPTIMIZATIONS
// Allow SSE optimizations
@@ -162,10 +165,16 @@ namespace soundtouch
#endif // SOUNDTOUCH_INTEGER_SAMPLES
-};
+ #if ((SOUNDTOUCH_ALLOW_SSE) || (__SSE__) || (SOUNDTOUCH_USE_NEON))
+ #if SOUNDTOUCH_ALLOW_NONEXACT_SIMD_OPTIMIZATION
+ #define ST_SIMD_AVOID_UNALIGNED
+ #endif
+ #endif
+
+}
// define ST_NO_EXCEPTION_HANDLING switch to disable throwing std exceptions:
-// #define ST_NO_EXCEPTION_HANDLING 1
+#define ST_NO_EXCEPTION_HANDLING 1
#ifdef ST_NO_EXCEPTION_HANDLING
// Exceptions disabled. Throw asserts instead if enabled.
#include <assert.h>
diff --git a/media/libsoundtouch/src/SoundTouch.cpp b/media/libsoundtouch/src/SoundTouch.cpp
index 955818810b..69fba8b9b5 100644
--- a/media/libsoundtouch/src/SoundTouch.cpp
+++ b/media/libsoundtouch/src/SoundTouch.cpp
@@ -41,13 +41,6 @@
///
////////////////////////////////////////////////////////////////////////////////
//
-// Last changed : $Date: 2014-10-08 15:26:57 +0000 (Wed, 08 Oct 2014) $
-// File revision : $Revision: 4 $
-//
-// $Id: SoundTouch.cpp 201 2014-10-08 15:26:57Z oparviai $
-//
-////////////////////////////////////////////////////////////////////////////////
-//
// License :
//
// SoundTouch audio processing library
@@ -110,12 +103,14 @@ SoundTouch::SoundTouch()
calcEffectiveRateAndTempo();
+ samplesExpectedOut = 0;
+ samplesOutput = 0;
+
channels = 0;
bSrateSet = false;
}
-
SoundTouch::~SoundTouch()
{
delete pRateTransposer;
@@ -123,7 +118,6 @@ SoundTouch::~SoundTouch()
}
-
/// Get SoundTouch library version string
const char *SoundTouch::getVersionString()
{
@@ -143,90 +137,79 @@ uint SoundTouch::getVersionId()
// Sets the number of channels, 1 = mono, 2 = stereo
void SoundTouch::setChannels(uint numChannels)
{
- /*if (numChannels != 1 && numChannels != 2)
- {
- //ST_THROW_RT_ERROR("Illegal number of channels");
- return;
- }*/
+ if (!verifyNumberOfChannels(numChannels)) return;
+
channels = numChannels;
pRateTransposer->setChannels((int)numChannels);
pTDStretch->setChannels((int)numChannels);
}
-
// Sets new rate control value. Normal rate = 1.0, smaller values
// represent slower rate, larger faster rates.
-void SoundTouch::setRate(float newRate)
+void SoundTouch::setRate(double newRate)
{
virtualRate = newRate;
calcEffectiveRateAndTempo();
}
-
// Sets new rate control value as a difference in percents compared
// to the original rate (-50 .. +100 %)
-void SoundTouch::setRateChange(float newRate)
+void SoundTouch::setRateChange(double newRate)
{
- virtualRate = 1.0f + 0.01f * newRate;
+ virtualRate = 1.0 + 0.01 * newRate;
calcEffectiveRateAndTempo();
}
-
// Sets new tempo control value. Normal tempo = 1.0, smaller values
// represent slower tempo, larger faster tempo.
-void SoundTouch::setTempo(float newTempo)
+void SoundTouch::setTempo(double newTempo)
{
virtualTempo = newTempo;
calcEffectiveRateAndTempo();
}
-
// Sets new tempo control value as a difference in percents compared
// to the original tempo (-50 .. +100 %)
-void SoundTouch::setTempoChange(float newTempo)
+void SoundTouch::setTempoChange(double newTempo)
{
- virtualTempo = 1.0f + 0.01f * newTempo;
+ virtualTempo = 1.0 + 0.01 * newTempo;
calcEffectiveRateAndTempo();
}
-
// Sets new pitch control value. Original pitch = 1.0, smaller values
// represent lower pitches, larger values higher pitch.
-void SoundTouch::setPitch(float newPitch)
+void SoundTouch::setPitch(double newPitch)
{
virtualPitch = newPitch;
calcEffectiveRateAndTempo();
}
-
// Sets pitch change in octaves compared to the original pitch
// (-1.00 .. +1.00)
-void SoundTouch::setPitchOctaves(float newPitch)
+void SoundTouch::setPitchOctaves(double newPitch)
{
- virtualPitch = (float)exp(0.69314718056f * newPitch);
+ virtualPitch = exp(0.69314718056 * newPitch);
calcEffectiveRateAndTempo();
}
-
// Sets pitch change in semi-tones compared to the original pitch
// (-12 .. +12)
void SoundTouch::setPitchSemiTones(int newPitch)
{
- setPitchOctaves((float)newPitch / 12.0f);
+ setPitchOctaves((double)newPitch / 12.0);
}
-
-void SoundTouch::setPitchSemiTones(float newPitch)
+void SoundTouch::setPitchSemiTones(double newPitch)
{
- setPitchOctaves(newPitch / 12.0f);
+ setPitchOctaves(newPitch / 12.0);
}
@@ -234,8 +217,8 @@ void SoundTouch::setPitchSemiTones(float newPitch)
// nominal control values.
void SoundTouch::calcEffectiveRateAndTempo()
{
- float oldTempo = tempo;
- float oldRate = rate;
+ double oldTempo = tempo;
+ double oldRate = rate;
tempo = virtualTempo / virtualPitch;
rate = virtualPitch * virtualRate;
@@ -302,23 +285,12 @@ void SoundTouch::putSamples(const SAMPLETYPE *samples, uint nSamples)
ST_THROW_RT_ERROR("SoundTouch : Number of channels not defined");
}
- // Transpose the rate of the new samples if necessary
- /* Bypass the nominal setting - can introduce a click in sound when tempo/pitch control crosses the nominal value...
- if (rate == 1.0f)
- {
- // The rate value is same as the original, simply evaluate the tempo changer.
- assert(output == pTDStretch);
- if (pRateTransposer->isEmpty() == 0)
- {
- // yet flush the last samples in the pitch transposer buffer
- // (may happen if 'rate' changes from a non-zero value to zero)
- pTDStretch->moveSamples(*pRateTransposer);
- }
- pTDStretch->putSamples(samples, nSamples);
- }
- */
+ // accumulate how many samples are expected out from processing, given the current
+ // processing setting
+ samplesExpectedOut += (double)nSamples / ((double)rate * (double)tempo);
+
#ifndef SOUNDTOUCH_PREVENT_CLICK_AT_RATE_CROSSOVER
- else if (rate <= 1.0f)
+ if (rate <= 1.0f)
{
// transpose the rate down, output the transposed sound to tempo changer buffer
assert(output == pTDStretch);
@@ -346,44 +318,30 @@ void SoundTouch::putSamples(const SAMPLETYPE *samples, uint nSamples)
void SoundTouch::flush()
{
int i;
- int nUnprocessed;
- int nOut;
- SAMPLETYPE *buff = new SAMPLETYPE[64 * channels];
-
- // check how many samples still await processing, and scale
- // that by tempo & rate to get expected output sample count
- nUnprocessed = numUnprocessedSamples();
- nUnprocessed = (int)((double)nUnprocessed / (tempo * rate) + 0.5);
+ int numStillExpected;
+ SAMPLETYPE *buff = new SAMPLETYPE[128 * channels];
- nOut = numSamples(); // ready samples currently in buffer ...
- nOut += nUnprocessed; // ... and how many we expect there to be in the end
-
- memset(buff, 0, 64 * channels * sizeof(SAMPLETYPE));
+ // how many samples are still expected to output
+ numStillExpected = (int)((long)(samplesExpectedOut + 0.5) - samplesOutput);
+ if (numStillExpected < 0) numStillExpected = 0;
+
+ memset(buff, 0, 128 * channels * sizeof(SAMPLETYPE));
// "Push" the last active samples out from the processing pipeline by
// feeding blank samples into the processing pipeline until new,
// processed samples appear in the output (not however, more than
- // 8ksamples in any case)
- for (i = 0; i < 128; i ++)
+ // 24ksamples in any case)
+ for (i = 0; (numStillExpected > (int)numSamples()) && (i < 200); i ++)
{
- putSamples(buff, 64);
- if ((int)numSamples() >= nOut)
- {
- // Enough new samples have appeared into the output!
- // As samples come from processing with bigger chunks, now truncate it
- // back to maximum "nOut" samples to improve duration accuracy
- adjustAmountOfSamples(nOut);
-
- // finish
- break;
- }
+ putSamples(buff, 128);
}
+ adjustAmountOfSamples(numStillExpected);
+
delete[] buff;
- // Clear working buffers
- pRateTransposer->clear();
+ // Clear input buffers
pTDStretch->clearInput();
- // yet leave the 'tempoChanger' output intouched as that's where the
+ // yet leave the output intouched as that's where the
// flushed samples are!
}
@@ -452,7 +410,7 @@ int SoundTouch::getSetting(int settingId) const
return pRateTransposer->getAAFilter()->getLength();
case SETTING_USE_QUICKSEEK :
- return (uint) pTDStretch->isQuickSeekEnabled();
+ return (uint)pTDStretch->isQuickSeekEnabled();
case SETTING_SEQUENCE_MS:
pTDStretch->getParameters(NULL, &temp, NULL, NULL);
@@ -466,13 +424,53 @@ int SoundTouch::getSetting(int settingId) const
pTDStretch->getParameters(NULL, NULL, NULL, &temp);
return temp;
- case SETTING_NOMINAL_INPUT_SEQUENCE :
- return pTDStretch->getInputSampleReq();
+ case SETTING_NOMINAL_INPUT_SEQUENCE :
+ {
+ int size = pTDStretch->getInputSampleReq();
+
+#ifndef SOUNDTOUCH_PREVENT_CLICK_AT_RATE_CROSSOVER
+ if (rate <= 1.0)
+ {
+ // transposing done before timestretch, which impacts latency
+ return (int)(size * rate + 0.5);
+ }
+#endif
+ return size;
+ }
+
+ case SETTING_NOMINAL_OUTPUT_SEQUENCE :
+ {
+ int size = pTDStretch->getOutputBatchSize();
+
+ if (rate > 1.0)
+ {
+ // transposing done after timestretch, which impacts latency
+ return (int)(size / rate + 0.5);
+ }
+ return size;
+ }
+
+ case SETTING_INITIAL_LATENCY:
+ {
+ double latency = pTDStretch->getLatency();
+ int latency_tr = pRateTransposer->getLatency();
+
+#ifndef SOUNDTOUCH_PREVENT_CLICK_AT_RATE_CROSSOVER
+ if (rate <= 1.0)
+ {
+ // transposing done before timestretch, which impacts latency
+ latency = (latency + latency_tr) * rate;
+ }
+ else
+#endif
+ {
+ latency += (double)latency_tr / rate;
+ }
- case SETTING_NOMINAL_OUTPUT_SEQUENCE :
- return pTDStretch->getOutputBatchSize();
+ return (int)(latency + 0.5);
+ }
- default :
+ default :
return 0;
}
}
@@ -482,12 +480,13 @@ int SoundTouch::getSetting(int settingId) const
// buffers.
void SoundTouch::clear()
{
+ samplesExpectedOut = 0;
+ samplesOutput = 0;
pRateTransposer->clear();
pTDStretch->clear();
}
-
/// Returns number of samples currently unprocessed.
uint SoundTouch::numUnprocessedSamples() const
{
@@ -502,3 +501,38 @@ uint SoundTouch::numUnprocessedSamples() const
}
return 0;
}
+
+
+/// Output samples from beginning of the sample buffer. Copies requested samples to
+/// output buffer and removes them from the sample buffer. If there are less than
+/// 'numsample' samples in the buffer, returns all that available.
+///
+/// \return Number of samples returned.
+uint SoundTouch::receiveSamples(SAMPLETYPE *output, uint maxSamples)
+{
+ uint ret = FIFOProcessor::receiveSamples(output, maxSamples);
+ samplesOutput += (long)ret;
+ return ret;
+}
+
+
+/// Adjusts book-keeping so that given number of samples are removed from beginning of the
+/// sample buffer without copying them anywhere.
+///
+/// Used to reduce the number of samples in the buffer when accessing the sample buffer directly
+/// with 'ptrBegin' function.
+uint SoundTouch::receiveSamples(uint maxSamples)
+{
+ uint ret = FIFOProcessor::receiveSamples(maxSamples);
+ samplesOutput += (long)ret;
+ return ret;
+}
+
+
+/// Get ratio between input and output audio durations, useful for calculating
+/// processed output duration: if you'll process a stream of N samples, then
+/// you can expect to get out N * getInputOutputSampleRatio() samples.
+double SoundTouch::getInputOutputSampleRatio()
+{
+ return 1.0 / (tempo * rate);
+}
diff --git a/media/libsoundtouch/src/SoundTouch.h b/media/libsoundtouch/src/SoundTouch.h
index 0581926b49..c8a48940ea 100644
--- a/media/libsoundtouch/src/SoundTouch.h
+++ b/media/libsoundtouch/src/SoundTouch.h
@@ -41,13 +41,6 @@
///
////////////////////////////////////////////////////////////////////////////////
//
-// Last changed : $Date: 2015-05-18 15:28:41 +0000 (Mon, 18 May 2015) $
-// File revision : $Revision: 4 $
-//
-// $Id: SoundTouch.h 216 2015-05-18 15:28:41Z oparviai $
-//
-////////////////////////////////////////////////////////////////////////////////
-//
// License :
//
// SoundTouch audio processing library
@@ -79,10 +72,10 @@ namespace soundtouch
{
/// Soundtouch library version string
-#define SOUNDTOUCH_VERSION "1.9.0"
+#define SOUNDTOUCH_VERSION "2.3.1"
/// SoundTouch library version id
-#define SOUNDTOUCH_VERSION_ID (10900)
+#define SOUNDTOUCH_VERSION_ID (20301)
//
// Available setting IDs for the 'setSetting' & 'get_setting' functions:
@@ -116,32 +109,63 @@ namespace soundtouch
#define SETTING_OVERLAP_MS 5
-/// Call "getSetting" with this ID to query nominal average processing sequence
-/// size in samples. This value tells approcimate value how many input samples
-/// SoundTouch needs to gather before it does DSP processing run for the sample batch.
+/// Call "getSetting" with this ID to query processing sequence size in samples.
+/// This value gives approximate value of how many input samples you'll need to
+/// feed into SoundTouch after initial buffering to get out a new batch of
+/// output samples.
+///
+/// This value does not include initial buffering at beginning of a new processing
+/// stream, use SETTING_INITIAL_LATENCY to get the initial buffering size.
///
/// Notices:
/// - This is read-only parameter, i.e. setSetting ignores this parameter
-/// - Returned value is approximate average value, exact processing batch
-/// size may wary from time to time
-/// - This parameter value is not constant but may change depending on
+/// - This parameter value is not constant but change depending on
/// tempo/pitch/rate/samplerate settings.
-#define SETTING_NOMINAL_INPUT_SEQUENCE 6
+#define SETTING_NOMINAL_INPUT_SEQUENCE 6
/// Call "getSetting" with this ID to query nominal average processing output
/// size in samples. This value tells approcimate value how many output samples
/// SoundTouch outputs once it does DSP processing run for a batch of input samples.
-///
+///
/// Notices:
/// - This is read-only parameter, i.e. setSetting ignores this parameter
-/// - Returned value is approximate average value, exact processing batch
-/// size may wary from time to time
-/// - This parameter value is not constant but may change depending on
+/// - This parameter value is not constant but change depending on
/// tempo/pitch/rate/samplerate settings.
-#define SETTING_NOMINAL_OUTPUT_SEQUENCE 7
+#define SETTING_NOMINAL_OUTPUT_SEQUENCE 7
+
-class EXPORT SoundTouch : public FIFOProcessor
+/// Call "getSetting" with this ID to query initial processing latency, i.e.
+/// approx. how many samples you'll need to enter to SoundTouch pipeline before
+/// you can expect to get first batch of ready output samples out.
+///
+/// After the first output batch, you can then expect to get approx.
+/// SETTING_NOMINAL_OUTPUT_SEQUENCE ready samples out for every
+/// SETTING_NOMINAL_INPUT_SEQUENCE samples that you enter into SoundTouch.
+///
+/// Example:
+/// processing with parameter -tempo=5
+/// => initial latency = 5509 samples
+/// input sequence = 4167 samples
+/// output sequence = 3969 samples
+///
+/// Accordingly, you can expect to feed in approx. 5509 samples at beginning of
+/// the stream, and then you'll get out the first 3969 samples. After that, for
+/// every approx. 4167 samples that you'll put in, you'll receive again approx.
+/// 3969 samples out.
+///
+/// This also means that average latency during stream processing is
+/// INITIAL_LATENCY-OUTPUT_SEQUENCE/2, in the above example case 5509-3969/2
+/// = 3524 samples
+///
+/// Notices:
+/// - This is read-only parameter, i.e. setSetting ignores this parameter
+/// - This parameter value is not constant but change depending on
+/// tempo/pitch/rate/samplerate settings.
+#define SETTING_INITIAL_LATENCY 8
+
+
+class SOUNDTOUCH_API SoundTouch : public FIFOProcessor
{
private:
/// Rate transposer class instance
@@ -151,17 +175,24 @@ private:
class TDStretch *pTDStretch;
/// Virtual pitch parameter. Effective rate & tempo are calculated from these parameters.
- float virtualRate;
+ double virtualRate;
/// Virtual pitch parameter. Effective rate & tempo are calculated from these parameters.
- float virtualTempo;
+ double virtualTempo;
/// Virtual pitch parameter. Effective rate & tempo are calculated from these parameters.
- float virtualPitch;
+ double virtualPitch;
/// Flag: Has sample rate been set?
bool bSrateSet;
+ /// Accumulator for how many samples in total will be expected as output vs. samples put in,
+ /// considering current processing settings.
+ double samplesExpectedOut;
+
+ /// Accumulator for how many samples in total have been read out from the processing so far
+ long samplesOutput;
+
/// Calculates effective rate & tempo valuescfrom 'virtualRate', 'virtualTempo' and
/// 'virtualPitch' parameters.
void calcEffectiveRateAndTempo();
@@ -171,10 +202,10 @@ protected :
uint channels;
/// Effective 'rate' value calculated from 'virtualRate', 'virtualTempo' and 'virtualPitch'
- float rate;
+ double rate;
/// Effective 'tempo' value calculated from 'virtualRate', 'virtualTempo' and 'virtualPitch'
- float tempo;
+ double tempo;
public:
SoundTouch();
@@ -188,32 +219,32 @@ public:
/// Sets new rate control value. Normal rate = 1.0, smaller values
/// represent slower rate, larger faster rates.
- void setRate(float newRate);
+ void setRate(double newRate);
/// Sets new tempo control value. Normal tempo = 1.0, smaller values
/// represent slower tempo, larger faster tempo.
- void setTempo(float newTempo);
+ void setTempo(double newTempo);
/// Sets new rate control value as a difference in percents compared
/// to the original rate (-50 .. +100 %)
- void setRateChange(float newRate);
+ void setRateChange(double newRate);
/// Sets new tempo control value as a difference in percents compared
/// to the original tempo (-50 .. +100 %)
- void setTempoChange(float newTempo);
+ void setTempoChange(double newTempo);
/// Sets new pitch control value. Original pitch = 1.0, smaller values
/// represent lower pitches, larger values higher pitch.
- void setPitch(float newPitch);
+ void setPitch(double newPitch);
/// Sets pitch change in octaves compared to the original pitch
/// (-1.00 .. +1.00)
- void setPitchOctaves(float newPitch);
+ void setPitchOctaves(double newPitch);
/// Sets pitch change in semi-tones compared to the original pitch
/// (-12 .. +12)
void setPitchSemiTones(int newPitch);
- void setPitchSemiTones(float newPitch);
+ void setPitchSemiTones(double newPitch);
/// Sets the number of channels, 1 = mono, 2 = stereo
void setChannels(uint numChannels);
@@ -221,6 +252,24 @@ public:
/// Sets sample rate.
void setSampleRate(uint srate);
+ /// Get ratio between input and output audio durations, useful for calculating
+ /// processed output duration: if you'll process a stream of N samples, then
+ /// you can expect to get out N * getInputOutputSampleRatio() samples.
+ ///
+ /// This ratio will give accurate target duration ratio for a full audio track,
+ /// given that the the whole track is processed with same processing parameters.
+ ///
+ /// If this ratio is applied to calculate intermediate offsets inside a processing
+ /// stream, then this ratio is approximate and can deviate +- some tens of milliseconds
+ /// from ideal offset, yet by end of the audio stream the duration ratio will become
+ /// exact.
+ ///
+ /// Example: if processing with parameters "-tempo=15 -pitch=-3", the function
+ /// will return value 0.8695652... Now, if processing an audio stream whose duration
+ /// is exactly one million audio samples, then you can expect the processed
+ /// output duration be 0.869565 * 1000000 = 869565 samples.
+ double getInputOutputSampleRatio();
+
/// Flushes the last samples from the processing pipeline to the output.
/// Clears also the internal processing buffers.
//
@@ -240,6 +289,23 @@ public:
///< contains data for both channels.
);
+ /// Output samples from beginning of the sample buffer. Copies requested samples to
+ /// output buffer and removes them from the sample buffer. If there are less than
+ /// 'numsample' samples in the buffer, returns all that available.
+ ///
+ /// \return Number of samples returned.
+ virtual uint receiveSamples(SAMPLETYPE *output, ///< Buffer where to copy output samples.
+ uint maxSamples ///< How many samples to receive at max.
+ );
+
+ /// Adjusts book-keeping so that given number of samples are removed from beginning of the
+ /// sample buffer without copying them anywhere.
+ ///
+ /// Used to reduce the number of samples in the buffer when accessing the sample buffer directly
+ /// with 'ptrBegin' function.
+ virtual uint receiveSamples(uint maxSamples ///< Remove this many samples from the beginning of pipe.
+ );
+
/// Clears all the samples in the object's output and internal processing
/// buffers.
virtual void clear();
@@ -247,7 +313,7 @@ public:
/// Changes a setting controlling the processing system behaviour. See the
/// 'SETTING_...' defines for available setting ID's.
///
- /// \return 'true' if the setting was succesfully changed
+ /// \return 'true' if the setting was successfully changed
bool setSetting(int settingId, ///< Setting ID number. see SETTING_... defines.
int value ///< New setting value.
);
@@ -262,6 +328,11 @@ public:
/// Returns number of samples currently unprocessed.
virtual uint numUnprocessedSamples() const;
+ /// Return number of channels
+ uint numChannels() const
+ {
+ return channels;
+ }
/// Other handy functions that are implemented in the ancestor classes (see
/// classes 'FIFOProcessor' and 'FIFOSamplePipe')
diff --git a/media/libsoundtouch/src/SoundTouchFactory.cpp b/media/libsoundtouch/src/SoundTouchFactory.cpp
index b577616fca..d33fc133d7 100644
--- a/media/libsoundtouch/src/SoundTouchFactory.cpp
+++ b/media/libsoundtouch/src/SoundTouchFactory.cpp
@@ -9,14 +9,14 @@
namespace soundtouch
{
-EXPORT
+SOUNDTOUCH_API
soundtouch::SoundTouch*
createSoundTouchObj()
{
return new soundtouch::SoundTouch();
}
-EXPORT
+SOUNDTOUCH_API
void
destroySoundTouchObj(soundtouch::SoundTouch* aObj)
{
diff --git a/media/libsoundtouch/src/SoundTouchFactory.h b/media/libsoundtouch/src/SoundTouchFactory.h
index cea4d9a649..98d8a7deb1 100644
--- a/media/libsoundtouch/src/SoundTouchFactory.h
+++ b/media/libsoundtouch/src/SoundTouchFactory.h
@@ -12,11 +12,11 @@
namespace soundtouch
{
-EXPORT
+SOUNDTOUCH_API
soundtouch::SoundTouch*
createSoundTouchObj();
-EXPORT
+SOUNDTOUCH_API
void
destroySoundTouchObj(soundtouch::SoundTouch* aObj);
}
diff --git a/media/libsoundtouch/src/TDStretch.cpp b/media/libsoundtouch/src/TDStretch.cpp
index b955bfc961..709e979d1d 100644
--- a/media/libsoundtouch/src/TDStretch.cpp
+++ b/media/libsoundtouch/src/TDStretch.cpp
@@ -1,11 +1,17 @@
-////////////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////////
///
/// Sampled sound tempo changer/time stretch algorithm. Changes the sound tempo
/// while maintaining the original pitch by using a time domain WSOLA-like
/// method with several performance-increasing tweaks.
///
-/// Note : MMX optimized functions reside in a separate, platform-specific
-/// file, e.g. 'mmx_win.cpp' or 'mmx_gcc.cpp'
+/// Notes : MMX optimized functions reside in a separate, platform-specific
+/// file, e.g. 'mmx_win.cpp' or 'mmx_gcc.cpp'.
+///
+/// This source file contains OpenMP optimizations that allow speeding up the
+/// corss-correlation algorithm by executing it in several threads / CPU cores
+/// in parallel. See the following article link for more detailed discussion
+/// about SoundTouch OpenMP optimizations:
+/// http://www.softwarecoven.com/parallel-computing-in-embedded-mobile-devices
///
/// Author : Copyright (c) Olli Parviainen
/// Author e-mail : oparviai 'at' iki.fi
@@ -13,13 +19,6 @@
///
////////////////////////////////////////////////////////////////////////////////
//
-// Last changed : $Date: 2015-02-22 15:07:12 +0000 (Sun, 22 Feb 2015) $
-// File revision : $Revision: 1.12 $
-//
-// $Id: TDStretch.cpp 205 2015-02-22 15:07:12Z oparviai $
-//
-////////////////////////////////////////////////////////////////////////////////
-//
// License :
//
// SoundTouch audio processing library
@@ -55,7 +54,6 @@ using namespace soundtouch;
#define max(x, y) (((x) > (y)) ? (x) : (y))
-
/*****************************************************************************
*
* Constant definitions
@@ -63,7 +61,7 @@ using namespace soundtouch;
*****************************************************************************/
// Table for the hierarchical mixing position seeking algorithm
-static const short _scanOffsets[5][24]={
+const short _scanOffsets[5][24]={
{ 124, 186, 248, 310, 372, 434, 496, 558, 620, 682, 744, 806,
868, 930, 992, 1054, 1116, 1178, 1240, 1302, 1364, 1426, 1488, 0},
{-100, -75, -50, -25, 25, 50, 75, 100, 0, 0, 0, 0,
@@ -94,9 +92,6 @@ TDStretch::TDStretch() : FIFOProcessor(&outputBuffer)
bAutoSeqSetting = true;
bAutoSeekSetting = true;
-// outDebt = 0;
- skipFract = 0;
-
tempo = 1.0f;
setParameters(44100, DEFAULT_SEQUENCE_MS, DEFAULT_SEEKWINDOW_MS, DEFAULT_OVERLAP_MS);
setTempo(1.0f);
@@ -202,7 +197,7 @@ void TDStretch::overlapMono(SAMPLETYPE *pOutput, const SAMPLETYPE *pInput) const
m1 = (SAMPLETYPE)0;
m2 = (SAMPLETYPE)overlapLength;
- for (i = 0; i < overlapLength ; i ++)
+ for (i = 0; i < overlapLength ; i ++)
{
pOutput[i] = (pInput[i] * m1 + pMidBuffer[i] * m2 ) / overlapLength;
m1 += 1;
@@ -222,6 +217,10 @@ void TDStretch::clearInput()
{
inputBuffer.clear();
clearMidBuffer();
+ isBeginning = true;
+ maxnorm = 0;
+ maxnormf = 1e8;
+ skipFract = 0;
}
@@ -255,7 +254,7 @@ int TDStretch::seekBestOverlapPosition(const SAMPLETYPE *refPos)
if (bQuickSeek)
{
return seekBestOverlapPositionQuick(refPos);
- }
+ }
else
{
return seekBestOverlapPositionFull(refPos);
@@ -287,7 +286,6 @@ inline void TDStretch::overlap(SAMPLETYPE *pOutput, const SAMPLETYPE *pInput, ui
}
-
// Seeks for the optimal overlap-mixing position. The 'stereo' version of the
// routine
//
@@ -301,21 +299,23 @@ int TDStretch::seekBestOverlapPositionFull(const SAMPLETYPE *refPos)
int i;
double norm;
- bestCorr = FLT_MIN;
+ bestCorr = -FLT_MAX;
bestOffs = 0;
// Scans for the best correlation value by testing each possible position
// over the permitted range.
bestCorr = calcCrossCorr(refPos, pMidBuffer, norm);
+ bestCorr = (bestCorr + 0.1) * 0.75;
#pragma omp parallel for
- for (i = 1; i < seekLength; i ++)
+ for (i = 1; i < seekLength; i ++)
{
double corr;
// Calculates correlation value for the mixing position corresponding to 'i'
-#ifdef _OPENMP
+#if defined(_OPENMP) || defined(ST_SIMD_AVOID_UNALIGNED)
// in parallel OpenMP mode, can't use norm accumulator version as parallel executor won't
// iterate the loop in sequential order
+ // in SIMD mode, avoid accumulator version to allow avoiding unaligned positions
corr = calcCrossCorr(refPos + channels * i, pMidBuffer, norm);
#else
// In non-parallel version call "calcCrossCorrAccumulate" that is otherwise same
@@ -341,6 +341,11 @@ int TDStretch::seekBestOverlapPositionFull(const SAMPLETYPE *refPos)
}
}
}
+
+#ifdef SOUNDTOUCH_INTEGER_SAMPLES
+ adaptNormalizer();
+#endif
+
// clear cross correlation routine state if necessary (is so e.g. in MMX routines).
clearCrossCorrState();
@@ -348,64 +353,157 @@ int TDStretch::seekBestOverlapPositionFull(const SAMPLETYPE *refPos)
}
-// Seeks for the optimal overlap-mixing position. The 'stereo' version of the
-// routine
+// Quick seek algorithm for improved runtime-performance: First roughly scans through the
+// correlation area, and then scan surroundings of two best preliminary correlation candidates
+// with improved precision
//
-// The best position is determined as the position where the two overlapped
-// sample sequences are 'most alike', in terms of the highest cross-correlation
-// value over the overlapping period
-int TDStretch::seekBestOverlapPositionQuick(const SAMPLETYPE *refPos)
+// Based on testing:
+// - This algorithm gives on average 99% as good match as the full algorithm
+// - this quick seek algorithm finds the best match on ~90% of cases
+// - on those 10% of cases when this algorithm doesn't find best match,
+// it still finds on average ~90% match vs. the best possible match
+int TDStretch::seekBestOverlapPositionQuick(const SAMPLETYPE *refPos)
{
- int j;
+#define _MIN(a, b) (((a) < (b)) ? (a) : (b))
+#define SCANSTEP 16
+#define SCANWIND 8
+
int bestOffs;
- double bestCorr, corr;
- int scanCount, corrOffset, tempOffset;
+ int i;
+ int bestOffs2;
+ float bestCorr, corr;
+ float bestCorr2;
+ double norm;
+
+ // note: 'float' types used in this function in case that the platform would need to use software-fp
- bestCorr = FLT_MIN;
- bestOffs = _scanOffsets[0][0];
- corrOffset = 0;
- tempOffset = 0;
+ bestCorr =
+ bestCorr2 = -FLT_MAX;
+ bestOffs =
+ bestOffs2 = SCANWIND;
- // Scans for the best correlation value using four-pass hierarchical search.
+ // Scans for the best correlation value by testing each possible position
+ // over the permitted range. Look for two best matches on the first pass to
+ // increase possibility of ideal match.
//
- // The look-up table 'scans' has hierarchical position adjusting steps.
- // In first pass the routine searhes for the highest correlation with
- // relatively coarse steps, then rescans the neighbourhood of the highest
- // correlation with better resolution and so on.
- for (scanCount = 0;scanCount < 4; scanCount ++)
- {
- j = 0;
- while (_scanOffsets[scanCount][j])
+ // Begin from "SCANSTEP" instead of SCANWIND to make the calculation
+ // catch the 'middlepoint' of seekLength vector as that's the a-priori
+ // expected best match position
+ //
+ // Roughly:
+ // - 15% of cases find best result directly on the first round,
+ // - 75% cases find better match on 2nd round around the best match from 1st round
+ // - 10% cases find better match on 2nd round around the 2nd-best-match from 1st round
+ for (i = SCANSTEP; i < seekLength - SCANWIND - 1; i += SCANSTEP)
+ {
+ // Calculates correlation value for the mixing position corresponding
+ // to 'i'
+ corr = (float)calcCrossCorr(refPos + channels*i, pMidBuffer, norm);
+ // heuristic rule to slightly favour values close to mid of the seek range
+ float tmp = (float)(2 * i - seekLength - 1) / (float)seekLength;
+ corr = ((corr + 0.1f) * (1.0f - 0.25f * tmp * tmp));
+
+ // Checks for the highest correlation value
+ if (corr > bestCorr)
{
- double norm;
- tempOffset = corrOffset + _scanOffsets[scanCount][j];
- if (tempOffset >= seekLength) break;
-
- // Calculates correlation value for the mixing position corresponding
- // to 'tempOffset'
- corr = (double)calcCrossCorr(refPos + channels * tempOffset, pMidBuffer, norm);
- // heuristic rule to slightly favour values close to mid of the range
- double tmp = (double)(2 * tempOffset - seekLength) / seekLength;
- corr = ((corr + 0.1) * (1.0 - 0.25 * tmp * tmp));
-
- // Checks for the highest correlation value
- if (corr > bestCorr)
- {
- bestCorr = corr;
- bestOffs = tempOffset;
- }
- j ++;
+ // found new best match. keep the previous best as 2nd best match
+ bestCorr2 = bestCorr;
+ bestOffs2 = bestOffs;
+ bestCorr = corr;
+ bestOffs = i;
+ }
+ else if (corr > bestCorr2)
+ {
+ // not new best, but still new 2nd best match
+ bestCorr2 = corr;
+ bestOffs2 = i;
+ }
+ }
+
+ // Scans surroundings of the found best match with small stepping
+ int end = _MIN(bestOffs + SCANWIND + 1, seekLength);
+ for (i = bestOffs - SCANWIND; i < end; i++)
+ {
+ if (i == bestOffs) continue; // this offset already calculated, thus skip
+
+ // Calculates correlation value for the mixing position corresponding
+ // to 'i'
+ corr = (float)calcCrossCorr(refPos + channels*i, pMidBuffer, norm);
+ // heuristic rule to slightly favour values close to mid of the range
+ float tmp = (float)(2 * i - seekLength - 1) / (float)seekLength;
+ corr = ((corr + 0.1f) * (1.0f - 0.25f * tmp * tmp));
+
+ // Checks for the highest correlation value
+ if (corr > bestCorr)
+ {
+ bestCorr = corr;
+ bestOffs = i;
+ }
+ }
+
+ // Scans surroundings of the 2nd best match with small stepping
+ end = _MIN(bestOffs2 + SCANWIND + 1, seekLength);
+ for (i = bestOffs2 - SCANWIND; i < end; i++)
+ {
+ if (i == bestOffs2) continue; // this offset already calculated, thus skip
+
+ // Calculates correlation value for the mixing position corresponding
+ // to 'i'
+ corr = (float)calcCrossCorr(refPos + channels*i, pMidBuffer, norm);
+ // heuristic rule to slightly favour values close to mid of the range
+ float tmp = (float)(2 * i - seekLength - 1) / (float)seekLength;
+ corr = ((corr + 0.1f) * (1.0f - 0.25f * tmp * tmp));
+
+ // Checks for the highest correlation value
+ if (corr > bestCorr)
+ {
+ bestCorr = corr;
+ bestOffs = i;
}
- corrOffset = bestOffs;
}
+
// clear cross correlation routine state if necessary (is so e.g. in MMX routines).
clearCrossCorrState();
+#ifdef SOUNDTOUCH_INTEGER_SAMPLES
+ adaptNormalizer();
+#endif
+
return bestOffs;
}
+
+/// For integer algorithm: adapt normalization factor divider with music so that
+/// it'll not be pessimistically restrictive that can degrade quality on quieter sections
+/// yet won't cause integer overflows either
+void TDStretch::adaptNormalizer()
+{
+ // Do not adapt normalizer over too silent sequences to avoid averaging filter depleting to
+ // too low values during pauses in music
+ if ((maxnorm > 1000) || (maxnormf > 40000000))
+ {
+ //norm averaging filter
+ maxnormf = 0.9f * maxnormf + 0.1f * (float)maxnorm;
+
+ if ((maxnorm > 800000000) && (overlapDividerBitsNorm < 16))
+ {
+ // large values, so increase divider
+ overlapDividerBitsNorm++;
+ if (maxnorm > 1600000000) overlapDividerBitsNorm++; // extra large value => extra increase
+ }
+ else if ((maxnormf < 1000000) && (overlapDividerBitsNorm > 0))
+ {
+ // extra small values, decrease divider
+ overlapDividerBitsNorm--;
+ }
+ }
+
+ maxnorm = 0;
+}
+
+
/// clear cross correlation routine state if necessary
void TDStretch::clearCrossCorrState()
{
@@ -417,18 +515,18 @@ void TDStretch::clearCrossCorrState()
void TDStretch::calcSeqParameters()
{
// Adjust tempo param according to tempo, so that variating processing sequence length is used
- // at varius tempo settings, between the given low...top limits
+ // at various tempo settings, between the given low...top limits
#define AUTOSEQ_TEMPO_LOW 0.5 // auto setting low tempo range (-50%)
#define AUTOSEQ_TEMPO_TOP 2.0 // auto setting top tempo range (+100%)
// sequence-ms setting values at above low & top tempo
- #define AUTOSEQ_AT_MIN 125.0
- #define AUTOSEQ_AT_MAX 50.0
+ #define AUTOSEQ_AT_MIN 90.0
+ #define AUTOSEQ_AT_MAX 40.0
#define AUTOSEQ_K ((AUTOSEQ_AT_MAX - AUTOSEQ_AT_MIN) / (AUTOSEQ_TEMPO_TOP - AUTOSEQ_TEMPO_LOW))
#define AUTOSEQ_C (AUTOSEQ_AT_MIN - (AUTOSEQ_K) * (AUTOSEQ_TEMPO_LOW))
- // seek-window-ms setting values at above low & top tempo
- #define AUTOSEEK_AT_MIN 25.0
+ // seek-window-ms setting values at above low & top tempoq
+ #define AUTOSEEK_AT_MIN 20.0
#define AUTOSEEK_AT_MAX 15.0
#define AUTOSEEK_K ((AUTOSEEK_AT_MAX - AUTOSEEK_AT_MIN) / (AUTOSEQ_TEMPO_TOP - AUTOSEQ_TEMPO_LOW))
#define AUTOSEEK_C (AUTOSEEK_AT_MIN - (AUTOSEEK_K) * (AUTOSEQ_TEMPO_LOW))
@@ -464,7 +562,7 @@ void TDStretch::calcSeqParameters()
// Sets new target tempo. Normal tempo = 'SCALE', smaller values represent slower
// tempo, larger faster tempo.
-void TDStretch::setTempo(float newTempo)
+void TDStretch::setTempo(double newTempo)
{
int intskip;
@@ -475,7 +573,7 @@ void TDStretch::setTempo(float newTempo)
// Calculate ideal skip length (according to tempo value)
nominalSkip = tempo * (seekWindowLength - overlapLength);
- intskip = (int)(nominalSkip + 0.5f);
+ intskip = (int)(nominalSkip + 0.5);
// Calculate how many samples are needed in the 'inputBuffer' to
// process another batch of samples
@@ -488,9 +586,8 @@ void TDStretch::setTempo(float newTempo)
// Sets the number of channels, 1 = mono, 2 = stereo
void TDStretch::setChannels(int numChannels)
{
- assert(numChannels > 0);
- if (channels == numChannels) return;
-// assert(numChannels == 1 || numChannels == 2);
+ if (!verifyNumberOfChannels(numChannels) ||
+ (channels == numChannels)) return;
channels = numChannels;
inputBuffer.setChannels(channels);
@@ -539,7 +636,8 @@ void TDStretch::processNominalTempo()
// the result into 'outputBuffer'
void TDStretch::processSamples()
{
- int ovlSkip, offset;
+ int ovlSkip;
+ int offset = 0;
int temp;
/* Removed this small optimization - can introduce a click to sound when tempo setting
@@ -556,35 +654,62 @@ void TDStretch::processSamples()
// to form a processing frame.
while ((int)inputBuffer.numSamples() >= sampleReq)
{
- // If tempo differs from the normal ('SCALE'), scan for the best overlapping
- // position
- offset = seekBestOverlapPosition(inputBuffer.ptrBegin());
-
- // Mix the samples in the 'inputBuffer' at position of 'offset' with the
- // samples in 'midBuffer' using sliding overlapping
- // ... first partially overlap with the end of the previous sequence
- // (that's in 'midBuffer')
- overlap(outputBuffer.ptrEnd((uint)overlapLength), inputBuffer.ptrBegin(), (uint)offset);
- outputBuffer.putSamples((uint)overlapLength);
+ if (isBeginning == false)
+ {
+ // apart from the very beginning of the track,
+ // scan for the best overlapping position & do overlap-add
+ offset = seekBestOverlapPosition(inputBuffer.ptrBegin());
+
+ // Mix the samples in the 'inputBuffer' at position of 'offset' with the
+ // samples in 'midBuffer' using sliding overlapping
+ // ... first partially overlap with the end of the previous sequence
+ // (that's in 'midBuffer')
+ overlap(outputBuffer.ptrEnd((uint)overlapLength), inputBuffer.ptrBegin(), (uint)offset);
+ outputBuffer.putSamples((uint)overlapLength);
+ offset += overlapLength;
+ }
+ else
+ {
+ // Adjust processing offset at beginning of track by not perform initial overlapping
+ // and compensating that in the 'input buffer skip' calculation
+ isBeginning = false;
+ int skip = (int)(tempo * overlapLength + 0.5 * seekLength + 0.5);
+
+ #ifdef ST_SIMD_AVOID_UNALIGNED
+ // in SIMD mode, round the skip amount to value corresponding to aligned memory address
+ if (channels == 1)
+ {
+ skip &= -4;
+ }
+ else if (channels == 2)
+ {
+ skip &= -2;
+ }
+ #endif
+ skipFract -= skip;
+ if (skipFract <= -nominalSkip)
+ {
+ skipFract = -nominalSkip;
+ }
+ }
// ... then copy sequence samples from 'inputBuffer' to output:
- // length of sequence
- temp = (seekWindowLength - 2 * overlapLength);
-
// crosscheck that we don't have buffer overflow...
- if ((int)inputBuffer.numSamples() < (offset + temp + overlapLength * 2))
+ if ((int)inputBuffer.numSamples() < (offset + seekWindowLength - overlapLength))
{
continue; // just in case, shouldn't really happen
}
- outputBuffer.putSamples(inputBuffer.ptrBegin() + channels * (offset + overlapLength), (uint)temp);
+ // length of sequence
+ temp = (seekWindowLength - 2 * overlapLength);
+ outputBuffer.putSamples(inputBuffer.ptrBegin() + channels * offset, (uint)temp);
// Copies the end of the current sequence from 'inputBuffer' to
// 'midBuffer' for being mixed with the beginning of the next
// processing sequence and so on
- assert((offset + temp + overlapLength * 2) <= (int)inputBuffer.numSamples());
- memcpy(pMidBuffer, inputBuffer.ptrBegin() + channels * (offset + temp + overlapLength),
+ assert((offset + temp + overlapLength) <= (int)inputBuffer.numSamples());
+ memcpy(pMidBuffer, inputBuffer.ptrBegin() + channels * (offset + temp),
channels * sizeof(SAMPLETYPE) * overlapLength);
// Remove the processed samples from the input buffer. Update
@@ -680,7 +805,7 @@ TDStretch * TDStretch::newInstance()
//////////////////////////////////////////////////////////////////////////////
//
-// Integer arithmetics specific algorithm implementations.
+// Integer arithmetic specific algorithm implementations.
//
//////////////////////////////////////////////////////////////////////////////
@@ -694,7 +819,7 @@ void TDStretch::overlapStereo(short *poutput, const short *input) const
short temp;
int cnt2;
- for (i = 0; i < overlapLength ; i ++)
+ for (i = 0; i < overlapLength ; i ++)
{
temp = (short)(overlapLength - i);
cnt2 = 2 * i;
@@ -706,21 +831,19 @@ void TDStretch::overlapStereo(short *poutput, const short *input) const
// Overlaps samples in 'midBuffer' with the samples in 'input'. The 'Multi'
// version of the routine.
-void TDStretch::overlapMulti(SAMPLETYPE *poutput, const SAMPLETYPE *input) const
+void TDStretch::overlapMulti(short *poutput, const short *input) const
{
- SAMPLETYPE m1=(SAMPLETYPE)0;
- SAMPLETYPE m2;
- int i=0;
+ short m1;
+ int i = 0;
- for (m2 = (SAMPLETYPE)overlapLength; m2; m2 --)
+ for (m1 = 0; m1 < overlapLength; m1 ++)
{
+ short m2 = (short)(overlapLength - m1);
for (int c = 0; c < channels; c ++)
{
poutput[i] = (input[i] * m1 + pMidBuffer[i] * m2) / overlapLength;
i++;
}
-
- m1++;
}
}
@@ -743,13 +866,15 @@ void TDStretch::calculateOverlapLength(int aoverlapMs)
// calculate overlap length so that it's power of 2 - thus it's easy to do
// integer division by right-shifting. Term "-1" at end is to account for
// the extra most significatnt bit left unused in result by signed multiplication
- overlapDividerBits = _getClosest2Power((sampleRate * aoverlapMs) / 1000.0) - 1;
- if (overlapDividerBits > 9) overlapDividerBits = 9;
- if (overlapDividerBits < 3) overlapDividerBits = 3;
- newOvl = (int)pow(2.0, (int)overlapDividerBits + 1); // +1 => account for -1 above
+ overlapDividerBitsPure = _getClosest2Power((sampleRate * aoverlapMs) / 1000.0) - 1;
+ if (overlapDividerBitsPure > 9) overlapDividerBitsPure = 9;
+ if (overlapDividerBitsPure < 3) overlapDividerBitsPure = 3;
+ newOvl = (int)pow(2.0, (int)overlapDividerBitsPure + 1); // +1 => account for -1 above
acceptNewOverlapLength(newOvl);
+ overlapDividerBitsNorm = overlapDividerBitsPure;
+
// calculate sloping divider so that crosscorrelation operation won't
// overflow 32-bit register. Max. sum of the crosscorrelation sum without
// divider would be 2^30*(N^3-N)/3, where N = overlap length
@@ -757,28 +882,40 @@ void TDStretch::calculateOverlapLength(int aoverlapMs)
}
-double TDStretch::calcCrossCorr(const short *mixingPos, const short *compare, double &norm) const
+double TDStretch::calcCrossCorr(const short *mixingPos, const short *compare, double &norm)
{
long corr;
- long lnorm;
+ unsigned long lnorm;
int i;
+ #ifdef ST_SIMD_AVOID_UNALIGNED
+ // in SIMD mode skip 'mixingPos' positions that aren't aligned to 16-byte boundary
+ if (((ulongptr)mixingPos) & 15) return -1e50;
+ #endif
+
+ // hint compiler autovectorization that loop length is divisible by 8
+ int ilength = (channels * overlapLength) & -8;
+
corr = lnorm = 0;
- // Same routine for stereo and mono. For stereo, unroll loop for better
- // efficiency and gives slightly better resolution against rounding.
- // For mono it same routine, just unrolls loop by factor of 4
- for (i = 0; i < channels * overlapLength; i += 4)
+ // Same routine for stereo and mono
+ for (i = 0; i < ilength; i += 2)
{
corr += (mixingPos[i] * compare[i] +
- mixingPos[i + 1] * compare[i + 1]) >> overlapDividerBits; // notice: do intermediate division here to avoid integer overflow
- corr += (mixingPos[i + 2] * compare[i + 2] +
- mixingPos[i + 3] * compare[i + 3]) >> overlapDividerBits;
+ mixingPos[i + 1] * compare[i + 1]) >> overlapDividerBitsNorm;
lnorm += (mixingPos[i] * mixingPos[i] +
- mixingPos[i + 1] * mixingPos[i + 1]) >> overlapDividerBits; // notice: do intermediate division here to avoid integer overflow
- lnorm += (mixingPos[i + 2] * mixingPos[i + 2] +
- mixingPos[i + 3] * mixingPos[i + 3]) >> overlapDividerBits;
+ mixingPos[i + 1] * mixingPos[i + 1]) >> overlapDividerBitsNorm;
+ // do intermediate scalings to avoid integer overflow
}
+ if (lnorm > maxnorm)
+ {
+ // modify 'maxnorm' inside critical section to avoid multi-access conflict if in OpenMP mode
+ #pragma omp critical
+ if (lnorm > maxnorm)
+ {
+ maxnorm = lnorm;
+ }
+ }
// Normalize result by dividing by sqrt(norm) - this step is easiest
// done using floating point operation
norm = (double)lnorm;
@@ -787,38 +924,42 @@ double TDStretch::calcCrossCorr(const short *mixingPos, const short *compare, do
/// Update cross-correlation by accumulating "norm" coefficient by previously calculated value
-double TDStretch::calcCrossCorrAccumulate(const short *mixingPos, const short *compare, double &norm) const
+double TDStretch::calcCrossCorrAccumulate(const short *mixingPos, const short *compare, double &norm)
{
long corr;
long lnorm;
int i;
+ // hint compiler autovectorization that loop length is divisible by 8
+ int ilength = (channels * overlapLength) & -8;
+
// cancel first normalizer tap from previous round
lnorm = 0;
for (i = 1; i <= channels; i ++)
{
- lnorm -= (mixingPos[-i] * mixingPos[-i]) >> overlapDividerBits;
+ lnorm -= (mixingPos[-i] * mixingPos[-i]) >> overlapDividerBitsNorm;
}
corr = 0;
- // Same routine for stereo and mono. For stereo, unroll loop for better
- // efficiency and gives slightly better resolution against rounding.
- // For mono it same routine, just unrolls loop by factor of 4
- for (i = 0; i < channels * overlapLength; i += 4)
+ // Same routine for stereo and mono.
+ for (i = 0; i < ilength; i += 2)
{
corr += (mixingPos[i] * compare[i] +
- mixingPos[i + 1] * compare[i + 1]) >> overlapDividerBits; // notice: do intermediate division here to avoid integer overflow
- corr += (mixingPos[i + 2] * compare[i + 2] +
- mixingPos[i + 3] * compare[i + 3]) >> overlapDividerBits;
+ mixingPos[i + 1] * compare[i + 1]) >> overlapDividerBitsNorm;
}
// update normalizer with last samples of this round
for (int j = 0; j < channels; j ++)
{
i --;
- lnorm += (mixingPos[i] * mixingPos[i]) >> overlapDividerBits;
+ lnorm += (mixingPos[i] * mixingPos[i]) >> overlapDividerBitsNorm;
}
+
norm += (double)lnorm;
+ if (norm > maxnorm)
+ {
+ maxnorm = (unsigned long)norm;
+ }
// Normalize result by dividing by sqrt(norm) - this step is easiest
// done using floating point operation
@@ -829,7 +970,7 @@ double TDStretch::calcCrossCorrAccumulate(const short *mixingPos, const short *c
//////////////////////////////////////////////////////////////////////////////
//
-// Floating point arithmetics specific algorithm implementations.
+// Floating point arithmetic specific algorithm implementations.
//
#ifdef SOUNDTOUCH_FLOAT_SAMPLES
@@ -903,29 +1044,26 @@ void TDStretch::calculateOverlapLength(int overlapInMsec)
/// Calculate cross-correlation
-double TDStretch::calcCrossCorr(const float *mixingPos, const float *compare, double &anorm) const
+double TDStretch::calcCrossCorr(const float *mixingPos, const float *compare, double &anorm)
{
- double corr;
- double norm;
+ float corr;
+ float norm;
int i;
- corr = norm = 0;
- // Same routine for stereo and mono. For Stereo, unroll by factor of 2.
- // For mono it's same routine yet unrollsd by factor of 4.
- for (i = 0; i < channels * overlapLength; i += 4)
- {
- corr += mixingPos[i] * compare[i] +
- mixingPos[i + 1] * compare[i + 1];
-
- norm += mixingPos[i] * mixingPos[i] +
- mixingPos[i + 1] * mixingPos[i + 1];
+ #ifdef ST_SIMD_AVOID_UNALIGNED
+ // in SIMD mode skip 'mixingPos' positions that aren't aligned to 16-byte boundary
+ if (((ulongptr)mixingPos) & 15) return -1e50;
+ #endif
- // unroll the loop for better CPU efficiency:
- corr += mixingPos[i + 2] * compare[i + 2] +
- mixingPos[i + 3] * compare[i + 3];
+ // hint compiler autovectorization that loop length is divisible by 8
+ int ilength = (channels * overlapLength) & -8;
- norm += mixingPos[i + 2] * mixingPos[i + 2] +
- mixingPos[i + 3] * mixingPos[i + 3];
+ corr = norm = 0;
+ // Same routine for stereo and mono
+ for (i = 0; i < ilength; i ++)
+ {
+ corr += mixingPos[i] * compare[i];
+ norm += mixingPos[i] * mixingPos[i];
}
anorm = norm;
@@ -934,9 +1072,9 @@ double TDStretch::calcCrossCorr(const float *mixingPos, const float *compare, do
/// Update cross-correlation by accumulating "norm" coefficient by previously calculated value
-double TDStretch::calcCrossCorrAccumulate(const float *mixingPos, const float *compare, double &norm) const
+double TDStretch::calcCrossCorrAccumulate(const float *mixingPos, const float *compare, double &norm)
{
- double corr;
+ float corr;
int i;
corr = 0;
@@ -947,14 +1085,13 @@ double TDStretch::calcCrossCorrAccumulate(const float *mixingPos, const float *c
norm -= mixingPos[-i] * mixingPos[-i];
}
- // Same routine for stereo and mono. For Stereo, unroll by factor of 2.
- // For mono it's same routine yet unrollsd by factor of 4.
- for (i = 0; i < channels * overlapLength; i += 4)
+ // hint compiler autovectorization that loop length is divisible by 8
+ int ilength = (channels * overlapLength) & -8;
+
+ // Same routine for stereo and mono
+ for (i = 0; i < ilength; i ++)
{
- corr += mixingPos[i] * compare[i] +
- mixingPos[i + 1] * compare[i + 1] +
- mixingPos[i + 2] * compare[i + 2] +
- mixingPos[i + 3] * compare[i + 3];
+ corr += mixingPos[i] * compare[i];
}
// update normalizer with last samples of this round
diff --git a/media/libsoundtouch/src/TDStretch.h b/media/libsoundtouch/src/TDStretch.h
index b390736913..3ef79c7cdf 100644
--- a/media/libsoundtouch/src/TDStretch.h
+++ b/media/libsoundtouch/src/TDStretch.h
@@ -13,13 +13,6 @@
///
////////////////////////////////////////////////////////////////////////////////
//
-// Last changed : $Date: 2014-04-06 15:57:21 +0000 (Sun, 06 Apr 2014) $
-// File revision : $Revision: 4 $
-//
-// $Id: TDStretch.h 195 2014-04-06 15:57:21Z oparviai $
-//
-////////////////////////////////////////////////////////////////////////////////
-//
// License :
//
// SoundTouch audio processing library
@@ -112,39 +105,47 @@ class TDStretch : public FIFOProcessor
protected:
int channels;
int sampleReq;
- float tempo;
- SAMPLETYPE *pMidBuffer;
- SAMPLETYPE *pMidBufferUnaligned;
int overlapLength;
int seekLength;
int seekWindowLength;
- int overlapDividerBits;
+ int overlapDividerBitsNorm;
+ int overlapDividerBitsPure;
int slopingDivider;
- float nominalSkip;
- float skipFract;
- FIFOSampleBuffer outputBuffer;
- FIFOSampleBuffer inputBuffer;
- bool bQuickSeek;
-
int sampleRate;
int sequenceMs;
int seekWindowMs;
int overlapMs;
+
+ unsigned long maxnorm;
+ float maxnormf;
+
+ double tempo;
+ double nominalSkip;
+ double skipFract;
+
+ bool bQuickSeek;
bool bAutoSeqSetting;
bool bAutoSeekSetting;
+ bool isBeginning;
+
+ SAMPLETYPE *pMidBuffer;
+ SAMPLETYPE *pMidBufferUnaligned;
+
+ FIFOSampleBuffer outputBuffer;
+ FIFOSampleBuffer inputBuffer;
void acceptNewOverlapLength(int newOverlapLength);
virtual void clearCrossCorrState();
void calculateOverlapLength(int overlapMs);
- virtual double calcCrossCorr(const SAMPLETYPE *mixingPos, const SAMPLETYPE *compare, double &norm) const;
- virtual double calcCrossCorrAccumulate(const SAMPLETYPE *mixingPos, const SAMPLETYPE *compare, double &norm) const;
+ virtual double calcCrossCorr(const SAMPLETYPE *mixingPos, const SAMPLETYPE *compare, double &norm);
+ virtual double calcCrossCorrAccumulate(const SAMPLETYPE *mixingPos, const SAMPLETYPE *compare, double &norm);
virtual int seekBestOverlapPositionFull(const SAMPLETYPE *refPos);
virtual int seekBestOverlapPositionQuick(const SAMPLETYPE *refPos);
- int seekBestOverlapPosition(const SAMPLETYPE *refPos);
+ virtual int seekBestOverlapPosition(const SAMPLETYPE *refPos);
virtual void overlapStereo(SAMPLETYPE *output, const SAMPLETYPE *input) const;
virtual void overlapMono(SAMPLETYPE *output, const SAMPLETYPE *input) const;
@@ -154,6 +155,7 @@ protected:
void overlap(SAMPLETYPE *output, const SAMPLETYPE *input, uint ovlPos) const;
void calcSeqParameters();
+ void adaptNormalizer();
/// Changes the tempo of the given sound samples.
/// Returns amount of samples returned in the "output" buffer.
@@ -182,7 +184,7 @@ public:
/// Sets new target tempo. Normal tempo = 'SCALE', smaller values represent slower
/// tempo, larger faster tempo.
- void setTempo(float newTempo);
+ void setTempo(double newTempo);
/// Returns nonzero if there aren't any samples available for outputting.
virtual void clear();
@@ -238,8 +240,13 @@ public:
{
return seekWindowLength - overlapLength;
}
-};
+ /// return approximate initial input-output latency
+ int getLatency() const
+ {
+ return sampleReq;
+ }
+};
// Implementation-specific class declarations:
@@ -249,8 +256,8 @@ public:
class TDStretchMMX : public TDStretch
{
protected:
- double calcCrossCorr(const short *mixingPos, const short *compare, double &norm) const;
- double calcCrossCorrAccumulate(const short *mixingPos, const short *compare, double &norm) const;
+ double calcCrossCorr(const short *mixingPos, const short *compare, double &norm);
+ double calcCrossCorrAccumulate(const short *mixingPos, const short *compare, double &norm);
virtual void overlapStereo(short *output, const short *input) const;
virtual void clearCrossCorrState();
};
@@ -262,8 +269,8 @@ public:
class TDStretchSSE : public TDStretch
{
protected:
- double calcCrossCorr(const float *mixingPos, const float *compare, double &norm) const;
- double calcCrossCorrAccumulate(const float *mixingPos, const float *compare, double &norm) const;
+ double calcCrossCorr(const float *mixingPos, const float *compare, double &norm);
+ double calcCrossCorrAccumulate(const float *mixingPos, const float *compare, double &norm);
};
#endif /// SOUNDTOUCH_ALLOW_SSE
diff --git a/media/libsoundtouch/src/cpu_detect.h b/media/libsoundtouch/src/cpu_detect.h
index e7582e8da3..093b6097aa 100644
--- a/media/libsoundtouch/src/cpu_detect.h
+++ b/media/libsoundtouch/src/cpu_detect.h
@@ -12,13 +12,6 @@
///
////////////////////////////////////////////////////////////////////////////////
//
-// Last changed : $Date: 2008-02-10 16:26:55 +0000 (Sun, 10 Feb 2008) $
-// File revision : $Revision: 4 $
-//
-// $Id: cpu_detect.h 11 2008-02-10 16:26:55Z oparviai $
-//
-////////////////////////////////////////////////////////////////////////////////
-//
// License :
//
// SoundTouch audio processing library
diff --git a/media/libsoundtouch/src/cpu_detect_x86.cpp b/media/libsoundtouch/src/cpu_detect_x86.cpp
index 63f860664a..f0f026b20d 100644
--- a/media/libsoundtouch/src/cpu_detect_x86.cpp
+++ b/media/libsoundtouch/src/cpu_detect_x86.cpp
@@ -11,13 +11,6 @@
///
////////////////////////////////////////////////////////////////////////////////
//
-// Last changed : $Date: 2014-01-07 18:24:28 +0000 (Tue, 07 Jan 2014) $
-// File revision : $Revision: 4 $
-//
-// $Id: cpu_detect_x86.cpp 183 2014-01-07 18:24:28Z oparviai $
-//
-////////////////////////////////////////////////////////////////////////////////
-//
// License :
//
// SoundTouch audio processing library
@@ -74,7 +67,6 @@ void disableExtensions(uint dwDisableMask)
}
-
/// Checks which instruction set extensions are supported by the CPU.
uint detectCPUextensions(void)
{
diff --git a/media/libsoundtouch/src/mmx_optimized.cpp b/media/libsoundtouch/src/mmx_optimized.cpp
index 9062026399..0bc7fe86f7 100644
--- a/media/libsoundtouch/src/mmx_optimized.cpp
+++ b/media/libsoundtouch/src/mmx_optimized.cpp
@@ -20,13 +20,6 @@
///
////////////////////////////////////////////////////////////////////////////////
//
-// Last changed : $Date: 2015-02-22 15:10:38 +0000 (Sun, 22 Feb 2015) $
-// File revision : $Revision: 4 $
-//
-// $Id: mmx_optimized.cpp 206 2015-02-22 15:10:38Z oparviai $
-//
-////////////////////////////////////////////////////////////////////////////////
-//
// License :
//
// SoundTouch audio processing library
@@ -68,7 +61,7 @@ using namespace soundtouch;
// Calculates cross correlation of two buffers
-double TDStretchMMX::calcCrossCorr(const short *pV1, const short *pV2, double &dnorm) const
+double TDStretchMMX::calcCrossCorr(const short *pV1, const short *pV2, double &dnorm)
{
const __m64 *pVec1, *pVec2;
__m64 shifter;
@@ -79,7 +72,7 @@ double TDStretchMMX::calcCrossCorr(const short *pV1, const short *pV2, double &d
pVec1 = (__m64*)pV1;
pVec2 = (__m64*)pV2;
- shifter = _m_from_int(overlapDividerBits);
+ shifter = _m_from_int(overlapDividerBitsNorm);
normaccu = accu = _mm_setzero_si64();
// Process 4 parallel sets of 2 * stereo samples or 4 * mono samples
@@ -123,6 +116,16 @@ double TDStretchMMX::calcCrossCorr(const short *pV1, const short *pV2, double &d
// Clear MMS state
_m_empty();
+ if (norm > (long)maxnorm)
+ {
+ // modify 'maxnorm' inside critical section to avoid multi-access conflict if in OpenMP mode
+ #pragma omp critical
+ if (norm > (long)maxnorm)
+ {
+ maxnorm = norm;
+ }
+ }
+
// Normalize result by dividing by sqrt(norm) - this step is easiest
// done using floating point operation
dnorm = (double)norm;
@@ -134,7 +137,7 @@ double TDStretchMMX::calcCrossCorr(const short *pV1, const short *pV2, double &d
/// Update cross-correlation by accumulating "norm" coefficient by previously calculated value
-double TDStretchMMX::calcCrossCorrAccumulate(const short *pV1, const short *pV2, double &dnorm) const
+double TDStretchMMX::calcCrossCorrAccumulate(const short *pV1, const short *pV2, double &dnorm)
{
const __m64 *pVec1, *pVec2;
__m64 shifter;
@@ -146,13 +149,13 @@ double TDStretchMMX::calcCrossCorrAccumulate(const short *pV1, const short *pV2,
lnorm = 0;
for (i = 1; i <= channels; i ++)
{
- lnorm -= (pV1[-i] * pV1[-i]) >> overlapDividerBits;
+ lnorm -= (pV1[-i] * pV1[-i]) >> overlapDividerBitsNorm;
}
pVec1 = (__m64*)pV1;
pVec2 = (__m64*)pV2;
- shifter = _m_from_int(overlapDividerBits);
+ shifter = _m_from_int(overlapDividerBitsNorm);
accu = _mm_setzero_si64();
// Process 4 parallel sets of 2 * stereo samples or 4 * mono samples
@@ -191,10 +194,15 @@ double TDStretchMMX::calcCrossCorrAccumulate(const short *pV1, const short *pV2,
pV1 = (short *)pVec1;
for (int j = 1; j <= channels; j ++)
{
- lnorm += (pV1[-j] * pV1[-j]) >> overlapDividerBits;
+ lnorm += (pV1[-j] * pV1[-j]) >> overlapDividerBitsNorm;
}
dnorm += (double)lnorm;
+ if (lnorm > (long)maxnorm)
+ {
+ maxnorm = lnorm;
+ }
+
// Normalize result by dividing by sqrt(norm) - this step is easiest
// done using floating point operation
return (double)corr / sqrt((dnorm < 1e-9) ? 1.0 : dnorm);
@@ -209,7 +217,6 @@ void TDStretchMMX::clearCrossCorrState()
}
-
// MMX-optimized version of the function overlapStereo
void TDStretchMMX::overlapStereo(short *output, const short *input) const
{
@@ -233,7 +240,7 @@ void TDStretchMMX::overlapStereo(short *output, const short *input) const
// Overlaplength-division by shifter. "+1" is to account for "-1" deduced in
// overlapDividerBits calculation earlier.
- shifter = _m_from_int(overlapDividerBits + 1);
+ shifter = _m_from_int(overlapDividerBitsPure + 1);
for (i = 0; i < overlapLength / 4; i ++)
{
@@ -325,7 +332,6 @@ void FIRFilterMMX::setCoefficients(const short *coeffs, uint newLength, uint uRe
}
-
// mmx-optimized version of the filter routine for stereo sound
uint FIRFilterMMX::evaluateFilterStereo(short *dest, const short *src, uint numSamples) const
{
@@ -382,4 +388,9 @@ uint FIRFilterMMX::evaluateFilterStereo(short *dest, const short *src, uint numS
return (numSamples & 0xfffffffe) - length;
}
+#else
+
+// workaround to not complain about empty module
+bool _dontcomplain_mmx_empty;
+
#endif // SOUNDTOUCH_ALLOW_MMX
diff --git a/media/libsoundtouch/src/moz.build b/media/libsoundtouch/src/moz.build
index a4294864f9..0912889f6f 100644
--- a/media/libsoundtouch/src/moz.build
+++ b/media/libsoundtouch/src/moz.build
@@ -1,4 +1,5 @@
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
+# vim: set filetype=python:
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
@@ -41,6 +42,8 @@ else:
# Windows need alloca renamed to _alloca
DEFINES['alloca'] = '_alloca'
+DEFINES['BUILDING_SOUNDTOUCH'] = 1
+
# We allow warnings for third-party code that can be updated from upstream.
ALLOW_COMPILER_WARNINGS = True
diff --git a/media/libsoundtouch/src/sse_optimized.cpp b/media/libsoundtouch/src/sse_optimized.cpp
index fa622efa55..9c16ea8f89 100644
--- a/media/libsoundtouch/src/sse_optimized.cpp
+++ b/media/libsoundtouch/src/sse_optimized.cpp
@@ -23,13 +23,6 @@
///
////////////////////////////////////////////////////////////////////////////////
//
-// Last changed : $Date: 2015-02-21 21:24:29 +0000 (Sat, 21 Feb 2015) $
-// File revision : $Revision: 4 $
-//
-// $Id: sse_optimized.cpp 202 2015-02-21 21:24:29Z oparviai $
-//
-////////////////////////////////////////////////////////////////////////////////
-//
// License :
//
// SoundTouch audio processing library
@@ -71,7 +64,7 @@ using namespace soundtouch;
#include <math.h>
// Calculates cross correlation of two buffers
-double TDStretchSSE::calcCrossCorr(const float *pV1, const float *pV2, double &anorm) const
+double TDStretchSSE::calcCrossCorr(const float *pV1, const float *pV2, double &anorm)
{
int i;
const float *pVec1;
@@ -87,7 +80,7 @@ double TDStretchSSE::calcCrossCorr(const float *pV1, const float *pV2, double &a
// Compile-time define SOUNDTOUCH_ALLOW_NONEXACT_SIMD_OPTIMIZATION is provided
// for choosing if this little cheating is allowed.
-#ifdef SOUNDTOUCH_ALLOW_NONEXACT_SIMD_OPTIMIZATION
+#ifdef ST_SIMD_AVOID_UNALIGNED
// Little cheating allowed, return valid correlation only for
// aligned locations, meaning every second round for stereo sound.
@@ -183,7 +176,7 @@ double TDStretchSSE::calcCrossCorr(const float *pV1, const float *pV2, double &a
-double TDStretchSSE::calcCrossCorrAccumulate(const float *pV1, const float *pV2, double &norm) const
+double TDStretchSSE::calcCrossCorrAccumulate(const float *pV1, const float *pV2, double &norm)
{
// call usual calcCrossCorr function because SSE does not show big benefit of
// accumulating "norm" value, and also the "norm" rolling algorithm would get
diff --git a/media/libsoundtouch/update.sh b/media/libsoundtouch/update.sh
index 821e135f15..e279cc7ff6 100755
--- a/media/libsoundtouch/update.sh
+++ b/media/libsoundtouch/update.sh
@@ -43,4 +43,6 @@ done
# Patch the imported files.
patch -p1 < moz-libsoundtouch.patch
+patch -p1 < mcp-disableexceptions.patch
+echo "Remember to update README_MCP with the version details."
diff --git a/media/libtheora/AUTHORS b/media/libtheora/AUTHORS
index 077d4e588c..8a4e529b5a 100644
--- a/media/libtheora/AUTHORS
+++ b/media/libtheora/AUTHORS
@@ -1,24 +1,25 @@
Monty <monty@xiph.org>
- Original VP3 port
-Ralph Giles
Timothy B. Terriberry
+Gregory Maxwell
+Ralph Giles
Monty
- Ongoing development
-
+
Dan B. Miller
- Pre alpha3 development
-
+
Rudolf Marek
Wim Tayman
Dan Lenski
Nils Pipenbrinck
Monty
- MMX optimized functions
-
+
David Schleef
- C64x port
-
+
Aaron Colwell
Thomas Vander Stichele
Jan Gerber
@@ -26,8 +27,9 @@ Conrad Parker
Cristian Adam
Sebastian Pippin
Simon Hosie
+Brad Smith
- Bug fixes, enhancements, build systems.
-
+
Mauricio Piacentini
- Original win32 projects and example ports
- VP3->Theora transcoder
diff --git a/media/libtheora/LICENSE b/media/libtheora/LICENSE
index 5e5ec08469..97e8431790 100644
--- a/media/libtheora/LICENSE
+++ b/media/libtheora/LICENSE
@@ -4,13 +4,13 @@ In addition to and irrespective of the copyright license associated
with this software, On2 Technologies, Inc. makes the following statement
regarding technology used in this software:
- On2 represents and warrants that it shall not assert any rights
+ On2 represents and warrants that it shall not assert any rights
relating to infringement of On2's registered patents, nor initiate
any litigation asserting such rights, against any person who, or
- entity which utilizes the On2 VP3 Codec Software, including any
- use, distribution, and sale of said Software; which make changes,
+ entity which utilizes the On2 VP3 Codec Software, including any
+ use, distribution, and sale of said Software; which make changes,
modifications, and improvements in said Software; and to use,
- distribute, and sell said changes as well as applications for other
+ distribute, and sell said changes as well as applications for other
fields of use.
This reference implementation is originally derived from the On2 VP3
diff --git a/media/libtheora/README b/media/libtheora/README.md
index 7663f9ff8c..b136f7114c 100644
--- a/media/libtheora/README
+++ b/media/libtheora/README.md
@@ -1,13 +1,11 @@
--------------------------------------------------------------------------
- The Xiph.org Foundation's libtheora 1.2
--------------------------------------------------------------------------
+# Xiph.org Foundation's libtheora
-*** What is Theora?
+### What is Theora?
-Theora is Xiph.Org's first publicly released video codec, intended
+Theora was Xiph.Org's first publicly released video codec, intended
for use within the Foundation's Ogg multimedia streaming system.
Theora is derived directly from On2's VP3 codec, adds new features
-while allow it a longer useful lifetime as an competitive codec.
+while allowing it a longer useful lifetime.
The 1.0 release decoder supported all the new features, but the
encoder is nearly identical to the VP3 code.
@@ -20,46 +18,43 @@ The 1.2 release features significant additional improvements in
compression and performance. Files produced by newer encoders can
be decoded by earlier releases.
-*** Where is Theora?
+### Where is Theora?
-Theora's main site is www.theora.org. Theora and related libraries
-can be gotten from www.theora.org or the main Xiph.Org site at
-www.xiph.org. Development source is kept in an open subversion
-repository, see http://theora.org/svn/ for instructions.
+Theora's main site is https://www.theora.org. Releases of Theora
+and related libraries can be found on the
+[download page](https://www.theora.org/downloads/) or the
+[main Xiph.Org site](https://xiph.org/downloads/).
--------------------------------------------------------------------------
-Getting started with the code
--------------------------------------------------------------------------
+Development source is kept at https://gitlab.xiph.org/xiph/theora.
-*** What do I need to build the source?
+## Getting started with the code
-Requirements summary:
-
- For libtheora:
-
- libogg 1.1 or newer.
+### What do I need to build the source?
- For example encoder:
+Requirements summary:
- as above,
+For libtheora:
- libvorbis and libvorbisenc 1.0.1 or newer.
- (libvorbis 1.3.1 or newer for 5.1 audio)
+* libogg 1.1 or newer.
- For creating a source distribution package:
+For example encoder:
- as above,
+* as above,
+* libvorbis and libvorbisenc 1.0.1 or newer.
+ (libvorbis 1.3.1 or newer for 5.1 audio)
- Doxygen to build the API documentation,
- pdflatex and fig2dev to build the format specification
- (transfig package in Ubuntu).
+For creating a source distribution package:
- For the player only:
+* as above,
+* Doxygen to build the API documentation,
+* pdflatex and fig2dev to build the format specification
+ (transfig package in Ubuntu).
- as above,
+For the player only:
- SDL (Simple Direct media Layer) libraries and headers,
- OSS audio driver and development headers.
+* as above,
+* SDL (Simple Direct media Layer) libraries and headers,
+* OSS audio driver and development headers.
The provided build system is the GNU automake/autoconf system, and
the main library, libtheora, should already build smoothly on any
@@ -72,11 +67,11 @@ Project files for Apple XCode are included in the macosx directory.
There is also a more limited scons build.
-*** How do I use the sample encoder?
+### How do I use the sample encoder?
The sample encoder takes raw video in YUV4MPEG2 format, as used by
lavtools, mjpeg-tools and other packages. The encoder expects audio,
-if any, in a separate wave WAV file. Try 'encoder_example -h' for a
+if any, in a separate wave WAV file. Try 'encoder_example -h' for a
complete list of options.
An easy way to get raw video and audio files is to use MPlayer as an
@@ -85,7 +80,7 @@ wav file named audiodump.wav and a YUV video file in the correct
format for encoder_example as stream.yuv. Be careful when exporting
video alone; MPlayer may drop frames to 'keep up' with the audio
timer. The example encoder can't properly synchronize input audio and
-video file that aren't in sync to begin with.
+video file that aren't in sync to begin with.
The encoder will also take video or audio on stdin if '-' is specified
as the input file name.
@@ -93,64 +88,61 @@ as the input file name.
There is also a 'png2theora' example which accepts a set of image
files in that format.
-*** How do I use the sample player?
+### How do I use the sample player?
The sample player takes an Ogg file on standard in; the file may be
audio alone, video alone or video with audio.
-*** What other tools are available?
+### What other tools are available?
-The programs in the examples directory are intended as tutorial source
-for developers using the library. As such they sacrifice features and
-robustness in the interests of comprehension and should not be
+The programs in the examples directory are intended as tutorial source
+for developers using the library. As such they sacrifice features and
+robustness in the interests of comprehension and should not be
considered serious applications.
If you're wanting to just use theora, consider the programs linked
-from http://www.theora.org/. There is playback support in a number
+from https://www.theora.org/. There is playback support in a number
of common free players, and plugins for major media frameworks.
Jan Gerber's ffmpeg2theora is an excellent encoding front end.
--------------------------------------------------------------------------
-Troubleshooting the build process
--------------------------------------------------------------------------
+## Troubleshooting the build process
-*** Compile error, such as:
+### Compile error, such as:
-encoder_internal.h:664: parse error before `ogg_uint16_t'
+encoder_internal.h:664: parse error before `ogg_uint16_t`
-This means you have version of libogg prior to 1.1. A *complete* new Ogg
+This means you have version of libogg prior to 1.1. A *complete* new Ogg
install, libs and headers is needed.
Also be sure that there aren't multiple copies of Ogg installed in
/usr and /usr/local; an older one might be first on the search path
for libs and headers.
-*** Link error, such as:
+### Link error, such as:
-undefined reference to `oggpackB_stream'
+undefined reference to `oggpackB_stream`
See above; you need libogg 1.1 or later.
-*** Link error, such as:
+### Link error, such as:
-undefined reference to `vorbis_granule_time'
+undefined reference to `vorbis_granule_time`
You need libvorbis and libvorbisenc from the 1.0.1 release or later.
-*** Link error, such as:
+### Link error, such as:
-/usr/lib/libSDL.a(SDL_esdaudio.lo): In function `ESD_OpenAudio':
-SDL_esdaudio.lo(.text+0x25d): undefined reference to `esd_play_stream'
+/usr/lib/libSDL.a(SDL_esdaudio.lo): In function `ESD_OpenAudio`:
+SDL_esdaudio.lo(.text+0x25d): undefined reference to `esd_play_stream`
Be sure to use an SDL that's built to work with OSS. If you use an
SDL that is also built with ESD and/or ALSA support, it will try to
suck in all those extra libraries at link time too. That will only
work if the extra libraries are also installed.
-*** Link warning, such as:
+### Link warning, such as:
-libtool: link: warning: library `/usr/lib/libogg.la' was moved.
-libtool: link: warning: library `/usr/lib/libogg.la' was moved.
+libtool: link: warning: library `/usr/lib/libogg.la` was moved.
+libtool: link: warning: library `/usr/lib/libogg.la` was moved.
Re-run theora/autogen.sh after an Ogg or Vorbis rebuild/reinstall
-
diff --git a/media/libtheora/README_MCP b/media/libtheora/README_MCP
new file mode 100644
index 0000000000..d0b00002ef
--- /dev/null
+++ b/media/libtheora/README_MCP
@@ -0,0 +1,7 @@
+The source from this directory was copied from the theora
+git repository using the update.sh script. The only changes
+made were those applied by update.sh and the addition/update of
+Makefile.in files for the UXP build system.
+
+The upstream release used was https://gitlab.xiph.org/xiph/theora
+The git revision used was 7180717276af1ebc7da15c83162d6c5d6203aabf.
diff --git a/media/libtheora/README_MOZILLA b/media/libtheora/README_MOZILLA
deleted file mode 100644
index d48dbfa6f6..0000000000
--- a/media/libtheora/README_MOZILLA
+++ /dev/null
@@ -1,5 +0,0 @@
-The source from this directory was copied from the theora subversion trunk
-using the update.sh script. The changes made were those applied by update.sh,
-the addition/update of Makefile.in files for the Mozilla build system.
-
-The subversion revision used was r17578.
diff --git a/media/libtheora/bug468275-r18219.patch b/media/libtheora/bug468275-r18219.patch
deleted file mode 100644
index 7b64b4195a..0000000000
--- a/media/libtheora/bug468275-r18219.patch
+++ /dev/null
@@ -1,22 +0,0 @@
-diff --git a/media/libtheora/lib/state.c b/media/libtheora/lib/state.c
---- a/media/libtheora/lib/state.c
-+++ b/media/libtheora/lib/state.c
-@@ -583,17 +583,17 @@ static int oc_state_ref_bufs_init(oc_the
- ref_frame_sz<yplane_sz||ref_frame_data_sz/_nrefs!=ref_frame_sz){
- return TH_EIMPL;
- }
- ref_frame_data=oc_aligned_malloc(ref_frame_data_sz,16);
- frag_buf_offs=_state->frag_buf_offs=
- _ogg_malloc(_state->nfrags*sizeof(*frag_buf_offs));
- if(ref_frame_data==NULL||frag_buf_offs==NULL){
- _ogg_free(frag_buf_offs);
-- _ogg_free(ref_frame_data);
-+ oc_aligned_free(ref_frame_data);
- return TH_EFAULT;
- }
- /*Set up the width, height and stride for the image buffers.*/
- _state->ref_frame_bufs[0][0].width=info->frame_width;
- _state->ref_frame_bufs[0][0].height=info->frame_height;
- _state->ref_frame_bufs[0][0].stride=yhstride;
- _state->ref_frame_bufs[0][1].width=_state->ref_frame_bufs[0][2].width=
- info->frame_width>>hdec;
diff --git a/media/libtheora/bug625773-r17780.patch b/media/libtheora/bug625773-r17780.patch
deleted file mode 100644
index af112560b0..0000000000
--- a/media/libtheora/bug625773-r17780.patch
+++ /dev/null
@@ -1,23 +0,0 @@
-diff --git a/media/libtheora/lib/decode.c b/media/libtheora/lib/decode.c
---- a/media/libtheora/lib/decode.c
-+++ b/media/libtheora/lib/decode.c
-@@ -2072,18 +2072,17 @@ static void oc_dec_init_dummy_frame(th_d
- sizeof(_dec->pp_frame_buf[0])*3);
- info=&_dec->state.info;
- yhstride=abs(_dec->state.ref_ystride[0]);
- yheight=info->frame_height+2*OC_UMV_PADDING;
- chstride=abs(_dec->state.ref_ystride[1]);
- cheight=yheight>>!(info->pixel_fmt&2);
- yplane_sz=yhstride*(size_t)yheight+16;
- cplane_sz=chstride*(size_t)cheight;
-- yoffset=_dec->state.ref_ystride[0]*(yheight-1)-
-- (OC_UMV_PADDING+OC_UMV_PADDING*(ptrdiff_t)yhstride);
-+ yoffset=yhstride*(ptrdiff_t)(yheight-OC_UMV_PADDING-1)+OC_UMV_PADDING;
- memset(_dec->state.ref_frame_data[0]-yoffset,0x80,yplane_sz+2*cplane_sz);
- }
-
- int th_decode_packetin(th_dec_ctx *_dec,const ogg_packet *_op,
- ogg_int64_t *_granpos){
- int ret;
- if(_dec==NULL||_op==NULL)return TH_EFAULT;
- /*A completely empty packet indicates a dropped frame and is treated exactly
diff --git a/media/libtheora/bug752139-r18031.patch b/media/libtheora/bug752139-r18031.patch
deleted file mode 100644
index 62ea87632b..0000000000
--- a/media/libtheora/bug752139-r18031.patch
+++ /dev/null
@@ -1,53 +0,0 @@
-diff --git a/media/libtheora/lib/arm/arm2gnu.pl b/media/libtheora/lib/arm/arm2gnu.pl
---- a/media/libtheora/lib/arm/arm2gnu.pl
-+++ b/media/libtheora/lib/arm/arm2gnu.pl
-@@ -1,11 +1,14 @@
- #!/usr/bin/perl
-
- my $bigend; # little/big endian
-+my $nxstack;
-+
-+$nxstack = 0;
-
- eval 'exec /usr/local/bin/perl -S $0 ${1+"$@"}'
- if $running_under_some_shell;
-
- while ($ARGV[0] =~ /^-/) {
- $_ = shift;
- last if /^--/;
- if (/^-n/) {
-@@ -77,16 +80,19 @@ while (<>) {
- if ( /\bMEND\b/ ) {
- s/\bMEND\b/.endm/;
- $n=0;
- }
-
- # ".rdata" doesn't work in 'as' version 2.13.2, as it is ".rodata" there.
- #
- if ( /\bAREA\b/ ) {
-+ if ( /CODE/ ) {
-+ $nxstack = 1;
-+ }
- s/^(.+)CODE(.+)READONLY(.*)/ .text/;
- s/^(.+)DATA(.+)READONLY(.*)/ .section .rdata\n .align 2/;
- s/^(.+)\|\|\.data\|\|(.+)/ .data\n .align 2/;
- s/^(.+)\|\|\.bss\|\|(.+)/ .bss/;
- }
-
- s/\|\|\.constdata\$(\d+)\|\|/.L_CONST$1/; # ||.constdata$3||
- s/\|\|\.bss\$(\d+)\|\|/.L_BSS$1/; # ||.bss$2||
-@@ -263,9 +269,13 @@ while (<>) {
- } continue {
- printf ("%s", $_) if $printit;
- if ($addPadding != 0)
- {
- printf (" mov r0,r0\n");
- $addPadding = 0;
- }
- }
--
-+#If we had a code section, mark that this object doesn't need an executable
-+# stack.
-+if ($nxstack) {
-+ printf (" .section\t.note.GNU-stack,\"\",\%\%progbits\n");
-+}
diff --git a/media/libtheora/bug752668-r18268.patch b/media/libtheora/bug752668-r18268.patch
deleted file mode 100644
index 6931e07faf..0000000000
--- a/media/libtheora/bug752668-r18268.patch
+++ /dev/null
@@ -1,28 +0,0 @@
-diff -r 1092c1a3ac50 media/libtheora/lib/decode.c
---- a/media/libtheora/lib/decode.c Tue May 08 08:53:50 2012 +0200
-+++ b/media/libtheora/lib/decode.c Tue May 08 01:00:59 2012 -0700
-@@ -395,20 +395,20 @@ static int oc_dec_init(oc_dec_ctx *_dec,
- _dec->state.dequant_table_data[qi][pli][qti];
- }
- oc_dequant_tables_init(_dec->state.dequant_tables,_dec->pp_dc_scale,
- &_setup->qinfo);
- for(qi=0;qi<64;qi++){
- int qsum;
- qsum=0;
- for(qti=0;qti<2;qti++)for(pli=0;pli<3;pli++){
-- qsum+=_dec->state.dequant_tables[qti][pli][qi][12]+
-- _dec->state.dequant_tables[qti][pli][qi][17]+
-- _dec->state.dequant_tables[qti][pli][qi][18]+
-- _dec->state.dequant_tables[qti][pli][qi][24]<<(pli==0);
-+ qsum+=_dec->state.dequant_tables[qi][pli][qti][12]+
-+ _dec->state.dequant_tables[qi][pli][qti][17]+
-+ _dec->state.dequant_tables[qi][pli][qti][18]+
-+ _dec->state.dequant_tables[qi][pli][qti][24]<<(pli==0);
- }
- _dec->pp_sharp_mod[qi]=-(qsum>>11);
- }
- memcpy(_dec->state.loop_filter_limits,_setup->qinfo.loop_filter_limits,
- sizeof(_dec->state.loop_filter_limits));
- oc_dec_accel_init(_dec);
- _dec->pp_level=OC_PP_LEVEL_DISABLED;
- _dec->dc_qis=NULL;
diff --git a/media/libtheora/bug920992.patch b/media/libtheora/bug920992.patch
deleted file mode 100644
index eada85a49b..0000000000
--- a/media/libtheora/bug920992.patch
+++ /dev/null
@@ -1,103 +0,0 @@
-diff --git a/media/libtheora/lib/arm/armbits.s b/media/libtheora/lib/arm/armbits.s
---- a/media/libtheora/lib/arm/armbits.s
-+++ b/media/libtheora/lib/arm/armbits.s
-@@ -12,16 +12,22 @@
- ;
- ; function:
- ; last mod: $Id: armbits.s 17481 2010-10-03 22:49:42Z tterribe $
- ;
- ;********************************************************************
-
- AREA |.text|, CODE, READONLY
-
-+ ; Explicitly specifying alignment here because some versions of
-+ ; gas don't align code correctly. See
-+ ; http://lists.gnu.org/archive/html/bug-binutils/2011-06/msg00199.html
-+ ; https://bugzilla.mozilla.org/show_bug.cgi?id=920992
-+ ALIGN
-+
- EXPORT oc_pack_read_arm
- EXPORT oc_pack_read1_arm
- EXPORT oc_huff_token_decode_arm
-
- oc_pack_read1_arm PROC
- ; r0 = oc_pack_buf *_b
- ADD r12,r0,#8
- LDMIA r12,{r2,r3} ; r2 = window
-diff --git a/media/libtheora/lib/arm/armfrag.s b/media/libtheora/lib/arm/armfrag.s
---- a/media/libtheora/lib/arm/armfrag.s
-+++ b/media/libtheora/lib/arm/armfrag.s
-@@ -11,16 +11,22 @@
- ;********************************************************************
- ; Original implementation:
- ; Copyright (C) 2009 Robin Watts for Pinknoise Productions Ltd
- ; last mod: $Id: armfrag.s 17481 2010-10-03 22:49:42Z tterribe $
- ;********************************************************************
-
- AREA |.text|, CODE, READONLY
-
-+ ; Explicitly specifying alignment here because some versions of
-+ ; gas don't align code correctly. See
-+ ; http://lists.gnu.org/archive/html/bug-binutils/2011-06/msg00199.html
-+ ; https://bugzilla.mozilla.org/show_bug.cgi?id=920992
-+ ALIGN
-+
- GET armopts.s
-
- ; Vanilla ARM v4 versions
- EXPORT oc_frag_copy_list_arm
- EXPORT oc_frag_recon_intra_arm
- EXPORT oc_frag_recon_inter_arm
- EXPORT oc_frag_recon_inter2_arm
-
-diff --git a/media/libtheora/lib/arm/armidct.s b/media/libtheora/lib/arm/armidct.s
---- a/media/libtheora/lib/arm/armidct.s
-+++ b/media/libtheora/lib/arm/armidct.s
-@@ -11,16 +11,22 @@
- ;********************************************************************
- ; Original implementation:
- ; Copyright (C) 2009 Robin Watts for Pinknoise Productions Ltd
- ; last mod: $Id: armidct.s 17481 2010-10-03 22:49:42Z tterribe $
- ;********************************************************************
-
- AREA |.text|, CODE, READONLY
-
-+ ; Explicitly specifying alignment here because some versions of
-+ ; gas don't align code correctly. See
-+ ; http://lists.gnu.org/archive/html/bug-binutils/2011-06/msg00199.html
-+ ; https://bugzilla.mozilla.org/show_bug.cgi?id=920992
-+ ALIGN
-+
- GET armopts.s
-
- EXPORT oc_idct8x8_1_arm
- EXPORT oc_idct8x8_arm
-
- oc_idct8x8_1_arm PROC
- ; r0 = ogg_int16_t *_y
- ; r1 = ogg_uint16_t _dc
-diff --git a/media/libtheora/lib/arm/armloop.s b/media/libtheora/lib/arm/armloop.s
---- a/media/libtheora/lib/arm/armloop.s
-+++ b/media/libtheora/lib/arm/armloop.s
-@@ -11,16 +11,22 @@
- ;********************************************************************
- ; Original implementation:
- ; Copyright (C) 2009 Robin Watts for Pinknoise Productions Ltd
- ; last mod: $Id: armloop.s 17481 2010-10-03 22:49:42Z tterribe $
- ;********************************************************************
-
- AREA |.text|, CODE, READONLY
-
-+ ; Explicitly specifying alignment here because some versions of
-+ ; gas don't align code correctly. See
-+ ; http://lists.gnu.org/archive/html/bug-binutils/2011-06/msg00199.html
-+ ; https://bugzilla.mozilla.org/show_bug.cgi?id=920992
-+ ALIGN
-+
- GET armopts.s
-
- EXPORT oc_loop_filter_frag_rows_arm
-
- ; Which bit this is depends on the order of packing within a bitfield.
- ; Hopefully that doesn't change among any of the relevant compilers.
- OC_FRAG_CODED_FLAG * 1
diff --git a/media/libtheora/include/theora/codec.h b/media/libtheora/include/theora/codec.h
index 5c2669630c..29b8602325 100644
--- a/media/libtheora/include/theora/codec.h
+++ b/media/libtheora/include/theora/codec.h
@@ -16,11 +16,12 @@
********************************************************************/
/**\mainpage
- *
+ *
* \section intro Introduction
*
- * This is the documentation for <tt>libtheora</tt> C API.
- * The current reference
+ * This is the documentation for the <tt>libtheora</tt> C API.
+ *
+ * The \c libtheora package is the current reference
* implementation for <a href="http://www.theora.org/">Theora</a>, a free,
* patent-unencumbered video codec.
* Theora is derived from On2's VP3 codec with additional features and
@@ -30,29 +31,31 @@
* <a href="http://www.theora.org/doc/Theora.pdf">the Theora
* specification</a>.
*
- * \subsection Organization
+ * \section Organization
*
- * The functions documented here are actually subdivided into three
+ * The functions documented here are divided between two
* separate libraries:
- * - <tt>libtheoraenc</tt> contains the encoder interface,
+ * - \c libtheoraenc contains the encoder interface,
* described in \ref encfuncs.
- * - <tt>libtheoradec</tt> contains the decoder interface and
- * routines shared with the encoder.
- * You must also link to this if you link to <tt>libtheoraenc</tt>.
- * The routines in this library are described in \ref decfuncs and
- * \ref basefuncs.
- * - <tt>libtheora</tt> contains the \ref oldfuncs.
+ * - \c libtheoradec contains the decoder interface,
+ * described in \ref decfuncs, \n
+ * and additional \ref basefuncs.
+ *
+ * New code should link to \c libtheoradec. If using encoder
+ * features, it must also link to \c libtheoraenc.
*
- * New code should link to <tt>libtheoradec</tt> and, if using encoder
- * features, <tt>libtheoraenc</tt>. Together these two export both
- * the standard and the legacy API, so this is all that is needed by
- * any code. The older <tt>libtheora</tt> library is provided just for
- * compatibility with older build configurations.
+ * During initial development, prior to the 1.0 release,
+ * \c libtheora exported a different \ref oldfuncs which
+ * combined both encode and decode functions.
+ * In general, legacy API symbols can be indentified
+ * by their \c theora_ or \c OC_ namespace prefixes.
+ * The current API uses \c th_ or \c TH_ instead.
*
- * In general the recommended 1.x API symbols can be distinguished
- * by their <tt>th_</tt> or <tt>TH_</tt> namespace prefix.
- * The older, legacy API uses <tt>theora_</tt> or <tt>OC_</tt>
- * prefixes instead.
+ * While deprecated, \c libtheoraenc and \c libtheoradec
+ * together export the legacy api as well at the one documented above.
+ * Likewise, the legacy \c libtheora included with this package
+ * exports the new 1.x API. Older code and build scripts can therefore
+ * but updated independently to the current scheme.
*/
/**\file
@@ -168,7 +171,7 @@ typedef struct{
typedef th_img_plane th_ycbcr_buffer[3];
/**Theora bitstream information.
- * This contains the basic playback parameters for a stream, and corresponds to
+ * This contains the basic playback parameters for a stream, and corresponds to
* the initial 'info' header packet.
* To initialize an encoder, the application fills in this structure and
* passes it to th_encode_alloc().
@@ -317,7 +320,7 @@ typedef struct{
* In filling in this structure, th_decode_headerin() will null-terminate
* the user_comment strings for safety.
* However, the bitstream format itself treats them as 8-bit clean vectors,
- * possibly containing null characters, and so the length array should be
+ * possibly containing null characters, so the length array should be
* treated as their authoritative length.
*/
typedef struct th_comment{
@@ -448,7 +451,13 @@ typedef struct{
/**\defgroup basefuncs Functions Shared by Encode and Decode*/
/*@{*/
-/**\name Basic shared functions*/
+/**\name Basic shared functions
+ * These functions return information about the library itself,
+ * or provide high-level information about codec state
+ * and packet type.
+ *
+ * You must link to \c libtheoradec if you use any of the
+ * functions in this section.*/
/*@{*/
/**Retrieves a human-readable string to identify the library vendor and
* version.
@@ -510,7 +519,12 @@ extern int th_packet_iskeyframe(ogg_packet *_op);
/*@}*/
-/**\name Functions for manipulating header data*/
+/**\name Functions for manipulating header data
+ * These functions manipulate the #th_info and #th_comment structures
+ * which describe video parameters and key-value metadata, respectively.
+ *
+ * You must link to \c libtheoradec if you use any of the
+ * functions in this section.*/
/*@{*/
/**Initializes a th_info structure.
* This should be called on a freshly allocated #th_info structure before
@@ -537,7 +551,7 @@ extern void th_comment_init(th_comment *_tc);
* \param _tc The #th_comment struct to add the comment to.
* \param _comment Must be a null-terminated UTF-8 string containing the
* comment in "TAG=the value" form.*/
-extern void th_comment_add(th_comment *_tc, char *_comment);
+extern void th_comment_add(th_comment *_tc,const char *_comment);
/**Add a comment to an initialized #th_comment structure.
* \note Neither th_comment_add() nor th_comment_add_tag() support
* comments containing null values, although the bitstream format does
@@ -545,10 +559,11 @@ extern void th_comment_add(th_comment *_tc, char *_comment);
* To add such comments you will need to manipulate the #th_comment
* structure directly.
* \param _tc The #th_comment struct to add the comment to.
- * \param _tag A null-terminated string containing the tag associated with
+ * \param _tag A null-terminated string containing the tag associated with
* the comment.
* \param _val The corresponding value as a null-terminated string.*/
-extern void th_comment_add_tag(th_comment *_tc,char *_tag,char *_val);
+extern void th_comment_add_tag(th_comment *_tc,const char *_tag,
+ const char *_val);
/**Look up a comment value by its tag.
* \param _tc An initialized #th_comment structure.
* \param _tag The tag to look up.
@@ -564,15 +579,15 @@ extern void th_comment_add_tag(th_comment *_tc,char *_tag,char *_val);
* It should not be modified or freed by the application, and
* modifications to the structure may invalidate the pointer.
* \retval NULL If no matching tag is found.*/
-extern char *th_comment_query(th_comment *_tc,char *_tag,int _count);
+extern char *th_comment_query(th_comment *_tc,const char *_tag,int _count);
/**Look up the number of instances of a tag.
* Call this first when querying for a specific tag and then iterate over the
* number of instances with separate calls to th_comment_query() to
* retrieve all the values for that tag in order.
* \param _tc An initialized #th_comment structure.
* \param _tag The tag to look up.
- * \return The number on instances of this particular tag.*/
-extern int th_comment_query_count(th_comment *_tc,char *_tag);
+ * \return The number of instances of this particular tag.*/
+extern int th_comment_query_count(th_comment *_tc,const char *_tag);
/**Clears a #th_comment structure.
* This should be called on a #th_comment structure after it is no longer
* needed.
diff --git a/media/libtheora/include/theora/theora.h b/media/libtheora/include/theora/theora.h
index 575a889b71..a729a76890 100644
--- a/media/libtheora/include/theora/theora.h
+++ b/media/libtheora/include/theora/theora.h
@@ -34,41 +34,41 @@ extern "C"
*
* \section intro Introduction
*
- * This is the documentation for the libtheora legacy C API, declared in
+ * This is the documentation for the libtheora legacy C API, declared in
* the theora.h header, which describes the old interface used before
* the 1.0 release. This API was widely deployed for several years and
- * remains supported, but for new code we recommend the cleaner API
+ * remains supported, but for new code we recommend the cleaner API
* declared in theoradec.h and theoraenc.h.
*
* libtheora is the reference implementation for
* <a href="http://www.theora.org/">Theora</a>, a free video codec.
* Theora is derived from On2's VP3 codec with improved integration with
* Ogg multimedia formats by <a href="http://www.xiph.org/">Xiph.Org</a>.
- *
+ *
* \section overview Overview
*
- * This library will both decode and encode theora packets to/from raw YUV
+ * This library will both decode and encode theora packets to/from raw YUV
* frames. In either case, the packets will most likely either come from or
- * need to be embedded in an Ogg stream. Use
- * <a href="http://xiph.org/ogg/">libogg</a> or
+ * need to be embedded in an Ogg stream. Use
+ * <a href="http://xiph.org/ogg/">libogg</a> or
* <a href="http://www.annodex.net/software/liboggz/index.html">liboggz</a>
* to extract/package these packets.
*
* \section decoding Decoding Process
*
* Decoding can be separated into the following steps:
- * -# initialise theora_info and theora_comment structures using
+ * -# initialise theora_info and theora_comment structures using
* theora_info_init() and theora_comment_init():
\verbatim
theora_info info;
theora_comment comment;
-
+
theora_info_init(&info);
theora_comment_init(&comment);
\endverbatim
- * -# retrieve header packets from Ogg stream (there should be 3) and decode
- * into theora_info and theora_comment structures using
- * theora_decode_header(). See \ref identification for more information on
+ * -# retrieve header packets from Ogg stream (there should be 3) and decode
+ * into theora_info and theora_comment structures using
+ * theora_decode_header(). See \ref identification for more information on
* identifying which packets are theora packets.
\verbatim
int i;
@@ -79,14 +79,14 @@ extern "C"
}
\endverbatim
* -# initialise the decoder based on the information retrieved into the
- * theora_info struct by theora_decode_header(). You will need a
+ * theora_info struct by theora_decode_header(). You will need a
* theora_state struct.
\verbatim
theora_state state;
-
+
theora_decode_init(&state, &info);
\endverbatim
- * -# pass in packets and retrieve decoded frames! See the yuv_buffer
+ * -# pass in packets and retrieve decoded frames! See the yuv_buffer
* documentation for information on how to retrieve raw YUV data.
\verbatim
yuf_buffer buffer;
@@ -96,20 +96,20 @@ extern "C"
theora_decode_YUVout(&state, &buffer);
}
\endverbatim
- *
+ *
*
* \subsection identification Identifying Theora Packets
*
- * All streams inside an Ogg file have a unique serial_no attached to the
- * stream. Typically, you will want to
- * - retrieve the serial_no for each b_o_s (beginning of stream) page
- * encountered within the Ogg file;
- * - test the first (only) packet on that page to determine if it is a theora
+ * All streams inside an Ogg file have a unique serial_no attached to the
+ * stream. Typically, you will want to
+ * - retrieve the serial_no for each b_o_s (beginning of stream) page
+ * encountered within the Ogg file;
+ * - test the first (only) packet on that page to determine if it is a theora
* packet;
- * - once you have found a theora b_o_s page then use the retrieved serial_no
+ * - once you have found a theora b_o_s page then use the retrieved serial_no
* to identify future packets belonging to the same theora stream.
- *
- * Note that you \e cannot use theora_packet_isheader() to determine if a
+ *
+ * Note that you \e cannot use theora_packet_isheader() to determine if a
* packet is a theora packet or not, as this function does not perform any
* checking beyond whether a header bit is present. Instead, use the
* theora_decode_header() function and check the return value; or examine the
@@ -124,9 +124,9 @@ extern "C"
* A YUV buffer for passing uncompressed frames to and from the codec.
* This holds a Y'CbCr frame in planar format. The CbCr planes can be
* subsampled and have their own separate dimensions and row stride
- * offsets. Note that the strides may be negative in some
+ * offsets. Note that the strides may be negative in some
* configurations. For theora the width and height of the largest plane
- * must be a multiple of 16. The actual meaningful picture size and
+ * must be a multiple of 16. The actual meaningful picture size and
* offset are stored in the theora_info structure; frames returned by
* the decoder may need to be cropped for display.
*
@@ -135,8 +135,8 @@ extern "C"
* are ordered from left to right.
*
* During decode, the yuv_buffer struct is allocated by the user, but all
- * fields (including luma and chroma pointers) are filled by the library.
- * These pointers address library-internal memory and their contents should
+ * fields (including luma and chroma pointers) are filled by the library.
+ * These pointers address library-internal memory and their contents should
* not be modified.
*
* Conversely, during encode the user allocates the struct and fills out all
@@ -186,7 +186,7 @@ typedef enum {
* Theora bitstream info.
* Contains the basic playback parameters for a stream,
* corresponding to the initial 'info' header packet.
- *
+ *
* Encoded theora frames must be a multiple of 16 in width and height.
* To handle other frame sizes, a crop rectangle is specified in
* frame_height and frame_width, offset_x and * offset_y. The offset
@@ -198,10 +198,10 @@ typedef enum {
* fraction. Aspect ratio is also stored as a rational fraction, and
* refers to the aspect ratio of the frame pixels, not of the
* overall frame itself.
- *
+ *
* See <a href="http://svn.xiph.org/trunk/theora/examples/encoder_example.c">
* examples/encoder_example.c</a> for usage examples of the
- * other paramters and good default settings for the encoder parameters.
+ * other parameters and good default settings for the encoder parameters.
*/
typedef struct {
ogg_uint32_t width; /**< encoded frame width */
@@ -253,14 +253,14 @@ typedef struct{
} theora_state;
-/**
+/**
* Comment header metadata.
*
* This structure holds the in-stream metadata corresponding to
* the 'comment' header packet.
*
* Meta data is stored as a series of (tag, value) pairs, in
- * length-encoded string vectors. The first occurence of the
+ * length-encoded string vectors. The first occurence of the
* '=' character delimits the tag and value. A particular tag
* may occur more than once. The character set encoding for
* the strings is always UTF-8, but the tag names are limited
@@ -285,7 +285,7 @@ typedef struct theora_comment{
/* \anchor decctlcodes_old
* These are the available request codes for theora_control()
* when called with a decoder instance.
- * By convention decoder control codes are odd, to distinguish
+ * By convention decoder control codes are odd, to distinguish
* them from \ref encctlcodes_old "encoder control codes" which
* are even.
*
@@ -306,7 +306,7 @@ typedef struct theora_comment{
#define TH_DECCTL_GET_PPLEVEL_MAX (1)
/**Set the post-processing level.
- * Sets the level of post-processing to use when decoding the
+ * Sets the level of post-processing to use when decoding the
* compressed stream. This must be a value between zero (off)
* and the maximum returned by TH_DECCTL_GET_PPLEVEL_MAX.
*/
@@ -345,9 +345,9 @@ typedef struct theora_comment{
* \param[in] buf #th_quant_info
* \retval OC_FAULT \a theora_state is <tt>NULL</tt>.
* \retval OC_EINVAL Encoding has already begun, the quantization parameters
- * are not acceptable to this version of the encoder,
- * \a buf is <tt>NULL</tt> and \a buf_sz is not zero,
- * or \a buf is non-<tt>NULL</tt> and \a buf_sz is
+ * are not acceptable to this version of the encoder,
+ * \a buf is <tt>NULL</tt> and \a buf_sz is not zero,
+ * or \a buf is non-<tt>NULL</tt> and \a buf_sz is
* not <tt>sizeof(#th_quant_info)</tt>.
* \retval OC_IMPL Not supported by this implementation.*/
#define TH_ENCCTL_SET_QUANT_PARAMS (2)
@@ -424,7 +424,7 @@ typedef struct theora_comment{
#define OC_NEWPACKET -25 /**< Packet is an (ignorable) unhandled extension */
#define OC_DUPFRAME 1 /**< Packet is a dropped frame */
-/**
+/**
* Retrieve a human-readable string to identify the encoder vendor and version.
* \returns A version string.
*/
@@ -462,7 +462,7 @@ extern int theora_encode_init(theora_state *th, theora_info *ti);
extern int theora_encode_YUVin(theora_state *t, yuv_buffer *yuv);
/**
- * Request the next packet of encoded video.
+ * Request the next packet of encoded video.
* The encoded data is placed in a user-provided ogg_packet structure.
* \param t A theora_state handle previously initialized for encoding.
* \param last_p whether this is the last packet the encoder should produce.
@@ -496,7 +496,11 @@ extern int theora_encode_header(theora_state *t, ogg_packet *op);
* \param op An ogg_packet structure to fill. libtheora will set all
* elements of this structure, including a pointer to the encoded
* comment data. The memory for the comment data is owned by
- * libtheora.
+ * the application, and must be freed by it using _ogg_free().
+ * On some systems (such as Windows when using dynamic linking), this
+ * may mean the free is executed in a different module from the
+ * malloc, which will crash; there is no way to free this memory on
+ * such systems.
* \retval 0 Success
*/
extern int theora_encode_comment(theora_comment *tc, ogg_packet *op);
@@ -581,8 +585,8 @@ extern int theora_decode_packetin(theora_state *th,ogg_packet *op);
* \param th A theora_state handle previously initialized for decoding.
* \param yuv A yuv_buffer in which libtheora should place the decoded data.
* Note that the buffer struct itself is allocated by the user, but
- * that the luma and chroma pointers will be filled in by the
- * library. Also note that these luma and chroma regions should be
+ * that the luma and chroma pointers will be filled in by the
+ * library. Also note that these luma and chroma regions should be
* considered read-only by the user.
* \retval 0 Success
*/
@@ -617,22 +621,22 @@ extern int theora_packet_iskeyframe(ogg_packet *op);
/**
* Report the granulepos shift radix
*
- * When embedded in Ogg, Theora uses a two-part granulepos,
+ * When embedded in Ogg, Theora uses a two-part granulepos,
* splitting the 64-bit field into two pieces. The more-significant
* section represents the frame count at the last keyframe,
* and the less-significant section represents the count of
* frames since the last keyframe. In this way the overall
* field is still non-decreasing with time, but usefully encodes
* a pointer to the last keyframe, which is necessary for
- * correctly restarting decode after a seek.
+ * correctly restarting decode after a seek.
*
* This function reports the number of bits used to represent
* the distance to the last keyframe, and thus how the granulepos
* field must be shifted or masked to obtain the two parts.
- *
+ *
* Since libtheora returns compressed data in an ogg_packet
* structure, this may be generally useful even if the Theora
- * packets are not being used in an Ogg container.
+ * packets are not being used in an Ogg container.
*
* \param ti A previously initialized theora_info struct
* \returns The bit shift dividing the two granulepos fields
@@ -644,7 +648,7 @@ int theora_granule_shift(theora_info *ti);
/**
* Convert a granulepos to an absolute frame index, starting at 0.
* The granulepos is interpreted in the context of a given theora_state handle.
- *
+ *
* Note that while the granulepos encodes the frame count (i.e. starting
* from 1) this call returns the frame index, starting from zero. Thus
* One can calculate the presentation time by multiplying the index by
@@ -670,9 +674,7 @@ extern ogg_int64_t theora_granule_frame(theora_state *th,ogg_int64_t granulepos)
* This is the "end time" for the frame, or the latest time it should
* be displayed.
* It is not the presentation time.
- * \retval -1. The given granulepos is undefined (i.e. negative), or
- * \retval -1. The function has been disabled because floating
- * point support is not available.
+ * \retval -1. The given granulepos is undefined (i.e. negative).
*/
extern double theora_granule_time(theora_state *th,ogg_int64_t granulepos);
@@ -699,7 +701,7 @@ extern void theora_clear(theora_state *t);
/**
* Initialize an allocated theora_comment structure
- * \param tc An allocated theora_comment structure
+ * \param tc An allocated theora_comment structure
**/
extern void theora_comment_init(theora_comment *tc);
@@ -720,7 +722,7 @@ extern void theora_comment_add(theora_comment *tc, char *comment);
/**
* Add a comment to an initialized theora_comment structure.
* \param tc A previously initialized theora comment structure
- * \param tag A null-terminated string containing the tag
+ * \param tag A null-terminated string containing the tag
* associated with the comment.
* \param value The corresponding value as a null-terminated string
*
@@ -752,9 +754,9 @@ extern char *theora_comment_query(theora_comment *tc, char *tag, int count);
* \param tc An initialized theora_comment structure
* \param tag The tag to look up
* \returns The number on instances of a particular tag.
- *
+ *
* Call this first when querying for a specific tag and then interate
- * over the number of instances with separate calls to
+ * over the number of instances with separate calls to
* theora_comment_query() to retrieve all instances in order.
**/
extern int theora_comment_query_count(theora_comment *tc, char *tag);
@@ -769,7 +771,7 @@ extern void theora_comment_clear(theora_comment *tc);
* This is used to provide advanced control the encoding process.
* \param th A #theora_state handle.
* \param req The control code to process.
- * See \ref encctlcodes_old "the list of available
+ * See \ref encctlcodes_old "the list of available
* control codes" for details.
* \param buf The parameters for this control code.
* \param buf_sz The size of the parameter buffer.*/
diff --git a/media/libtheora/include/theora/theoradec.h b/media/libtheora/include/theora/theoradec.h
index 6177af3216..77bef81909 100644
--- a/media/libtheora/include/theora/theoradec.h
+++ b/media/libtheora/include/theora/theoradec.h
@@ -92,13 +92,17 @@ extern "C" {
* <tt>sizeof(th_stripe_callback)</tt>.*/
#define TH_DECCTL_SET_STRIPE_CB (7)
-/**Enables telemetry and sets the macroblock display mode */
+/**Sets the macroblock display mode. Set to 0 to disable displaying
+ * macroblocks.*/
#define TH_DECCTL_SET_TELEMETRY_MBMODE (9)
-/**Enables telemetry and sets the motion vector display mode */
+/**Sets the motion vector display mode. Set to 0 to disable displaying motion
+ * vectors.*/
#define TH_DECCTL_SET_TELEMETRY_MV (11)
-/**Enables telemetry and sets the adaptive quantization display mode */
+/**Sets the adaptive quantization display mode. Set to 0 to disable displaying
+ * adaptive quantization. */
#define TH_DECCTL_SET_TELEMETRY_QI (13)
-/**Enables telemetry and sets the bitstream breakdown visualization mode */
+/**Sets the bitstream breakdown visualization mode. Set to 0 to disable
+ * displaying bitstream breakdown.*/
#define TH_DECCTL_SET_TELEMETRY_BITS (15)
/*@}*/
@@ -171,7 +175,7 @@ typedef struct th_setup_info th_setup_info;
/**\defgroup decfuncs Functions for Decoding*/
/*@{*/
/**\name Functions for decoding
- * You must link to <tt>libtheoradec</tt> if you use any of the
+ * You must link to <tt>libtheoradec</tt> if you use any of the
* functions in this section.
*
* The functions are listed in the order they are used in a typical decode.
@@ -267,7 +271,10 @@ extern void th_setup_free(th_setup_info *_setup);
* See \ref decctlcodes "the list of available control codes"
* for details.
* \param _buf The parameters for this control code.
- * \param _buf_sz The size of the parameter buffer.*/
+ * \param _buf_sz The size of the parameter buffer.
+ * \return Possible return values depend on the control code used.
+ * See \ref decctlcodes "the list of control codes" for
+ * specific values. Generally 0 indicates success.*/
extern int th_decode_ctl(th_dec_ctx *_dec,int _req,void *_buf,
size_t _buf_sz);
/**Submits a packet containing encoded video data to the decoder.
diff --git a/media/libtheora/include/theora/theoraenc.h b/media/libtheora/include/theora/theoraenc.h
deleted file mode 100644
index 721ea89b9d..0000000000
--- a/media/libtheora/include/theora/theoraenc.h
+++ /dev/null
@@ -1,540 +0,0 @@
-/********************************************************************
- * *
- * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE. *
- * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
- * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
- * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
- * *
- * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2009 *
- * by the Xiph.Org Foundation http://www.xiph.org/ *
- * *
- ********************************************************************
-
- function:
- last mod: $Id: theora.h,v 1.8 2004/03/15 22:17:32 derf Exp $
-
- ********************************************************************/
-
-/**\file
- * The <tt>libtheoraenc</tt> C encoding API.*/
-
-#if !defined(_O_THEORA_THEORAENC_H_)
-# define _O_THEORA_THEORAENC_H_ (1)
-# include <stddef.h>
-# include <ogg/ogg.h>
-# include "codec.h"
-
-#if defined(__cplusplus)
-extern "C" {
-#endif
-
-
-
-/**\name th_encode_ctl() codes
- * \anchor encctlcodes
- * These are the available request codes for th_encode_ctl().
- * By convention, these are even, to distinguish them from the
- * \ref decctlcodes "decoder control codes".
- * Keep any experimental or vendor-specific values above \c 0x8000.*/
-/*@{*/
-/**Sets the Huffman tables to use.
- * The tables are copied, not stored by reference, so they can be freed after
- * this call.
- * <tt>NULL</tt> may be specified to revert to the default tables.
- *
- * \param[in] _buf <tt>#th_huff_code[#TH_NHUFFMAN_TABLES][#TH_NDCT_TOKENS]</tt>
- * \retval TH_EFAULT \a _enc is <tt>NULL</tt>.
- * \retval TH_EINVAL Encoding has already begun or one or more of the given
- * tables is not full or prefix-free, \a _buf is
- * <tt>NULL</tt> and \a _buf_sz is not zero, or \a _buf is
- * non-<tt>NULL</tt> and \a _buf_sz is not
- * <tt>sizeof(#th_huff_code)*#TH_NHUFFMAN_TABLES*#TH_NDCT_TOKENS</tt>.
- * \retval TH_EIMPL Not supported by this implementation.*/
-#define TH_ENCCTL_SET_HUFFMAN_CODES (0)
-/**Sets the quantization parameters to use.
- * The parameters are copied, not stored by reference, so they can be freed
- * after this call.
- * <tt>NULL</tt> may be specified to revert to the default parameters.
- *
- * \param[in] _buf #th_quant_info
- * \retval TH_EFAULT \a _enc is <tt>NULL</tt>.
- * \retval TH_EINVAL Encoding has already begun, \a _buf is
- * <tt>NULL</tt> and \a _buf_sz is not zero,
- * or \a _buf is non-<tt>NULL</tt> and
- * \a _buf_sz is not <tt>sizeof(#th_quant_info)</tt>.
- * \retval TH_EIMPL Not supported by this implementation.*/
-#define TH_ENCCTL_SET_QUANT_PARAMS (2)
-/**Sets the maximum distance between key frames.
- * This can be changed during an encode, but will be bounded by
- * <tt>1<<th_info#keyframe_granule_shift</tt>.
- * If it is set before encoding begins, th_info#keyframe_granule_shift will
- * be enlarged appropriately.
- *
- * \param[in] _buf <tt>ogg_uint32_t</tt>: The maximum distance between key
- * frames.
- * \param[out] _buf <tt>ogg_uint32_t</tt>: The actual maximum distance set.
- * \retval TH_EFAULT \a _enc or \a _buf is <tt>NULL</tt>.
- * \retval TH_EINVAL \a _buf_sz is not <tt>sizeof(ogg_uint32_t)</tt>.
- * \retval TH_EIMPL Not supported by this implementation.*/
-#define TH_ENCCTL_SET_KEYFRAME_FREQUENCY_FORCE (4)
-/**Disables any encoder features that would prevent lossless transcoding back
- * to VP3.
- * This primarily means disabling block-adaptive quantization and always coding
- * all four luma blocks in a macro block when 4MV is used.
- * It also includes using the VP3 quantization tables and Huffman codes; if you
- * set them explicitly after calling this function, the resulting stream will
- * not be VP3-compatible.
- * If you enable VP3-compatibility when encoding 4:2:2 or 4:4:4 source
- * material, or when using a picture region smaller than the full frame (e.g.
- * a non-multiple-of-16 width or height), then non-VP3 bitstream features will
- * still be disabled, but the stream will still not be VP3-compatible, as VP3
- * was not capable of encoding such formats.
- * If you call this after encoding has already begun, then the quantization
- * tables and codebooks cannot be changed, but the frame-level features will
- * be enabled or disabled as requested.
- *
- * \param[in] _buf <tt>int</tt>: a non-zero value to enable VP3 compatibility,
- * or 0 to disable it (the default).
- * \param[out] _buf <tt>int</tt>: 1 if all bitstream features required for
- * VP3-compatibility could be set, and 0 otherwise.
- * The latter will be returned if the pixel format is not
- * 4:2:0, the picture region is smaller than the full frame,
- * or if encoding has begun, preventing the quantization
- * tables and codebooks from being set.
- * \retval TH_EFAULT \a _enc or \a _buf is <tt>NULL</tt>.
- * \retval TH_EINVAL \a _buf_sz is not <tt>sizeof(int)</tt>.
- * \retval TH_EIMPL Not supported by this implementation.*/
-#define TH_ENCCTL_SET_VP3_COMPATIBLE (10)
-/**Gets the maximum speed level.
- * Higher speed levels favor quicker encoding over better quality per bit.
- * Depending on the encoding mode, and the internal algorithms used, quality
- * may actually improve, but in this case bitrate will also likely increase.
- * In any case, overall rate/distortion performance will probably decrease.
- * The maximum value, and the meaning of each value, may change depending on
- * the current encoding mode (VBR vs. constant quality, etc.).
- *
- * \param[out] _buf <tt>int</tt>: The maximum encoding speed level.
- * \retval TH_EFAULT \a _enc or \a _buf is <tt>NULL</tt>.
- * \retval TH_EINVAL \a _buf_sz is not <tt>sizeof(int)</tt>.
- * \retval TH_EIMPL Not supported by this implementation in the current
- * encoding mode.*/
-#define TH_ENCCTL_GET_SPLEVEL_MAX (12)
-/**Sets the speed level.
- * The current speed level may be retrieved using #TH_ENCCTL_GET_SPLEVEL.
- *
- * \param[in] _buf <tt>int</tt>: The new encoding speed level.
- * 0 is slowest, larger values use less CPU.
- * \retval TH_EFAULT \a _enc or \a _buf is <tt>NULL</tt>.
- * \retval TH_EINVAL \a _buf_sz is not <tt>sizeof(int)</tt>, or the
- * encoding speed level is out of bounds.
- * The maximum encoding speed level may be
- * implementation- and encoding mode-specific, and can be
- * obtained via #TH_ENCCTL_GET_SPLEVEL_MAX.
- * \retval TH_EIMPL Not supported by this implementation in the current
- * encoding mode.*/
-#define TH_ENCCTL_SET_SPLEVEL (14)
-/**Gets the current speed level.
- * The default speed level may vary according to encoder implementation, but if
- * this control code is not supported (it returns #TH_EIMPL), the default may
- * be assumed to be the slowest available speed (0).
- * The maximum encoding speed level may be implementation- and encoding
- * mode-specific, and can be obtained via #TH_ENCCTL_GET_SPLEVEL_MAX.
- *
- * \param[out] _buf <tt>int</tt>: The current encoding speed level.
- * 0 is slowest, larger values use less CPU.
- * \retval TH_EFAULT \a _enc or \a _buf is <tt>NULL</tt>.
- * \retval TH_EINVAL \a _buf_sz is not <tt>sizeof(int)</tt>.
- * \retval TH_EIMPL Not supported by this implementation in the current
- * encoding mode.*/
-#define TH_ENCCTL_GET_SPLEVEL (16)
-/**Sets the number of duplicates of the next frame to produce.
- * Although libtheora can encode duplicate frames very cheaply, it costs some
- * amount of CPU to detect them, and a run of duplicates cannot span a
- * keyframe boundary.
- * This control code tells the encoder to produce the specified number of extra
- * duplicates of the next frame.
- * This allows the encoder to make smarter keyframe placement decisions and
- * rate control decisions, and reduces CPU usage as well, when compared to
- * just submitting the same frame for encoding multiple times.
- * This setting only applies to the next frame submitted for encoding.
- * You MUST call th_encode_packetout() repeatedly until it returns 0, or the
- * extra duplicate frames will be lost.
- *
- * \param[in] _buf <tt>int</tt>: The number of duplicates to produce.
- * If this is negative or zero, no duplicates will be produced.
- * \retval TH_EFAULT \a _enc or \a _buf is <tt>NULL</tt>.
- * \retval TH_EINVAL \a _buf_sz is not <tt>sizeof(int)</tt>, or the
- * number of duplicates is greater than or equal to the
- * maximum keyframe interval.
- * In the latter case, NO duplicate frames will be produced.
- * You must ensure that the maximum keyframe interval is set
- * larger than the maximum number of duplicates you will
- * ever wish to insert prior to encoding.
- * \retval TH_EIMPL Not supported by this implementation in the current
- * encoding mode.*/
-#define TH_ENCCTL_SET_DUP_COUNT (18)
-/**Modifies the default bitrate management behavior.
- * Use to allow or disallow frame dropping, and to enable or disable capping
- * bit reservoir overflows and underflows.
- * See \ref encctlcodes "the list of available flags".
- * The flags are set by default to
- * <tt>#TH_RATECTL_DROP_FRAMES|#TH_RATECTL_CAP_OVERFLOW</tt>.
- *
- * \param[in] _buf <tt>int</tt>: Any combination of
- * \ref ratectlflags "the available flags":
- * - #TH_RATECTL_DROP_FRAMES: Enable frame dropping.
- * - #TH_RATECTL_CAP_OVERFLOW: Don't bank excess bits for later
- * use.
- * - #TH_RATECTL_CAP_UNDERFLOW: Don't try to make up shortfalls
- * later.
- * \retval TH_EFAULT \a _enc or \a _buf is <tt>NULL</tt>.
- * \retval TH_EINVAL \a _buf_sz is not <tt>sizeof(int)</tt> or rate control
- * is not enabled.
- * \retval TH_EIMPL Not supported by this implementation in the current
- * encoding mode.*/
-#define TH_ENCCTL_SET_RATE_FLAGS (20)
-/**Sets the size of the bitrate management bit reservoir as a function
- * of number of frames.
- * The reservoir size affects how quickly bitrate management reacts to
- * instantaneous changes in the video complexity.
- * Larger reservoirs react more slowly, and provide better overall quality, but
- * require more buffering by a client, adding more latency to live streams.
- * By default, libtheora sets the reservoir to the maximum distance between
- * keyframes, subject to a minimum and maximum limit.
- * This call may be used to increase or decrease the reservoir, increasing or
- * decreasing the allowed temporary variance in bitrate.
- * An implementation may impose some limits on the size of a reservoir it can
- * handle, in which case the actual reservoir size may not be exactly what was
- * requested.
- * The actual value set will be returned.
- *
- * \param[in] _buf <tt>int</tt>: Requested size of the reservoir measured in
- * frames.
- * \param[out] _buf <tt>int</tt>: The actual size of the reservoir set.
- * \retval TH_EFAULT \a _enc or \a _buf is <tt>NULL</tt>.
- * \retval TH_EINVAL \a _buf_sz is not <tt>sizeof(int)</tt>, or rate control
- * is not enabled. The buffer has an implementation
- * defined minimum and maximum size and the value in _buf
- * will be adjusted to match the actual value set.
- * \retval TH_EIMPL Not supported by this implementation in the current
- * encoding mode.*/
-#define TH_ENCCTL_SET_RATE_BUFFER (22)
-/**Enable pass 1 of two-pass encoding mode and retrieve the first pass metrics.
- * Pass 1 mode must be enabled before the first frame is encoded, and a target
- * bitrate must have already been specified to the encoder.
- * Although this does not have to be the exact rate that will be used in the
- * second pass, closer values may produce better results.
- * The first call returns the size of the two-pass header data, along with some
- * placeholder content, and sets the encoder into pass 1 mode implicitly.
- * This call sets the encoder to pass 1 mode implicitly.
- * Then, a subsequent call must be made after each call to
- * th_encode_ycbcr_in() to retrieve the metrics for that frame.
- * An additional, final call must be made to retrieve the summary data,
- * containing such information as the total number of frames, etc.
- * This must be stored in place of the placeholder data that was returned
- * in the first call, before the frame metrics data.
- * All of this data must be presented back to the encoder during pass 2 using
- * #TH_ENCCTL_2PASS_IN.
- *
- * \param[out] <tt>char *</tt>_buf: Returns a pointer to internal storage
- * containing the two pass metrics data.
- * This storage is only valid until the next call, or until the
- * encoder context is freed, and must be copied by the
- * application.
- * \retval >=0 The number of bytes of metric data available in the
- * returned buffer.
- * \retval TH_EFAULT \a _enc or \a _buf is <tt>NULL</tt>.
- * \retval TH_EINVAL \a _buf_sz is not <tt>sizeof(char *)</tt>, no target
- * bitrate has been set, or the first call was made after
- * the first frame was submitted for encoding.
- * \retval TH_EIMPL Not supported by this implementation.*/
-#define TH_ENCCTL_2PASS_OUT (24)
-/**Submits two-pass encoding metric data collected the first encoding pass to
- * the second pass.
- * The first call must be made before the first frame is encoded, and a target
- * bitrate must have already been specified to the encoder.
- * It sets the encoder to pass 2 mode implicitly; this cannot be disabled.
- * The encoder may require reading data from some or all of the frames in
- * advance, depending on, e.g., the reservoir size used in the second pass.
- * You must call this function repeatedly before each frame to provide data
- * until either a) it fails to consume all of the data presented or b) all of
- * the pass 1 data has been consumed.
- * In the first case, you must save the remaining data to be presented after
- * the next frame.
- * You can call this function with a NULL argument to get an upper bound on
- * the number of bytes that will be required before the next frame.
- *
- * When pass 2 is first enabled, the default bit reservoir is set to the entire
- * file; this gives maximum flexibility but can lead to very high peak rates.
- * You can subsequently set it to another value with #TH_ENCCTL_SET_RATE_BUFFER
- * (e.g., to set it to the keyframe interval for non-live streaming), however,
- * you may then need to provide more data before the next frame.
- *
- * \param[in] _buf <tt>char[]</tt>: A buffer containing the data returned by
- * #TH_ENCCTL_2PASS_OUT in pass 1.
- * You may pass <tt>NULL</tt> for \a _buf to return an upper
- * bound on the number of additional bytes needed before the
- * next frame.
- * The summary data returned at the end of pass 1 must be at
- * the head of the buffer on the first call with a
- * non-<tt>NULL</tt> \a _buf, and the placeholder data
- * returned at the start of pass 1 should be omitted.
- * After each call you should advance this buffer by the number
- * of bytes consumed.
- * \retval >0 The number of bytes of metric data required/consumed.
- * \retval 0 No more data is required before the next frame.
- * \retval TH_EFAULT \a _enc is <tt>NULL</tt>.
- * \retval TH_EINVAL No target bitrate has been set, or the first call was
- * made after the first frame was submitted for
- * encoding.
- * \retval TH_ENOTFORMAT The data did not appear to be pass 1 from a compatible
- * implementation of this library.
- * \retval TH_EBADHEADER The data was invalid; this may be returned when
- * attempting to read an aborted pass 1 file that still
- * has the placeholder data in place of the summary
- * data.
- * \retval TH_EIMPL Not supported by this implementation.*/
-#define TH_ENCCTL_2PASS_IN (26)
-/**Sets the current encoding quality.
- * This is only valid so long as no bitrate has been specified, either through
- * the #th_info struct used to initialize the encoder or through
- * #TH_ENCCTL_SET_BITRATE (this restriction may be relaxed in a future
- * version).
- * If it is set before the headers are emitted, the target quality encoded in
- * them will be updated.
- *
- * \param[in] _buf <tt>int</tt>: The new target quality, in the range 0...63,
- * inclusive.
- * \retval 0 Success.
- * \retval TH_EFAULT \a _enc or \a _buf is <tt>NULL</tt>.
- * \retval TH_EINVAL A target bitrate has already been specified, or the
- * quality index was not in the range 0...63.
- * \retval TH_EIMPL Not supported by this implementation.*/
-#define TH_ENCCTL_SET_QUALITY (28)
-/**Sets the current encoding bitrate.
- * Once a bitrate is set, the encoder must use a rate-controlled mode for all
- * future frames (this restriction may be relaxed in a future version).
- * If it is set before the headers are emitted, the target bitrate encoded in
- * them will be updated.
- * Due to the buffer delay, the exact bitrate of each section of the encode is
- * not guaranteed.
- * The encoder may have already used more bits than allowed for the frames it
- * has encoded, expecting to make them up in future frames, or it may have
- * used fewer, holding the excess in reserve.
- * The exact transition between the two bitrates is not well-defined by this
- * API, but may be affected by flags set with #TH_ENCCTL_SET_RATE_FLAGS.
- * After a number of frames equal to the buffer delay, one may expect further
- * output to average at the target bitrate.
- *
- * \param[in] _buf <tt>long</tt>: The new target bitrate, in bits per second.
- * \retval 0 Success.
- * \retval TH_EFAULT \a _enc or \a _buf is <tt>NULL</tt>.
- * \retval TH_EINVAL The target bitrate was not positive.
- * \retval TH_EIMPL Not supported by this implementation.*/
-#define TH_ENCCTL_SET_BITRATE (30)
-/**Sets the configuration to be compatible with that from the given setup
- * header.
- * This sets the Huffman codebooks and quantization parameters to match those
- * found in the given setup header.
- * This guarantees that packets encoded by this encoder will be decodable using
- * a decoder configured with the passed-in setup header.
- * It does <em>not</em> guarantee that th_encode_flushheader() will produce a
- * bit-identical setup header, only that they will be compatible.
- * If you need a bit-identical setup header, then use the one you passed into
- * this command, and not the one returned by th_encode_flushheader().
- *
- * This also does <em>not</em> enable or disable VP3 compatibility; that is not
- * signaled in the setup header (or anywhere else in the encoded stream), and
- * is controlled independently by the #TH_ENCCTL_SET_VP3_COMPATIBLE function.
- * If you wish to enable VP3 compatibility mode <em>and</em> want the codebooks
- * and quantization parameters to match the given setup header, you should
- * enable VP3 compatibility before invoking this command, otherwise the
- * codebooks and quantization parameters will be reset to the VP3 defaults.
- *
- * The current encoder does not support Huffman codebooks which do not contain
- * codewords for all 32 tokens.
- * Such codebooks are legal, according to the specification, but cannot be
- * configured with this function.
- *
- * \param[in] _buf <tt>unsigned char[]</tt>: The encoded setup header to copy
- * the configuration from.
- * This should be the original,
- * undecoded setup header packet,
- * and <em>not</em> a #th_setup_info
- * structure filled in by
- * th_decode_headerin().
- * \retval TH_EFAULT \a _enc or \a _buf is <tt>NULL</tt>.
- * \retval TH_EINVAL Encoding has already begun, so the codebooks and
- * quantization parameters cannot be changed, or the
- * data in the setup header was not supported by this
- * encoder.
- * \retval TH_EBADHEADER \a _buf did not contain a valid setup header packet.
- * \retval TH_ENOTFORMAT \a _buf did not contain a Theora header at all.
- * \retval TH_EIMPL Not supported by this implementation.*/
-#define TH_ENCCTL_SET_COMPAT_CONFIG (32)
-
-/*@}*/
-
-
-/**\name TH_ENCCTL_SET_RATE_FLAGS flags
- * \anchor ratectlflags
- * These are the flags available for use with #TH_ENCCTL_SET_RATE_FLAGS.*/
-/*@{*/
-/**Drop frames to keep within bitrate buffer constraints.
- * This can have a severe impact on quality, but is the only way to ensure that
- * bitrate targets are met at low rates during sudden bursts of activity.*/
-#define TH_RATECTL_DROP_FRAMES (0x1)
-/**Ignore bitrate buffer overflows.
- * If the encoder uses so few bits that the reservoir of available bits
- * overflows, ignore the excess.
- * The encoder will not try to use these extra bits in future frames.
- * At high rates this may cause the result to be undersized, but allows a
- * client to play the stream using a finite buffer; it should normally be
- * enabled.*/
-#define TH_RATECTL_CAP_OVERFLOW (0x2)
-/**Ignore bitrate buffer underflows.
- * If the encoder uses so many bits that the reservoir of available bits
- * underflows, ignore the deficit.
- * The encoder will not try to make up these extra bits in future frames.
- * At low rates this may cause the result to be oversized; it should normally
- * be disabled.*/
-#define TH_RATECTL_CAP_UNDERFLOW (0x4)
-/*@}*/
-
-
-
-/**The quantization parameters used by VP3.*/
-extern const th_quant_info TH_VP31_QUANT_INFO;
-
-/**The Huffman tables used by VP3.*/
-extern const th_huff_code
- TH_VP31_HUFF_CODES[TH_NHUFFMAN_TABLES][TH_NDCT_TOKENS];
-
-
-
-/**\name Encoder state
- The following data structure is opaque, and its contents are not publicly
- defined by this API.
- Referring to its internals directly is unsupported, and may break without
- warning.*/
-/*@{*/
-/**The encoder context.*/
-typedef struct th_enc_ctx th_enc_ctx;
-/*@}*/
-
-
-
-/**\defgroup encfuncs Functions for Encoding*/
-/*@{*/
-/**\name Functions for encoding
- * You must link to <tt>libtheoraenc</tt> and <tt>libtheoradec</tt>
- * if you use any of the functions in this section.
- *
- * The functions are listed in the order they are used in a typical encode.
- * The basic steps are:
- * - Fill in a #th_info structure with details on the format of the video you
- * wish to encode.
- * - Allocate a #th_enc_ctx handle with th_encode_alloc().
- * - Perform any additional encoder configuration required with
- * th_encode_ctl().
- * - Repeatedly call th_encode_flushheader() to retrieve all the header
- * packets.
- * - For each uncompressed frame:
- * - Submit the uncompressed frame via th_encode_ycbcr_in()
- * - Repeatedly call th_encode_packetout() to retrieve any video data packets
- * that are ready.
- * - Call th_encode_free() to release all encoder memory.*/
-/*@{*/
-/**Allocates an encoder instance.
- * \param _info A #th_info struct filled with the desired encoding parameters.
- * \return The initialized #th_enc_ctx handle.
- * \retval NULL If the encoding parameters were invalid.*/
-extern th_enc_ctx *th_encode_alloc(const th_info *_info);
-/**Encoder control function.
- * This is used to provide advanced control the encoding process.
- * \param _enc A #th_enc_ctx handle.
- * \param _req The control code to process.
- * See \ref encctlcodes "the list of available control codes"
- * for details.
- * \param _buf The parameters for this control code.
- * \param _buf_sz The size of the parameter buffer.*/
-extern int th_encode_ctl(th_enc_ctx *_enc,int _req,void *_buf,size_t _buf_sz);
-/**Outputs the next header packet.
- * This should be called repeatedly after encoder initialization until it
- * returns 0 in order to get all of the header packets, in order, before
- * encoding actual video data.
- * \param _enc A #th_enc_ctx handle.
- * \param _comments The metadata to place in the comment header, when it is
- * encoded.
- * \param _op An <tt>ogg_packet</tt> structure to fill.
- * All of the elements of this structure will be set,
- * including a pointer to the header data.
- * The memory for the header data is owned by
- * <tt>libtheoraenc</tt>, and may be invalidated when the
- * next encoder function is called.
- * \return A positive value indicates that a header packet was successfully
- * produced.
- * \retval 0 No packet was produced, and no more header packets remain.
- * \retval TH_EFAULT \a _enc, \a _comments, or \a _op was <tt>NULL</tt>.*/
-extern int th_encode_flushheader(th_enc_ctx *_enc,
- th_comment *_comments,ogg_packet *_op);
-/**Submits an uncompressed frame to the encoder.
- * \param _enc A #th_enc_ctx handle.
- * \param _ycbcr A buffer of Y'CbCr data to encode.
- * If the width and height of the buffer matches the frame size
- * the encoder was initialized with, the encoder will only
- * reference the portion inside the picture region.
- * Any data outside this region will be ignored, and need not map
- * to a valid address.
- * Alternatively, you can pass a buffer equal to the size of the
- * picture region, if this is less than the full frame size.
- * When using subsampled chroma planes, odd picture sizes or odd
- * picture offsets may require an unexpected chroma plane size,
- * and their use is generally discouraged, as they will not be
- * well-supported by players and other media frameworks.
- * See Section 4.4 of
- * <a href="http://www.theora.org/doc/Theora.pdf">the Theora
- * specification</a> for details if you wish to use them anyway.
- * \retval 0 Success.
- * \retval TH_EFAULT \a _enc or \a _ycbcr is <tt>NULL</tt>.
- * \retval TH_EINVAL The buffer size matches neither the frame size nor the
- * picture size the encoder was initialized with, or
- * encoding has already completed.*/
-extern int th_encode_ycbcr_in(th_enc_ctx *_enc,th_ycbcr_buffer _ycbcr);
-/**Retrieves encoded video data packets.
- * This should be called repeatedly after each frame is submitted to flush any
- * encoded packets, until it returns 0.
- * The encoder will not buffer these packets as subsequent frames are
- * compressed, so a failure to do so will result in lost video data.
- * \note Currently the encoder operates in a one-frame-in, one-packet-out
- * manner.
- * However, this may be changed in the future.
- * \param _enc A #th_enc_ctx handle.
- * \param _last Set this flag to a non-zero value if no more uncompressed
- * frames will be submitted.
- * This ensures that a proper EOS flag is set on the last packet.
- * \param _op An <tt>ogg_packet</tt> structure to fill.
- * All of the elements of this structure will be set, including a
- * pointer to the video data.
- * The memory for the video data is owned by
- * <tt>libtheoraenc</tt>, and may be invalidated when the next
- * encoder function is called.
- * \return A positive value indicates that a video data packet was successfully
- * produced.
- * \retval 0 No packet was produced, and no more encoded video data
- * remains.
- * \retval TH_EFAULT \a _enc or \a _op was <tt>NULL</tt>.*/
-extern int th_encode_packetout(th_enc_ctx *_enc,int _last,ogg_packet *_op);
-/**Frees an allocated encoder instance.
- * \param _enc A #th_enc_ctx handle.*/
-extern void th_encode_free(th_enc_ctx *_enc);
-/*@}*/
-/*@}*/
-
-
-
-#if defined(__cplusplus)
-}
-#endif
-
-#endif
diff --git a/media/libtheora/lib/apiwrapper.c b/media/libtheora/lib/apiwrapper.c
deleted file mode 100644
index dc959b8d13..0000000000
--- a/media/libtheora/lib/apiwrapper.c
+++ /dev/null
@@ -1,166 +0,0 @@
-/********************************************************************
- * *
- * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE. *
- * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
- * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
- * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
- * *
- * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2009 *
- * by the Xiph.Org Foundation and contributors http://www.xiph.org/ *
- * *
- ********************************************************************
-
- function:
- last mod: $Id: apiwrapper.c 16503 2009-08-22 18:14:02Z giles $
-
- ********************************************************************/
-
-#include <stdlib.h>
-#include <string.h>
-#include <limits.h>
-#include "apiwrapper.h"
-
-
-
-const char *theora_version_string(void){
- return th_version_string();
-}
-
-ogg_uint32_t theora_version_number(void){
- return th_version_number();
-}
-
-void theora_info_init(theora_info *_ci){
- memset(_ci,0,sizeof(*_ci));
-}
-
-void theora_info_clear(theora_info *_ci){
- th_api_wrapper *api;
- api=(th_api_wrapper *)_ci->codec_setup;
- memset(_ci,0,sizeof(*_ci));
- if(api!=NULL){
- if(api->clear!=NULL)(*api->clear)(api);
- _ogg_free(api);
- }
-}
-
-void theora_clear(theora_state *_th){
- /*Provide compatibility with mixed encoder and decoder shared lib versions.*/
- if(_th->internal_decode!=NULL){
- (*((oc_state_dispatch_vtable *)_th->internal_decode)->clear)(_th);
- }
- if(_th->internal_encode!=NULL){
- (*((oc_state_dispatch_vtable *)_th->internal_encode)->clear)(_th);
- }
- if(_th->i!=NULL)theora_info_clear(_th->i);
- memset(_th,0,sizeof(*_th));
-}
-
-int theora_control(theora_state *_th,int _req,void *_buf,size_t _buf_sz){
- /*Provide compatibility with mixed encoder and decoder shared lib versions.*/
- if(_th->internal_decode!=NULL){
- return (*((oc_state_dispatch_vtable *)_th->internal_decode)->control)(_th,
- _req,_buf,_buf_sz);
- }
- else if(_th->internal_encode!=NULL){
- return (*((oc_state_dispatch_vtable *)_th->internal_encode)->control)(_th,
- _req,_buf,_buf_sz);
- }
- else return TH_EINVAL;
-}
-
-ogg_int64_t theora_granule_frame(theora_state *_th,ogg_int64_t _gp){
- /*Provide compatibility with mixed encoder and decoder shared lib versions.*/
- if(_th->internal_decode!=NULL){
- return (*((oc_state_dispatch_vtable *)_th->internal_decode)->granule_frame)(
- _th,_gp);
- }
- else if(_th->internal_encode!=NULL){
- return (*((oc_state_dispatch_vtable *)_th->internal_encode)->granule_frame)(
- _th,_gp);
- }
- else return -1;
-}
-
-double theora_granule_time(theora_state *_th, ogg_int64_t _gp){
- /*Provide compatibility with mixed encoder and decoder shared lib versions.*/
- if(_th->internal_decode!=NULL){
- return (*((oc_state_dispatch_vtable *)_th->internal_decode)->granule_time)(
- _th,_gp);
- }
- else if(_th->internal_encode!=NULL){
- return (*((oc_state_dispatch_vtable *)_th->internal_encode)->granule_time)(
- _th,_gp);
- }
- else return -1;
-}
-
-void oc_theora_info2th_info(th_info *_info,const theora_info *_ci){
- _info->version_major=_ci->version_major;
- _info->version_minor=_ci->version_minor;
- _info->version_subminor=_ci->version_subminor;
- _info->frame_width=_ci->width;
- _info->frame_height=_ci->height;
- _info->pic_width=_ci->frame_width;
- _info->pic_height=_ci->frame_height;
- _info->pic_x=_ci->offset_x;
- _info->pic_y=_ci->offset_y;
- _info->fps_numerator=_ci->fps_numerator;
- _info->fps_denominator=_ci->fps_denominator;
- _info->aspect_numerator=_ci->aspect_numerator;
- _info->aspect_denominator=_ci->aspect_denominator;
- switch(_ci->colorspace){
- case OC_CS_ITU_REC_470M:_info->colorspace=TH_CS_ITU_REC_470M;break;
- case OC_CS_ITU_REC_470BG:_info->colorspace=TH_CS_ITU_REC_470BG;break;
- default:_info->colorspace=TH_CS_UNSPECIFIED;break;
- }
- switch(_ci->pixelformat){
- case OC_PF_420:_info->pixel_fmt=TH_PF_420;break;
- case OC_PF_422:_info->pixel_fmt=TH_PF_422;break;
- case OC_PF_444:_info->pixel_fmt=TH_PF_444;break;
- default:_info->pixel_fmt=TH_PF_RSVD;
- }
- _info->target_bitrate=_ci->target_bitrate;
- _info->quality=_ci->quality;
- _info->keyframe_granule_shift=_ci->keyframe_frequency_force>0?
- OC_MINI(31,oc_ilog(_ci->keyframe_frequency_force-1)):0;
-}
-
-int theora_packet_isheader(ogg_packet *_op){
- return th_packet_isheader(_op);
-}
-
-int theora_packet_iskeyframe(ogg_packet *_op){
- return th_packet_iskeyframe(_op);
-}
-
-int theora_granule_shift(theora_info *_ci){
- /*This breaks when keyframe_frequency_force is not positive or is larger than
- 2**31 (if your int is more than 32 bits), but that's what the original
- function does.*/
- return oc_ilog(_ci->keyframe_frequency_force-1);
-}
-
-void theora_comment_init(theora_comment *_tc){
- th_comment_init((th_comment *)_tc);
-}
-
-char *theora_comment_query(theora_comment *_tc,char *_tag,int _count){
- return th_comment_query((th_comment *)_tc,_tag,_count);
-}
-
-int theora_comment_query_count(theora_comment *_tc,char *_tag){
- return th_comment_query_count((th_comment *)_tc,_tag);
-}
-
-void theora_comment_clear(theora_comment *_tc){
- th_comment_clear((th_comment *)_tc);
-}
-
-void theora_comment_add(theora_comment *_tc,char *_comment){
- th_comment_add((th_comment *)_tc,_comment);
-}
-
-void theora_comment_add_tag(theora_comment *_tc, char *_tag, char *_value){
- th_comment_add_tag((th_comment *)_tc,_tag,_value);
-}
diff --git a/media/libtheora/lib/apiwrapper.h b/media/libtheora/lib/apiwrapper.h
deleted file mode 100644
index ff45e0a4d6..0000000000
--- a/media/libtheora/lib/apiwrapper.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/********************************************************************
- * *
- * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE. *
- * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
- * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
- * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
- * *
- * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2009 *
- * by the Xiph.Org Foundation and contributors http://www.xiph.org/ *
- * *
- ********************************************************************
-
- function:
- last mod: $Id: apiwrapper.h 13596 2007-08-23 20:05:38Z tterribe $
-
- ********************************************************************/
-
-#if !defined(_apiwrapper_H)
-# define _apiwrapper_H (1)
-# include <ogg/ogg.h>
-# include <theora/theora.h>
-# include "theora/theoradec.h"
-# include "theora/theoraenc.h"
-# include "state.h"
-
-typedef struct th_api_wrapper th_api_wrapper;
-typedef struct th_api_info th_api_info;
-
-/*Provide an entry point for the codec setup to clear itself in case we ever
- want to break pieces off into a common base library shared by encoder and
- decoder.
- In addition, this makes several other pieces of the API wrapper cleaner.*/
-typedef void (*oc_setup_clear_func)(void *_ts);
-
-/*Generally only one of these pointers will be non-NULL in any given instance.
- Technically we do not even really need this struct, since we should be able
- to figure out which one from "context", but doing it this way makes sure we
- don't flub it up.*/
-struct th_api_wrapper{
- oc_setup_clear_func clear;
- th_setup_info *setup;
- th_dec_ctx *decode;
- th_enc_ctx *encode;
-};
-
-struct th_api_info{
- th_api_wrapper api;
- theora_info info;
-};
-
-
-void oc_theora_info2th_info(th_info *_info,const theora_info *_ci);
-
-#endif
diff --git a/media/libtheora/lib/arm/arm2gnu.pl b/media/libtheora/lib/arm/arm2gnu.pl
index 5831bd81e2..8cb68e4a9f 100644..100755
--- a/media/libtheora/lib/arm/arm2gnu.pl
+++ b/media/libtheora/lib/arm/arm2gnu.pl
@@ -23,6 +23,7 @@ $\ = "\n"; # automatically add newline on print
$n=0;
$thumb = 0; # ARM mode by default, not Thumb.
+@proc_stack = ();
LINE:
while (<>) {
@@ -85,13 +86,19 @@ while (<>) {
# ".rdata" doesn't work in 'as' version 2.13.2, as it is ".rodata" there.
#
if ( /\bAREA\b/ ) {
+ my $align;
+ $align = "2";
+ if ( /ALIGN=(\d+)/ ) {
+ $align = $1;
+ }
if ( /CODE/ ) {
$nxstack = 1;
}
s/^(.+)CODE(.+)READONLY(.*)/ .text/;
- s/^(.+)DATA(.+)READONLY(.*)/ .section .rdata\n .align 2/;
- s/^(.+)\|\|\.data\|\|(.+)/ .data\n .align 2/;
+ s/^(.+)DATA(.+)READONLY(.*)/ .section .rdata/;
+ s/^(.+)\|\|\.data\|\|(.+)/ .data/;
s/^(.+)\|\|\.bss\|\|(.+)/ .bss/;
+ s/$/; .p2align $align/;
}
s/\|\|\.constdata\$(\d+)\|\|/.L_CONST$1/; # ||.constdata$3||
@@ -105,12 +112,30 @@ while (<>) {
s/\bCODE16\b/.code 16/ && do {$thumb = 1};
if (/\bPROC\b/)
{
- print " .thumb_func" if ($thumb);
+ my $prefix;
+ my $proc;
+ /^([A-Za-z_\.]\w+)\b/;
+ $proc = $1;
+ $prefix = "";
+ if ($proc)
+ {
+ $prefix = $prefix.sprintf("\t.type\t%s, %%function; ",$proc);
+ push(@proc_stack, $proc);
+ s/^[A-Za-z_\.]\w+/$&:/;
+ }
+ $prefix = $prefix."\t.thumb_func; " if ($thumb);
s/\bPROC\b/@ $&/;
+ $_ = $prefix.$_;
}
s/^(\s*)(S|Q|SH|U|UQ|UH)ASX\b/$1$2ADDSUBX/;
s/^(\s*)(S|Q|SH|U|UQ|UH)SAX\b/$1$2SUBADDX/;
- s/\bENDP\b/@ $&/;
+ if (/\bENDP\b/)
+ {
+ my $proc;
+ s/\bENDP\b/@ $&/;
+ $proc = pop(@proc_stack);
+ $_ = "\t.size $proc, .-$proc".$_ if ($proc);
+ }
s/\bSUBT\b/@ $&/;
s/\bDATA\b/@ $&/; # DATA directive is deprecated -- Asm guide, p.7-25
s/\bKEEP\b/@ $&/;
@@ -223,6 +248,7 @@ while (<>) {
{
my $cmd=$_;
my $value;
+ my $prefix;
my $w1;
my $w2;
my $w3;
@@ -241,25 +267,22 @@ while (<>) {
if( $bigend ne "")
{
# big endian
-
- print " .byte 0x".$w1;
- print " .byte 0x".$w2;
- print " .byte 0x".$w3;
- print " .byte 0x".$w4;
+ $prefix = "\t.byte\t0x".$w1.";".
+ "\t.byte\t0x".$w2.";".
+ "\t.byte\t0x".$w3.";".
+ "\t.byte\t0x".$w4."; ";
}
else
{
# little endian
-
- print " .byte 0x".$w4;
- print " .byte 0x".$w3;
- print " .byte 0x".$w2;
- print " .byte 0x".$w1;
+ $prefix = "\t.byte\t0x".$w4.";".
+ "\t.byte\t0x".$w3.";".
+ "\t.byte\t0x".$w2.";".
+ "\t.byte\t0x".$w1."; ";
}
-
+ $_=$prefix.$_;
}
-
if ( /\badrl\b/i )
{
s/\badrl\s+(\w+)\s*,\s*(\w+)/ldr $1,=$2/i;
diff --git a/media/libtheora/lib/arm/armbits.s b/media/libtheora/lib/arm/armbits.s
index 0fdb6fdd37..9400722543 100644
--- a/media/libtheora/lib/arm/armbits.s
+++ b/media/libtheora/lib/arm/armbits.s
@@ -11,18 +11,12 @@
;********************************************************************
;
; function:
-; last mod: $Id: armbits.s 17481 2010-10-03 22:49:42Z tterribe $
+; last mod: $Id$
;
;********************************************************************
AREA |.text|, CODE, READONLY
- ; Explicitly specifying alignment here because some versions of
- ; gas don't align code correctly. See
- ; http://lists.gnu.org/archive/html/bug-binutils/2011-06/msg00199.html
- ; https://bugzilla.mozilla.org/show_bug.cgi?id=920992
- ALIGN
-
EXPORT oc_pack_read_arm
EXPORT oc_pack_read1_arm
EXPORT oc_huff_token_decode_arm
diff --git a/media/libtheora/lib/arm/armcpu.c b/media/libtheora/lib/arm/armcpu.c
index 8b0f9a8574..f1941bdc15 100644
--- a/media/libtheora/lib/arm/armcpu.c
+++ b/media/libtheora/lib/arm/armcpu.c
@@ -20,7 +20,7 @@
#include "armcpu.h"
#if !defined(OC_ARM_ASM)|| \
- !defined(OC_ARM_ASM_EDSP)&&!defined(OC_ARM_ASM_ARMV6)&& \
+ !defined(OC_ARM_ASM_EDSP)&&!defined(OC_ARM_ASM_MEDIA)&& \
!defined(OC_ARM_ASM_NEON)
ogg_uint32_t oc_cpu_flags_get(void){
return 0;
@@ -107,6 +107,44 @@ ogg_uint32_t oc_cpu_flags_get(void){
return flags;
}
+#elif defined(__riscos__)
+#include <kernel.h>
+#include <swis.h>
+
+ogg_uint32_t oc_cpu_flags_get(void) {
+ ogg_uint32_t flags = 0;
+
+#if defined(OC_ARM_ASM_EDSP) || defined(OC_ARM_ASM_MEDIA)
+
+ if (_swi(OS_Byte,_IN(0)|_IN(2)|_RETURN(1), 129, 0xFF) <= 0xA9)
+ _swix(OS_Module, _INR(0,1), 1, "System:Modules.CallASWI");
+
+ ogg_uint32_t features;
+ _kernel_oserror* test = _swix(OS_PlatformFeatures, _IN(0)|_OUT(0), 0, &features);
+ if (test == NULL) {
+#if defined(OC_ARM_ASM_EDSP)
+ if((features>>10 & 1) == 1)flags|=OC_CPU_ARM_EDSP;
+#endif
+
+#if defined(OC_ARM_ASM_MEDIA)
+ if ((features>>31 & 1) == 1) {
+ ogg_uint32_t shadd = 0;
+ test =_swix(OS_PlatformFeatures, _INR(0,1)|_OUT(0), 34, 29, &shadd);
+ if (test==NULL && shadd==1)flags|=OC_CPU_ARM_MEDIA;
+ }
+#endif
+ }
+#endif
+
+#if defined(OC_ARM_ASM_NEON)
+ ogg_uint32_t mvfr1;
+ test = _swix(VFPSupport_Features, _IN(0)|_OUT(2), 0, &mvfr1);
+ if (test==NULL && (mvfr1 & 0xFFF00)==0x11100)flags|=OC_CPU_ARM_NEON;
+#endif
+
+ return flags;
+}
+
#else
/*The feature registers which can tell us what the processor supports are
accessible in priveleged modes only, so we can't have a general user-space
diff --git a/media/libtheora/lib/arm/armfrag.s b/media/libtheora/lib/arm/armfrag.s
index e20579eee4..38627ed669 100644
--- a/media/libtheora/lib/arm/armfrag.s
+++ b/media/libtheora/lib/arm/armfrag.s
@@ -11,17 +11,11 @@
;********************************************************************
; Original implementation:
; Copyright (C) 2009 Robin Watts for Pinknoise Productions Ltd
-; last mod: $Id: armfrag.s 17481 2010-10-03 22:49:42Z tterribe $
+; last mod: $Id$
;********************************************************************
AREA |.text|, CODE, READONLY
- ; Explicitly specifying alignment here because some versions of
- ; gas don't align code correctly. See
- ; http://lists.gnu.org/archive/html/bug-binutils/2011-06/msg00199.html
- ; https://bugzilla.mozilla.org/show_bug.cgi?id=920992
- ALIGN
-
GET armopts.s
; Vanilla ARM v4 versions
@@ -516,8 +510,7 @@ oc_frag_recon_intra_neon PROC
; r0 = unsigned char *_dst
; r1 = int _ystride
; r2 = const ogg_int16_t _residue[64]
- MOV r3, #128
- VDUP.S16 Q0, r3
+ VMOV.I16 Q0, #128
VLDMIA r2, {D16-D31} ; D16= 3333222211110000 etc ; 9(8) cycles
VQADD.S16 Q8, Q8, Q0
VQADD.S16 Q9, Q9, Q0
diff --git a/media/libtheora/lib/arm/armidct.s b/media/libtheora/lib/arm/armidct.s
index babd846ecd..68530c7140 100644
--- a/media/libtheora/lib/arm/armidct.s
+++ b/media/libtheora/lib/arm/armidct.s
@@ -11,17 +11,11 @@
;********************************************************************
; Original implementation:
; Copyright (C) 2009 Robin Watts for Pinknoise Productions Ltd
-; last mod: $Id: armidct.s 17481 2010-10-03 22:49:42Z tterribe $
+; last mod: $Id$
;********************************************************************
AREA |.text|, CODE, READONLY
- ; Explicitly specifying alignment here because some versions of
- ; gas don't align code correctly. See
- ; http://lists.gnu.org/archive/html/bug-binutils/2011-06/msg00199.html
- ; https://bugzilla.mozilla.org/show_bug.cgi?id=920992
- ALIGN
-
GET armopts.s
EXPORT oc_idct8x8_1_arm
@@ -70,11 +64,8 @@ oc_idct8x8_slow_arm
BL idct8core_arm
BL idct8core_arm
LDR r0, [r13], #4 ; Write to the final destination.
- ; Clear input data for next block (decoder only).
SUB r2, r1, #8*16
- CMP r0, r2
- MOV r1, r13 ; And read from temp storage.
- BEQ oc_idct8x8_slow_arm_cols
+ ; Clear input data for next block.
MOV r4, #0
MOV r5, #0
MOV r6, #0
@@ -87,7 +78,7 @@ oc_idct8x8_slow_arm
STMIA r2!,{r4,r5,r6,r7}
STMIA r2!,{r4,r5,r6,r7}
STMIA r2!,{r4,r5,r6,r7}
-oc_idct8x8_slow_arm_cols
+ MOV r1, r13 ; And read from temp storage.
; Column transforms
BL idct8core_down_arm
BL idct8core_down_arm
@@ -111,18 +102,15 @@ oc_idct8x8_10_arm PROC
BL idct3core_arm
BL idct2core_arm
BL idct1core_arm
- ; Clear input data for next block (decoder only).
- SUB r0, r1, #4*16
- CMP r0, r2
- MOV r1, r13 ; Read from temp storage.
- BEQ oc_idct8x8_10_arm_cols
+ ; Clear input data for next block.
MOV r4, #0
- STR r4, [r0]
- STR r4, [r0,#4]
- STR r4, [r0,#16]
- STR r4, [r0,#20]
- STR r4, [r0,#32]
- STR r4, [r0,#48]
+ STR r4, [r1,#-4*16]!
+ STR r4, [r1,#4]
+ STR r4, [r1,#16]
+ STR r4, [r1,#20]
+ STR r4, [r1,#32]
+ STR r4, [r1,#48]
+ MOV r1, r13 ; Read from temp storage.
MOV r0, r2 ; Write to the final destination
oc_idct8x8_10_arm_cols
; Column transforms
@@ -147,18 +135,14 @@ oc_idct8x8_6_arm PROC
BL idct3core_arm
BL idct2core_arm
BL idct1core_arm
- ; Clear input data for next block (decoder only).
- SUB r0, r1, #3*16
- CMP r0, r2
- MOV r1, r13 ; Read from temp storage.
- BEQ oc_idct8x8_6_arm_cols
+ ; Clear input data for next block.
MOV r4, #0
- STR r4, [r0]
- STR r4, [r0,#4]
- STR r4, [r0,#16]
- STR r4, [r0,#32]
+ STR r4, [r1,#-3*16]!
+ STR r4, [r1,#4]
+ STR r4, [r1,#16]
+ STR r4, [r1,#32]
+ MOV r1, r13 ; Read from temp storage.
MOV r0, r2 ; Write to the final destination
-oc_idct8x8_6_arm_cols
; Column transforms
BL idct3core_down_arm
BL idct3core_down_arm
@@ -180,14 +164,12 @@ oc_idct8x8_3_arm PROC
MOV r0, r13 ; Write to temp storage.
BL idct2core_arm
BL idct1core_arm
- ; Clear input data for next block (decoder only).
- SUB r0, r1, #2*16
- CMP r0, r2
+ ; Clear input data for next block.
+ MOV r4, #0
+ STR r4, [r1,#-2*16]!
+ STR r4, [r1,#16]
MOV r1, r13 ; Read from temp storage.
- MOVNE r4, #0
- STRNE r4, [r0]
- STRNE r4, [r0,#16]
- MOVNE r0, r2 ; Write to the final destination
+ MOV r0, r2 ; Write to the final destination
; Column transforms
BL idct2core_down_arm
BL idct2core_down_arm
@@ -805,30 +787,26 @@ oc_idct8x8_slow_v6
BL idct8_8core_v6
BL idct8_8core_v6
LDR r0, [r13], #4 ; Write to the final destination.
- ; Clear input data for next block (decoder only).
- SUB r2, r1, #8*16
- CMP r0, r2
- MOV r1, r13 ; And read from temp storage.
- BEQ oc_idct8x8_slow_v6_cols
+ ; Clear input data for next block.
MOV r4, #0
MOV r5, #0
- STRD r4, [r2], #8
- STRD r4, [r2], #8
- STRD r4, [r2], #8
- STRD r4, [r2], #8
- STRD r4, [r2], #8
- STRD r4, [r2], #8
- STRD r4, [r2], #8
- STRD r4, [r2], #8
- STRD r4, [r2], #8
- STRD r4, [r2], #8
- STRD r4, [r2], #8
- STRD r4, [r2], #8
- STRD r4, [r2], #8
- STRD r4, [r2], #8
- STRD r4, [r2], #8
- STRD r4, [r2], #8
-oc_idct8x8_slow_v6_cols
+ STRD r4, [r1,#-8*16]!
+ STRD r4, [r1,#8]
+ STRD r4, [r1,#16]
+ STRD r4, [r1,#24]
+ STRD r4, [r1,#32]
+ STRD r4, [r1,#40]
+ STRD r4, [r1,#48]
+ STRD r4, [r1,#56]
+ STRD r4, [r1,#64]
+ STRD r4, [r1,#72]
+ STRD r4, [r1,#80]
+ STRD r4, [r1,#88]
+ STRD r4, [r1,#96]
+ STRD r4, [r1,#104]
+ STRD r4, [r1,#112]
+ STRD r4, [r1,#120]
+ MOV r1, r13 ; And read from temp storage.
; Column transforms
BL idct8_8core_down_v6
BL idct8_8core_down_v6
@@ -849,20 +827,16 @@ oc_idct8x8_10_v6 PROC
BL idct4_3core_v6
BL idct2_1core_v6
LDR r0, [r13], #4 ; Write to the final destination.
- ; Clear input data for next block (decoder only).
- SUB r2, r1, #4*16
- CMP r0, r2
- AND r1, r13,#4 ; Align the stack.
- BEQ oc_idct8x8_10_v6_cols
+ ; Clear input data for next block.
MOV r4, #0
MOV r5, #0
- STRD r4, [r2]
- STRD r4, [r2,#16]
- STR r4, [r2,#32]
- STR r4, [r2,#48]
-oc_idct8x8_10_v6_cols
-; Column transforms
+ STRD r4, [r1,#-4*16]!
+ STRD r4, [r1,#16]
+ STR r4, [r1,#32]
+ STR r4, [r1,#48]
+ AND r1, r13,#4 ; Align the stack.
ADD r1, r1, r13 ; And read from temp storage.
+; Column transforms
BL idct4_4core_down_v6
BL idct4_4core_down_v6
BL idct4_4core_down_v6
@@ -878,14 +852,12 @@ oc_idct8x8_3_v6 PROC
MOV r8, r0
MOV r0, r13 ; Write to temp storage.
BL idct2_1core_v6
- ; Clear input data for next block (decoder only).
- SUB r0, r1, #2*16
- CMP r0, r8
+ ; Clear input data for next block.
+ MOV r4, #0
+ STR r4, [r1,#-2*16]!
+ STR r4, [r1,#16]
MOV r1, r13 ; Read from temp storage.
- MOVNE r4, #0
- STRNE r4, [r0]
- STRNE r4, [r0,#16]
- MOVNE r0, r8 ; Write to the final destination.
+ MOV r0, r8 ; Write to the final destination.
; Column transforms
BL idct2_2core_down_v6
BL idct2_2core_down_v6
@@ -1041,20 +1013,16 @@ oc_idct8x8_6_v6 PROC
ADD r0, r0, r13 ; Write to temp storage.
BL idct3_2core_v6
BL idct1core_v6
- ; Clear input data for next block (decoder only).
- SUB r0, r1, #3*16
- CMP r0, r8
- AND r1, r13,#4 ; Align the stack.
- BEQ oc_idct8x8_6_v6_cols
+ ; Clear input data for next block.
MOV r4, #0
MOV r5, #0
- STRD r4, [r0]
- STR r4, [r0,#16]
- STR r4, [r0,#32]
+ STRD r4, [r1,#-3*16]!
+ STR r4, [r1,#16]
+ STR r4, [r1,#32]
+ AND r1, r13,#4 ; Align the stack.
MOV r0, r8 ; Write to the final destination.
-oc_idct8x8_6_v6_cols
-; Column transforms
ADD r1, r1, r13 ; And read from temp storage.
+; Column transforms
BL idct3_3core_down_v6
BL idct3_3core_down_v6
BL idct3_3core_down_v6
@@ -1596,7 +1564,6 @@ oc_idct8x8_slow_neon
VSWP D23,D30
; Column transforms
BL oc_idct8x8_stage123_neon
- CMP r0,r1
; We have to put the return address back in the LR, or the branch
; predictor will not recognize the function return and mis-predict the
; entire call stack.
@@ -1610,7 +1577,6 @@ oc_idct8x8_slow_neon
VADD.S16 Q10,Q10,Q5 ; Q10 = y[2]=t[2]'+t[5]''
VSUB.S16 Q12,Q11,Q4 ; Q12 = y[4]=t[3]'-t[4]'
VADD.S16 Q11,Q11,Q4 ; Q11 = y[3]=t[3]'+t[4]'
- BEQ oc_idct8x8_slow_neon_noclear
VMOV.I8 Q2,#0
VPOP {D8-D15}
VMOV.I8 Q3,#0
@@ -1628,19 +1594,6 @@ oc_idct8x8_slow_neon
VRSHR.S16 Q15,Q15,#4 ; Q15 = y[7]+8>>4
VSTMIA r0, {D16-D31}
MOV PC, r14
-
-oc_idct8x8_slow_neon_noclear
- VPOP {D8-D15}
- VRSHR.S16 Q8, Q8, #4 ; Q8 = y[0]+8>>4
- VRSHR.S16 Q9, Q9, #4 ; Q9 = y[1]+8>>4
- VRSHR.S16 Q10,Q10,#4 ; Q10 = y[2]+8>>4
- VRSHR.S16 Q11,Q11,#4 ; Q11 = y[3]+8>>4
- VRSHR.S16 Q12,Q12,#4 ; Q12 = y[4]+8>>4
- VRSHR.S16 Q13,Q13,#4 ; Q13 = y[5]+8>>4
- VRSHR.S16 Q14,Q14,#4 ; Q14 = y[6]+8>>4
- VRSHR.S16 Q15,Q15,#4 ; Q15 = y[7]+8>>4
- VSTMIA r0, {D16-D31}
- MOV PC, r14
ENDP
oc_idct8x8_stage123_neon PROC
@@ -1871,7 +1824,6 @@ oc_idct8x8_10_neon PROC
VADD.S16 Q10,Q1, Q2 ; Q10= t[1]'=t[0]+t[2]
VSUB.S16 Q2, Q1, Q2 ; Q2 = t[2]'=t[0]-t[2]
; Stage 4
- CMP r0, r1
VADD.S16 Q8, Q11,Q15 ; Q8 = y[0]=t[0]'+t[7]'
VADD.S16 Q9, Q10,Q14 ; Q9 = y[1]=t[1]'+t[6]''
VSUB.S16 Q15,Q11,Q15 ; Q15 = y[7]=t[0]'-t[7]'
@@ -1880,7 +1832,6 @@ oc_idct8x8_10_neon PROC
VADD.S16 Q11,Q3, Q12 ; Q11 = y[3]=t[3]'+t[4]'
VSUB.S16 Q12,Q3, Q12 ; Q12 = y[4]=t[3]'-t[4]'
VSUB.S16 Q13,Q2, Q13 ; Q13 = y[5]=t[2]'-t[5]''
- BEQ oc_idct8x8_10_neon_noclear
VMOV.I8 D2, #0
VRSHR.S16 Q8, Q8, #4 ; Q8 = y[0]+8>>4
VST1.64 {D2}, [r1@64], r12
@@ -1896,18 +1847,6 @@ oc_idct8x8_10_neon PROC
VRSHR.S16 Q15,Q15,#4 ; Q15 = y[7]+8>>4
VSTMIA r0, {D16-D31}
MOV PC, r14
-
-oc_idct8x8_10_neon_noclear
- VRSHR.S16 Q8, Q8, #4 ; Q8 = y[0]+8>>4
- VRSHR.S16 Q9, Q9, #4 ; Q9 = y[1]+8>>4
- VRSHR.S16 Q10,Q10,#4 ; Q10 = y[2]+8>>4
- VRSHR.S16 Q11,Q11,#4 ; Q11 = y[3]+8>>4
- VRSHR.S16 Q12,Q12,#4 ; Q12 = y[4]+8>>4
- VRSHR.S16 Q13,Q13,#4 ; Q13 = y[5]+8>>4
- VRSHR.S16 Q14,Q14,#4 ; Q14 = y[6]+8>>4
- VRSHR.S16 Q15,Q15,#4 ; Q15 = y[7]+8>>4
- VSTMIA r0, {D16-D31}
- MOV PC, r14
ENDP
]
diff --git a/media/libtheora/lib/arm/armloop.s b/media/libtheora/lib/arm/armloop.s
index 0a1d4705e7..bbd4d630ed 100644
--- a/media/libtheora/lib/arm/armloop.s
+++ b/media/libtheora/lib/arm/armloop.s
@@ -11,17 +11,11 @@
;********************************************************************
; Original implementation:
; Copyright (C) 2009 Robin Watts for Pinknoise Productions Ltd
-; last mod: $Id: armloop.s 17481 2010-10-03 22:49:42Z tterribe $
+; last mod: $Id$
;********************************************************************
AREA |.text|, CODE, READONLY
- ; Explicitly specifying alignment here because some versions of
- ; gas don't align code correctly. See
- ; http://lists.gnu.org/archive/html/bug-binutils/2011-06/msg00199.html
- ; https://bugzilla.mozilla.org/show_bug.cgi?id=920992
- ALIGN
-
GET armopts.s
EXPORT oc_loop_filter_frag_rows_arm
diff --git a/media/libtheora/lib/arm/armopts.s b/media/libtheora/lib/arm/armopts.s
index e4da429e47..4dfdca9608 100644
--- a/media/libtheora/lib/arm/armopts.s
+++ b/media/libtheora/lib/arm/armopts.s
@@ -11,7 +11,7 @@
;********************************************************************
; Original implementation:
; Copyright (C) 2009 Robin Watts for Pinknoise Productions Ltd
-; last mod: $Id: armopts.s.in 17430 2010-09-22 21:54:09Z tterribe $
+; last mod: $Id$
;********************************************************************
; Set the following to 1 if we have EDSP instructions
diff --git a/media/libtheora/lib/bitpack.c b/media/libtheora/lib/bitpack.c
index 8bfce4c3d0..5125dde6b0 100644
--- a/media/libtheora/lib/bitpack.c
+++ b/media/libtheora/lib/bitpack.c
@@ -11,7 +11,7 @@
********************************************************************
function: packing variable sized words into an octet stream
- last mod: $Id: bitpack.c 17410 2010-09-21 21:53:48Z tterribe $
+ last mod: $Id$
********************************************************************/
#include <string.h>
diff --git a/media/libtheora/lib/config.h b/media/libtheora/lib/config.h
index 49772ac7f3..b5c9aedfbc 100644
--- a/media/libtheora/lib/config.h
+++ b/media/libtheora/lib/config.h
@@ -13,8 +13,8 @@
/* Define to 1 if you have the <machine/soundcard.h> header file. */
/* #undef HAVE_MACHINE_SOUNDCARD_H */
-/* Define to 1 if you have the <memory.h> header file. */
-#define HAVE_MEMORY_H 1
+/* Abort if size exceeds 16384x16384 (for fuzzing only) */
+/* #undef HAVE_MEMORY_CONSTRAINT */
/* Define to 1 if you have the <soundcard.h> header file. */
/* #undef HAVE_SOUNDCARD_H */
@@ -22,6 +22,9 @@
/* Define to 1 if you have the <stdint.h> header file. */
#define HAVE_STDINT_H 1
+/* Define to 1 if you have the <stdio.h> header file. */
+#define HAVE_STDIO_H 1
+
/* Define to 1 if you have the <stdlib.h> header file. */
#define HAVE_STDLIB_H 1
@@ -43,56 +46,58 @@
/* Define to 1 if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1
-/* Define to 1 if your C compiler doesn't accept -c and -o together. */
-/* #undef NO_MINUS_C_MINUS_O */
+/* Define to the sub-directory where libtool stores uninstalled libraries. */
+#define LT_OBJDIR ".libs/"
/* make use of arm asm optimization */
-
+/* #undef OC_ARM_ASM */
/* Define if assembler supports EDSP instructions */
-
+/* #undef OC_ARM_ASM_EDSP */
/* Define if assembler supports ARMv6 media instructions */
-
+/* #undef OC_ARM_ASM_MEDIA */
/* Define if compiler supports NEON instructions */
-
+/* #undef OC_ARM_ASM_NEON */
/* make use of c64x+ asm optimization */
/* #undef OC_C64X_ASM */
/* make use of x86_64 asm optimization */
-/* #undef OC_X86_64_ASM */
+ /**/
/* make use of x86 asm optimization */
-/* #undef OC_X86_ASM */
+ /**/
/* Name of package */
#define PACKAGE "libtheora"
/* Define to the address where bug reports for this package should be sent. */
-#define PACKAGE_BUGREPORT ""
+#define PACKAGE_BUGREPORT "theora-dev@xiph.org"
/* Define to the full name of this package. */
#define PACKAGE_NAME "libtheora"
/* Define to the full name and version of this package. */
-#define PACKAGE_STRING "libtheora 1.2.0alpha1+svn"
+#define PACKAGE_STRING "libtheora 1.2.0alpha1+git"
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "libtheora"
+/* Define to the home page for this package. */
+#define PACKAGE_URL ""
+
/* Define to the version of this package. */
-#define PACKAGE_VERSION "1.2.0alpha1+svn"
+#define PACKAGE_VERSION "1.2.0alpha1+git"
-/* Define to 1 if you have the ANSI C header files. */
+/* Define to 1 if all of the C90 standard headers exist (not just the ones
+ required in a freestanding environment). This macro is provided for
+ backward compatibility; new code need not use it. */
#define STDC_HEADERS 1
/* Define to exclude encode support from the build */
/* #undef THEORA_DISABLE_ENCODE */
-/* Define to exclude floating point code from the build */
-/* #undef THEORA_DISABLE_FLOAT */
-
/* Version number of package */
-#define VERSION "1.2.0alpha1+svn"
+#define VERSION "1.2.0alpha1+git"
diff --git a/media/libtheora/lib/dct.h b/media/libtheora/lib/dct.h
index 24ba6f111a..8052ea6bc1 100644
--- a/media/libtheora/lib/dct.h
+++ b/media/libtheora/lib/dct.h
@@ -11,7 +11,7 @@
********************************************************************
function:
- last mod: $Id: dct.h 16503 2009-08-22 18:14:02Z giles $
+ last mod: $Id$
********************************************************************/
diff --git a/media/libtheora/lib/decapiwrapper.c b/media/libtheora/lib/decapiwrapper.c
deleted file mode 100644
index 12ea475d17..0000000000
--- a/media/libtheora/lib/decapiwrapper.c
+++ /dev/null
@@ -1,193 +0,0 @@
-/********************************************************************
- * *
- * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE. *
- * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
- * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
- * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
- * *
- * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2009 *
- * by the Xiph.Org Foundation and contributors http://www.xiph.org/ *
- * *
- ********************************************************************
-
- function:
- last mod: $Id: decapiwrapper.c 13596 2007-08-23 20:05:38Z tterribe $
-
- ********************************************************************/
-
-#include <stdlib.h>
-#include <string.h>
-#include <limits.h>
-#include "apiwrapper.h"
-#include "decint.h"
-#include "theora/theoradec.h"
-
-static void th_dec_api_clear(th_api_wrapper *_api){
- if(_api->setup)th_setup_free(_api->setup);
- if(_api->decode)th_decode_free(_api->decode);
- memset(_api,0,sizeof(*_api));
-}
-
-static void theora_decode_clear(theora_state *_td){
- if(_td->i!=NULL)theora_info_clear(_td->i);
- memset(_td,0,sizeof(*_td));
-}
-
-static int theora_decode_control(theora_state *_td,int _req,
- void *_buf,size_t _buf_sz){
- return th_decode_ctl(((th_api_wrapper *)_td->i->codec_setup)->decode,
- _req,_buf,_buf_sz);
-}
-
-static ogg_int64_t theora_decode_granule_frame(theora_state *_td,
- ogg_int64_t _gp){
- return th_granule_frame(((th_api_wrapper *)_td->i->codec_setup)->decode,_gp);
-}
-
-static double theora_decode_granule_time(theora_state *_td,ogg_int64_t _gp){
- return th_granule_time(((th_api_wrapper *)_td->i->codec_setup)->decode,_gp);
-}
-
-static const oc_state_dispatch_vtable OC_DEC_DISPATCH_VTBL={
- (oc_state_clear_func)theora_decode_clear,
- (oc_state_control_func)theora_decode_control,
- (oc_state_granule_frame_func)theora_decode_granule_frame,
- (oc_state_granule_time_func)theora_decode_granule_time,
-};
-
-static void th_info2theora_info(theora_info *_ci,const th_info *_info){
- _ci->version_major=_info->version_major;
- _ci->version_minor=_info->version_minor;
- _ci->version_subminor=_info->version_subminor;
- _ci->width=_info->frame_width;
- _ci->height=_info->frame_height;
- _ci->frame_width=_info->pic_width;
- _ci->frame_height=_info->pic_height;
- _ci->offset_x=_info->pic_x;
- _ci->offset_y=_info->pic_y;
- _ci->fps_numerator=_info->fps_numerator;
- _ci->fps_denominator=_info->fps_denominator;
- _ci->aspect_numerator=_info->aspect_numerator;
- _ci->aspect_denominator=_info->aspect_denominator;
- switch(_info->colorspace){
- case TH_CS_ITU_REC_470M:_ci->colorspace=OC_CS_ITU_REC_470M;break;
- case TH_CS_ITU_REC_470BG:_ci->colorspace=OC_CS_ITU_REC_470BG;break;
- default:_ci->colorspace=OC_CS_UNSPECIFIED;break;
- }
- switch(_info->pixel_fmt){
- case TH_PF_420:_ci->pixelformat=OC_PF_420;break;
- case TH_PF_422:_ci->pixelformat=OC_PF_422;break;
- case TH_PF_444:_ci->pixelformat=OC_PF_444;break;
- default:_ci->pixelformat=OC_PF_RSVD;
- }
- _ci->target_bitrate=_info->target_bitrate;
- _ci->quality=_info->quality;
- _ci->keyframe_frequency_force=1<<_info->keyframe_granule_shift;
-}
-
-int theora_decode_init(theora_state *_td,theora_info *_ci){
- th_api_info *apiinfo;
- th_api_wrapper *api;
- th_info info;
- api=(th_api_wrapper *)_ci->codec_setup;
- /*Allocate our own combined API wrapper/theora_info struct.
- We put them both in one malloc'd block so that when the API wrapper is
- freed, the info struct goes with it.
- This avoids having to figure out whether or not we need to free the info
- struct in either theora_info_clear() or theora_clear().*/
- apiinfo=(th_api_info *)_ogg_calloc(1,sizeof(*apiinfo));
- if(apiinfo==NULL)return OC_FAULT;
- /*Make our own copy of the info struct, since its lifetime should be
- independent of the one we were passed in.*/
- *&apiinfo->info=*_ci;
- /*Convert the info struct now instead of saving the the one we decoded with
- theora_decode_header(), since the user might have modified values (i.e.,
- color space, aspect ratio, etc. can be specified from a higher level).
- The user also might be doing something "clever" with the header packets if
- they are not using an Ogg encapsulation.*/
- oc_theora_info2th_info(&info,_ci);
- /*Don't bother to copy the setup info; th_decode_alloc() makes its own copy
- of the stuff it needs.*/
- apiinfo->api.decode=th_decode_alloc(&info,api->setup);
- if(apiinfo->api.decode==NULL){
- _ogg_free(apiinfo);
- return OC_EINVAL;
- }
- apiinfo->api.clear=(oc_setup_clear_func)th_dec_api_clear;
- _td->internal_encode=NULL;
- /*Provide entry points for ABI compatibility with old decoder shared libs.*/
- _td->internal_decode=(void *)&OC_DEC_DISPATCH_VTBL;
- _td->granulepos=0;
- _td->i=&apiinfo->info;
- _td->i->codec_setup=&apiinfo->api;
- return 0;
-}
-
-int theora_decode_header(theora_info *_ci,theora_comment *_cc,ogg_packet *_op){
- th_api_wrapper *api;
- th_info info;
- int ret;
- api=(th_api_wrapper *)_ci->codec_setup;
- /*Allocate an API wrapper struct on demand, since it will not also include a
- theora_info struct like the ones that are used in a theora_state struct.*/
- if(api==NULL){
- _ci->codec_setup=_ogg_calloc(1,sizeof(*api));
- if(_ci->codec_setup==NULL)return OC_FAULT;
- api=(th_api_wrapper *)_ci->codec_setup;
- api->clear=(oc_setup_clear_func)th_dec_api_clear;
- }
- /*Convert from the theora_info struct instead of saving our own th_info
- struct between calls.
- The user might be doing something "clever" with the header packets if they
- are not using an Ogg encapsulation, and we don't want to break this.*/
- oc_theora_info2th_info(&info,_ci);
- /*We rely on the fact that theora_comment and th_comment structures are
- actually identical.
- Take care not to change this fact unless you change the code here as
- well!*/
- ret=th_decode_headerin(&info,(th_comment *)_cc,&api->setup,_op);
- /*We also rely on the fact that the error return code values are the same,
- and that the implementations of these two functions return the same set of
- them.
- Note that theora_decode_header() really can return OC_NOTFORMAT, even
- though it is not currently documented to do so.*/
- if(ret<0)return ret;
- th_info2theora_info(_ci,&info);
- return 0;
-}
-
-int theora_decode_packetin(theora_state *_td,ogg_packet *_op){
- th_api_wrapper *api;
- ogg_int64_t gp;
- int ret;
- if(!_td||!_td->i||!_td->i->codec_setup)return OC_FAULT;
- api=(th_api_wrapper *)_td->i->codec_setup;
- ret=th_decode_packetin(api->decode,_op,&gp);
- if(ret<0)return OC_BADPACKET;
- _td->granulepos=gp;
- return 0;
-}
-
-int theora_decode_YUVout(theora_state *_td,yuv_buffer *_yuv){
- th_api_wrapper *api;
- th_dec_ctx *decode;
- th_ycbcr_buffer buf;
- int ret;
- if(!_td||!_td->i||!_td->i->codec_setup)return OC_FAULT;
- api=(th_api_wrapper *)_td->i->codec_setup;
- decode=(th_dec_ctx *)api->decode;
- if(!decode)return OC_FAULT;
- ret=th_decode_ycbcr_out(decode,buf);
- if(ret>=0){
- _yuv->y_width=buf[0].width;
- _yuv->y_height=buf[0].height;
- _yuv->y_stride=buf[0].stride;
- _yuv->uv_width=buf[1].width;
- _yuv->uv_height=buf[1].height;
- _yuv->uv_stride=buf[1].stride;
- _yuv->y=buf[0].data;
- _yuv->u=buf[1].data;
- _yuv->v=buf[2].data;
- }
- return ret;
-}
diff --git a/media/libtheora/lib/decinfo.c b/media/libtheora/lib/decinfo.c
index 603b1f93e4..a91e740b15 100644
--- a/media/libtheora/lib/decinfo.c
+++ b/media/libtheora/lib/decinfo.c
@@ -11,7 +11,7 @@
********************************************************************
function:
- last mod: $Id: decinfo.c 17276 2010-06-05 05:57:05Z tterribe $
+ last mod: $Id$
********************************************************************/
@@ -20,6 +20,11 @@
#include <limits.h>
#include "decint.h"
+/*Only used for fuzzing.*/
+#if defined(HAVE_MEMORY_CONSTRAINT)
+static const int MAX_FUZZING_WIDTH = 16384;
+static const int MAX_FUZZING_HEIGHT = 16384;
+#endif
/*Unpacks a series of octets from a given byte array into the pack buffer.
@@ -55,8 +60,8 @@ static int oc_info_unpack(oc_pack_buf *_opb,th_info *_info){
/*verify we can parse this bitstream version.
We accept earlier minors and all subminors, by spec*/
if(_info->version_major>TH_VERSION_MAJOR||
- _info->version_major==TH_VERSION_MAJOR&&
- _info->version_minor>TH_VERSION_MINOR){
+ (_info->version_major==TH_VERSION_MAJOR&&
+ _info->version_minor>TH_VERSION_MINOR)){
return TH_EVERSION;
}
/*Read the encoded frame description.*/
@@ -82,6 +87,11 @@ static int oc_info_unpack(oc_pack_buf *_opb,th_info *_info){
_info->fps_numerator==0||_info->fps_denominator==0){
return TH_EBADHEADER;
}
+#if defined(HAVE_MEMORY_CONSTRAINT)
+ if(_info->frame_width>=MAX_FUZZING_WIDTH&&_info->frame_height>=MAX_FUZZING_HEIGHT){
+ return TH_EBADHEADER;
+ }
+#endif
/*Note: The sense of pic_y is inverted in what we pass back to the
application compared to how it is stored in the bitstream.
This is because the bitstream uses a right-handed coordinate system, while
@@ -172,9 +182,23 @@ static int oc_dec_headerin(oc_pack_buf *_opb,th_info *_info,
int ret;
val=oc_pack_read(_opb,8);
packtype=(int)val;
- /*If we're at a data packet and we have received all three headers, we're
- done.*/
- if(!(packtype&0x80)&&_info->frame_width>0&&_tc->vendor!=NULL&&*_setup!=NULL){
+ /*If we're at a data packet...*/
+ if(!(packtype&0x80)){
+ /*Check to make sure we received all three headers...
+ If we haven't seen any valid headers, assume this is not actually
+ Theora.*/
+ if(_info->frame_width<=0)return TH_ENOTFORMAT;
+ /*Follow our documentation, which says we'll return TH_EFAULT if this
+ are NULL (_info was checked by our caller).*/
+ if(_tc==NULL)return TH_EFAULT;
+ /*And if any other headers were missing, declare this packet "out of
+ sequence" instead.*/
+ if(_tc->vendor==NULL)return TH_EBADHEADER;
+ /*Don't check this until it's needed, since we allow passing NULL for the
+ arguments that we're not expecting the next header to fill in yet.*/
+ if(_setup==NULL)return TH_EFAULT;
+ if(*_setup==NULL)return TH_EBADHEADER;
+ /*If we got everything, we're done.*/
return 0;
}
/*Check the codec string.*/
diff --git a/media/libtheora/lib/decint.h b/media/libtheora/lib/decint.h
index bd65222732..3cea6b1439 100644
--- a/media/libtheora/lib/decint.h
+++ b/media/libtheora/lib/decint.h
@@ -11,7 +11,7 @@
********************************************************************
function:
- last mod: $Id: decint.h 17457 2010-09-24 02:05:49Z tterribe $
+ last mod: $Id$
********************************************************************/
@@ -162,7 +162,6 @@ struct th_dec_ctx{
# endif
# if defined(HAVE_CAIRO)
/*Output metrics for debugging.*/
- int telemetry;
int telemetry_mbmode;
int telemetry_mv;
int telemetry_qi;
diff --git a/media/libtheora/lib/decode.c b/media/libtheora/lib/decode.c
index 563782b7a2..fad26e0927 100644
--- a/media/libtheora/lib/decode.c
+++ b/media/libtheora/lib/decode.c
@@ -11,7 +11,7 @@
********************************************************************
function:
- last mod: $Id: decode.c 17576 2010-10-29 01:07:51Z tterribe $
+ last mod: $Id$
********************************************************************/
@@ -417,7 +417,6 @@ static int oc_dec_init(oc_dec_ctx *_dec,const th_info *_info,
_dec->stripe_cb.ctx=NULL;
_dec->stripe_cb.stripe_decoded=NULL;
#if defined(HAVE_CAIRO)
- _dec->telemetry=0;
_dec->telemetry_bits=0;
_dec->telemetry_qi=0;
_dec->telemetry_mbmode=0;
@@ -1203,6 +1202,9 @@ static void oc_dec_residual_tokens_unpack(oc_dec_ctx *_dec){
static int oc_dec_postprocess_init(oc_dec_ctx *_dec){
+ /*musl libc malloc()/realloc() calls might use floating point, so make sure
+ we've cleared the MMX state for them.*/
+ oc_restore_fpu(&_dec->state);
/*pp_level 0: disabled; free any memory used and return*/
if(_dec->pp_level<=OC_PP_LEVEL_DISABLED){
if(_dec->dc_qis!=NULL){
@@ -2019,28 +2021,24 @@ int th_decode_ctl(th_dec_ctx *_dec,int _req,void *_buf,
case TH_DECCTL_SET_TELEMETRY_MBMODE:{
if(_dec==NULL||_buf==NULL)return TH_EFAULT;
if(_buf_sz!=sizeof(int))return TH_EINVAL;
- _dec->telemetry=1;
_dec->telemetry_mbmode=*(int *)_buf;
return 0;
}break;
case TH_DECCTL_SET_TELEMETRY_MV:{
if(_dec==NULL||_buf==NULL)return TH_EFAULT;
if(_buf_sz!=sizeof(int))return TH_EINVAL;
- _dec->telemetry=1;
_dec->telemetry_mv=*(int *)_buf;
return 0;
}break;
case TH_DECCTL_SET_TELEMETRY_QI:{
if(_dec==NULL||_buf==NULL)return TH_EFAULT;
if(_buf_sz!=sizeof(int))return TH_EINVAL;
- _dec->telemetry=1;
_dec->telemetry_qi=*(int *)_buf;
return 0;
}break;
case TH_DECCTL_SET_TELEMETRY_BITS:{
if(_dec==NULL||_buf==NULL)return TH_EFAULT;
if(_buf_sz!=sizeof(int))return TH_EINVAL;
- _dec->telemetry=1;
_dec->telemetry_bits=*(int *)_buf;
return 0;
}break;
@@ -2081,6 +2079,664 @@ static void oc_dec_init_dummy_frame(th_dec_ctx *_dec){
memset(_dec->state.ref_frame_data[0]-yoffset,0x80,yplane_sz+2*cplane_sz);
}
+#if defined(HAVE_CAIRO)
+static void oc_render_telemetry(th_dec_ctx *_dec,th_ycbcr_buffer _ycbcr,
+ int _telemetry){
+ /*Stuff the plane into cairo.*/
+ cairo_surface_t *cs;
+ unsigned char *data;
+ unsigned char *y_row;
+ unsigned char *u_row;
+ unsigned char *v_row;
+ unsigned char *rgb_row;
+ int cstride;
+ int w;
+ int h;
+ int x;
+ int y;
+ int hdec;
+ int vdec;
+ w=_ycbcr[0].width;
+ h=_ycbcr[0].height;
+ hdec=!(_dec->state.info.pixel_fmt&1);
+ vdec=!(_dec->state.info.pixel_fmt&2);
+ /*Lazy data buffer init.
+ We could try to re-use the post-processing buffer, which would save
+ memory, but complicate the allocation logic there.
+ I don't think anyone cares about memory usage when using telemetry; it is
+ not meant for embedded devices.*/
+ if(_dec->telemetry_frame_data==NULL){
+ _dec->telemetry_frame_data=_ogg_malloc(
+ (w*h+2*(w>>hdec)*(h>>vdec))*sizeof(*_dec->telemetry_frame_data));
+ if(_dec->telemetry_frame_data==NULL)return;
+ }
+ cs=cairo_image_surface_create(CAIRO_FORMAT_RGB24,w,h);
+ /*Sadly, no YUV support in Cairo (yet); convert into the RGB buffer.*/
+ data=cairo_image_surface_get_data(cs);
+ if(data==NULL){
+ cairo_surface_destroy(cs);
+ return;
+ }
+ cstride=cairo_image_surface_get_stride(cs);
+ y_row=_ycbcr[0].data;
+ u_row=_ycbcr[1].data;
+ v_row=_ycbcr[2].data;
+ rgb_row=data;
+ for(y=0;y<h;y++){
+ for(x=0;x<w;x++){
+ int r;
+ int g;
+ int b;
+ r=(1904000*y_row[x]+2609823*v_row[x>>hdec]-363703744)/1635200;
+ g=(3827562*y_row[x]-1287801*u_row[x>>hdec]
+ -2672387*v_row[x>>hdec]+447306710)/3287200;
+ b=(952000*y_row[x]+1649289*u_row[x>>hdec]-225932192)/817600;
+ rgb_row[4*x+0]=OC_CLAMP255(b);
+ rgb_row[4*x+1]=OC_CLAMP255(g);
+ rgb_row[4*x+2]=OC_CLAMP255(r);
+ }
+ y_row+=_ycbcr[0].stride;
+ u_row+=_ycbcr[1].stride&-((y&1)|!vdec);
+ v_row+=_ycbcr[2].stride&-((y&1)|!vdec);
+ rgb_row+=cstride;
+ }
+ /*Draw coded identifier for each macroblock (stored in Hilbert order).*/
+ {
+ cairo_t *c;
+ const oc_fragment *frags;
+ oc_mv *frag_mvs;
+ const signed char *mb_modes;
+ oc_mb_map *mb_maps;
+ size_t nmbs;
+ size_t mbi;
+ int row2;
+ int col2;
+ int qim[3]={0,0,0};
+ if(_dec->state.nqis==2){
+ int bqi;
+ bqi=_dec->state.qis[0];
+ if(_dec->state.qis[1]>bqi)qim[1]=1;
+ if(_dec->state.qis[1]<bqi)qim[1]=-1;
+ }
+ if(_dec->state.nqis==3){
+ int bqi;
+ int cqi;
+ int dqi;
+ bqi=_dec->state.qis[0];
+ cqi=_dec->state.qis[1];
+ dqi=_dec->state.qis[2];
+ if(cqi>bqi&&dqi>bqi){
+ if(dqi>cqi){
+ qim[1]=1;
+ qim[2]=2;
+ }
+ else{
+ qim[1]=2;
+ qim[2]=1;
+ }
+ }
+ else if(cqi<bqi&&dqi<bqi){
+ if(dqi<cqi){
+ qim[1]=-1;
+ qim[2]=-2;
+ }
+ else{
+ qim[1]=-2;
+ qim[2]=-1;
+ }
+ }
+ else{
+ if(cqi<bqi)qim[1]=-1;
+ else qim[1]=1;
+ if(dqi<bqi)qim[2]=-1;
+ else qim[2]=1;
+ }
+ }
+ c=cairo_create(cs);
+ frags=_dec->state.frags;
+ frag_mvs=_dec->state.frag_mvs;
+ mb_modes=_dec->state.mb_modes;
+ mb_maps=_dec->state.mb_maps;
+ nmbs=_dec->state.nmbs;
+ row2=0;
+ col2=0;
+ for(mbi=0;mbi<nmbs;mbi++){
+ float x;
+ float y;
+ int bi;
+ y=h-(row2+((col2+1>>1)&1))*16-16;
+ x=(col2>>1)*16;
+ cairo_set_line_width(c,1.);
+ /*Keyframe (all intra) red box.*/
+ if(_dec->state.frame_type==OC_INTRA_FRAME){
+ if(_dec->telemetry_mbmode&0x02){
+ cairo_set_source_rgba(c,1.,0,0,.5);
+ cairo_rectangle(c,x+2.5,y+2.5,11,11);
+ cairo_stroke_preserve(c);
+ cairo_set_source_rgba(c,1.,0,0,.25);
+ cairo_fill(c);
+ }
+ }
+ else{
+ ptrdiff_t fragi;
+ int frag_mvx;
+ int frag_mvy;
+ for(bi=0;bi<4;bi++){
+ fragi=mb_maps[mbi][0][bi];
+ if(fragi>=0&&frags[fragi].coded){
+ frag_mvx=OC_MV_X(frag_mvs[fragi]);
+ frag_mvy=OC_MV_Y(frag_mvs[fragi]);
+ break;
+ }
+ }
+ if(bi<4){
+ switch(mb_modes[mbi]){
+ case OC_MODE_INTRA:{
+ if(_dec->telemetry_mbmode&0x02){
+ cairo_set_source_rgba(c,1.,0,0,.5);
+ cairo_rectangle(c,x+2.5,y+2.5,11,11);
+ cairo_stroke_preserve(c);
+ cairo_set_source_rgba(c,1.,0,0,.25);
+ cairo_fill(c);
+ }
+ }break;
+ case OC_MODE_INTER_NOMV:{
+ if(_dec->telemetry_mbmode&0x01){
+ cairo_set_source_rgba(c,0,0,1.,.5);
+ cairo_rectangle(c,x+2.5,y+2.5,11,11);
+ cairo_stroke_preserve(c);
+ cairo_set_source_rgba(c,0,0,1.,.25);
+ cairo_fill(c);
+ }
+ }break;
+ case OC_MODE_INTER_MV:{
+ if(_dec->telemetry_mbmode&0x04){
+ cairo_rectangle(c,x+2.5,y+2.5,11,11);
+ cairo_set_source_rgba(c,0,1.,0,.5);
+ cairo_stroke(c);
+ }
+ if(_dec->telemetry_mv&0x04){
+ cairo_move_to(c,x+8+frag_mvx,y+8-frag_mvy);
+ cairo_set_source_rgba(c,1.,1.,1.,.9);
+ cairo_set_line_width(c,3.);
+ cairo_line_to(c,x+8+frag_mvx*.66,y+8-frag_mvy*.66);
+ cairo_stroke_preserve(c);
+ cairo_set_line_width(c,2.);
+ cairo_line_to(c,x+8+frag_mvx*.33,y+8-frag_mvy*.33);
+ cairo_stroke_preserve(c);
+ cairo_set_line_width(c,1.);
+ cairo_line_to(c,x+8,y+8);
+ cairo_stroke(c);
+ }
+ }break;
+ case OC_MODE_INTER_MV_LAST:{
+ if(_dec->telemetry_mbmode&0x08){
+ cairo_rectangle(c,x+2.5,y+2.5,11,11);
+ cairo_set_source_rgba(c,0,1.,0,.5);
+ cairo_move_to(c,x+13.5,y+2.5);
+ cairo_line_to(c,x+2.5,y+8);
+ cairo_line_to(c,x+13.5,y+13.5);
+ cairo_stroke(c);
+ }
+ if(_dec->telemetry_mv&0x08){
+ cairo_move_to(c,x+8+frag_mvx,y+8-frag_mvy);
+ cairo_set_source_rgba(c,1.,1.,1.,.9);
+ cairo_set_line_width(c,3.);
+ cairo_line_to(c,x+8+frag_mvx*.66,y+8-frag_mvy*.66);
+ cairo_stroke_preserve(c);
+ cairo_set_line_width(c,2.);
+ cairo_line_to(c,x+8+frag_mvx*.33,y+8-frag_mvy*.33);
+ cairo_stroke_preserve(c);
+ cairo_set_line_width(c,1.);
+ cairo_line_to(c,x+8,y+8);
+ cairo_stroke(c);
+ }
+ }break;
+ case OC_MODE_INTER_MV_LAST2:{
+ if(_dec->telemetry_mbmode&0x10){
+ cairo_rectangle(c,x+2.5,y+2.5,11,11);
+ cairo_set_source_rgba(c,0,1.,0,.5);
+ cairo_move_to(c,x+8,y+2.5);
+ cairo_line_to(c,x+2.5,y+8);
+ cairo_line_to(c,x+8,y+13.5);
+ cairo_move_to(c,x+13.5,y+2.5);
+ cairo_line_to(c,x+8,y+8);
+ cairo_line_to(c,x+13.5,y+13.5);
+ cairo_stroke(c);
+ }
+ if(_dec->telemetry_mv&0x10){
+ cairo_move_to(c,x+8+frag_mvx,y+8-frag_mvy);
+ cairo_set_source_rgba(c,1.,1.,1.,.9);
+ cairo_set_line_width(c,3.);
+ cairo_line_to(c,x+8+frag_mvx*.66,y+8-frag_mvy*.66);
+ cairo_stroke_preserve(c);
+ cairo_set_line_width(c,2.);
+ cairo_line_to(c,x+8+frag_mvx*.33,y+8-frag_mvy*.33);
+ cairo_stroke_preserve(c);
+ cairo_set_line_width(c,1.);
+ cairo_line_to(c,x+8,y+8);
+ cairo_stroke(c);
+ }
+ }break;
+ case OC_MODE_GOLDEN_NOMV:{
+ if(_dec->telemetry_mbmode&0x20){
+ cairo_set_source_rgba(c,1.,1.,0,.5);
+ cairo_rectangle(c,x+2.5,y+2.5,11,11);
+ cairo_stroke_preserve(c);
+ cairo_set_source_rgba(c,1.,1.,0,.25);
+ cairo_fill(c);
+ }
+ }break;
+ case OC_MODE_GOLDEN_MV:{
+ if(_dec->telemetry_mbmode&0x40){
+ cairo_rectangle(c,x+2.5,y+2.5,11,11);
+ cairo_set_source_rgba(c,1.,1.,0,.5);
+ cairo_stroke(c);
+ }
+ if(_dec->telemetry_mv&0x40){
+ cairo_move_to(c,x+8+frag_mvx,y+8-frag_mvy);
+ cairo_set_source_rgba(c,1.,1.,1.,.9);
+ cairo_set_line_width(c,3.);
+ cairo_line_to(c,x+8+frag_mvx*.66,y+8-frag_mvy*.66);
+ cairo_stroke_preserve(c);
+ cairo_set_line_width(c,2.);
+ cairo_line_to(c,x+8+frag_mvx*.33,y+8-frag_mvy*.33);
+ cairo_stroke_preserve(c);
+ cairo_set_line_width(c,1.);
+ cairo_line_to(c,x+8,y+8);
+ cairo_stroke(c);
+ }
+ }break;
+ case OC_MODE_INTER_MV_FOUR:{
+ if(_dec->telemetry_mbmode&0x80){
+ cairo_rectangle(c,x+2.5,y+2.5,4,4);
+ cairo_rectangle(c,x+9.5,y+2.5,4,4);
+ cairo_rectangle(c,x+2.5,y+9.5,4,4);
+ cairo_rectangle(c,x+9.5,y+9.5,4,4);
+ cairo_set_source_rgba(c,0,1.,0,.5);
+ cairo_stroke(c);
+ }
+ /*4mv is odd, coded in raster order.*/
+ fragi=mb_maps[mbi][0][0];
+ if(frags[fragi].coded&&_dec->telemetry_mv&0x80){
+ frag_mvx=OC_MV_X(frag_mvs[fragi]);
+ frag_mvx=OC_MV_Y(frag_mvs[fragi]);
+ cairo_move_to(c,x+4+frag_mvx,y+12-frag_mvy);
+ cairo_set_source_rgba(c,1.,1.,1.,.9);
+ cairo_set_line_width(c,3.);
+ cairo_line_to(c,x+4+frag_mvx*.66,y+12-frag_mvy*.66);
+ cairo_stroke_preserve(c);
+ cairo_set_line_width(c,2.);
+ cairo_line_to(c,x+4+frag_mvx*.33,y+12-frag_mvy*.33);
+ cairo_stroke_preserve(c);
+ cairo_set_line_width(c,1.);
+ cairo_line_to(c,x+4,y+12);
+ cairo_stroke(c);
+ }
+ fragi=mb_maps[mbi][0][1];
+ if(frags[fragi].coded&&_dec->telemetry_mv&0x80){
+ frag_mvx=OC_MV_X(frag_mvs[fragi]);
+ frag_mvx=OC_MV_Y(frag_mvs[fragi]);
+ cairo_move_to(c,x+12+frag_mvx,y+12-frag_mvy);
+ cairo_set_source_rgba(c,1.,1.,1.,.9);
+ cairo_set_line_width(c,3.);
+ cairo_line_to(c,x+12+frag_mvx*.66,y+12-frag_mvy*.66);
+ cairo_stroke_preserve(c);
+ cairo_set_line_width(c,2.);
+ cairo_line_to(c,x+12+frag_mvx*.33,y+12-frag_mvy*.33);
+ cairo_stroke_preserve(c);
+ cairo_set_line_width(c,1.);
+ cairo_line_to(c,x+12,y+12);
+ cairo_stroke(c);
+ }
+ fragi=mb_maps[mbi][0][2];
+ if(frags[fragi].coded&&_dec->telemetry_mv&0x80){
+ frag_mvx=OC_MV_X(frag_mvs[fragi]);
+ frag_mvx=OC_MV_Y(frag_mvs[fragi]);
+ cairo_move_to(c,x+4+frag_mvx,y+4-frag_mvy);
+ cairo_set_source_rgba(c,1.,1.,1.,.9);
+ cairo_set_line_width(c,3.);
+ cairo_line_to(c,x+4+frag_mvx*.66,y+4-frag_mvy*.66);
+ cairo_stroke_preserve(c);
+ cairo_set_line_width(c,2.);
+ cairo_line_to(c,x+4+frag_mvx*.33,y+4-frag_mvy*.33);
+ cairo_stroke_preserve(c);
+ cairo_set_line_width(c,1.);
+ cairo_line_to(c,x+4,y+4);
+ cairo_stroke(c);
+ }
+ fragi=mb_maps[mbi][0][3];
+ if(frags[fragi].coded&&_dec->telemetry_mv&0x80){
+ frag_mvx=OC_MV_X(frag_mvs[fragi]);
+ frag_mvx=OC_MV_Y(frag_mvs[fragi]);
+ cairo_move_to(c,x+12+frag_mvx,y+4-frag_mvy);
+ cairo_set_source_rgba(c,1.,1.,1.,.9);
+ cairo_set_line_width(c,3.);
+ cairo_line_to(c,x+12+frag_mvx*.66,y+4-frag_mvy*.66);
+ cairo_stroke_preserve(c);
+ cairo_set_line_width(c,2.);
+ cairo_line_to(c,x+12+frag_mvx*.33,y+4-frag_mvy*.33);
+ cairo_stroke_preserve(c);
+ cairo_set_line_width(c,1.);
+ cairo_line_to(c,x+12,y+4);
+ cairo_stroke(c);
+ }
+ }break;
+ }
+ }
+ }
+ /*qii illustration.*/
+ if(_dec->telemetry_qi&0x2){
+ cairo_set_line_cap(c,CAIRO_LINE_CAP_SQUARE);
+ for(bi=0;bi<4;bi++){
+ ptrdiff_t fragi;
+ int qiv;
+ int xp;
+ int yp;
+ xp=x+(bi&1)*8;
+ yp=y+8-(bi&2)*4;
+ fragi=mb_maps[mbi][0][bi];
+ if(fragi>=0&&frags[fragi].coded){
+ qiv=qim[frags[fragi].qii];
+ cairo_set_line_width(c,3.);
+ cairo_set_source_rgba(c,0.,0.,0.,.5);
+ switch(qiv){
+ /*Double plus:*/
+ case 2:{
+ if((bi&1)^((bi&2)>>1)){
+ cairo_move_to(c,xp+2.5,yp+1.5);
+ cairo_line_to(c,xp+2.5,yp+3.5);
+ cairo_move_to(c,xp+1.5,yp+2.5);
+ cairo_line_to(c,xp+3.5,yp+2.5);
+ cairo_move_to(c,xp+5.5,yp+4.5);
+ cairo_line_to(c,xp+5.5,yp+6.5);
+ cairo_move_to(c,xp+4.5,yp+5.5);
+ cairo_line_to(c,xp+6.5,yp+5.5);
+ cairo_stroke_preserve(c);
+ cairo_set_source_rgba(c,0.,1.,1.,1.);
+ }
+ else{
+ cairo_move_to(c,xp+5.5,yp+1.5);
+ cairo_line_to(c,xp+5.5,yp+3.5);
+ cairo_move_to(c,xp+4.5,yp+2.5);
+ cairo_line_to(c,xp+6.5,yp+2.5);
+ cairo_move_to(c,xp+2.5,yp+4.5);
+ cairo_line_to(c,xp+2.5,yp+6.5);
+ cairo_move_to(c,xp+1.5,yp+5.5);
+ cairo_line_to(c,xp+3.5,yp+5.5);
+ cairo_stroke_preserve(c);
+ cairo_set_source_rgba(c,0.,1.,1.,1.);
+ }
+ }break;
+ /*Double minus:*/
+ case -2:{
+ cairo_move_to(c,xp+2.5,yp+2.5);
+ cairo_line_to(c,xp+5.5,yp+2.5);
+ cairo_move_to(c,xp+2.5,yp+5.5);
+ cairo_line_to(c,xp+5.5,yp+5.5);
+ cairo_stroke_preserve(c);
+ cairo_set_source_rgba(c,1.,1.,1.,1.);
+ }break;
+ /*Plus:*/
+ case 1:{
+ if((bi&2)==0)yp-=2;
+ if((bi&1)==0)xp-=2;
+ cairo_move_to(c,xp+4.5,yp+2.5);
+ cairo_line_to(c,xp+4.5,yp+6.5);
+ cairo_move_to(c,xp+2.5,yp+4.5);
+ cairo_line_to(c,xp+6.5,yp+4.5);
+ cairo_stroke_preserve(c);
+ cairo_set_source_rgba(c,.1,1.,.3,1.);
+ break;
+ }
+ /*Fall through.*/
+ /*Minus:*/
+ case -1:{
+ cairo_move_to(c,xp+2.5,yp+4.5);
+ cairo_line_to(c,xp+6.5,yp+4.5);
+ cairo_stroke_preserve(c);
+ cairo_set_source_rgba(c,1.,.3,.1,1.);
+ }break;
+ default:continue;
+ }
+ cairo_set_line_width(c,1.);
+ cairo_stroke(c);
+ }
+ }
+ }
+ col2++;
+ if((col2>>1)>=_dec->state.nhmbs){
+ col2=0;
+ row2+=2;
+ }
+ }
+ /*Bit usage indicator[s]:*/
+ if(_dec->telemetry_bits){
+ int widths[6];
+ int fpsn;
+ int fpsd;
+ int mult;
+ int fullw;
+ int padw;
+ int i;
+ fpsn=_dec->state.info.fps_numerator;
+ fpsd=_dec->state.info.fps_denominator;
+ mult=(_dec->telemetry_bits>=0xFF?1:_dec->telemetry_bits);
+ fullw=250.f*h*fpsd*mult/fpsn;
+ padw=w-24;
+ /*Header and coded block bits.*/
+ if(_dec->telemetry_frame_bytes<0||
+ _dec->telemetry_frame_bytes==OC_LOTS_OF_BITS){
+ _dec->telemetry_frame_bytes=0;
+ }
+ if(_dec->telemetry_coding_bytes<0||
+ _dec->telemetry_coding_bytes>_dec->telemetry_frame_bytes){
+ _dec->telemetry_coding_bytes=0;
+ }
+ if(_dec->telemetry_mode_bytes<0||
+ _dec->telemetry_mode_bytes>_dec->telemetry_frame_bytes){
+ _dec->telemetry_mode_bytes=0;
+ }
+ if(_dec->telemetry_mv_bytes<0||
+ _dec->telemetry_mv_bytes>_dec->telemetry_frame_bytes){
+ _dec->telemetry_mv_bytes=0;
+ }
+ if(_dec->telemetry_qi_bytes<0||
+ _dec->telemetry_qi_bytes>_dec->telemetry_frame_bytes){
+ _dec->telemetry_qi_bytes=0;
+ }
+ if(_dec->telemetry_dc_bytes<0||
+ _dec->telemetry_dc_bytes>_dec->telemetry_frame_bytes){
+ _dec->telemetry_dc_bytes=0;
+ }
+ widths[0]=padw*
+ (_dec->telemetry_frame_bytes-_dec->telemetry_coding_bytes)/fullw;
+ widths[1]=padw*
+ (_dec->telemetry_coding_bytes-_dec->telemetry_mode_bytes)/fullw;
+ widths[2]=padw*
+ (_dec->telemetry_mode_bytes-_dec->telemetry_mv_bytes)/fullw;
+ widths[3]=padw*(_dec->telemetry_mv_bytes-_dec->telemetry_qi_bytes)/fullw;
+ widths[4]=padw*(_dec->telemetry_qi_bytes-_dec->telemetry_dc_bytes)/fullw;
+ widths[5]=padw*(_dec->telemetry_dc_bytes)/fullw;
+ for(i=0;i<6;i++)if(widths[i]>w)widths[i]=w;
+ cairo_set_source_rgba(c,.0,.0,.0,.6);
+ cairo_rectangle(c,10,h-33,widths[0]+1,5);
+ cairo_rectangle(c,10,h-29,widths[1]+1,5);
+ cairo_rectangle(c,10,h-25,widths[2]+1,5);
+ cairo_rectangle(c,10,h-21,widths[3]+1,5);
+ cairo_rectangle(c,10,h-17,widths[4]+1,5);
+ cairo_rectangle(c,10,h-13,widths[5]+1,5);
+ cairo_fill(c);
+ cairo_set_source_rgb(c,1,0,0);
+ cairo_rectangle(c,10.5,h-32.5,widths[0],4);
+ cairo_fill(c);
+ cairo_set_source_rgb(c,0,1,0);
+ cairo_rectangle(c,10.5,h-28.5,widths[1],4);
+ cairo_fill(c);
+ cairo_set_source_rgb(c,0,0,1);
+ cairo_rectangle(c,10.5,h-24.5,widths[2],4);
+ cairo_fill(c);
+ cairo_set_source_rgb(c,.6,.4,.0);
+ cairo_rectangle(c,10.5,h-20.5,widths[3],4);
+ cairo_fill(c);
+ cairo_set_source_rgb(c,.3,.3,.3);
+ cairo_rectangle(c,10.5,h-16.5,widths[4],4);
+ cairo_fill(c);
+ cairo_set_source_rgb(c,.5,.5,.8);
+ cairo_rectangle(c,10.5,h-12.5,widths[5],4);
+ cairo_fill(c);
+ }
+ /*Master qi indicator[s]:*/
+ if(_dec->telemetry_qi&0x1){
+ cairo_text_extents_t extents;
+ char buffer[10];
+ int p;
+ int y;
+ p=0;
+ y=h-7.5;
+ if(_dec->state.qis[0]>=10)buffer[p++]=48+_dec->state.qis[0]/10;
+ buffer[p++]=48+_dec->state.qis[0]%10;
+ if(_dec->state.nqis>=2){
+ buffer[p++]=' ';
+ if(_dec->state.qis[1]>=10)buffer[p++]=48+_dec->state.qis[1]/10;
+ buffer[p++]=48+_dec->state.qis[1]%10;
+ }
+ if(_dec->state.nqis==3){
+ buffer[p++]=' ';
+ if(_dec->state.qis[2]>=10)buffer[p++]=48+_dec->state.qis[2]/10;
+ buffer[p++]=48+_dec->state.qis[2]%10;
+ }
+ buffer[p++]='\0';
+ cairo_select_font_face(c,"sans",
+ CAIRO_FONT_SLANT_NORMAL,CAIRO_FONT_WEIGHT_BOLD);
+ cairo_set_font_size(c,18);
+ cairo_text_extents(c,buffer,&extents);
+ cairo_set_source_rgb(c,1,1,1);
+ cairo_move_to(c,w-extents.x_advance-10,y);
+ cairo_show_text(c,buffer);
+ cairo_set_source_rgb(c,0,0,0);
+ cairo_move_to(c,w-extents.x_advance-10,y);
+ cairo_text_path(c,buffer);
+ cairo_set_line_width(c,.8);
+ cairo_set_line_join(c,CAIRO_LINE_JOIN_ROUND);
+ cairo_stroke(c);
+ }
+ cairo_destroy(c);
+ }
+ /*Out of the Cairo plane into the telemetry YUV buffer.*/
+ _ycbcr[0].data=_dec->telemetry_frame_data;
+ _ycbcr[0].stride=_ycbcr[0].width;
+ _ycbcr[1].data=_ycbcr[0].data+h*_ycbcr[0].stride;
+ _ycbcr[1].stride=_ycbcr[1].width;
+ _ycbcr[2].data=_ycbcr[1].data+(h>>vdec)*_ycbcr[1].stride;
+ _ycbcr[2].stride=_ycbcr[2].width;
+ y_row=_ycbcr[0].data;
+ u_row=_ycbcr[1].data;
+ v_row=_ycbcr[2].data;
+ rgb_row=data;
+ /*This is one of the few places it's worth handling chroma on a
+ case-by-case basis.*/
+ switch(_dec->state.info.pixel_fmt){
+ case TH_PF_420:{
+ for(y=0;y<h;y+=2){
+ unsigned char *y_row2;
+ unsigned char *rgb_row2;
+ y_row2=y_row+_ycbcr[0].stride;
+ rgb_row2=rgb_row+cstride;
+ for(x=0;x<w;x+=2){
+ int y;
+ int u;
+ int v;
+ y=(65481*rgb_row[4*x+2]+128553*rgb_row[4*x+1]
+ +24966*rgb_row[4*x+0]+4207500)/255000;
+ y_row[x]=OC_CLAMP255(y);
+ y=(65481*rgb_row[4*x+6]+128553*rgb_row[4*x+5]
+ +24966*rgb_row[4*x+4]+4207500)/255000;
+ y_row[x+1]=OC_CLAMP255(y);
+ y=(65481*rgb_row2[4*x+2]+128553*rgb_row2[4*x+1]
+ +24966*rgb_row2[4*x+0]+4207500)/255000;
+ y_row2[x]=OC_CLAMP255(y);
+ y=(65481*rgb_row2[4*x+6]+128553*rgb_row2[4*x+5]
+ +24966*rgb_row2[4*x+4]+4207500)/255000;
+ y_row2[x+1]=OC_CLAMP255(y);
+ u=(-8372*(rgb_row[4*x+2]+rgb_row[4*x+6]
+ +rgb_row2[4*x+2]+rgb_row2[4*x+6])
+ -16436*(rgb_row[4*x+1]+rgb_row[4*x+5]
+ +rgb_row2[4*x+1]+rgb_row2[4*x+5])
+ +24808*(rgb_row[4*x+0]+rgb_row[4*x+4]
+ +rgb_row2[4*x+0]+rgb_row2[4*x+4])+29032005)/225930;
+ v=(39256*(rgb_row[4*x+2]+rgb_row[4*x+6]
+ +rgb_row2[4*x+2]+rgb_row2[4*x+6])
+ -32872*(rgb_row[4*x+1]+rgb_row[4*x+5]
+ +rgb_row2[4*x+1]+rgb_row2[4*x+5])
+ -6384*(rgb_row[4*x+0]+rgb_row[4*x+4]
+ +rgb_row2[4*x+0]+rgb_row2[4*x+4])+45940035)/357510;
+ u_row[x>>1]=OC_CLAMP255(u);
+ v_row[x>>1]=OC_CLAMP255(v);
+ }
+ y_row+=_ycbcr[0].stride<<1;
+ u_row+=_ycbcr[1].stride;
+ v_row+=_ycbcr[2].stride;
+ rgb_row+=cstride<<1;
+ }
+ }break;
+ case TH_PF_422:{
+ for(y=0;y<h;y++){
+ for(x=0;x<w;x+=2){
+ int y;
+ int u;
+ int v;
+ y=(65481*rgb_row[4*x+2]+128553*rgb_row[4*x+1]
+ +24966*rgb_row[4*x+0]+4207500)/255000;
+ y_row[x]=OC_CLAMP255(y);
+ y=(65481*rgb_row[4*x+6]+128553*rgb_row[4*x+5]
+ +24966*rgb_row[4*x+4]+4207500)/255000;
+ y_row[x+1]=OC_CLAMP255(y);
+ u=(-16744*(rgb_row[4*x+2]+rgb_row[4*x+6])
+ -32872*(rgb_row[4*x+1]+rgb_row[4*x+5])
+ +49616*(rgb_row[4*x+0]+rgb_row[4*x+4])+29032005)/225930;
+ v=(78512*(rgb_row[4*x+2]+rgb_row[4*x+6])
+ -65744*(rgb_row[4*x+1]+rgb_row[4*x+5])
+ -12768*(rgb_row[4*x+0]+rgb_row[4*x+4])+45940035)/357510;
+ u_row[x>>1]=OC_CLAMP255(u);
+ v_row[x>>1]=OC_CLAMP255(v);
+ }
+ y_row+=_ycbcr[0].stride;
+ u_row+=_ycbcr[1].stride;
+ v_row+=_ycbcr[2].stride;
+ rgb_row+=cstride;
+ }
+ }break;
+ /*case TH_PF_444:*/
+ default:{
+ for(y=0;y<h;y++){
+ for(x=0;x<w;x++){
+ int y;
+ int u;
+ int v;
+ y=(65481*rgb_row[4*x+2]+128553*rgb_row[4*x+1]
+ +24966*rgb_row[4*x+0]+4207500)/255000;
+ u=(-33488*rgb_row[4*x+2]-65744*rgb_row[4*x+1]
+ +99232*rgb_row[4*x+0]+29032005)/225930;
+ v=(157024*rgb_row[4*x+2]-131488*rgb_row[4*x+1]
+ -25536*rgb_row[4*x+0]+45940035)/357510;
+ y_row[x]=OC_CLAMP255(y);
+ u_row[x]=OC_CLAMP255(u);
+ v_row[x]=OC_CLAMP255(v);
+ }
+ y_row+=_ycbcr[0].stride;
+ u_row+=_ycbcr[1].stride;
+ v_row+=_ycbcr[2].stride;
+ rgb_row+=cstride;
+ }
+ }break;
+ }
+ /*Finished.
+ Destroy the surface.*/
+ cairo_surface_destroy(cs);
+}
+#endif
+
int th_decode_packetin(th_dec_ctx *_dec,const ogg_packet *_op,
ogg_int64_t *_granpos){
int ret;
@@ -2121,6 +2777,15 @@ int th_decode_packetin(th_dec_ctx *_dec,const ogg_packet *_op,
int pli;
int notstart;
int notdone;
+#ifdef HAVE_CAIRO
+ int telemetry;
+ /*Save the current telemetry state.
+ This prevents it from being modified in the middle of decoding this
+ frame, which could cause us to skip calls to the striped decoding
+ callback.*/
+ telemetry=_dec->telemetry_mbmode||_dec->telemetry_mv||
+ _dec->telemetry_qi||_dec->telemetry_bits;
+#endif
/*Select a free buffer to use for the reconstructed version of this frame.*/
for(refi=0;refi==_dec->state.ref_frame_idx[OC_FRAME_GOLD]||
refi==_dec->state.ref_frame_idx[OC_FRAME_PREV];refi++);
@@ -2258,7 +2923,11 @@ int th_decode_packetin(th_dec_ctx *_dec,const ogg_packet *_op,
avail_fragy_end=OC_MINI(avail_fragy_end,
_dec->pipe.fragy_end[pli]-edelay<<frag_shift);
}
+#ifdef HAVE_CAIRO
+ if(_dec->stripe_cb.stripe_decoded!=NULL&&!telemetry){
+#else
if(_dec->stripe_cb.stripe_decoded!=NULL){
+#endif
/*The callback might want to use the FPU, so let's make sure they can.
We violate all kinds of ABI restrictions by not doing this until
now, but none of them actually matter since we don't use floating
@@ -2294,6 +2963,20 @@ int th_decode_packetin(th_dec_ctx *_dec,const ogg_packet *_op,
/*Restore the FPU before dump_frame, since that _does_ use the FPU (for PNG
gamma values, if nothing else).*/
oc_restore_fpu(&_dec->state);
+#ifdef HAVE_CAIRO
+ /*If telemetry ioctls are active, we need to draw to the output buffer.*/
+ if(telemetry){
+ oc_render_telemetry(_dec,stripe_buf,telemetry);
+ oc_ycbcr_buffer_flip(_dec->pp_frame_buf,stripe_buf);
+ /*If we had a striped decoding callback, we skipped calling it above
+ (because the telemetry wasn't rendered yet).
+ Call it now with the whole frame.*/
+ if(_dec->stripe_cb.stripe_decoded!=NULL){
+ (*_dec->stripe_cb.stripe_decoded)(_dec->stripe_cb.ctx,
+ stripe_buf,0,_dec->state.fplanes[0].nvfrags);
+ }
+ }
+#endif
#if defined(OC_DUMP_IMAGES)
/*We only dump images if there were some coded blocks.*/
oc_state_dump_frame(&_dec->state,OC_FRAME_SELF,"dec");
@@ -2305,659 +2988,5 @@ int th_decode_packetin(th_dec_ctx *_dec,const ogg_packet *_op,
int th_decode_ycbcr_out(th_dec_ctx *_dec,th_ycbcr_buffer _ycbcr){
if(_dec==NULL||_ycbcr==NULL)return TH_EFAULT;
oc_ycbcr_buffer_flip(_ycbcr,_dec->pp_frame_buf);
-#if defined(HAVE_CAIRO)
- /*If telemetry ioctls are active, we need to draw to the output buffer.
- Stuff the plane into cairo.*/
- if(_dec->telemetry){
- cairo_surface_t *cs;
- unsigned char *data;
- unsigned char *y_row;
- unsigned char *u_row;
- unsigned char *v_row;
- unsigned char *rgb_row;
- int cstride;
- int w;
- int h;
- int x;
- int y;
- int hdec;
- int vdec;
- w=_ycbcr[0].width;
- h=_ycbcr[0].height;
- hdec=!(_dec->state.info.pixel_fmt&1);
- vdec=!(_dec->state.info.pixel_fmt&2);
- /*Lazy data buffer init.
- We could try to re-use the post-processing buffer, which would save
- memory, but complicate the allocation logic there.
- I don't think anyone cares about memory usage when using telemetry; it is
- not meant for embedded devices.*/
- if(_dec->telemetry_frame_data==NULL){
- _dec->telemetry_frame_data=_ogg_malloc(
- (w*h+2*(w>>hdec)*(h>>vdec))*sizeof(*_dec->telemetry_frame_data));
- if(_dec->telemetry_frame_data==NULL)return 0;
- }
- cs=cairo_image_surface_create(CAIRO_FORMAT_RGB24,w,h);
- /*Sadly, no YUV support in Cairo (yet); convert into the RGB buffer.*/
- data=cairo_image_surface_get_data(cs);
- if(data==NULL){
- cairo_surface_destroy(cs);
- return 0;
- }
- cstride=cairo_image_surface_get_stride(cs);
- y_row=_ycbcr[0].data;
- u_row=_ycbcr[1].data;
- v_row=_ycbcr[2].data;
- rgb_row=data;
- for(y=0;y<h;y++){
- for(x=0;x<w;x++){
- int r;
- int g;
- int b;
- r=(1904000*y_row[x]+2609823*v_row[x>>hdec]-363703744)/1635200;
- g=(3827562*y_row[x]-1287801*u_row[x>>hdec]
- -2672387*v_row[x>>hdec]+447306710)/3287200;
- b=(952000*y_row[x]+1649289*u_row[x>>hdec]-225932192)/817600;
- rgb_row[4*x+0]=OC_CLAMP255(b);
- rgb_row[4*x+1]=OC_CLAMP255(g);
- rgb_row[4*x+2]=OC_CLAMP255(r);
- }
- y_row+=_ycbcr[0].stride;
- u_row+=_ycbcr[1].stride&-((y&1)|!vdec);
- v_row+=_ycbcr[2].stride&-((y&1)|!vdec);
- rgb_row+=cstride;
- }
- /*Draw coded identifier for each macroblock (stored in Hilbert order).*/
- {
- cairo_t *c;
- const oc_fragment *frags;
- oc_mv *frag_mvs;
- const signed char *mb_modes;
- oc_mb_map *mb_maps;
- size_t nmbs;
- size_t mbi;
- int row2;
- int col2;
- int qim[3]={0,0,0};
- if(_dec->state.nqis==2){
- int bqi;
- bqi=_dec->state.qis[0];
- if(_dec->state.qis[1]>bqi)qim[1]=1;
- if(_dec->state.qis[1]<bqi)qim[1]=-1;
- }
- if(_dec->state.nqis==3){
- int bqi;
- int cqi;
- int dqi;
- bqi=_dec->state.qis[0];
- cqi=_dec->state.qis[1];
- dqi=_dec->state.qis[2];
- if(cqi>bqi&&dqi>bqi){
- if(dqi>cqi){
- qim[1]=1;
- qim[2]=2;
- }
- else{
- qim[1]=2;
- qim[2]=1;
- }
- }
- else if(cqi<bqi&&dqi<bqi){
- if(dqi<cqi){
- qim[1]=-1;
- qim[2]=-2;
- }
- else{
- qim[1]=-2;
- qim[2]=-1;
- }
- }
- else{
- if(cqi<bqi)qim[1]=-1;
- else qim[1]=1;
- if(dqi<bqi)qim[2]=-1;
- else qim[2]=1;
- }
- }
- c=cairo_create(cs);
- frags=_dec->state.frags;
- frag_mvs=_dec->state.frag_mvs;
- mb_modes=_dec->state.mb_modes;
- mb_maps=_dec->state.mb_maps;
- nmbs=_dec->state.nmbs;
- row2=0;
- col2=0;
- for(mbi=0;mbi<nmbs;mbi++){
- float x;
- float y;
- int bi;
- y=h-(row2+((col2+1>>1)&1))*16-16;
- x=(col2>>1)*16;
- cairo_set_line_width(c,1.);
- /*Keyframe (all intra) red box.*/
- if(_dec->state.frame_type==OC_INTRA_FRAME){
- if(_dec->telemetry_mbmode&0x02){
- cairo_set_source_rgba(c,1.,0,0,.5);
- cairo_rectangle(c,x+2.5,y+2.5,11,11);
- cairo_stroke_preserve(c);
- cairo_set_source_rgba(c,1.,0,0,.25);
- cairo_fill(c);
- }
- }
- else{
- ptrdiff_t fragi;
- int frag_mvx;
- int frag_mvy;
- for(bi=0;bi<4;bi++){
- fragi=mb_maps[mbi][0][bi];
- if(fragi>=0&&frags[fragi].coded){
- frag_mvx=OC_MV_X(frag_mvs[fragi]);
- frag_mvy=OC_MV_Y(frag_mvs[fragi]);
- break;
- }
- }
- if(bi<4){
- switch(mb_modes[mbi]){
- case OC_MODE_INTRA:{
- if(_dec->telemetry_mbmode&0x02){
- cairo_set_source_rgba(c,1.,0,0,.5);
- cairo_rectangle(c,x+2.5,y+2.5,11,11);
- cairo_stroke_preserve(c);
- cairo_set_source_rgba(c,1.,0,0,.25);
- cairo_fill(c);
- }
- }break;
- case OC_MODE_INTER_NOMV:{
- if(_dec->telemetry_mbmode&0x01){
- cairo_set_source_rgba(c,0,0,1.,.5);
- cairo_rectangle(c,x+2.5,y+2.5,11,11);
- cairo_stroke_preserve(c);
- cairo_set_source_rgba(c,0,0,1.,.25);
- cairo_fill(c);
- }
- }break;
- case OC_MODE_INTER_MV:{
- if(_dec->telemetry_mbmode&0x04){
- cairo_rectangle(c,x+2.5,y+2.5,11,11);
- cairo_set_source_rgba(c,0,1.,0,.5);
- cairo_stroke(c);
- }
- if(_dec->telemetry_mv&0x04){
- cairo_move_to(c,x+8+frag_mvx,y+8-frag_mvy);
- cairo_set_source_rgba(c,1.,1.,1.,.9);
- cairo_set_line_width(c,3.);
- cairo_line_to(c,x+8+frag_mvx*.66,y+8-frag_mvy*.66);
- cairo_stroke_preserve(c);
- cairo_set_line_width(c,2.);
- cairo_line_to(c,x+8+frag_mvx*.33,y+8-frag_mvy*.33);
- cairo_stroke_preserve(c);
- cairo_set_line_width(c,1.);
- cairo_line_to(c,x+8,y+8);
- cairo_stroke(c);
- }
- }break;
- case OC_MODE_INTER_MV_LAST:{
- if(_dec->telemetry_mbmode&0x08){
- cairo_rectangle(c,x+2.5,y+2.5,11,11);
- cairo_set_source_rgba(c,0,1.,0,.5);
- cairo_move_to(c,x+13.5,y+2.5);
- cairo_line_to(c,x+2.5,y+8);
- cairo_line_to(c,x+13.5,y+13.5);
- cairo_stroke(c);
- }
- if(_dec->telemetry_mv&0x08){
- cairo_move_to(c,x+8+frag_mvx,y+8-frag_mvy);
- cairo_set_source_rgba(c,1.,1.,1.,.9);
- cairo_set_line_width(c,3.);
- cairo_line_to(c,x+8+frag_mvx*.66,y+8-frag_mvy*.66);
- cairo_stroke_preserve(c);
- cairo_set_line_width(c,2.);
- cairo_line_to(c,x+8+frag_mvx*.33,y+8-frag_mvy*.33);
- cairo_stroke_preserve(c);
- cairo_set_line_width(c,1.);
- cairo_line_to(c,x+8,y+8);
- cairo_stroke(c);
- }
- }break;
- case OC_MODE_INTER_MV_LAST2:{
- if(_dec->telemetry_mbmode&0x10){
- cairo_rectangle(c,x+2.5,y+2.5,11,11);
- cairo_set_source_rgba(c,0,1.,0,.5);
- cairo_move_to(c,x+8,y+2.5);
- cairo_line_to(c,x+2.5,y+8);
- cairo_line_to(c,x+8,y+13.5);
- cairo_move_to(c,x+13.5,y+2.5);
- cairo_line_to(c,x+8,y+8);
- cairo_line_to(c,x+13.5,y+13.5);
- cairo_stroke(c);
- }
- if(_dec->telemetry_mv&0x10){
- cairo_move_to(c,x+8+frag_mvx,y+8-frag_mvy);
- cairo_set_source_rgba(c,1.,1.,1.,.9);
- cairo_set_line_width(c,3.);
- cairo_line_to(c,x+8+frag_mvx*.66,y+8-frag_mvy*.66);
- cairo_stroke_preserve(c);
- cairo_set_line_width(c,2.);
- cairo_line_to(c,x+8+frag_mvx*.33,y+8-frag_mvy*.33);
- cairo_stroke_preserve(c);
- cairo_set_line_width(c,1.);
- cairo_line_to(c,x+8,y+8);
- cairo_stroke(c);
- }
- }break;
- case OC_MODE_GOLDEN_NOMV:{
- if(_dec->telemetry_mbmode&0x20){
- cairo_set_source_rgba(c,1.,1.,0,.5);
- cairo_rectangle(c,x+2.5,y+2.5,11,11);
- cairo_stroke_preserve(c);
- cairo_set_source_rgba(c,1.,1.,0,.25);
- cairo_fill(c);
- }
- }break;
- case OC_MODE_GOLDEN_MV:{
- if(_dec->telemetry_mbmode&0x40){
- cairo_rectangle(c,x+2.5,y+2.5,11,11);
- cairo_set_source_rgba(c,1.,1.,0,.5);
- cairo_stroke(c);
- }
- if(_dec->telemetry_mv&0x40){
- cairo_move_to(c,x+8+frag_mvx,y+8-frag_mvy);
- cairo_set_source_rgba(c,1.,1.,1.,.9);
- cairo_set_line_width(c,3.);
- cairo_line_to(c,x+8+frag_mvx*.66,y+8-frag_mvy*.66);
- cairo_stroke_preserve(c);
- cairo_set_line_width(c,2.);
- cairo_line_to(c,x+8+frag_mvx*.33,y+8-frag_mvy*.33);
- cairo_stroke_preserve(c);
- cairo_set_line_width(c,1.);
- cairo_line_to(c,x+8,y+8);
- cairo_stroke(c);
- }
- }break;
- case OC_MODE_INTER_MV_FOUR:{
- if(_dec->telemetry_mbmode&0x80){
- cairo_rectangle(c,x+2.5,y+2.5,4,4);
- cairo_rectangle(c,x+9.5,y+2.5,4,4);
- cairo_rectangle(c,x+2.5,y+9.5,4,4);
- cairo_rectangle(c,x+9.5,y+9.5,4,4);
- cairo_set_source_rgba(c,0,1.,0,.5);
- cairo_stroke(c);
- }
- /*4mv is odd, coded in raster order.*/
- fragi=mb_maps[mbi][0][0];
- if(frags[fragi].coded&&_dec->telemetry_mv&0x80){
- frag_mvx=OC_MV_X(frag_mvs[fragi]);
- frag_mvx=OC_MV_Y(frag_mvs[fragi]);
- cairo_move_to(c,x+4+frag_mvx,y+12-frag_mvy);
- cairo_set_source_rgba(c,1.,1.,1.,.9);
- cairo_set_line_width(c,3.);
- cairo_line_to(c,x+4+frag_mvx*.66,y+12-frag_mvy*.66);
- cairo_stroke_preserve(c);
- cairo_set_line_width(c,2.);
- cairo_line_to(c,x+4+frag_mvx*.33,y+12-frag_mvy*.33);
- cairo_stroke_preserve(c);
- cairo_set_line_width(c,1.);
- cairo_line_to(c,x+4,y+12);
- cairo_stroke(c);
- }
- fragi=mb_maps[mbi][0][1];
- if(frags[fragi].coded&&_dec->telemetry_mv&0x80){
- frag_mvx=OC_MV_X(frag_mvs[fragi]);
- frag_mvx=OC_MV_Y(frag_mvs[fragi]);
- cairo_move_to(c,x+12+frag_mvx,y+12-frag_mvy);
- cairo_set_source_rgba(c,1.,1.,1.,.9);
- cairo_set_line_width(c,3.);
- cairo_line_to(c,x+12+frag_mvx*.66,y+12-frag_mvy*.66);
- cairo_stroke_preserve(c);
- cairo_set_line_width(c,2.);
- cairo_line_to(c,x+12+frag_mvx*.33,y+12-frag_mvy*.33);
- cairo_stroke_preserve(c);
- cairo_set_line_width(c,1.);
- cairo_line_to(c,x+12,y+12);
- cairo_stroke(c);
- }
- fragi=mb_maps[mbi][0][2];
- if(frags[fragi].coded&&_dec->telemetry_mv&0x80){
- frag_mvx=OC_MV_X(frag_mvs[fragi]);
- frag_mvx=OC_MV_Y(frag_mvs[fragi]);
- cairo_move_to(c,x+4+frag_mvx,y+4-frag_mvy);
- cairo_set_source_rgba(c,1.,1.,1.,.9);
- cairo_set_line_width(c,3.);
- cairo_line_to(c,x+4+frag_mvx*.66,y+4-frag_mvy*.66);
- cairo_stroke_preserve(c);
- cairo_set_line_width(c,2.);
- cairo_line_to(c,x+4+frag_mvx*.33,y+4-frag_mvy*.33);
- cairo_stroke_preserve(c);
- cairo_set_line_width(c,1.);
- cairo_line_to(c,x+4,y+4);
- cairo_stroke(c);
- }
- fragi=mb_maps[mbi][0][3];
- if(frags[fragi].coded&&_dec->telemetry_mv&0x80){
- frag_mvx=OC_MV_X(frag_mvs[fragi]);
- frag_mvx=OC_MV_Y(frag_mvs[fragi]);
- cairo_move_to(c,x+12+frag_mvx,y+4-frag_mvy);
- cairo_set_source_rgba(c,1.,1.,1.,.9);
- cairo_set_line_width(c,3.);
- cairo_line_to(c,x+12+frag_mvx*.66,y+4-frag_mvy*.66);
- cairo_stroke_preserve(c);
- cairo_set_line_width(c,2.);
- cairo_line_to(c,x+12+frag_mvx*.33,y+4-frag_mvy*.33);
- cairo_stroke_preserve(c);
- cairo_set_line_width(c,1.);
- cairo_line_to(c,x+12,y+4);
- cairo_stroke(c);
- }
- }break;
- }
- }
- }
- /*qii illustration.*/
- if(_dec->telemetry_qi&0x2){
- cairo_set_line_cap(c,CAIRO_LINE_CAP_SQUARE);
- for(bi=0;bi<4;bi++){
- ptrdiff_t fragi;
- int qiv;
- int xp;
- int yp;
- xp=x+(bi&1)*8;
- yp=y+8-(bi&2)*4;
- fragi=mb_maps[mbi][0][bi];
- if(fragi>=0&&frags[fragi].coded){
- qiv=qim[frags[fragi].qii];
- cairo_set_line_width(c,3.);
- cairo_set_source_rgba(c,0.,0.,0.,.5);
- switch(qiv){
- /*Double plus:*/
- case 2:{
- if((bi&1)^((bi&2)>>1)){
- cairo_move_to(c,xp+2.5,yp+1.5);
- cairo_line_to(c,xp+2.5,yp+3.5);
- cairo_move_to(c,xp+1.5,yp+2.5);
- cairo_line_to(c,xp+3.5,yp+2.5);
- cairo_move_to(c,xp+5.5,yp+4.5);
- cairo_line_to(c,xp+5.5,yp+6.5);
- cairo_move_to(c,xp+4.5,yp+5.5);
- cairo_line_to(c,xp+6.5,yp+5.5);
- cairo_stroke_preserve(c);
- cairo_set_source_rgba(c,0.,1.,1.,1.);
- }
- else{
- cairo_move_to(c,xp+5.5,yp+1.5);
- cairo_line_to(c,xp+5.5,yp+3.5);
- cairo_move_to(c,xp+4.5,yp+2.5);
- cairo_line_to(c,xp+6.5,yp+2.5);
- cairo_move_to(c,xp+2.5,yp+4.5);
- cairo_line_to(c,xp+2.5,yp+6.5);
- cairo_move_to(c,xp+1.5,yp+5.5);
- cairo_line_to(c,xp+3.5,yp+5.5);
- cairo_stroke_preserve(c);
- cairo_set_source_rgba(c,0.,1.,1.,1.);
- }
- }break;
- /*Double minus:*/
- case -2:{
- cairo_move_to(c,xp+2.5,yp+2.5);
- cairo_line_to(c,xp+5.5,yp+2.5);
- cairo_move_to(c,xp+2.5,yp+5.5);
- cairo_line_to(c,xp+5.5,yp+5.5);
- cairo_stroke_preserve(c);
- cairo_set_source_rgba(c,1.,1.,1.,1.);
- }break;
- /*Plus:*/
- case 1:{
- if(bi&2==0)yp-=2;
- if(bi&1==0)xp-=2;
- cairo_move_to(c,xp+4.5,yp+2.5);
- cairo_line_to(c,xp+4.5,yp+6.5);
- cairo_move_to(c,xp+2.5,yp+4.5);
- cairo_line_to(c,xp+6.5,yp+4.5);
- cairo_stroke_preserve(c);
- cairo_set_source_rgba(c,.1,1.,.3,1.);
- break;
- }
- /*Fall through.*/
- /*Minus:*/
- case -1:{
- cairo_move_to(c,xp+2.5,yp+4.5);
- cairo_line_to(c,xp+6.5,yp+4.5);
- cairo_stroke_preserve(c);
- cairo_set_source_rgba(c,1.,.3,.1,1.);
- }break;
- default:continue;
- }
- cairo_set_line_width(c,1.);
- cairo_stroke(c);
- }
- }
- }
- col2++;
- if((col2>>1)>=_dec->state.nhmbs){
- col2=0;
- row2+=2;
- }
- }
- /*Bit usage indicator[s]:*/
- if(_dec->telemetry_bits){
- int widths[6];
- int fpsn;
- int fpsd;
- int mult;
- int fullw;
- int padw;
- int i;
- fpsn=_dec->state.info.fps_numerator;
- fpsd=_dec->state.info.fps_denominator;
- mult=(_dec->telemetry_bits>=0xFF?1:_dec->telemetry_bits);
- fullw=250.f*h*fpsd*mult/fpsn;
- padw=w-24;
- /*Header and coded block bits.*/
- if(_dec->telemetry_frame_bytes<0||
- _dec->telemetry_frame_bytes==OC_LOTS_OF_BITS){
- _dec->telemetry_frame_bytes=0;
- }
- if(_dec->telemetry_coding_bytes<0||
- _dec->telemetry_coding_bytes>_dec->telemetry_frame_bytes){
- _dec->telemetry_coding_bytes=0;
- }
- if(_dec->telemetry_mode_bytes<0||
- _dec->telemetry_mode_bytes>_dec->telemetry_frame_bytes){
- _dec->telemetry_mode_bytes=0;
- }
- if(_dec->telemetry_mv_bytes<0||
- _dec->telemetry_mv_bytes>_dec->telemetry_frame_bytes){
- _dec->telemetry_mv_bytes=0;
- }
- if(_dec->telemetry_qi_bytes<0||
- _dec->telemetry_qi_bytes>_dec->telemetry_frame_bytes){
- _dec->telemetry_qi_bytes=0;
- }
- if(_dec->telemetry_dc_bytes<0||
- _dec->telemetry_dc_bytes>_dec->telemetry_frame_bytes){
- _dec->telemetry_dc_bytes=0;
- }
- widths[0]=padw*(_dec->telemetry_frame_bytes-_dec->telemetry_coding_bytes)/fullw;
- widths[1]=padw*(_dec->telemetry_coding_bytes-_dec->telemetry_mode_bytes)/fullw;
- widths[2]=padw*(_dec->telemetry_mode_bytes-_dec->telemetry_mv_bytes)/fullw;
- widths[3]=padw*(_dec->telemetry_mv_bytes-_dec->telemetry_qi_bytes)/fullw;
- widths[4]=padw*(_dec->telemetry_qi_bytes-_dec->telemetry_dc_bytes)/fullw;
- widths[5]=padw*(_dec->telemetry_dc_bytes)/fullw;
- for(i=0;i<6;i++)if(widths[i]>w)widths[i]=w;
- cairo_set_source_rgba(c,.0,.0,.0,.6);
- cairo_rectangle(c,10,h-33,widths[0]+1,5);
- cairo_rectangle(c,10,h-29,widths[1]+1,5);
- cairo_rectangle(c,10,h-25,widths[2]+1,5);
- cairo_rectangle(c,10,h-21,widths[3]+1,5);
- cairo_rectangle(c,10,h-17,widths[4]+1,5);
- cairo_rectangle(c,10,h-13,widths[5]+1,5);
- cairo_fill(c);
- cairo_set_source_rgb(c,1,0,0);
- cairo_rectangle(c,10.5,h-32.5,widths[0],4);
- cairo_fill(c);
- cairo_set_source_rgb(c,0,1,0);
- cairo_rectangle(c,10.5,h-28.5,widths[1],4);
- cairo_fill(c);
- cairo_set_source_rgb(c,0,0,1);
- cairo_rectangle(c,10.5,h-24.5,widths[2],4);
- cairo_fill(c);
- cairo_set_source_rgb(c,.6,.4,.0);
- cairo_rectangle(c,10.5,h-20.5,widths[3],4);
- cairo_fill(c);
- cairo_set_source_rgb(c,.3,.3,.3);
- cairo_rectangle(c,10.5,h-16.5,widths[4],4);
- cairo_fill(c);
- cairo_set_source_rgb(c,.5,.5,.8);
- cairo_rectangle(c,10.5,h-12.5,widths[5],4);
- cairo_fill(c);
- }
- /*Master qi indicator[s]:*/
- if(_dec->telemetry_qi&0x1){
- cairo_text_extents_t extents;
- char buffer[10];
- int p;
- int y;
- p=0;
- y=h-7.5;
- if(_dec->state.qis[0]>=10)buffer[p++]=48+_dec->state.qis[0]/10;
- buffer[p++]=48+_dec->state.qis[0]%10;
- if(_dec->state.nqis>=2){
- buffer[p++]=' ';
- if(_dec->state.qis[1]>=10)buffer[p++]=48+_dec->state.qis[1]/10;
- buffer[p++]=48+_dec->state.qis[1]%10;
- }
- if(_dec->state.nqis==3){
- buffer[p++]=' ';
- if(_dec->state.qis[2]>=10)buffer[p++]=48+_dec->state.qis[2]/10;
- buffer[p++]=48+_dec->state.qis[2]%10;
- }
- buffer[p++]='\0';
- cairo_select_font_face(c,"sans",
- CAIRO_FONT_SLANT_NORMAL,CAIRO_FONT_WEIGHT_BOLD);
- cairo_set_font_size(c,18);
- cairo_text_extents(c,buffer,&extents);
- cairo_set_source_rgb(c,1,1,1);
- cairo_move_to(c,w-extents.x_advance-10,y);
- cairo_show_text(c,buffer);
- cairo_set_source_rgb(c,0,0,0);
- cairo_move_to(c,w-extents.x_advance-10,y);
- cairo_text_path(c,buffer);
- cairo_set_line_width(c,.8);
- cairo_set_line_join(c,CAIRO_LINE_JOIN_ROUND);
- cairo_stroke(c);
- }
- cairo_destroy(c);
- }
- /*Out of the Cairo plane into the telemetry YUV buffer.*/
- _ycbcr[0].data=_dec->telemetry_frame_data;
- _ycbcr[0].stride=_ycbcr[0].width;
- _ycbcr[1].data=_ycbcr[0].data+h*_ycbcr[0].stride;
- _ycbcr[1].stride=_ycbcr[1].width;
- _ycbcr[2].data=_ycbcr[1].data+(h>>vdec)*_ycbcr[1].stride;
- _ycbcr[2].stride=_ycbcr[2].width;
- y_row=_ycbcr[0].data;
- u_row=_ycbcr[1].data;
- v_row=_ycbcr[2].data;
- rgb_row=data;
- /*This is one of the few places it's worth handling chroma on a
- case-by-case basis.*/
- switch(_dec->state.info.pixel_fmt){
- case TH_PF_420:{
- for(y=0;y<h;y+=2){
- unsigned char *y_row2;
- unsigned char *rgb_row2;
- y_row2=y_row+_ycbcr[0].stride;
- rgb_row2=rgb_row+cstride;
- for(x=0;x<w;x+=2){
- int y;
- int u;
- int v;
- y=(65481*rgb_row[4*x+2]+128553*rgb_row[4*x+1]
- +24966*rgb_row[4*x+0]+4207500)/255000;
- y_row[x]=OC_CLAMP255(y);
- y=(65481*rgb_row[4*x+6]+128553*rgb_row[4*x+5]
- +24966*rgb_row[4*x+4]+4207500)/255000;
- y_row[x+1]=OC_CLAMP255(y);
- y=(65481*rgb_row2[4*x+2]+128553*rgb_row2[4*x+1]
- +24966*rgb_row2[4*x+0]+4207500)/255000;
- y_row2[x]=OC_CLAMP255(y);
- y=(65481*rgb_row2[4*x+6]+128553*rgb_row2[4*x+5]
- +24966*rgb_row2[4*x+4]+4207500)/255000;
- y_row2[x+1]=OC_CLAMP255(y);
- u=(-8372*(rgb_row[4*x+2]+rgb_row[4*x+6]
- +rgb_row2[4*x+2]+rgb_row2[4*x+6])
- -16436*(rgb_row[4*x+1]+rgb_row[4*x+5]
- +rgb_row2[4*x+1]+rgb_row2[4*x+5])
- +24808*(rgb_row[4*x+0]+rgb_row[4*x+4]
- +rgb_row2[4*x+0]+rgb_row2[4*x+4])+29032005)/225930;
- v=(39256*(rgb_row[4*x+2]+rgb_row[4*x+6]
- +rgb_row2[4*x+2]+rgb_row2[4*x+6])
- -32872*(rgb_row[4*x+1]+rgb_row[4*x+5]
- +rgb_row2[4*x+1]+rgb_row2[4*x+5])
- -6384*(rgb_row[4*x+0]+rgb_row[4*x+4]
- +rgb_row2[4*x+0]+rgb_row2[4*x+4])+45940035)/357510;
- u_row[x>>1]=OC_CLAMP255(u);
- v_row[x>>1]=OC_CLAMP255(v);
- }
- y_row+=_ycbcr[0].stride<<1;
- u_row+=_ycbcr[1].stride;
- v_row+=_ycbcr[2].stride;
- rgb_row+=cstride<<1;
- }
- }break;
- case TH_PF_422:{
- for(y=0;y<h;y++){
- for(x=0;x<w;x+=2){
- int y;
- int u;
- int v;
- y=(65481*rgb_row[4*x+2]+128553*rgb_row[4*x+1]
- +24966*rgb_row[4*x+0]+4207500)/255000;
- y_row[x]=OC_CLAMP255(y);
- y=(65481*rgb_row[4*x+6]+128553*rgb_row[4*x+5]
- +24966*rgb_row[4*x+4]+4207500)/255000;
- y_row[x+1]=OC_CLAMP255(y);
- u=(-16744*(rgb_row[4*x+2]+rgb_row[4*x+6])
- -32872*(rgb_row[4*x+1]+rgb_row[4*x+5])
- +49616*(rgb_row[4*x+0]+rgb_row[4*x+4])+29032005)/225930;
- v=(78512*(rgb_row[4*x+2]+rgb_row[4*x+6])
- -65744*(rgb_row[4*x+1]+rgb_row[4*x+5])
- -12768*(rgb_row[4*x+0]+rgb_row[4*x+4])+45940035)/357510;
- u_row[x>>1]=OC_CLAMP255(u);
- v_row[x>>1]=OC_CLAMP255(v);
- }
- y_row+=_ycbcr[0].stride;
- u_row+=_ycbcr[1].stride;
- v_row+=_ycbcr[2].stride;
- rgb_row+=cstride;
- }
- }break;
- /*case TH_PF_444:*/
- default:{
- for(y=0;y<h;y++){
- for(x=0;x<w;x++){
- int y;
- int u;
- int v;
- y=(65481*rgb_row[4*x+2]+128553*rgb_row[4*x+1]
- +24966*rgb_row[4*x+0]+4207500)/255000;
- u=(-33488*rgb_row[4*x+2]-65744*rgb_row[4*x+1]
- +99232*rgb_row[4*x+0]+29032005)/225930;
- v=(157024*rgb_row[4*x+2]-131488*rgb_row[4*x+1]
- -25536*rgb_row[4*x+0]+45940035)/357510;
- y_row[x]=OC_CLAMP255(y);
- u_row[x]=OC_CLAMP255(u);
- v_row[x]=OC_CLAMP255(v);
- }
- y_row+=_ycbcr[0].stride;
- u_row+=_ycbcr[1].stride;
- v_row+=_ycbcr[2].stride;
- rgb_row+=cstride;
- }
- }break;
- }
- /*Finished.
- Destroy the surface.*/
- cairo_surface_destroy(cs);
- }
-#endif
return 0;
}
diff --git a/media/libtheora/lib/dequant.c b/media/libtheora/lib/dequant.c
index e554872d4e..860536f72d 100644
--- a/media/libtheora/lib/dequant.c
+++ b/media/libtheora/lib/dequant.c
@@ -11,7 +11,7 @@
********************************************************************
function:
- last mod: $Id: dequant.c 16503 2009-08-22 18:14:02Z giles $
+ last mod: $Id$
********************************************************************/
diff --git a/media/libtheora/lib/dequant.h b/media/libtheora/lib/dequant.h
index ef25838e35..9d6cd6be56 100644
--- a/media/libtheora/lib/dequant.h
+++ b/media/libtheora/lib/dequant.h
@@ -11,7 +11,7 @@
********************************************************************
function:
- last mod: $Id: dequant.h 16503 2009-08-22 18:14:02Z giles $
+ last mod: $Id$
********************************************************************/
diff --git a/media/libtheora/lib/fragment.c b/media/libtheora/lib/fragment.c
index 4ba6af1b71..14c38be507 100644
--- a/media/libtheora/lib/fragment.c
+++ b/media/libtheora/lib/fragment.c
@@ -11,7 +11,7 @@
********************************************************************
function:
- last mod: $Id: fragment.c 17410 2010-09-21 21:53:48Z tterribe $
+ last mod: $Id$
********************************************************************/
#include <string.h>
diff --git a/media/libtheora/lib/huffdec.c b/media/libtheora/lib/huffdec.c
index fe013c611c..e227b40d71 100644
--- a/media/libtheora/lib/huffdec.c
+++ b/media/libtheora/lib/huffdec.c
@@ -11,7 +11,7 @@
********************************************************************
function:
- last mod: $Id: huffdec.c 17577 2010-10-29 04:00:07Z tterribe $
+ last mod: $Id$
********************************************************************/
diff --git a/media/libtheora/lib/huffdec.h b/media/libtheora/lib/huffdec.h
index 2fd112a90b..03d25dcd1e 100644
--- a/media/libtheora/lib/huffdec.h
+++ b/media/libtheora/lib/huffdec.h
@@ -11,7 +11,7 @@
********************************************************************
function:
- last mod: $Id: huffdec.h 17410 2010-09-21 21:53:48Z tterribe $
+ last mod: $Id$
********************************************************************/
diff --git a/media/libtheora/lib/huffman.h b/media/libtheora/lib/huffman.h
index 36cf7572e5..eb805866b9 100644
--- a/media/libtheora/lib/huffman.h
+++ b/media/libtheora/lib/huffman.h
@@ -11,12 +11,12 @@
********************************************************************
function:
- last mod: $Id: huffman.h 16503 2009-08-22 18:14:02Z giles $
+ last mod: $Id$
********************************************************************/
#if !defined(_huffman_H)
-# define _hufffman_H (1)
+# define _huffman_H (1)
# include "theora/codec.h"
# include "ocintrin.h"
diff --git a/media/libtheora/lib/idct.c b/media/libtheora/lib/idct.c
index c56eb94c5c..838e3ad8ca 100644
--- a/media/libtheora/lib/idct.c
+++ b/media/libtheora/lib/idct.c
@@ -11,7 +11,7 @@
********************************************************************
function:
- last mod: $Id: idct.c 17410 2010-09-21 21:53:48Z tterribe $
+ last mod: $Id$
********************************************************************/
@@ -241,8 +241,8 @@ static void oc_idct8x8_3(ogg_int16_t _y[64],ogg_int16_t _x[64]){
for(i=0;i<8;i++)idct8_2(_y+i,w+i*8);
/*Adjust for the scale factor.*/
for(i=0;i<64;i++)_y[i]=(ogg_int16_t)(_y[i]+8>>4);
- /*Clear input data for next block (decoder only).*/
- if(_x!=_y)_x[0]=_x[1]=_x[8]=0;
+ /*Clear input data for next block.*/
+ _x[0]=_x[1]=_x[8]=0;
}
/*Performs an inverse 8x8 Type-II DCT transform.
@@ -272,8 +272,8 @@ static void oc_idct8x8_10(ogg_int16_t _y[64],ogg_int16_t _x[64]){
for(i=0;i<8;i++)idct8_4(_y+i,w+i*8);
/*Adjust for the scale factor.*/
for(i=0;i<64;i++)_y[i]=(ogg_int16_t)(_y[i]+8>>4);
- /*Clear input data for next block (decoder only).*/
- if(_x!=_y)_x[0]=_x[1]=_x[2]=_x[3]=_x[8]=_x[9]=_x[10]=_x[16]=_x[17]=_x[24]=0;
+ /*Clear input data for next block.*/
+ _x[0]=_x[1]=_x[2]=_x[3]=_x[8]=_x[9]=_x[10]=_x[16]=_x[17]=_x[24]=0;
}
/*Performs an inverse 8x8 Type-II DCT transform.
@@ -291,7 +291,8 @@ static void oc_idct8x8_slow(ogg_int16_t _y[64],ogg_int16_t _x[64]){
for(i=0;i<8;i++)idct8(_y+i,w+i*8);
/*Adjust for the scale factor.*/
for(i=0;i<64;i++)_y[i]=(ogg_int16_t)(_y[i]+8>>4);
- if(_x!=_y)for(i=0;i<64;i++)_x[i]=0;
+ /*Clear input data for next block.*/
+ for(i=0;i<64;i++)_x[i]=0;
}
/*Performs an inverse 8x8 Type-II DCT transform.
diff --git a/media/libtheora/lib/info.c b/media/libtheora/lib/info.c
index 6b9762978b..e5cecd2de5 100644
--- a/media/libtheora/lib/info.c
+++ b/media/libtheora/lib/info.c
@@ -11,7 +11,7 @@
********************************************************************
function:
- last mod: $Id: info.c 16503 2009-08-22 18:14:02Z giles $
+ last mod: $Id$
********************************************************************/
@@ -54,7 +54,7 @@ void th_comment_init(th_comment *_tc){
memset(_tc,0,sizeof(*_tc));
}
-void th_comment_add(th_comment *_tc,char *_comment){
+void th_comment_add(th_comment *_tc,const char *_comment){
char **user_comments;
int *comment_lengths;
int comment_len;
@@ -75,7 +75,7 @@ void th_comment_add(th_comment *_tc,char *_comment){
_tc->user_comments[_tc->comments]=NULL;
}
-void th_comment_add_tag(th_comment *_tc,char *_tag,char *_val){
+void th_comment_add_tag(th_comment *_tc,const char *_tag,const char *_val){
char *comment;
int tag_len;
int val_len;
@@ -91,7 +91,7 @@ void th_comment_add_tag(th_comment *_tc,char *_tag,char *_val){
_ogg_free(comment);
}
-char *th_comment_query(th_comment *_tc,char *_tag,int _count){
+char *th_comment_query(th_comment *_tc,const char *_tag,int _count){
long i;
int found;
int tag_len;
@@ -107,7 +107,7 @@ char *th_comment_query(th_comment *_tc,char *_tag,int _count){
return NULL;
}
-int th_comment_query_count(th_comment *_tc,char *_tag){
+int th_comment_query_count(th_comment *_tc,const char *_tag){
long i;
int tag_len;
int count;
diff --git a/media/libtheora/lib/internal.c b/media/libtheora/lib/internal.c
index 1b2611da15..afbb6efae7 100644
--- a/media/libtheora/lib/internal.c
+++ b/media/libtheora/lib/internal.c
@@ -11,7 +11,7 @@
********************************************************************
function:
- last mod: $Id: internal.c 17506 2010-10-13 02:52:41Z tterribe $
+ last mod: $Id$
********************************************************************/
@@ -131,7 +131,6 @@ void **oc_malloc_2d(size_t _height,size_t _width,size_t _sz){
datsz=rowsz*_height;
/*Alloc array and row pointers.*/
ret=(char *)_ogg_malloc(datsz+colsz);
- if(ret==NULL)return NULL;
/*Initialize the array.*/
if(ret!=NULL){
size_t i;
@@ -154,7 +153,6 @@ void **oc_calloc_2d(size_t _height,size_t _width,size_t _sz){
datsz=rowsz*_height;
/*Alloc array and row pointers.*/
ret=(char *)_ogg_calloc(datsz+colsz,1);
- if(ret==NULL)return NULL;
/*Initialize the array.*/
if(ret!=NULL){
size_t i;
diff --git a/media/libtheora/lib/internal.h b/media/libtheora/lib/internal.h
index 24e1b51252..53c77b88be 100644
--- a/media/libtheora/lib/internal.h
+++ b/media/libtheora/lib/internal.h
@@ -11,7 +11,7 @@
********************************************************************
function:
- last mod: $Id: internal.h 17578 2010-10-29 04:21:26Z tterribe $
+ last mod: $Id$
********************************************************************/
#if !defined(_internal_H)
diff --git a/media/libtheora/lib/ocintrin.h b/media/libtheora/lib/ocintrin.h
index d49ebb2159..b200ceafce 100644
--- a/media/libtheora/lib/ocintrin.h
+++ b/media/libtheora/lib/ocintrin.h
@@ -11,7 +11,7 @@
********************************************************************
function:
- last mod: $Id: ocintrin.h 16503 2009-08-22 18:14:02Z giles $
+ last mod: $Id$
********************************************************************/
diff --git a/media/libtheora/lib/quant.c b/media/libtheora/lib/quant.c
index c3f3f47713..e206202844 100644
--- a/media/libtheora/lib/quant.c
+++ b/media/libtheora/lib/quant.c
@@ -11,7 +11,7 @@
********************************************************************
function:
- last mod: $Id: quant.c 17307 2010-06-27 06:02:15Z tterribe $
+ last mod: $Id$
********************************************************************/
diff --git a/media/libtheora/lib/quant.h b/media/libtheora/lib/quant.h
index 49ce13a65c..247210eaae 100644
--- a/media/libtheora/lib/quant.h
+++ b/media/libtheora/lib/quant.h
@@ -11,7 +11,7 @@
********************************************************************
function:
- last mod: $Id: quant.h 16503 2009-08-22 18:14:02Z giles $
+ last mod: $Id$
********************************************************************/
diff --git a/media/libtheora/lib/state.c b/media/libtheora/lib/state.c
index 5e7b0ae651..f4c6240387 100644
--- a/media/libtheora/lib/state.c
+++ b/media/libtheora/lib/state.c
@@ -11,7 +11,7 @@
********************************************************************
function:
- last mod: $Id: state.c 17576 2010-10-29 01:07:51Z tterribe $
+ last mod: $Id$
********************************************************************/
@@ -21,6 +21,7 @@
#if defined(OC_DUMP_IMAGES)
# include <stdio.h>
# include "png.h"
+# include "zlib.h"
#endif
/*The function used to fill in the chroma plane motion vectors for a macro
@@ -253,10 +254,14 @@ static void oc_mb_fill_cmapping10(oc_mb_map_plane _mb_map[3],
This version is for use with no chroma decimation (4:4:4).
This uses the already filled-in luma plane values.
_mb_map: The macro block map to fill.
- _fplanes: The descriptions of the fragment planes.*/
+ _fplanes: The descriptions of the fragment planes.
+ _xfrag0: The X location of the upper-left hand fragment in the luma plane.
+ _yfrag0: The Y location of the upper-left hand fragment in the luma plane.*/
static void oc_mb_fill_cmapping11(oc_mb_map_plane _mb_map[3],
- const oc_fragment_plane _fplanes[3]){
+ const oc_fragment_plane _fplanes[3],int _xfrag0,int _yfrag0){
int k;
+ (void)_xfrag0;
+ (void)_yfrag0;
for(k=0;k<4;k++){
_mb_map[1][k]=_mb_map[0][k]+_fplanes[1].froffset;
_mb_map[2][k]=_mb_map[0][k]+_fplanes[2].froffset;
@@ -278,7 +283,7 @@ static const oc_mb_fill_cmapping_func OC_MB_FILL_CMAPPING_TABLE[4]={
oc_mb_fill_cmapping00,
oc_mb_fill_cmapping01,
oc_mb_fill_cmapping10,
- (oc_mb_fill_cmapping_func)oc_mb_fill_cmapping11
+ oc_mb_fill_cmapping11
};
/*Fills in the mapping from macro blocks to their corresponding fragment
@@ -702,7 +707,8 @@ int oc_state_init(oc_theora_state *_state,const th_info *_info,int _nrefs){
how it is specified in the bitstream, because the Y axis is flipped in
the bitstream.
The displayable frame must fit inside the encoded frame.
- The color space must be one known by the encoder.*/
+ The color space must be one known by the encoder.
+ The framerate ratio must not contain a zero value.*/
if((_info->frame_width&0xF)||(_info->frame_height&0xF)||
_info->frame_width<=0||_info->frame_width>=0x100000||
_info->frame_height<=0||_info->frame_height>=0x100000||
@@ -715,7 +721,8 @@ int oc_state_init(oc_theora_state *_state,const th_info *_info,int _nrefs){
but there are a number of compilers which will mis-optimize this.
It's better to live with the spurious warnings.*/
_info->colorspace<0||_info->colorspace>=TH_CS_NSPACES||
- _info->pixel_fmt<0||_info->pixel_fmt>=TH_PF_NFORMATS){
+ _info->pixel_fmt<0||_info->pixel_fmt>=TH_PF_NFORMATS||
+ _info->fps_numerator<1||_info->fps_denominator<1){
return TH_EINVAL;
}
memset(_state,0,sizeof(*_state));
diff --git a/media/libtheora/lib/x86/mmxfrag.c b/media/libtheora/lib/x86/mmxfrag.c
index b7df1c1ec9..b3ec508956 100644
--- a/media/libtheora/lib/x86/mmxfrag.c
+++ b/media/libtheora/lib/x86/mmxfrag.c
@@ -11,7 +11,7 @@
********************************************************************
function:
- last mod: $Id: mmxfrag.c 17410 2010-09-21 21:53:48Z tterribe $
+ last mod: $Id$
********************************************************************/
@@ -355,7 +355,7 @@ void oc_frag_recon_inter2_mmx(unsigned char *_dst,const unsigned char *_src1,
/*Advance dest ptr.*/
"lea (%[dst],%[ystride],2),%[dst]\n\t"
:[dst]"+r"(_dst),[residue]"+r"(_residue),
- [src1]"+%r"(_src1),[src2]"+r"(_src2)
+ [src1]"+r"(_src1),[src2]"+r"(_src2)
:[ystride]"r"((ptrdiff_t)_ystride)
:"memory"
);
diff --git a/media/libtheora/lib/x86/mmxidct.c b/media/libtheora/lib/x86/mmxidct.c
index 8d61bdfb16..b8e3077066 100644
--- a/media/libtheora/lib/x86/mmxidct.c
+++ b/media/libtheora/lib/x86/mmxidct.c
@@ -11,7 +11,7 @@
********************************************************************
function:
- last mod: $Id: mmxidct.c 17446 2010-09-23 20:06:20Z tterribe $
+ last mod: $Id$
********************************************************************/
@@ -284,6 +284,7 @@
"#end OC_COLUMN_IDCT\n\t" \
static void oc_idct8x8_slow_mmx(ogg_int16_t _y[64],ogg_int16_t _x[64]){
+ int i;
/*This routine accepts an 8x8 matrix, but in partially transposed form.
Every 4x4 block is transposed.*/
__asm__ __volatile__(
@@ -313,18 +314,15 @@ static void oc_idct8x8_slow_mmx(ogg_int16_t _y[64],ogg_int16_t _x[64]){
:[x]"m"OC_CONST_ARRAY_OPERAND(ogg_int16_t,_x,64),
[c]"m"OC_CONST_ARRAY_OPERAND(ogg_int16_t,OC_IDCT_CONSTS,128)
);
- if(_x!=_y){
- int i;
- __asm__ __volatile__("pxor %%mm0,%%mm0\n\t"::);
- for(i=0;i<4;i++){
- __asm__ __volatile__(
- "movq %%mm0,"OC_MEM_OFFS(0x00,x)"\n\t"
- "movq %%mm0,"OC_MEM_OFFS(0x08,x)"\n\t"
- "movq %%mm0,"OC_MEM_OFFS(0x10,x)"\n\t"
- "movq %%mm0,"OC_MEM_OFFS(0x18,x)"\n\t"
- :[x]"=m"OC_ARRAY_OPERAND(ogg_int16_t,_x+16*i,16)
- );
- }
+ __asm__ __volatile__("pxor %%mm0,%%mm0\n\t"::);
+ for(i=0;i<4;i++){
+ __asm__ __volatile__(
+ "movq %%mm0,"OC_MEM_OFFS(0x00,x)"\n\t"
+ "movq %%mm0,"OC_MEM_OFFS(0x08,x)"\n\t"
+ "movq %%mm0,"OC_MEM_OFFS(0x10,x)"\n\t"
+ "movq %%mm0,"OC_MEM_OFFS(0x18,x)"\n\t"
+ :[x]"=m"OC_ARRAY_OPERAND(ogg_int16_t,_x+16*i,16)
+ );
}
}
@@ -514,16 +512,14 @@ static void oc_idct8x8_10_mmx(ogg_int16_t _y[64],ogg_int16_t _x[64]){
:[x]"m"OC_CONST_ARRAY_OPERAND(ogg_int16_t,_x,64),
[c]"m"OC_CONST_ARRAY_OPERAND(ogg_int16_t,OC_IDCT_CONSTS,128)
);
- if(_x!=_y){
- __asm__ __volatile__(
- "pxor %%mm0,%%mm0\n\t"
- "movq %%mm0,"OC_MEM_OFFS(0x00,x)"\n\t"
- "movq %%mm0,"OC_MEM_OFFS(0x10,x)"\n\t"
- "movq %%mm0,"OC_MEM_OFFS(0x20,x)"\n\t"
- "movq %%mm0,"OC_MEM_OFFS(0x30,x)"\n\t"
- :[x]"+m"OC_ARRAY_OPERAND(ogg_int16_t,_x,28)
- );
- }
+ __asm__ __volatile__(
+ "pxor %%mm0,%%mm0\n\t"
+ "movq %%mm0,"OC_MEM_OFFS(0x00,x)"\n\t"
+ "movq %%mm0,"OC_MEM_OFFS(0x10,x)"\n\t"
+ "movq %%mm0,"OC_MEM_OFFS(0x20,x)"\n\t"
+ "movq %%mm0,"OC_MEM_OFFS(0x30,x)"\n\t"
+ :[x]"+m"OC_ARRAY_OPERAND(ogg_int16_t,_x,28)
+ );
}
/*Performs an inverse 8x8 Type-II DCT transform.
diff --git a/media/libtheora/lib/x86/mmxstate.c b/media/libtheora/lib/x86/mmxstate.c
index 0b9586f943..eebea14fba 100644
--- a/media/libtheora/lib/x86/mmxstate.c
+++ b/media/libtheora/lib/x86/mmxstate.c
@@ -11,7 +11,7 @@
********************************************************************
function:
- last mod: $Id: mmxstate.c 17563 2010-10-25 17:40:54Z tterribe $
+ last mod: $Id$
********************************************************************/
diff --git a/media/libtheora/lib/x86/sse2idct.c b/media/libtheora/lib/x86/sse2idct.c
index 5f8523fa5f..4597ab074f 100644
--- a/media/libtheora/lib/x86/sse2idct.c
+++ b/media/libtheora/lib/x86/sse2idct.c
@@ -208,6 +208,7 @@ const unsigned short __attribute__((aligned(16),used)) OC_IDCT_CONSTS[64]={
static void oc_idct8x8_slow_sse2(ogg_int16_t _y[64],ogg_int16_t _x[64]){
OC_ALIGN16(ogg_int16_t buf[16]);
+ int i;
/*This routine accepts an 8x8 matrix pre-transposed.*/
__asm__ __volatile__(
/*Load rows 2, 3, 5, and 6 for the first stage of the iDCT.*/
@@ -230,19 +231,16 @@ static void oc_idct8x8_slow_sse2(ogg_int16_t _y[64],ogg_int16_t _x[64]){
:[x]"m"(OC_CONST_ARRAY_OPERAND(ogg_int16_t,_x,64)),
[c]"m"(OC_CONST_ARRAY_OPERAND(ogg_int16_t,OC_IDCT_CONSTS,128))
);
- if(_x!=_y){
- int i;
- __asm__ __volatile__("pxor %%xmm0,%%xmm0\n\t"::);
- /*Clear input data for next block (decoder only).*/
- for(i=0;i<2;i++){
- __asm__ __volatile__(
- "movdqa %%xmm0,"OC_MEM_OFFS(0x00,x)"\n\t"
- "movdqa %%xmm0,"OC_MEM_OFFS(0x10,x)"\n\t"
- "movdqa %%xmm0,"OC_MEM_OFFS(0x20,x)"\n\t"
- "movdqa %%xmm0,"OC_MEM_OFFS(0x30,x)"\n\t"
- :[x]"=m"(OC_ARRAY_OPERAND(ogg_int16_t,_x+i*32,32))
- );
- }
+ __asm__ __volatile__("pxor %%xmm0,%%xmm0\n\t"::);
+ /*Clear input data for next block (decoder only).*/
+ for(i=0;i<2;i++){
+ __asm__ __volatile__(
+ "movdqa %%xmm0,"OC_MEM_OFFS(0x00,x)"\n\t"
+ "movdqa %%xmm0,"OC_MEM_OFFS(0x10,x)"\n\t"
+ "movdqa %%xmm0,"OC_MEM_OFFS(0x20,x)"\n\t"
+ "movdqa %%xmm0,"OC_MEM_OFFS(0x30,x)"\n\t"
+ :[x]"=m"(OC_ARRAY_OPERAND(ogg_int16_t,_x+i*32,32))
+ );
}
}
@@ -411,17 +409,15 @@ static void oc_idct8x8_10_sse2(ogg_int16_t _y[64],ogg_int16_t _x[64]){
:[x]"m"OC_CONST_ARRAY_OPERAND(ogg_int16_t,_x,64),
[c]"m"(OC_CONST_ARRAY_OPERAND(ogg_int16_t,OC_IDCT_CONSTS,128))
);
- if(_x!=_y){
- /*Clear input data for next block (decoder only).*/
- __asm__ __volatile__(
- "pxor %%mm0,%%mm0\n\t"
- "movq %%mm0,"OC_MEM_OFFS(0x00,x)"\n\t"
- "movq %%mm0,"OC_MEM_OFFS(0x10,x)"\n\t"
- "movq %%mm0,"OC_MEM_OFFS(0x20,x)"\n\t"
- "movq %%mm0,"OC_MEM_OFFS(0x30,x)"\n\t"
- :[x]"+m"(OC_ARRAY_OPERAND(ogg_int16_t,_x,28))
- );
- }
+ /*Clear input data for next block (decoder only).*/
+ __asm__ __volatile__(
+ "pxor %%mm0,%%mm0\n\t"
+ "movq %%mm0,"OC_MEM_OFFS(0x00,x)"\n\t"
+ "movq %%mm0,"OC_MEM_OFFS(0x10,x)"\n\t"
+ "movq %%mm0,"OC_MEM_OFFS(0x20,x)"\n\t"
+ "movq %%mm0,"OC_MEM_OFFS(0x30,x)"\n\t"
+ :[x]"+m"(OC_ARRAY_OPERAND(ogg_int16_t,_x,28))
+ );
}
/*Performs an inverse 8x8 Type-II DCT transform.
diff --git a/media/libtheora/lib/x86/x86cpu.c b/media/libtheora/lib/x86/x86cpu.c
index c3a20b319c..49fd76d0ac 100644
--- a/media/libtheora/lib/x86/x86cpu.c
+++ b/media/libtheora/lib/x86/x86cpu.c
@@ -14,7 +14,7 @@
Originally written by Rudolf Marek.
function:
- last mod: $Id: x86cpu.c 17410 2010-09-21 21:53:48Z tterribe $
+ last mod: $Id$
********************************************************************/
diff --git a/media/libtheora/lib/x86/x86cpu.h b/media/libtheora/lib/x86/x86cpu.h
index 153a48d892..e0192d52e2 100644
--- a/media/libtheora/lib/x86/x86cpu.h
+++ b/media/libtheora/lib/x86/x86cpu.h
@@ -10,7 +10,7 @@
* *
********************************************************************
function:
- last mod: $Id: x86cpu.h 17410 2010-09-21 21:53:48Z tterribe $
+ last mod: $Id$
********************************************************************/
diff --git a/media/libtheora/lib/x86/x86int.h b/media/libtheora/lib/x86/x86int.h
index 35bfb0a02b..ceb2dbb0ec 100644
--- a/media/libtheora/lib/x86/x86int.h
+++ b/media/libtheora/lib/x86/x86int.h
@@ -11,7 +11,7 @@
********************************************************************
function:
- last mod: $Id: x86int.h 17578 2010-10-29 04:21:26Z tterribe $
+ last mod: $Id$
********************************************************************/
diff --git a/media/libtheora/lib/x86/x86state.c b/media/libtheora/lib/x86/x86state.c
index a3d37267f6..9f8bceb534 100644
--- a/media/libtheora/lib/x86/x86state.c
+++ b/media/libtheora/lib/x86/x86state.c
@@ -11,7 +11,7 @@
********************************************************************
function:
- last mod: $Id: x86state.c 17421 2010-09-22 16:46:18Z giles $
+ last mod: $Id$
********************************************************************/
@@ -19,6 +19,7 @@
#if defined(OC_X86_ASM)
+#if defined(OC_STATE_USE_VTABLE)
/*This table has been modified from OC_FZIG_ZAG by baking a 4x4 transpose into
each quadrant of the destination.*/
static const unsigned char OC_FZIG_ZAG_MMX[128]={
@@ -39,6 +40,7 @@ static const unsigned char OC_FZIG_ZAG_MMX[128]={
64,64,64,64,64,64,64,64,
64,64,64,64,64,64,64,64
};
+#endif
/*This table has been modified from OC_FZIG_ZAG by baking an 8x8 transpose into
the destination.*/
diff --git a/media/libtheora/lib/x86_vc/mmxfrag.c b/media/libtheora/lib/x86_vc/mmxfrag.c
index c16b026ffc..248312ff90 100644
--- a/media/libtheora/lib/x86_vc/mmxfrag.c
+++ b/media/libtheora/lib/x86_vc/mmxfrag.c
@@ -11,7 +11,7 @@
********************************************************************
function:
- last mod: $Id: mmxfrag.c 17446 2010-09-23 20:06:20Z tterribe $
+ last mod: $Id$
********************************************************************/
diff --git a/media/libtheora/lib/x86_vc/mmxidct.c b/media/libtheora/lib/x86_vc/mmxidct.c
index 53a9ac7f38..55e00aedcf 100644
--- a/media/libtheora/lib/x86_vc/mmxidct.c
+++ b/media/libtheora/lib/x86_vc/mmxidct.c
@@ -11,7 +11,7 @@
********************************************************************
function:
- last mod: $Id: mmxidct.c 17446 2010-09-23 20:06:20Z tterribe $
+ last mod: $Id$
********************************************************************/
@@ -339,22 +339,19 @@ static void oc_idct8x8_slow(ogg_int16_t _y[64],ogg_int16_t _x[64]){
#undef Y
#undef X
}
- if(_x!=_y){
- int i;
- __asm pxor mm0,mm0;
- for(i=0;i<4;i++){
- ogg_int16_t *x;
- x=_x+16*i;
+ __asm pxor mm0,mm0;
+ for(i=0;i<4;i++){
+ ogg_int16_t *x;
+ x=_x+16*i;
#define X ecx
- __asm{
- mov X,x
- movq [X+0x00],mm0
- movq [X+0x08],mm0
- movq [X+0x10],mm0
- movq [X+0x18],mm0
- }
-#undef X
+ __asm{
+ mov X,x
+ movq [X+0x00],mm0
+ movq [X+0x08],mm0
+ movq [X+0x10],mm0
+ movq [X+0x18],mm0
}
+#undef X
}
}
@@ -547,18 +544,16 @@ static void oc_idct8x8_10(ogg_int16_t _y[64],ogg_int16_t _x[64]){
#undef Y
#undef X
}
- if(_x!=_y){
#define X ecx
- __asm{
- pxor mm0,mm0;
- mov X,_x
- movq [X+0x00],mm0
- movq [X+0x10],mm0
- movq [X+0x20],mm0
- movq [X+0x30],mm0
- }
-#undef X
+ __asm{
+ pxor mm0,mm0;
+ mov X,_x
+ movq [X+0x00],mm0
+ movq [X+0x10],mm0
+ movq [X+0x20],mm0
+ movq [X+0x30],mm0
}
+#undef X
}
/*Performs an inverse 8x8 Type-II DCT transform.
diff --git a/media/libtheora/lib/x86_vc/mmxstate.c b/media/libtheora/lib/x86_vc/mmxstate.c
index d3d468d5f2..f532ee1b6f 100644
--- a/media/libtheora/lib/x86_vc/mmxstate.c
+++ b/media/libtheora/lib/x86_vc/mmxstate.c
@@ -11,7 +11,7 @@
********************************************************************
function:
- last mod: $Id: mmxstate.c 17563 2010-10-25 17:40:54Z tterribe $
+ last mod: $Id$
********************************************************************/
diff --git a/media/libtheora/lib/x86_vc/x86cpu.c b/media/libtheora/lib/x86_vc/x86cpu.c
index 41f4bcba9d..6a1d8d850c 100644
--- a/media/libtheora/lib/x86_vc/x86cpu.c
+++ b/media/libtheora/lib/x86_vc/x86cpu.c
@@ -14,7 +14,7 @@
Originally written by Rudolf Marek.
function:
- last mod: $Id: x86cpu.c 17410 2010-09-21 21:53:48Z tterribe $
+ last mod: $Id$
********************************************************************/
diff --git a/media/libtheora/lib/x86_vc/x86cpu.h b/media/libtheora/lib/x86_vc/x86cpu.h
index 327d932467..eea261d448 100644
--- a/media/libtheora/lib/x86_vc/x86cpu.h
+++ b/media/libtheora/lib/x86_vc/x86cpu.h
@@ -10,7 +10,7 @@
* *
********************************************************************
function:
- last mod: $Id: x86cpu.h 17410 2010-09-21 21:53:48Z tterribe $
+ last mod: $Id$
********************************************************************/
diff --git a/media/libtheora/lib/x86_vc/x86int.h b/media/libtheora/lib/x86_vc/x86int.h
index bc4c54a2f6..318a09dca0 100644
--- a/media/libtheora/lib/x86_vc/x86int.h
+++ b/media/libtheora/lib/x86_vc/x86int.h
@@ -11,7 +11,7 @@
********************************************************************
function:
- last mod: $Id: x86int.h 17410 2010-09-21 21:53:48Z tterribe $
+ last mod: $Id$
********************************************************************/
diff --git a/media/libtheora/lib/x86_vc/x86state.c b/media/libtheora/lib/x86_vc/x86state.c
index 7aa73deae4..fa3a0d42fc 100644
--- a/media/libtheora/lib/x86_vc/x86state.c
+++ b/media/libtheora/lib/x86_vc/x86state.c
@@ -11,7 +11,7 @@
********************************************************************
function:
- last mod: $Id: x86state.c 17410 2010-09-21 21:53:48Z tterribe $
+ last mod: $Id$
********************************************************************/
diff --git a/media/libtheora/moz.build b/media/libtheora/moz.build
index 8bcdb5fd47..6f9916544f 100644
--- a/media/libtheora/moz.build
+++ b/media/libtheora/moz.build
@@ -1,4 +1,5 @@
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
+# vim: set filetype=python:
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
@@ -9,7 +10,6 @@ with Files('*'):
EXPORTS.theora += [
'include/theora/codec.h',
'include/theora/theoradec.h',
- 'include/theora/theoraenc.h',
]
# We allow warnings for third-party code that can be updated from upstream.
@@ -24,20 +24,21 @@ if CONFIG['GKMEDIAS_SHARED_LIBRARY']:
DEFINES['THEORA_DISABLE_ENCODE'] = True
# Suppress warnings in third-party code.
-if CONFIG['GNU_CC'] or CONFIG['CLANG_CL']:
+if CONFIG['CC_TYPE'] in ('clang', 'clang-cl', 'gcc'):
CFLAGS += ['-Wno-type-limits']
-if CONFIG['CLANG_CXX'] or CONFIG['CLANG_CL']:
- CFLAGS += ['-Wno-tautological-compare']
-if CONFIG['CLANG_CL']:
+if CONFIG['CC_TYPE'] in ('clang', 'clang-cl'):
CFLAGS += [
+ '-Wno-shift-negative-value',
+ '-Wno-tautological-compare',
+ ]
+if CONFIG['CC_TYPE'] == 'clang-cl':
+ CFLAGS += [
+ '-Wno-parentheses',
'-Wno-pointer-sign',
- '-Wno-shift-op-parentheses',
]
UNIFIED_SOURCES += [
- 'lib/apiwrapper.c',
'lib/bitpack.c',
- 'lib/decapiwrapper.c',
'lib/decinfo.c',
'lib/decode.c',
'lib/dequant.c',
@@ -52,20 +53,19 @@ UNIFIED_SOURCES += [
LOCAL_INCLUDES += ['include']
-if '86' in CONFIG['OS_TEST']:
+if CONFIG['INTEL_ARCHITECTURE']:
if CONFIG['OS_ARCH'] != 'SunOS':
- if CONFIG['CLANG_CL']:
+ if CONFIG['CC_TYPE'] == 'clang-cl':
# clang-cl can't handle libtheora's inline asm.
pass
- elif CONFIG['OS_ARCH'] != 'WINNT' or CONFIG['OS_TEST'] != 'x86_64':
+ elif CONFIG['OS_ARCH'] != 'WINNT' or CONFIG['CPU_ARCH'] != 'x86_64':
DEFINES['OC_X86_ASM'] = True
- if '64' in CONFIG['OS_TEST']:
+ if CONFIG['CPU_ARCH'] == 'x86_64':
DEFINES['OC_X86_64_ASM'] = True
if CONFIG['_MSC_VER']:
- if CONFIG['CLANG_CL']:
- # clang-cl can't handle libtheora's inline asm.
- pass
- elif '64' not in CONFIG['OS_TEST']:
+ # MSVC doesn't allow inline assembly in 64-bit code.
+ # Thus, only 32-bit Windows builds benefit from optimization.
+ if CONFIG['CPU_ARCH'] != 'x86_64':
SOURCES += [
'lib/x86_vc/mmxfrag.c',
'lib/x86_vc/mmxidct.c',
@@ -84,7 +84,7 @@ if '86' in CONFIG['OS_TEST']:
]
if CONFIG['GNU_AS']:
- if 'arm' in CONFIG['OS_TEST']:
+ if CONFIG['CPU_ARCH'] == 'arm':
SOURCES += [
'lib/arm/armcpu.c',
'lib/arm/armstate.c',
@@ -109,7 +109,7 @@ if CONFIG['GNU_AS']:
]
ASFLAGS += CONFIG['NEON_FLAGS']
- if CONFIG['CLANG_CXX']:
+ if CONFIG['CC_TYPE'] == 'clang':
ASFLAGS += [
'-no-integrated-as',
]
diff --git a/media/libtheora/update.sh b/media/libtheora/update.sh
index e1a95425a6..acfde68922 100644..100755
--- a/media/libtheora/update.sh
+++ b/media/libtheora/update.sh
@@ -2,6 +2,9 @@
#
# Copies the needed files from a directory containing the original
# libtheora source that we need for the Mozilla HTML5 media support.
+
+mkdir -p include/theora lib lib/arm lib/x86 lib/x86_vc
+
sed \
-e s/\#define\ OC_X86_ASM//g \
-e s/\#define\ OC_X86_64_ASM//g \
@@ -19,14 +22,11 @@ sed \
cp $1/LICENSE ./LICENSE
cp $1/CHANGES ./CHANGES
cp $1/COPYING ./COPYING
-cp $1/README ./README
+cp $1/README.md ./README.md
cp $1/AUTHORS ./AUTHORS
-cp $1/lib/apiwrapper.c ./lib/
-cp $1/lib/apiwrapper.h ./lib/
cp $1/lib/bitpack.c ./lib/
cp $1/lib/bitpack.h ./lib/
cp $1/lib/dct.h ./lib/
-cp $1/lib/decapiwrapper.c ./lib/
cp $1/lib/decinfo.c ./lib/
cp $1/lib/decint.h ./lib/
cp $1/lib/decode.c ./lib/
@@ -76,11 +76,5 @@ cp $1/lib/x86_vc/x86int.h ./lib/x86_vc/
cp $1/lib/x86_vc/x86state.c ./lib/x86_vc/
cp $1/include/theora/theora.h ./include/theora/theora.h
cp $1/include/theora/theoradec.h ./include/theora/theoradec.h
-cp $1/include/theora/theoraenc.h ./include/theora/theoraenc.h
cp $1/include/theora/codec.h ./include/theora/codec.h
-patch -p3 < ./bug625773-r17780.patch
-patch -p3 < ./bug468275-r18219.patch
-patch -p3 < ./bug752139-r18031.patch
-patch -p3 < ./bug752668-r18268.patch
patch -p3 < ./bug703135.patch
-patch -p3 < ./bug920992.patch
diff --git a/media/libtremor/README_MCP b/media/libtremor/README_MCP
new file mode 100644
index 0000000000..a1d2bd12ec
--- /dev/null
+++ b/media/libtremor/README_MCP
@@ -0,0 +1,7 @@
+The source from this directory was copied from the libtremor
+git repository using the update.sh script. The only changes
+made were those applied by update.sh and the addition/update of
+Makefile.in files for the UXP build system.
+
+The upstream release used was https://gitlab.xiph.org/xiph/tremor
+The git revision used was 7c30a66346199f3f09017a09567c6c8a3a0eedc8.
diff --git a/media/libtremor/README_MOZILLA b/media/libtremor/README_MOZILLA
deleted file mode 100644
index ee67b53a05..0000000000
--- a/media/libtremor/README_MOZILLA
+++ /dev/null
@@ -1,7 +0,0 @@
-The source from this directory was copied from the libtremor
-subversion repository using the update.sh script. The only changes
-made were those applied by update.sh and the addition/upate of
-Makefile.in files for the Mozilla build system.
-
-The upstream release used was http://svn.xiph.org/trunk/Tremor/
-The subversion revision used was r17547.
diff --git a/media/libtremor/bug1117571-r19420.patch b/media/libtremor/bug1117571-r19420.patch
deleted file mode 100644
index 02de5e68ff..0000000000
--- a/media/libtremor/bug1117571-r19420.patch
+++ /dev/null
@@ -1,18 +0,0 @@
-diff -r 55f3224d7513 media/libtremor/lib/tremor_synthesis.c
---- a/media/libtremor/lib/tremor_synthesis.c Sat Jan 03 20:02:33 2015 -0800
-+++ b/media/libtremor/lib/tremor_synthesis.c Sun Jan 04 11:17:29 2015 -0800
-@@ -119,13 +119,13 @@ long vorbis_packet_blocksize(vorbis_info
- while(v>1){
- modebits++;
- v>>=1;
- }
-
- /* read our mode and pre/post windowsize */
- mode=oggpack_read(&opb,modebits);
- }
-- if(mode==-1)return(OV_EBADPACKET);
-+ if(mode==-1 || !ci->mode_param[mode])return(OV_EBADPACKET);
- return(ci->blocksizes[ci->mode_param[mode]->blockflag]);
- }
-
-
diff --git a/media/libtremor/bug719612.patch b/media/libtremor/bug719612.patch
deleted file mode 100644
index 36ac84f66c..0000000000
--- a/media/libtremor/bug719612.patch
+++ /dev/null
@@ -1,21 +0,0 @@
-diff --git a/media/libtremor/lib/tremor_floor1.c b/media/libtremor/lib/tremor_floor1.c
---- a/media/libtremor/lib/tremor_floor1.c
-+++ b/media/libtremor/lib/tremor_floor1.c
-@@ -103,16 +103,17 @@ static vorbis_info_floor *floor1_unpack
-
- /* read the post list */
- info->mult=oggpack_read(opb,2)+1; /* only 1,2,3,4 legal now */
- rangebits=oggpack_read(opb,4);
- if(rangebits<0)goto err_out;
-
- for(j=0,k=0;j<info->partitions;j++){
- count+=info->class_dim[info->partitionclass[j]];
-+ if(count>VIF_POSIT)goto err_out;
- for(;k<count;k++){
- int t=info->postlist[k+2]=oggpack_read(opb,rangebits);
- if(t<0 || t>=(1<<rangebits))
- goto err_out;
- }
- }
- info->postlist[0]=0;
- info->postlist[1]=1<<rangebits;
diff --git a/media/libtremor/lib/misc.h b/media/libtremor/lib/misc.h
index 2fc521a244..1ae4d2e813 100644
--- a/media/libtremor/lib/misc.h
+++ b/media/libtremor/lib/misc.h
@@ -49,7 +49,9 @@ union magic {
} halves;
ogg_int64_t whole;
};
-#elif BYTE_ORDER==BIG_ENDIAN
+#endif
+
+#if BYTE_ORDER==BIG_ENDIAN
union magic {
struct {
ogg_int32_t hi;
diff --git a/media/libtremor/lib/moz.build b/media/libtremor/lib/moz.build
index 60523504eb..ded81ee72b 100644
--- a/media/libtremor/lib/moz.build
+++ b/media/libtremor/lib/moz.build
@@ -1,4 +1,5 @@
# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
+# vim: set filetype=python:
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
@@ -23,7 +24,7 @@ FINAL_LIBRARY = 'gkmedias'
if CONFIG['OS_ARCH'] == 'AIX':
DEFINES['alloca'] = '__alloca'
-if CONFIG['TARGET_CPU'] == 'arm' and CONFIG['GNU_CC'] and not CONFIG['MOZ_THUMB2']:
+if CONFIG['CPU_ARCH'] == 'arm' and CONFIG['CC_TYPE'] in ('clang', 'gcc') and not CONFIG['MOZ_THUMB2']:
DEFINES['_ARM_ASSEM_'] = True
LOCAL_INCLUDES += [
diff --git a/media/libtremor/lib/tremor_floor0.c b/media/libtremor/lib/tremor_floor0.c
index 9f3ef56014..964383eff0 100644
--- a/media/libtremor/lib/tremor_floor0.c
+++ b/media/libtremor/lib/tremor_floor0.c
@@ -328,6 +328,7 @@ static vorbis_info_floor *floor0_unpack (vorbis_info *vi,oggpack_buffer *opb){
info->books[j]=oggpack_read(opb,8);
if(info->books[j]<0 || info->books[j]>=ci->books)goto err_out;
if(ci->book_param[info->books[j]]->maptype==0)goto err_out;
+ if(ci->book_param[info->books[j]]->dim<1)goto err_out;
}
return(info);
diff --git a/media/libtremor/lib/tremor_floor1.c b/media/libtremor/lib/tremor_floor1.c
index 12a687ec53..e63ae9fb34 100644
--- a/media/libtremor/lib/tremor_floor1.c
+++ b/media/libtremor/lib/tremor_floor1.c
@@ -426,7 +426,7 @@ static int floor1_inverse2(vorbis_block *vb,vorbis_look_floor *in,void *memo,
int hx=0;
int lx=0;
int ly=fit_value[0]*info->mult;
- /* guard lookup against out-of-rage values */
+ /* guard lookup against out-of-range values */
ly=(ly<0?0:ly>255?255:ly);
for(j=1;j<look->posts;j++){
@@ -436,10 +436,9 @@ static int floor1_inverse2(vorbis_block *vb,vorbis_look_floor *in,void *memo,
hx=info->postlist[current];
hy*=info->mult;
- /* guard lookup against out-of-rage values */
+ /* guard lookup against out-of-range values */
hy=(hy<0?0:hy>255?255:hy);
-
render_line(n,lx,hx,ly,hy,out);
lx=hx;
diff --git a/media/libtremor/lib/tremor_info.c b/media/libtremor/lib/tremor_info.c
index 3f3308ef95..24e24ac728 100644
--- a/media/libtremor/lib/tremor_info.c
+++ b/media/libtremor/lib/tremor_info.c
@@ -227,7 +227,6 @@ static int _vorbis_unpack_comment(vorbis_comment *vc,oggpack_buffer *opb){
static int _vorbis_unpack_books(vorbis_info *vi,oggpack_buffer *opb){
codec_setup_info *ci=(codec_setup_info *)vi->codec_setup;
int i;
- if(!ci)return(OV_EFAULT);
/* codebooks */
ci->books=oggpack_read(opb,8)+1;
@@ -367,6 +366,10 @@ int vorbis_synthesis_headerin(vorbis_info *vi,vorbis_comment *vc,ogg_packet *op)
/* um... we didn't get the initial header */
return(OV_EBADHEADER);
}
+ if(vc->vendor!=NULL){
+ /* previously initialized comment header */
+ return(OV_EBADHEADER);
+ }
return(_vorbis_unpack_comment(vc,&opb));
@@ -375,6 +378,14 @@ int vorbis_synthesis_headerin(vorbis_info *vi,vorbis_comment *vc,ogg_packet *op)
/* um... we didn;t get the initial header or comments yet */
return(OV_EBADHEADER);
}
+ if(vi->codec_setup==NULL){
+ /* improperly initialized vorbis_info */
+ return(OV_EFAULT);
+ }
+ if(((codec_setup_info *)vi->codec_setup)->books>0){
+ /* previously initialized setup header */
+ return(OV_EBADHEADER);
+ }
return(_vorbis_unpack_books(vi,&opb));
diff --git a/media/libtremor/lib/tremor_mdct.c b/media/libtremor/lib/tremor_mdct.c
index 4f39e7d531..2aed62c51c 100644
--- a/media/libtremor/lib/tremor_mdct.c
+++ b/media/libtremor/lib/tremor_mdct.c
@@ -13,7 +13,7 @@
function: normalized modified discrete cosine transform
power of two length transform only [64 <= n ]
- last mod: $Id: mdct.c,v 1.9 2002/10/16 09:17:39 xiphmont Exp $
+ last mod: $Id$
Original algorithm adapted long ago from _The use of multirate filter
banks for coding of high quality digital audio_, by T. Sporer,
diff --git a/media/libtremor/lib/tremor_synthesis.c b/media/libtremor/lib/tremor_synthesis.c
index c7680f6d02..d22cb823c1 100644
--- a/media/libtremor/lib/tremor_synthesis.c
+++ b/media/libtremor/lib/tremor_synthesis.c
@@ -67,7 +67,7 @@ static int _vorbis_synthesis1(vorbis_block *vb,ogg_packet *op,int decodep){
/* more setup */
vb->granulepos=op->granulepos;
- vb->sequence=op->packetno-3; /* first block is third packet */
+ vb->sequence=op->packetno; /* first block is third packet */
vb->eofflag=op->e_o_s;
if(decodep){
diff --git a/media/libtremor/update.sh b/media/libtremor/update.sh
index d27198cfe5..075343c82d 100755
--- a/media/libtremor/update.sh
+++ b/media/libtremor/update.sh
@@ -30,5 +30,5 @@ cp $1/ivorbiscodec.h ./include/tremor/ivorbiscodec.h
cp $1/os.h ./lib/os.h
cp $1/COPYING ./COPYING
cp $1/README ./README
-patch -p3 < ./bug719612.patch
-patch -p3 < ./bug1117571-r19420.patch
+
+echo "Remember to update the version details at README_MCP."
diff --git a/media/mtransport/nr_socket_prsock.cpp b/media/mtransport/nr_socket_prsock.cpp
index 80e5ef51e4..3fd223349c 100644
--- a/media/mtransport/nr_socket_prsock.cpp
+++ b/media/mtransport/nr_socket_prsock.cpp
@@ -858,6 +858,10 @@ int NrSocket::connect(nr_transport_addr *addr) {
PRNetAddr naddr;
int32_t connect_status, getsockname_status;
+ // TODO: Add TLS layer with nsISocketProviderService?
+ if (addr->tls_host[0] != '\0')
+ ABORT(R_INTERNAL);
+
if ((r=nr_transport_addr_to_praddr(addr, &naddr)))
ABORT(r);
@@ -1840,7 +1844,7 @@ void NrTcpSocketIpc::close() {
}
int NrTcpSocketIpc::connect(nr_transport_addr *addr) {
- nsCString remote_addr, local_addr;
+ nsCString remote_addr, local_addr, tls_host;
int32_t remote_port, local_port;
int r, _status;
if ((r=nr_transport_addr_get_addrstring_and_port(addr,
@@ -1856,6 +1860,8 @@ int NrTcpSocketIpc::connect(nr_transport_addr *addr) {
ABORT(r);
}
+ tls_host = addr->tls_host;
+
state_ = mirror_state_ = NR_CONNECTING;
RUN_ON_THREAD(io_thread_,
mozilla::WrapRunnable(RefPtr<NrTcpSocketIpc>(this),
@@ -1863,7 +1869,8 @@ int NrTcpSocketIpc::connect(nr_transport_addr *addr) {
remote_addr,
static_cast<uint16_t>(remote_port),
local_addr,
- static_cast<uint16_t>(local_port)),
+ static_cast<uint16_t>(local_port),
+ tls_host),
NS_DISPATCH_NORMAL);
// Make caller wait for ready to write.
@@ -1939,7 +1946,8 @@ int NrTcpSocketIpc::accept(nr_transport_addr *addrp, nr_socket **sockp) {
void NrTcpSocketIpc::connect_i(const nsACString &remote_addr,
uint16_t remote_port,
const nsACString &local_addr,
- uint16_t local_port) {
+ uint16_t local_port,
+ const nsACString &tls_host) {
ASSERT_ON_THREAD(io_thread_);
mirror_state_ = NR_CONNECTING;
@@ -1948,11 +1956,21 @@ void NrTcpSocketIpc::connect_i(const nsACString &remote_addr,
// Bug 1285330: put filtering back in here
- // XXX remove remote!
- socket_child_->SendWindowlessOpenBind(this,
- remote_addr, remote_port,
- local_addr, local_port,
- /* use ssl */ false);
+ if (tls_host.IsEmpty()) {
+ // XXX remove remote!
+ socket_child_->SendWindowlessOpenBind(this,
+ remote_addr, remote_port,
+ local_addr, local_port,
+ /* use ssl */ false,
+ /* reuse addr port */ true);
+ } else {
+ // XXX remove remote!
+ socket_child_->SendWindowlessOpenBind(this,
+ tls_host, remote_port,
+ local_addr, local_port,
+ /* use ssl */ true,
+ /* reuse addr port */ true);
+ }
}
void NrTcpSocketIpc::write_i(nsAutoPtr<InfallibleTArray<uint8_t>> arr,
diff --git a/media/mtransport/nr_socket_prsock.h b/media/mtransport/nr_socket_prsock.h
index 5ed9a6a219..7d372ccb16 100644
--- a/media/mtransport/nr_socket_prsock.h
+++ b/media/mtransport/nr_socket_prsock.h
@@ -369,7 +369,8 @@ private:
void connect_i(const nsACString &remote_addr,
uint16_t remote_port,
const nsACString &local_addr,
- uint16_t local_port);
+ uint16_t local_port,
+ const nsACString &tls_host);
void write_i(nsAutoPtr<InfallibleTArray<uint8_t>> buf,
uint32_t tracking_number);
void close_i();
diff --git a/media/mtransport/nricectx.cpp b/media/mtransport/nricectx.cpp
index be50f50169..75d3d2519d 100644
--- a/media/mtransport/nricectx.cpp
+++ b/media/mtransport/nricectx.cpp
@@ -108,6 +108,7 @@ MOZ_MTLOG_MODULE("mtransport")
const char kNrIceTransportUdp[] = "udp";
const char kNrIceTransportTcp[] = "tcp";
+const char kNrIceTransportTls[] = "tls";
static bool initialized = false;
@@ -210,6 +211,9 @@ nsresult NrIceStunServer::ToNicerStunStruct(nr_ice_stun_server *server) const {
server->transport = IPPROTO_UDP;
} else if (transport_ == kNrIceTransportTcp) {
server->transport = IPPROTO_TCP;
+ } else if (transport_ == kNrIceTransportTls) {
+ server->transport = IPPROTO_TCP;
+ server->tls = 1;
} else {
MOZ_MTLOG(ML_ERROR, "Unsupported STUN server transport: " << transport_);
return NS_ERROR_FAILURE;
@@ -586,6 +590,7 @@ NrIceCtx::Initialize(const std::string& ufrag,
nsCString mapping_type;
nsCString filtering_type;
bool block_udp = false;
+ bool block_tcp = false;
nsresult rv;
nsCOMPtr<nsIPrefService> pref_service =
@@ -604,6 +609,9 @@ NrIceCtx::Initialize(const std::string& ufrag,
rv = pref_branch->GetBoolPref(
"media.peerconnection.nat_simulator.block_udp",
&block_udp);
+ rv = pref_branch->GetBoolPref(
+ "media.peerconnection.nat_simulator.block_tcp",
+ &block_tcp);
}
}
@@ -614,6 +622,7 @@ NrIceCtx::Initialize(const std::string& ufrag,
test_nat->filtering_type_ = TestNat::ToNatBehavior(filtering_type.get());
test_nat->mapping_type_ = TestNat::ToNatBehavior(mapping_type.get());
test_nat->block_udp_ = block_udp;
+ test_nat->block_tcp_ = block_tcp;
test_nat->enabled_ = true;
SetNat(test_nat);
}
diff --git a/media/mtransport/nricectx.h b/media/mtransport/nricectx.h
index ce104ac317..87122121e5 100644
--- a/media/mtransport/nricectx.h
+++ b/media/mtransport/nricectx.h
@@ -90,6 +90,7 @@ class NrIceMediaStream;
extern const char kNrIceTransportUdp[];
extern const char kNrIceTransportTcp[];
+extern const char kNrIceTransportTls[];
class NrIceStunServer {
public:
diff --git a/media/mtransport/test_nr_socket.cpp b/media/mtransport/test_nr_socket.cpp
index e7dad79cd1..fb2de3096e 100644
--- a/media/mtransport/test_nr_socket.cpp
+++ b/media/mtransport/test_nr_socket.cpp
@@ -200,6 +200,7 @@ int TestNat::create_socket_factory(nr_socket_factory **factorypp) {
TestNrSocket::TestNrSocket(TestNat *nat)
: nat_(nat),
+ tls_(false),
timer_handle_(nullptr) {
nat_->insert_socket(this);
}
@@ -473,6 +474,10 @@ int TestNrSocket::connect(nr_transport_addr *addr) {
return R_INTERNAL;
}
+ if (addr->tls_host[0] != '\0') {
+ tls_ = true;
+ }
+
if (!nat_->enabled_
|| addr->protocol==IPPROTO_UDP // Horrible hack to allow default address
// discovery to work. Only works because
@@ -508,6 +513,24 @@ int TestNrSocket::connect(nr_transport_addr *addr) {
}
int TestNrSocket::write(const void *msg, size_t len, size_t *written) {
+ UCHAR *buf = static_cast<UCHAR*>(const_cast<void*>(msg));
+ if (nat_->block_stun_ && nr_is_stun_message(buf, len)) {
+ // Should cause this socket to be abandoned
+ r_log(LOG_GENERIC, LOG_DEBUG,
+ "TestNrSocket %s dropping outgoing TCP "
+ "because it is configured to drop STUN",
+ my_addr().as_string);
+ return R_INTERNAL;
+ }
+
+ if (nat_->block_tcp_ && !tls_) {
+ // Should cause this socket to be abandoned
+ r_log(LOG_GENERIC, LOG_DEBUG,
+ "TestNrSocket %s dropping outgoing TCP "
+ "because it is configured to drop TCP",
+ my_addr().as_string);
+ return R_INTERNAL;
+ }
if (port_mappings_.empty()) {
// The no-nat case, just pass call through.
@@ -518,7 +541,11 @@ int TestNrSocket::write(const void *msg, size_t len, size_t *written) {
} else {
destroy_stale_port_mappings();
if (port_mappings_.empty()) {
- return -1;
+ r_log(LOG_GENERIC, LOG_DEBUG,
+ "TestNrSocket %s dropping outgoing TCP "
+ "because the port mapping was stale",
+ my_addr().as_string);
+ return R_INTERNAL;
}
// This is TCP only
MOZ_ASSERT(port_mappings_.size() == 1);
@@ -533,18 +560,34 @@ int TestNrSocket::write(const void *msg, size_t len, size_t *written) {
}
int TestNrSocket::read(void *buf, size_t maxlen, size_t *len) {
+ int r;
if (port_mappings_.empty()) {
- return internal_socket_->read(buf, maxlen, len);
+ r = internal_socket_->read(buf, maxlen, len);
} else {
MOZ_ASSERT(port_mappings_.size() == 1);
- int bytesRead =
- port_mappings_.front()->external_socket_->read(buf, maxlen, len);
- if (bytesRead > 0 && nat_->refresh_on_ingress_) {
+ r = port_mappings_.front()->external_socket_->read(buf, maxlen, len);
+ if (!r && nat_->refresh_on_ingress_) {
port_mappings_.front()->last_used_ = PR_IntervalNow();
}
- return bytesRead;
}
+
+ if (r) {
+ return r;
+ }
+
+ if (nat_->block_tcp_ && !tls_) {
+ // Should cause this socket to be abandoned
+ return R_INTERNAL;
+ }
+
+ UCHAR *cbuf = static_cast<UCHAR*>(const_cast<void*>(buf));
+ if (nat_->block_stun_ && nr_is_stun_message(cbuf, *len)) {
+ // Should cause this socket to be abandoned
+ return R_INTERNAL;
+ }
+
+ return r;
}
int TestNrSocket::async_wait(int how, NR_async_cb cb, void *cb_arg,
diff --git a/media/mtransport/test_nr_socket.h b/media/mtransport/test_nr_socket.h
index 91c9030f17..a47a88beb9 100644
--- a/media/mtransport/test_nr_socket.h
+++ b/media/mtransport/test_nr_socket.h
@@ -137,6 +137,7 @@ class TestNat {
refresh_on_ingress_(false),
block_udp_(false),
block_stun_(false),
+ block_tcp_(false),
delay_stun_resp_ms_(0),
sockets_() {}
@@ -168,6 +169,7 @@ class TestNat {
bool refresh_on_ingress_;
bool block_udp_;
bool block_stun_;
+ bool block_tcp_;
/* Note: this can only delay a single response so far (bug 1253657) */
uint32_t delay_stun_resp_ms_;
@@ -319,6 +321,7 @@ class TestNrSocket : public NrSocketBase {
// same nat.
RefPtr<NrSocketBase> internal_socket_;
RefPtr<TestNat> nat_;
+ bool tls_;
// Since our comparison logic is different depending on what kind of NAT
// we simulate, and the STL does not make it very easy to switch out the
// comparison function at runtime, and these lists are going to be very
diff --git a/media/mtransport/third_party/nICEr/src/ice/ice_candidate.c b/media/mtransport/third_party/nICEr/src/ice/ice_candidate.c
index e48b7b5e1a..879b77933e 100644
--- a/media/mtransport/third_party/nICEr/src/ice/ice_candidate.c
+++ b/media/mtransport/third_party/nICEr/src/ice/ice_candidate.c
@@ -666,6 +666,14 @@ static int nr_ice_candidate_resolved_cb(void *cb_arg, nr_transport_addr *addr)
if(r=nr_transport_addr_copy(&cand->stun_server_addr,addr))
ABORT(r);
+ if (cand->stun_server->tls) {
+ /* Copy over the DNS name; needed for TLS. There is already a null at the
+ * end of the buffer, leave it there. */
+ strncpy(cand->stun_server_addr.tls_host,
+ cand->stun_server->u.dnsname.host,
+ sizeof(cand->stun_server_addr.tls_host) - 1);
+ }
+
if (cand->tcp_type == TCP_TYPE_PASSIVE || cand->tcp_type == TCP_TYPE_SO){
if (r=nr_socket_multi_tcp_stun_server_connect(cand->osock, addr))
ABORT(r);
diff --git a/media/mtransport/third_party/nICEr/src/ice/ice_ctx.h b/media/mtransport/third_party/nICEr/src/ice/ice_ctx.h
index cc79304f08..1e815ac2ac 100644
--- a/media/mtransport/third_party/nICEr/src/ice/ice_ctx.h
+++ b/media/mtransport/third_party/nICEr/src/ice/ice_ctx.h
@@ -63,6 +63,7 @@ typedef struct nr_ice_stun_server_ {
} u;
int id;
int transport;
+ int tls; /* Whether to use TLS or not */
} nr_ice_stun_server;
typedef struct nr_ice_turn_server_ {
diff --git a/media/mtransport/third_party/nICEr/src/net/transport_addr.h b/media/mtransport/third_party/nICEr/src/net/transport_addr.h
index dfec633291..06c8b8c9c5 100644
--- a/media/mtransport/third_party/nICEr/src/net/transport_addr.h
+++ b/media/mtransport/third_party/nICEr/src/net/transport_addr.h
@@ -66,6 +66,7 @@ typedef struct nr_transport_addr_ {
/* A string version.
56 = 5 ("IP6:[") + 39 (ipv6 address) + 2 ("]:") + 5 (port) + 4 (/UDP) + 1 (null) */
char as_string[56];
+ char tls_host[256];
} nr_transport_addr;
typedef struct nr_transport_addr_mask_ {
diff --git a/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp b/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp
index 3b4363a13c..ad87fa1f91 100644
--- a/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp
+++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp
@@ -335,6 +335,7 @@ PeerConnectionImpl::PeerConnectionImpl(const GlobalObject* aGlobal)
, mSTSThread(nullptr)
, mAllowIceLoopback(false)
, mAllowIceLinkLocal(false)
+ , mForceIceTcp(false)
, mMedia(nullptr)
, mUuidGen(MakeUnique<PCUuidGenerator>())
, mNumAudioStreams(0)
@@ -365,6 +366,8 @@ PeerConnectionImpl::PeerConnectionImpl(const GlobalObject* aGlobal)
"media.peerconnection.ice.loopback", false);
mAllowIceLinkLocal = Preferences::GetBool(
"media.peerconnection.ice.link_local", false);
+ mForceIceTcp = Preferences::GetBool(
+ "media.peerconnection.ice.force_ice_tcp", false);
#endif
memset(mMaxReceiving, 0, sizeof(mMaxReceiving));
memset(mMaxSending, 0, sizeof(mMaxSending));
@@ -526,8 +529,8 @@ PeerConnectionConfiguration::AddIceServer(const RTCIceServer &aServer)
if (!(isStun || isStuns || isTurn || isTurns)) {
return NS_ERROR_FAILURE;
}
- if (isTurns || isStuns) {
- continue; // TODO: Support TURNS and STUNS (Bug 1056934)
+ if (isStuns) {
+ continue; // TODO: Support STUNS (Bug 1056934)
}
nsAutoCString spec;
rv = url->GetSpec(spec);
@@ -576,6 +579,11 @@ PeerConnectionConfiguration::AddIceServer(const RTCIceServer &aServer)
if (port == -1)
port = (isStuns || isTurns)? 5349 : 3478;
+ if (isStuns || isTurns) {
+ // Should we barf if transport is set to udp or something?
+ transport = "tls";
+ }
+
// First check the known good ports for webrtc
bool knownGoodPort = false;
for (int i = 0; !knownGoodPort && gGoodWebrtcPortList[i]; i++) {
@@ -2255,6 +2263,11 @@ NS_IMETHODIMP
PeerConnectionImpl::AddIceCandidate(const char* aCandidate, const char* aMid, unsigned short aLevel) {
PC_AUTO_ENTER_API_CALL(true);
+ if (mForceIceTcp && std::string::npos != std::string(aCandidate).find(" UDP ")) {
+ CSFLogError(logTag, "Blocking remote UDP candidate: %s", aCandidate);
+ return NS_OK;
+ }
+
JSErrorResult rv;
RefPtr<PeerConnectionObserver> pco = do_QueryObjectReferent(mPCObserver);
if (!pco) {
@@ -3106,7 +3119,7 @@ PeerConnectionImpl::SetSignalingState_m(PCImplSignalingState aSignalingState,
mNegotiationNeeded = false;
// If we're rolling back a local offer, we might need to remove some
// transports, but nothing further needs to be done.
- mMedia->ActivateOrRemoveTransports(*mJsepSession);
+ mMedia->ActivateOrRemoveTransports(*mJsepSession, mForceIceTcp);
if (!rollback) {
mMedia->UpdateMediaPipelines(*mJsepSession);
InitializeDataChannel();
@@ -3268,6 +3281,11 @@ PeerConnectionImpl::CandidateReady(const std::string& candidate,
uint16_t level) {
PC_AUTO_ENTER_API_CALL_VOID_RETURN(false);
+ if (mForceIceTcp && std::string::npos != candidate.find(" UDP ")) {
+ CSFLogError(logTag, "Blocking local UDP candidate: %s", candidate.c_str());
+ return;
+ }
+
std::string mid;
bool skipped = false;
nsresult res = mJsepSession->AddLocalIceCandidate(candidate,
diff --git a/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.h b/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.h
index 7b53ea1160..098b34249a 100644
--- a/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.h
+++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.h
@@ -803,6 +803,7 @@ private:
bool mAllowIceLoopback;
bool mAllowIceLinkLocal;
+ bool mForceIceTcp;
RefPtr<PeerConnectionMedia> mMedia;
// The JSEP negotiation session.
diff --git a/media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.cpp b/media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.cpp
index 0d388a8f49..0306b57904 100644
--- a/media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.cpp
+++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.cpp
@@ -457,7 +457,8 @@ PeerConnectionMedia::EnsureTransport_s(size_t aLevel, size_t aComponentCount)
}
void
-PeerConnectionMedia::ActivateOrRemoveTransports(const JsepSession& aSession)
+PeerConnectionMedia::ActivateOrRemoveTransports(const JsepSession& aSession,
+ const bool forceIceTcp)
{
auto transports = aSession.GetTransports();
for (size_t i = 0; i < transports.size(); ++i) {
@@ -480,6 +481,14 @@ PeerConnectionMedia::ActivateOrRemoveTransports(const JsepSession& aSession)
RemoveTransportFlow(i, true);
}
+ if (forceIceTcp) {
+ candidates.erase(std::remove_if(candidates.begin(),
+ candidates.end(),
+ [](const std::string & s) {
+ return s.find(" UDP "); }),
+ candidates.end());
+ }
+
RUN_ON_THREAD(
GetSTSThread(),
WrapRunnable(RefPtr<PeerConnectionMedia>(this),
diff --git a/media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.h b/media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.h
index c0001a5e54..8908e51546 100644
--- a/media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.h
+++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionMedia.h
@@ -270,7 +270,8 @@ class PeerConnectionMedia : public sigslot::has_slots<> {
// Activate or remove ICE transports at the conclusion of offer/answer,
// or when rollback occurs.
- void ActivateOrRemoveTransports(const JsepSession& aSession);
+ void ActivateOrRemoveTransports(const JsepSession& aSession,
+ const bool forceIceTcp);
// Start ICE checks.
void StartIceChecks(const JsepSession& session);
diff --git a/media/webrtc/trunk/webrtc/modules/audio_coding/neteq/audio_classifier.cc b/media/webrtc/trunk/webrtc/modules/audio_coding/neteq/audio_classifier.cc
index 78e0ae76ed..8064f5e412 100644
--- a/media/webrtc/trunk/webrtc/modules/audio_coding/neteq/audio_classifier.cc
+++ b/media/webrtc/trunk/webrtc/modules/audio_coding/neteq/audio_classifier.cc
@@ -32,7 +32,7 @@ AudioClassifier::AudioClassifier()
kDefaultFrameSizeSamples,
NULL)) {
assert(celt_mode_);
- tonality_analysis_init(&analysis_state_);
+ tonality_analysis_init(&analysis_state_, kDefaultSampleRateHz);
}
AudioClassifier::~AudioClassifier() {}
diff --git a/media/webrtc/trunk/webrtc/system_wrappers/source/tick_util.cc b/media/webrtc/trunk/webrtc/system_wrappers/source/tick_util.cc
index 4b5f71aa37..cfd26497ae 100644
--- a/media/webrtc/trunk/webrtc/system_wrappers/source/tick_util.cc
+++ b/media/webrtc/trunk/webrtc/system_wrappers/source/tick_util.cc
@@ -77,7 +77,7 @@ int64_t TickTime::QueryOsForTicks() {
if (retval != KERN_SUCCESS) {
// TODO(wu): Implement CHECK similar to chrome for all the platforms.
// Then replace this with a CHECK(retval == KERN_SUCCESS);
-#ifndef WEBRTC_IOS
+#if !defined(WEBRTC_IOS) && !defined(__aarch64__)
asm("int3");
#else
__builtin_trap();