ws-apifix: one bitrate unit: every encoder's bitrate option is bit/s (MP3 now too), values below 1000 are kbit/s (the old MP3 values keep working; Opus accepts them too); the MP3 Decoder's bitrate field is bit/s as the Decoder contract says (was kbit/s)
This commit is contained in:
1 parent
3c2a646365
commit
ac47545aa3
10 files changed
+35
-14
No files matched your search
@@ -102,6 +102,13 @@ do
|
||||
local f1 = Mp3.encode(a, { bitrate = 128 }) :: buffer
|
||||
local f2 = Mp3.encode(Pcm.audioDecoder(a), { bitrate = 128 }) :: buffer
|
||||
t:check(buffer.tostring(f1) == buffer.tostring(f2), "Decoder source = Audio source")
|
||||
-- bitrate in bit/s (the documented unit), and the old kbit/s values below 1000: the same file
|
||||
local f4 = Mp3.encode(a, { bitrate = 128000 }) :: buffer
|
||||
t:check(f4 ~= nil and buffer.tostring(f1) == buffer.tostring(f4), "bitrate 128000 bit/s = 128 kbit/s")
|
||||
local d4 = Mp3.open(Bytes.reader(f4)) :: any
|
||||
t:check(math.abs(d4.bitrate - 128000) < 1000, "the decoder reports bit/s: " .. tostring(d4.bitrate))
|
||||
local _, e5 = Mp3.encode(a, { bitrate = 127000 })
|
||||
t:check(e5 and e5.code == Err.ARG and string.find(e5.message, "127000 bit/s", 1, true) ~= nil, "127000 bit/s refused: " .. tostring(e5))
|
||||
a.tags = { title = "Ünïcode title", artist = "An Artist", album = "Album", track = "4", comment = "made here" }
|
||||
local f3 = Mp3.encode(a, { layer = 2 }) :: buffer
|
||||
t:eq(buffer.readstring(f3, 0, 3), "ID3", "an ID3v2 tag in front")
|
||||
@@ -169,6 +176,7 @@ do
|
||||
t:eq(code({}, nil), Err.ARG, "junk")
|
||||
t:eq(code(a, { layer = 1 }), Err.ARG, "layer I")
|
||||
t:eq(code(a, { bitrate = 100 }), Err.ARG, "100 kbps")
|
||||
t:eq(code(a, { bitrate = 100000 }), Err.ARG, "100000 bit/s")
|
||||
t:eq(code(a, { mode = "dual" }), Err.ARG, "dual mode")
|
||||
t:eq(code(a, { sampleRate = 44000 }), Err.ARG, "opts.sampleRate 44 kHz")
|
||||
t:eq(code(a, { layer = 2, sampleRate = 8000 }), Err.ARG, "layer II at 8 kHz")
|
||||
|
||||
Reference in new issue
Block a user