Skip to content

Commit

Permalink
opus: Cleanup endian usage and fix incorrect preskip decode
Browse files Browse the repository at this point in the history
  • Loading branch information
wader committed Dec 4, 2021
1 parent 6a8d77b commit dc1aea3
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion format/matroska/testdata/opus.fqtest
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ $ fq -d matroska verbose /opus.mkv
0x180|70 75 73 48 65 61 64 |pusHead |
0x180| 01 | . | version: 1 0x187-0x187.7 (1)
0x180| 01 | . | channel_count: 1 0x188-0x188.7 (1)
0x180| 78 00 | x. | pre_skip: 30720 0x189-0x18a.7 (2)
0x180| 78 00 | x. | pre_skip: 120 0x189-0x18a.7 (2)
0x180| 80 bb 00 00 | .... | sample_rate: 48000 0x18b-0x18e.7 (4)
0x180| 00| .| output_gain: 0 0x18f-0x190.7 (2)
0x190|00 |. |
Expand Down
2 changes: 1 addition & 1 deletion format/ogg/testdata/opsu.fqtest
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ $ fq -d ogg verbose /opus.ogg
0x000|4f 70 75 73 48 65 61 64 |OpusHead | prefix: "OpusHead" 0x0-0x7.7 (8)
0x000| 01 | . | version: 1 0x8-0x8.7 (1)
0x000| 01 | . | channel_count: 1 0x9-0x9.7 (1)
0x000| 38 01 | 8. | pre_skip: 14337 0xa-0xb.7 (2)
0x000| 38 01 | 8. | pre_skip: 312 0xa-0xb.7 (2)
0x000| 80 bb 00 00| ....| sample_rate: 48000 0xc-0xf.7 (4)
0x010|00 00 |.. | output_gain: 0 0x10-0x11.7 (2)
0x010| 00| | .| | map_family: 0 0x12-0x12.7 (1)
Expand Down
6 changes: 4 additions & 2 deletions format/opus/opus_packet.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ func init() {
}

func opusDecode(d *decode.D, in interface{}) interface{} {
d.Endian = decode.LittleEndian

var prefix []byte
if d.BitsLeft() >= 8*8 {
prefix = d.PeekBytes(8)
Expand All @@ -35,8 +37,8 @@ func opusDecode(d *decode.D, in interface{}) interface{} {
d.FieldU8("version")
channelCount := d.FieldU8("channel_count")
d.FieldU16("pre_skip")
d.FieldU32LE("sample_rate")
d.FieldU16LE("output_gain")
d.FieldU32("sample_rate")
d.FieldU16("output_gain")
mapFamily := d.FieldU8("map_family")
if mapFamily != 0 {
d.FieldU8("stream_count")
Expand Down
2 changes: 1 addition & 1 deletion format/opus/testdata/opus.fqtest
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ $ fq -d opus_packet verbose /opus-head
0x00|4f 70 75 73 48 65 61 64 |OpusHead | prefix: "OpusHead" 0x0-0x7.7 (8)
0x00| 01 | . | version: 1 0x8-0x8.7 (1)
0x00| 02 | . | channel_count: 2 0x9-0x9.7 (1)
0x00| 38 01 | 8. | pre_skip: 14337 0xa-0xb.7 (2)
0x00| 38 01 | 8. | pre_skip: 312 0xa-0xb.7 (2)
0x00| 80 bb 00 00| ....| sample_rate: 48000 0xc-0xf.7 (4)
0x10|00 00 |.. | output_gain: 0 0x10-0x11.7 (2)
0x10| 00| | .| | map_family: 0 0x12-0x12.7 (1)
Expand Down

0 comments on commit dc1aea3

Please sign in to comment.