opus decoder adds one sample to many audio files

NEW
Unassigned

Status

()

Core
WebRTC
3 years ago
2 years ago

People

(Reporter: aykevanlaethem, Unassigned)

Tracking

Trunk
x86_64
Linux
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Reporter)

Description

3 years ago
Created attachment 8559028 [details]
sine.opus

User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Firefox/38.0
Build ID: 20150203030243

Steps to reproduce:

I loaded a simple audio file encoded with opusenc (see the attachment) with this jsFiddle: http://jsfiddle.net/nqg226wf/. This fiddle loads files and shows the number of samples for each file.

The audio file has a length of 44101 samples, generated using Audacity (Generate > Sine, default settings apart from the number of samples) and encoded using opusenc (Debian 8). Decoding the opus-encoded file with opusdec produces a WAV file with the same length as the original WAV file (44101 samples).

Tested in Firefox Nightly 38.0a1 (2015-02-03), Firefox Beta (36.0) and Debian Iceweasel (31.4.0).


Actual results:

It loads 44102 samples, not 44101.
Digging a bit further, it looks like there is a pattern: files with a number of samples dividable by 44100 have the correct length, but other file lengths cause one sample to be added.


Expected results:

I would expect the AudioBuffer to contain the same amount of samples as the input WAV file.
Blocks: 772341
Component: Untriaged → Video/Audio
Product: Firefox → Core
Component: Audio/Video → WebRTC
Status: UNCONFIRMED → NEW
backlog: --- → parking-lot
Ever confirmed: true
Opus uses 48 kHz internally, so any 44.1 kHz needs to be resampled before encoding and after decoding. The number of samples needs to be properly rounded in both cases to avoid ending up with too many or too few samples. I don't remember the details. Tim?
Flags: needinfo?(tterribe)
Take the ceiling of fractional samples on encode, take the floor of (i.e., discard) fractional samples on decode.
Flags: needinfo?(tterribe)
You need to log in before you can comment on or make changes to this bug.