adpcm: fixed merge error

This commit is contained in:
Trek H 2019-04-26 20:02:38 +09:30
parent 2fd8d8de1b
commit a9b1891bbb
1 changed files with 0 additions and 19 deletions

View File

@ -304,7 +304,6 @@ func (d *decoder) decodeBlock(block []byte) (int, error) {
// It writes its output to the encoder's dest.
// The number of bytes written out is returned along with any error that occured.
func (e *encoder) Write(inPcm []byte) (int, error) {
<<<<<<< HEAD:codec/adpcm/adpcm.go
// Determine if there will be a byte that won't contain two full nibbles and will need padding.
pcmLen := len(inPcm)
pad := false
@ -313,15 +312,10 @@ func (e *encoder) Write(inPcm []byte) (int, error) {
}
n, err := e.calcHead(inPcm[0:2], pad)
=======
n, err := e.calcHead(inPcm[0:2])
>>>>>>> 2600fa884f6d71d325dfad995cc1d053106a88d6:audio/adpcm/adpcm.go
if err != nil {
return n, err
}
<<<<<<< HEAD:codec/adpcm/adpcm.go
for i := 3; i < pcmLen; i += 4 {
nib1 := e.encodeSample(int16(binary.LittleEndian.Uint16(inPcm[i-1 : i+1])))
nib2 := e.encodeSample(int16(binary.LittleEndian.Uint16(inPcm[i+1 : i+3])))
@ -336,12 +330,6 @@ func (e *encoder) Write(inPcm []byte) (int, error) {
if pad {
nib := e.encodeSample(int16(binary.LittleEndian.Uint16(inPcm[pcmLen-2 : pcmLen])))
err = e.dest.WriteByte(nib)
=======
for i := 3; i < len(inPcm); i += 4 {
nib1 := e.encodeSample(int16(binary.LittleEndian.Uint16(inPcm[i-1 : i+1])))
nib2 := e.encodeSample(int16(binary.LittleEndian.Uint16(inPcm[i+1 : i+3])))
err = e.dest.WriteByte(byte((nib2 << 4) | nib1))
>>>>>>> 2600fa884f6d71d325dfad995cc1d053106a88d6:audio/adpcm/adpcm.go
if err != nil {
return n, err
}
@ -367,12 +355,8 @@ func (d *decoder) Write(inAdpcm []byte) (int, error) {
// For each byte, seperate it into two nibbles (each nibble is a compressed sample),
// then decode each nibble and output the resulting 16-bit samples.
<<<<<<< HEAD:codec/adpcm/adpcm.go
// If padding flag is true (Adpcm[3]), only decode up until the last byte, then decode that separately.
for i := 4; i < len(inAdpcm)-int(inAdpcm[3]); i++ {
=======
for i := 4; i < len(inAdpcm); i++ {
>>>>>>> 2600fa884f6d71d325dfad995cc1d053106a88d6:audio/adpcm/adpcm.go
twoNibs := inAdpcm[i]
nib2 := byte(twoNibs >> 4)
nib1 := byte((nib2 << 4) ^ twoNibs)
@ -388,7 +372,6 @@ func (d *decoder) Write(inAdpcm []byte) (int, error) {
secondBytes := make([]byte, 2)
binary.LittleEndian.PutUint16(secondBytes, uint16(d.decodeSample(nib2)))
_n, err = d.dest.Write(secondBytes)
<<<<<<< HEAD:codec/adpcm/adpcm.go
n += _n
if err != nil {
return n, err
@ -399,8 +382,6 @@ func (d *decoder) Write(inAdpcm []byte) (int, error) {
samp := make([]byte, 2)
binary.LittleEndian.PutUint16(samp, uint16(d.decodeSample(padNib)))
_n, err := d.dest.Write(samp)
=======
>>>>>>> 2600fa884f6d71d325dfad995cc1d053106a88d6:audio/adpcm/adpcm.go
n += _n
if err != nil {
return n, err