mirror of https://bitbucket.org/ausocean/av.git
Merged in adpcm-mts (pull request #252)
Small fixes for mts encoder handling audio Approved-by: kortschak <dan@kortschak.io>
This commit is contained in:
commit
bfcd2607c7
|
@ -369,7 +369,7 @@ func capAdd16(a, b int16) int16 {
|
||||||
// EncBytes will return the number of adpcm bytes that will be generated when encoding the given amount of pcm bytes (n).
|
// EncBytes will return the number of adpcm bytes that will be generated when encoding the given amount of pcm bytes (n).
|
||||||
func EncBytes(n int) int {
|
func EncBytes(n int) int {
|
||||||
// For 'n' pcm bytes, 1 sample is left uncompressed, the rest is compressed by a factor of 4
|
// For 'n' pcm bytes, 1 sample is left uncompressed, the rest is compressed by a factor of 4
|
||||||
// and a start index and padding-flag byte are added.
|
// and a chunk length (4B), start index (1B) and padding-flag (1B) are added.
|
||||||
// Also if there are an even number of samples, there will be half a byte of padding added to the last byte.
|
// Also if there are an even number of samples, there will be half a byte of padding added to the last byte.
|
||||||
if n%bytesPerEnc == 0 {
|
if n%bytesPerEnc == 0 {
|
||||||
return (n-byteDepth)/compFact + headSize + 1
|
return (n-byteDepth)/compFact + headSize + 1
|
||||||
|
|
|
@ -44,7 +44,7 @@ import (
|
||||||
const (
|
const (
|
||||||
H264ID = 27
|
H264ID = 27
|
||||||
H265ID = 36
|
H265ID = 36
|
||||||
audioStreamID = 0xc0 // First audio stream ID.
|
audioStreamID = 0xc0 // ADPCM audio stream ID.
|
||||||
)
|
)
|
||||||
|
|
||||||
// Constants used to communicate which media codec will be packetized.
|
// Constants used to communicate which media codec will be packetized.
|
||||||
|
@ -150,10 +150,12 @@ type Encoder struct {
|
||||||
func NewEncoder(dst io.WriteCloser, rate float64, mediaType int) *Encoder {
|
func NewEncoder(dst io.WriteCloser, rate float64, mediaType int) *Encoder {
|
||||||
var mPid int
|
var mPid int
|
||||||
var sid byte
|
var sid byte
|
||||||
|
nbp := true
|
||||||
switch mediaType {
|
switch mediaType {
|
||||||
case EncodeAudio:
|
case EncodeAudio:
|
||||||
mPid = AudioPid
|
mPid = AudioPid
|
||||||
sid = audioStreamID
|
sid = audioStreamID
|
||||||
|
nbp = false
|
||||||
case EncodeH265:
|
case EncodeH265:
|
||||||
mPid = VideoPid
|
mPid = VideoPid
|
||||||
sid = H265ID
|
sid = H265ID
|
||||||
|
@ -168,7 +170,7 @@ func NewEncoder(dst io.WriteCloser, rate float64, mediaType int) *Encoder {
|
||||||
Pil: 0,
|
Pil: 0,
|
||||||
Essd: &psi.ESSD{
|
Essd: &psi.ESSD{
|
||||||
St: byte(sid),
|
St: byte(sid),
|
||||||
Epid: 0x0100,
|
Epid: uint16(mPid),
|
||||||
Esil: 0x00,
|
Esil: 0x00,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -180,7 +182,7 @@ func NewEncoder(dst io.WriteCloser, rate float64, mediaType int) *Encoder {
|
||||||
writePeriod: time.Duration(float64(time.Second) / rate),
|
writePeriod: time.Duration(float64(time.Second) / rate),
|
||||||
ptsOffset: ptsOffset,
|
ptsOffset: ptsOffset,
|
||||||
|
|
||||||
nalBasedPSI: true,
|
nalBasedPSI: nbp,
|
||||||
|
|
||||||
pktCount: 8,
|
pktCount: 8,
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue