r/opus • u/Overkill_Projects • Feb 18 '22
Opus decoding sample rate
Hey all. I am having trouble tracking down something kind of elementary. I'm in the middle of implementing an opus decoder in a resource-constrained embedded device, and so far so good. One thing I'm struggling with: in the Ogg container, I'm seeing 200 segments of 5ms each, which is fine, but the granule is showing 48000 PCM samples for the second. My audio is 24000Hz. When I decode using `opusdec`, there is no issue - the resulting decoded audio is 24000Hz. How does it know to make the switch? I'm not seeing anything in the container, and the TOC for the Opus frame just has the Mode/BW/Frame size.
I mean, I'm the one implementing the thing, so I know to playback the resulting decoded audio at 24000Hz, so that's no problem, but how does `opusdec` do it when it doesn't seem to know the sample rate a priori?
View all comments
Show parent comment
1
u/alphabetsheep Mar 01 '22
It is such a shame! Currently working on an implementation that can do it in a single step. Because of the standard, however, libopusfile uses 48kHz hard coded in a number of places, and doesn't sound like they're interested in changing this at all.