Skip to content

Commit

Permalink
Move encoder to own file
Browse files Browse the repository at this point in the history
  • Loading branch information
mccoyst committed Aug 1, 2014
1 parent 63fbfa7 commit 6096deb
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 26 deletions.
26 changes: 0 additions & 26 deletions ogg.go → encode.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,32 +15,6 @@ import (
"io"
)

const MIMEType = "application/ogg"

var ByteOrder = binary.LittleEndian

type pageHeader struct {
OggS [4]byte // 0-3, always == "OggS"
StreamVersion byte // 4, always == 0
HeaderType byte // 5
Granule int64 // 6-13, codec-specific
Serial uint32 // 14-17, associated with a logical stream
Page uint32 // 18-21, sequence number of page in packet
Crc uint32 // 22-25
Nsegs byte // 26
}

const (
// Continuation of packet
cop byte = 1 + iota
// Beginning of stream
bos = 1 << iota
// End of stream
eos = 1 << iota
)

var crcTable = crc32.MakeTable(0x04c11db7)

type Encoder struct {
serial uint32
w io.Writer
Expand Down
34 changes: 34 additions & 0 deletions header.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// © 2014 Steve McCoy under the MIT license. See LICENSE for details.

package ogg

import (
"encoding/binary"
"hash/crc32"
)

const MIMEType = "application/ogg"

var ByteOrder = binary.LittleEndian

type pageHeader struct {
OggS [4]byte // 0-3, always == "OggS"
StreamVersion byte // 4, always == 0
HeaderType byte // 5
Granule int64 // 6-13, codec-specific
Serial uint32 // 14-17, associated with a logical stream
Page uint32 // 18-21, sequence number of page in packet
Crc uint32 // 22-25
Nsegs byte // 26
}

const (
// Continuation of packet
cop byte = 1 + iota
// Beginning of stream
bos = 1 << iota
// End of stream
eos = 1 << iota
)

var crcTable = crc32.MakeTable(0x04c11db7)

0 comments on commit 6096deb

Please sign in to comment.