《WebAssembly在音视频领域的应用.pdf》由会员分享,可在线阅读,更多相关《WebAssembly在音视频领域的应用.pdf(38页珍藏版)》请在三个皮匠报告上搜索。
1、WebAssembly 在音视频领域的应用为什么引入WebAssemblyWebAssembly介绍WebAssembly开发与在线教育视频的结合展望与预期01为什么引入WebAssembly产品介绍(TutorMeet+)WebRTC 1.0 已经定案,愈发成熟稳定更多的编码器(VP9,AV1)更广泛的浏览器端支持(Edge,Safari已全面支持)更多的终端设备支持(医疗设备、loT)与新技术的结合(VR/AR,机器学习)WebRTC发展现状2017 Oct-70.68%Can I Use WebRTC(By June 2018)Web前端对音视频的定制化处理不及客户端Javascript
2、的运行时性能问题JS缺少处理音视频相关的开源库浏览器处理音视频能力的不足02WebAssembly介绍使浏览器可以运行低级(low level)二进制代码,简写为(wasm)标准:由W3C WebAssembly Community Group设计开发 高性能:提供接近原生的性能 安全、可移植 开发语言:由其他语言(C/C+,Rust等)编译而成 运行:通过Javascript API与浏览器进行交互WebAssembly简介WebAssembly的诞生19952008201320152017-2018Javascript诞生V8asm.jsWebAssembly1.0 spec/go,c#等
3、的支持/已获得主流浏览器的支持理论上不受开发语言限制当前已经支持语言C/C+,Rust,AssemblyScript,C#,Reason,Lua,Go,KotlinMore languages coming soon;WebAssembly现状Can I Use WASM(By June 2018)数据来源:WebAssembly为什么快ParseCompile+Optimizere-optimizeexecuteGCdecodecompile+optimizeexecute二进制格式(Binary Format)Type SectionImport SectionFunction Secti
4、onTable SectionElement SectionStart SectionExport SectionGlobal SectionMemory SectionCode Section(function bodies)Data SectionCode=1Code=2Code=3Code=4Code=9Code=8Code=7Code=6Code=5Code=10Code=11Custom SectionCode=0 由多个区块(Section)按顺序组成 每个Section包括:Section id(1 byte)Section 大小(u32,in bytes)Section 内容
5、主体是Code Section,通常占比90%;二进制格式(Binary Format)二进制格式(Binary Format)对应于二进制格式的“可读的”文本格式 S-Expression(类似lisp的语法)通常保存为.wat(Web Assembly Text format)可以通过Binaryen实现与wasm的 编译/反编译文本格式(Text Format)前一位标示section id后一位表示section size函数体标示wasm以及版本号https:/wasdk.github.io/wasmcodeexplorer/文本格式对照3 支持4种数据类型(Type)i32,i64
6、,f32,f64 指令(Instructions)i32.add,i64.add,i32.sub,f32.sub.call,call_indirect,loop,if,block get_global,set_global,get_local,set_local i32.store,i32.store8,i32.load,i32.load8_u Stack machine数据格式&指令集i32.const 1i32.const 2i32.add123线性内存(Linear memory)“wasm”011101110111001101100001011011010123456789101112