ws-m4a: CELT-only Opus encoder in audio/opus (RangeEncoder + CeltEncoder ported from the libopus 1.6 encoder paths to mirror the absorbed decoder: 20 ms full-band CBR, mono and mid/side stereo, silence frames; Encode: Ogg Opus with OpusHead/OpusTags, end trimming, 48 kHz resampling); checked by opusdec / opusinfo / ffmpeg; Opus.caps.encode = true (opus test updated), deps += codecs/Mdct
This commit is contained in:
1 parent
29a95ce24f
commit
84d45c8190
13 files changed
+1761
-8
No files matched your search
@@ -5,14 +5,17 @@
|
||||
-- Supports: decode of every Opus mode / bandwidth / frame size, mono, stereo and surround (optional stereo downmix,
|
||||
-- opts.stereo), pre-skip, end trimming, output gain, OpusTags, sample-accurate seeking (granule bisection + 80 ms
|
||||
-- pre-roll), damaged files (concealment). Output is always 48 kHz f32.
|
||||
-- Not supported: encoding, mapping family 3 (ambisonics projection), chained streams (the first Opus stream is
|
||||
-- decoded), CELT pitch PLC (noise PLC only).
|
||||
-- Encoding (audio/opus/Encode + CeltEncoder, ws-m4a): a CELT-only fixed-frame encoder (20 ms, full band, constant
|
||||
-- bit rate, mono or dual stereo; other input rates resampled to 48 kHz) writing Ogg Opus with OpusTags.
|
||||
-- Not supported: SILK / hybrid encoding, transients / pitch pre-filter in the encoder, mapping family 3 (ambisonics
|
||||
-- projection), chained streams (the first Opus stream is decoded), CELT pitch PLC (noise PLC only).
|
||||
-- Changes from opus-luau: the injected Ogg demuxer is containers/Ogg; errors are core/Err values; read() takes an
|
||||
-- optional output buffer; decode() fully decodes to an Audio.
|
||||
--
|
||||
-- local dec, err = Opus.open(Bytes.reader(buf)) -- the Types.Decoder: dec:read(n, out?), dec:seek(s), ...
|
||||
-- local audio = Opus.decode(Bytes.reader(buf)) -- a Types.Audio
|
||||
-- Opus.Decoder.new(channels) + Opus.Decoder.decode(st, buf, off, len, pcm, base, maxFrames) -- raw packets
|
||||
-- local file = Opus.encode(audio, { bitrate = 96000 }) -- Ogg Opus (CELT only)
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ requires
|
||||
local Err = require("@formats/core/Err")
|
||||
@@ -24,6 +27,7 @@ local Packet = require("@formats/audio/opus/Packet")
|
||||
local RangeDecoder = require("@formats/audio/opus/RangeDecoder")
|
||||
local Celt = require("@formats/audio/opus/Celt")
|
||||
local Silk = require("@formats/audio/opus/Silk")
|
||||
local Encode = require("@formats/audio/opus/Encode")
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ contract
|
||||
local Opus = {
|
||||
@@ -31,8 +35,8 @@ local Opus = {
|
||||
category = "audio",
|
||||
extensions = { "opus" },
|
||||
mime = { "audio/opus", "audio/ogg" },
|
||||
deps = { "core/Err", "core/Bytes", "Types", "containers/Ogg" },
|
||||
caps = { decode = true, encode = false, streaming = true, seek = true, lossy = true, channels = 255, rates = { 48000 } },
|
||||
deps = { "core/Err", "core/Bytes", "Types", "containers/Ogg", "codecs/Mdct" },
|
||||
caps = { decode = true, encode = true, streaming = true, seek = true, lossy = true, channels = 255, rates = { 48000 }, encodeModes = { "celt" } },
|
||||
}
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ types
|
||||
@@ -213,6 +217,12 @@ function Opus.decode(r: any, opts: OpenOptions?): (Types.Audio?, Err.Err?)
|
||||
return a, nil
|
||||
end
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ encode
|
||||
-- encode(audio | decoder, opts?) -> Ogg Opus buffer | nil, Err (CELT only; see audio/opus/Encode)
|
||||
function Opus.encode(value: any, opts: Encode.Options?): (buffer?, Err.Err?)
|
||||
return Encode.encode(value, opts)
|
||||
end
|
||||
|
||||
-- ------------------------------------------------------------------------------------------------ open
|
||||
local Stream = {}
|
||||
Stream.__index = Stream
|
||||
|
||||
Reference in new issue
Block a user