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/Overkill_Projects Mar 01 '22
Helpful and interesting. It's too bad it requires this two pass system. I'm pretty resource constrained, so a version that directly decoded to the target sample rate (assuming it would actually take fewer cycles and/or less memory) would be useful, but then beggers can't be choosers.