Skip to content

Commit

Permalink
Fix aac.DecodeConfig sampleRate parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexxIT committed May 22, 2024
1 parent 53242ea commit 78a74da
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pkg/aac/aac.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ func DecodeConfig(b []byte) (objType, sampleFreqIdx, channels byte, sampleRate u
sampleFreqIdx = rd.ReadBits8(4)
if sampleFreqIdx == 0b1111 {
sampleRate = rd.ReadBits(24)
} else {
sampleRate = sampleRates[sampleFreqIdx]
}

channels = rd.ReadBits8(4)
Expand Down
9 changes: 9 additions & 0 deletions pkg/aac/aac_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,12 @@ func TestADTS(t *testing.T) {

require.Equal(t, src[:len(dst)], dst)
}

func TestEncodeConfig(t *testing.T) {
conf := EncodeConfig(TypeAACLC, 48000, 1, false)
require.Equal(t, "1188", hex.EncodeToString(conf))
conf = EncodeConfig(TypeAACLC, 16000, 1, false)
require.Equal(t, "1408", hex.EncodeToString(conf))
conf = EncodeConfig(TypeAACLC, 8000, 1, false)
require.Equal(t, "1588", hex.EncodeToString(conf))
}

0 comments on commit 78a74da

Please sign in to comment.