changed LFLAGS so it works on ubuntu and switched to non-deprecated libav calls

This commit is contained in:
Paul Kohler 2015-12-10 12:54:21 -05:00
parent 6e08365b9b
commit 0b26955b16
5 changed files with 151 additions and 162 deletions

View File

@ -1,4 +1,3 @@
package codec package codec
import ( import (
@ -36,8 +35,8 @@ import (
} }
*/ */
"C" "C"
"unsafe"
"errors" "errors"
"unsafe"
) )
type AACDecoder struct { type AACDecoder struct {
@ -81,4 +80,3 @@ func (m *AACDecoder) Decode(data []byte) (sample []byte, err error) {
} }
return return
} }

View File

@ -1,4 +1,3 @@
package codec package codec
import ( import (
@ -45,8 +44,8 @@ import (
} }
*/ */
"C" "C"
"unsafe"
"errors" "errors"
"unsafe"
) )
type AACEncoder struct { type AACEncoder struct {
@ -90,4 +89,3 @@ func (m *AACEncoder) Encode(sample []byte) (ret []byte, err error) {
) )
return return
} }

View File

@ -1,4 +1,3 @@
package codec package codec
import ( import (
@ -33,9 +32,9 @@ import (
} }
*/ */
"C" "C"
"unsafe"
"errors" "errors"
"image" "image"
"unsafe"
) )
type H264Decoder struct { type H264Decoder struct {
@ -87,4 +86,3 @@ func (m *H264Decoder) Decode(nal []byte) (f *image.YCbCr, err error) {
return return
} }

View File

@ -1,4 +1,3 @@
package codec package codec
import ( import (
@ -39,10 +38,10 @@ import (
*/ */
"C" "C"
"unsafe"
"image"
"errors" "errors"
"image"
"strings" "strings"
"unsafe"
//"log" //"log"
) )
@ -111,12 +110,12 @@ func (m *H264Encoder) Encode(img *image.YCbCr) (out h264Out, err error) {
return return
} }
f = m.m.f f = m.m.f
f.data[0] = (*C.uint8_t)(unsafe.Pointer(&img.Y[0])); f.data[0] = (*C.uint8_t)(unsafe.Pointer(&img.Y[0]))
f.data[1] = (*C.uint8_t)(unsafe.Pointer(&img.Cb[0])); f.data[1] = (*C.uint8_t)(unsafe.Pointer(&img.Cb[0]))
f.data[2] = (*C.uint8_t)(unsafe.Pointer(&img.Cr[0])); f.data[2] = (*C.uint8_t)(unsafe.Pointer(&img.Cr[0]))
f.linesize[0] = (C.int)(img.YStride); f.linesize[0] = (C.int)(img.YStride)
f.linesize[1] = (C.int)(img.CStride); f.linesize[1] = (C.int)(img.CStride)
f.linesize[2] = (C.int)(img.CStride); f.linesize[2] = (C.int)(img.CStride)
} }
C.av_init_packet(&m.m.pkt) C.av_init_packet(&m.m.pkt)
@ -130,7 +129,7 @@ func (m *H264Encoder) Encode(img *image.YCbCr) (out h264Out, err error) {
err = errors.New("no picture") err = errors.New("no picture")
return return
} }
if (m.m.pkt.size == 0) { if m.m.pkt.size == 0 {
err = errors.New("packet size == 0") err = errors.New("packet size == 0")
return return
} }
@ -145,4 +144,3 @@ func (m *H264Encoder) Encode(img *image.YCbCr) (out h264Out, err error) {
return return
} }

View File

@ -1,4 +1,3 @@
/* /*
Golang h264,aac decoder/encoder libav wrapper Golang h264,aac decoder/encoder libav wrapper
@ -19,11 +18,11 @@ Golang h264,aac decoder/encoder libav wrapper
package codec package codec
import ( import (
"unsafe"
"reflect" "reflect"
"unsafe"
/* /*
#cgo darwin LDFLAGS: -lavformat -lavutil -lavcodec #cgo LDFLAGS: -lavformat -lavutil -lavcodec
#include <libavutil/avutil.h> #include <libavutil/avutil.h>
#include <libavformat/avformat.h> #include <libavformat/avformat.h>
@ -47,5 +46,3 @@ func fromCPtr(buf unsafe.Pointer, size int) (ret []uint8) {
hdr.Data = uintptr(buf) hdr.Data = uintptr(buf)
return return
} }