mirror of
https://github.com/asticode/go-astiav.git
synced 2025-10-05 08:06:59 +08:00
Moved all c code to .h and .c files + removed struc_ prefix when not needed
This commit is contained in:
@@ -9,10 +9,10 @@ import (
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/release/5.1/libavcodec/bsf.h#L111
|
||||
type BitStreamFilter struct {
|
||||
c *C.struct_AVBitStreamFilter
|
||||
c *C.AVBitStreamFilter
|
||||
}
|
||||
|
||||
func newBitStreamFilterFromC(c *C.struct_AVBitStreamFilter) *BitStreamFilter {
|
||||
func newBitStreamFilterFromC(c *C.AVBitStreamFilter) *BitStreamFilter {
|
||||
if c == nil {
|
||||
return nil
|
||||
}
|
||||
|
@@ -9,10 +9,10 @@ import (
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/release/5.1/libavcodec/bsf.h#L68
|
||||
type BitStreamFilterContext struct {
|
||||
c *C.struct_AVBSFContext
|
||||
c *C.AVBSFContext
|
||||
}
|
||||
|
||||
func newBSFContextFromC(c *C.struct_AVBSFContext) *BitStreamFilterContext {
|
||||
func newBSFContextFromC(c *C.AVBSFContext) *BitStreamFilterContext {
|
||||
if c == nil {
|
||||
return nil
|
||||
}
|
||||
@@ -28,7 +28,7 @@ func AllocBitStreamFilterContext(f *BitStreamFilter) (*BitStreamFilterContext, e
|
||||
return nil, errors.New("astiav: bit stream filter must not be nil")
|
||||
}
|
||||
|
||||
var bsfc *C.struct_AVBSFContext
|
||||
var bsfc *C.AVBSFContext
|
||||
if err := newError(C.av_bsf_alloc(f.c, &bsfc)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -45,7 +45,7 @@ func (bsfc *BitStreamFilterContext) Initialize() error {
|
||||
}
|
||||
|
||||
func (bsfc *BitStreamFilterContext) SendPacket(p *Packet) error {
|
||||
var pc *C.struct_AVPacket
|
||||
var pc *C.AVPacket
|
||||
if p != nil {
|
||||
pc = p.c
|
||||
}
|
||||
|
@@ -1,96 +1,54 @@
|
||||
package astiav
|
||||
|
||||
//#include <libavutil/channel_layout.h>
|
||||
/*
|
||||
|
||||
// Calling C.AV_CHANNEL_LAYOUT_* in Go gives a "could not determine kind of name for X" error
|
||||
// therefore we need to bridge the channel layout values
|
||||
AVChannelLayout *c2goChannelLayoutMono = &(AVChannelLayout)AV_CHANNEL_LAYOUT_MONO;
|
||||
AVChannelLayout *c2goChannelLayoutStereo = &(AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO;
|
||||
AVChannelLayout *c2goChannelLayout2Point1 = &(AVChannelLayout)AV_CHANNEL_LAYOUT_2POINT1;
|
||||
AVChannelLayout *c2goChannelLayout21 = &(AVChannelLayout)AV_CHANNEL_LAYOUT_2_1;
|
||||
AVChannelLayout *c2goChannelLayoutSurround = &(AVChannelLayout)AV_CHANNEL_LAYOUT_SURROUND;
|
||||
AVChannelLayout *c2goChannelLayout3Point1 = &(AVChannelLayout)AV_CHANNEL_LAYOUT_3POINT1;
|
||||
AVChannelLayout *c2goChannelLayout4Point0 = &(AVChannelLayout)AV_CHANNEL_LAYOUT_4POINT0;
|
||||
AVChannelLayout *c2goChannelLayout4Point1 = &(AVChannelLayout)AV_CHANNEL_LAYOUT_4POINT1;
|
||||
AVChannelLayout *c2goChannelLayout22 = &(AVChannelLayout)AV_CHANNEL_LAYOUT_2_2;
|
||||
AVChannelLayout *c2goChannelLayoutQuad = &(AVChannelLayout)AV_CHANNEL_LAYOUT_QUAD;
|
||||
AVChannelLayout *c2goChannelLayout5Point0 = &(AVChannelLayout)AV_CHANNEL_LAYOUT_5POINT0;
|
||||
AVChannelLayout *c2goChannelLayout5Point1 = &(AVChannelLayout)AV_CHANNEL_LAYOUT_5POINT1;
|
||||
AVChannelLayout *c2goChannelLayout5Point0Back = &(AVChannelLayout)AV_CHANNEL_LAYOUT_5POINT0_BACK;
|
||||
AVChannelLayout *c2goChannelLayout5Point1Back = &(AVChannelLayout)AV_CHANNEL_LAYOUT_5POINT1_BACK;
|
||||
AVChannelLayout *c2goChannelLayout6Point0 = &(AVChannelLayout)AV_CHANNEL_LAYOUT_6POINT0;
|
||||
AVChannelLayout *c2goChannelLayout6Point0Front = &(AVChannelLayout)AV_CHANNEL_LAYOUT_6POINT0_FRONT;
|
||||
AVChannelLayout *c2goChannelLayoutHexagonal = &(AVChannelLayout)AV_CHANNEL_LAYOUT_HEXAGONAL;
|
||||
AVChannelLayout *c2goChannelLayout3Point1Point2 = &(AVChannelLayout)AV_CHANNEL_LAYOUT_3POINT1POINT2;
|
||||
AVChannelLayout *c2goChannelLayout6Point1 = &(AVChannelLayout)AV_CHANNEL_LAYOUT_6POINT1;
|
||||
AVChannelLayout *c2goChannelLayout6Point1Back = &(AVChannelLayout)AV_CHANNEL_LAYOUT_6POINT1_BACK;
|
||||
AVChannelLayout *c2goChannelLayout6Point1Front = &(AVChannelLayout)AV_CHANNEL_LAYOUT_6POINT1_FRONT;
|
||||
AVChannelLayout *c2goChannelLayout7Point0 = &(AVChannelLayout)AV_CHANNEL_LAYOUT_7POINT0;
|
||||
AVChannelLayout *c2goChannelLayout7Point0Front = &(AVChannelLayout)AV_CHANNEL_LAYOUT_7POINT0_FRONT;
|
||||
AVChannelLayout *c2goChannelLayout7Point1 = &(AVChannelLayout)AV_CHANNEL_LAYOUT_7POINT1;
|
||||
AVChannelLayout *c2goChannelLayout7Point1Wide = &(AVChannelLayout)AV_CHANNEL_LAYOUT_7POINT1_WIDE;
|
||||
AVChannelLayout *c2goChannelLayout7Point1WideBack = &(AVChannelLayout)AV_CHANNEL_LAYOUT_7POINT1_WIDE_BACK;
|
||||
AVChannelLayout *c2goChannelLayout5Point1Point2Back = &(AVChannelLayout)AV_CHANNEL_LAYOUT_5POINT1POINT2_BACK;
|
||||
AVChannelLayout *c2goChannelLayoutOctagonal = &(AVChannelLayout)AV_CHANNEL_LAYOUT_OCTAGONAL;
|
||||
AVChannelLayout *c2goChannelLayoutCube = &(AVChannelLayout)AV_CHANNEL_LAYOUT_CUBE;
|
||||
AVChannelLayout *c2goChannelLayout5Point1Point4Back = &(AVChannelLayout)AV_CHANNEL_LAYOUT_5POINT1POINT4_BACK;
|
||||
AVChannelLayout *c2goChannelLayout7Point1Point2 = &(AVChannelLayout)AV_CHANNEL_LAYOUT_7POINT1POINT2;
|
||||
AVChannelLayout *c2goChannelLayout7Point1Point4Back = &(AVChannelLayout)AV_CHANNEL_LAYOUT_7POINT1POINT4_BACK;
|
||||
AVChannelLayout *c2goChannelLayoutHexadecagonal = &(AVChannelLayout)AV_CHANNEL_LAYOUT_HEXADECAGONAL;
|
||||
AVChannelLayout *c2goChannelLayoutStereoDownmix = &(AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO_DOWNMIX;
|
||||
AVChannelLayout *c2goChannelLayout22Point2 = &(AVChannelLayout)AV_CHANNEL_LAYOUT_22POINT2;
|
||||
AVChannelLayout *c2goChannelLayout7Point1TopBack = &(AVChannelLayout)AV_CHANNEL_LAYOUT_7POINT1_TOP_BACK;
|
||||
|
||||
*/
|
||||
//#include "channel_layout.h"
|
||||
import "C"
|
||||
import "unsafe"
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n5.0/libavutil/channel_layout.h#L90
|
||||
var (
|
||||
ChannelLayoutMono = newChannelLayoutFromC(C.c2goChannelLayoutMono)
|
||||
ChannelLayoutStereo = newChannelLayoutFromC(C.c2goChannelLayoutStereo)
|
||||
ChannelLayout2Point1 = newChannelLayoutFromC(C.c2goChannelLayout2Point1)
|
||||
ChannelLayout21 = newChannelLayoutFromC(C.c2goChannelLayout21)
|
||||
ChannelLayoutSurround = newChannelLayoutFromC(C.c2goChannelLayoutSurround)
|
||||
ChannelLayout3Point1 = newChannelLayoutFromC(C.c2goChannelLayout3Point1)
|
||||
ChannelLayout4Point0 = newChannelLayoutFromC(C.c2goChannelLayout4Point0)
|
||||
ChannelLayout4Point1 = newChannelLayoutFromC(C.c2goChannelLayout4Point1)
|
||||
ChannelLayout22 = newChannelLayoutFromC(C.c2goChannelLayout22)
|
||||
ChannelLayoutQuad = newChannelLayoutFromC(C.c2goChannelLayoutQuad)
|
||||
ChannelLayout5Point0 = newChannelLayoutFromC(C.c2goChannelLayout5Point0)
|
||||
ChannelLayout5Point1 = newChannelLayoutFromC(C.c2goChannelLayout5Point1)
|
||||
ChannelLayout5Point0Back = newChannelLayoutFromC(C.c2goChannelLayout5Point0Back)
|
||||
ChannelLayout5Point1Back = newChannelLayoutFromC(C.c2goChannelLayout5Point1Back)
|
||||
ChannelLayout6Point0 = newChannelLayoutFromC(C.c2goChannelLayout6Point0)
|
||||
ChannelLayout6Point0Front = newChannelLayoutFromC(C.c2goChannelLayout6Point0Front)
|
||||
ChannelLayoutHexagonal = newChannelLayoutFromC(C.c2goChannelLayoutHexagonal)
|
||||
ChannelLayout3Point1Point2 = newChannelLayoutFromC(C.c2goChannelLayout3Point1Point2)
|
||||
ChannelLayout6Point1 = newChannelLayoutFromC(C.c2goChannelLayout6Point1)
|
||||
ChannelLayout6Point1Back = newChannelLayoutFromC(C.c2goChannelLayout6Point1Back)
|
||||
ChannelLayout6Point1Front = newChannelLayoutFromC(C.c2goChannelLayout6Point1Front)
|
||||
ChannelLayout7Point0 = newChannelLayoutFromC(C.c2goChannelLayout7Point0)
|
||||
ChannelLayout7Point0Front = newChannelLayoutFromC(C.c2goChannelLayout7Point0Front)
|
||||
ChannelLayout7Point1 = newChannelLayoutFromC(C.c2goChannelLayout7Point1)
|
||||
ChannelLayout7Point1Wide = newChannelLayoutFromC(C.c2goChannelLayout7Point1Wide)
|
||||
ChannelLayout7Point1WideBack = newChannelLayoutFromC(C.c2goChannelLayout7Point1WideBack)
|
||||
ChannelLayout5Point1Point2Back = newChannelLayoutFromC(C.c2goChannelLayout5Point1Point2Back)
|
||||
ChannelLayoutOctagonal = newChannelLayoutFromC(C.c2goChannelLayoutOctagonal)
|
||||
ChannelLayoutCube = newChannelLayoutFromC(C.c2goChannelLayoutCube)
|
||||
ChannelLayout5Point1Point4Back = newChannelLayoutFromC(C.c2goChannelLayout5Point1Point4Back)
|
||||
ChannelLayout7Point1Point2 = newChannelLayoutFromC(C.c2goChannelLayout7Point1Point2)
|
||||
ChannelLayout7Point1Point4Back = newChannelLayoutFromC(C.c2goChannelLayout7Point1Point4Back)
|
||||
ChannelLayoutHexadecagonal = newChannelLayoutFromC(C.c2goChannelLayoutHexadecagonal)
|
||||
ChannelLayoutStereoDownmix = newChannelLayoutFromC(C.c2goChannelLayoutStereoDownmix)
|
||||
ChannelLayout22Point2 = newChannelLayoutFromC(C.c2goChannelLayout22Point2)
|
||||
ChannelLayout7Point1TopBack = newChannelLayoutFromC(C.c2goChannelLayout7Point1TopBack)
|
||||
ChannelLayoutMono = newChannelLayoutFromC(C.astiavChannelLayoutMono)
|
||||
ChannelLayoutStereo = newChannelLayoutFromC(C.astiavChannelLayoutStereo)
|
||||
ChannelLayout2Point1 = newChannelLayoutFromC(C.astiavChannelLayout2Point1)
|
||||
ChannelLayout21 = newChannelLayoutFromC(C.astiavChannelLayout21)
|
||||
ChannelLayoutSurround = newChannelLayoutFromC(C.astiavChannelLayoutSurround)
|
||||
ChannelLayout3Point1 = newChannelLayoutFromC(C.astiavChannelLayout3Point1)
|
||||
ChannelLayout4Point0 = newChannelLayoutFromC(C.astiavChannelLayout4Point0)
|
||||
ChannelLayout4Point1 = newChannelLayoutFromC(C.astiavChannelLayout4Point1)
|
||||
ChannelLayout22 = newChannelLayoutFromC(C.astiavChannelLayout22)
|
||||
ChannelLayoutQuad = newChannelLayoutFromC(C.astiavChannelLayoutQuad)
|
||||
ChannelLayout5Point0 = newChannelLayoutFromC(C.astiavChannelLayout5Point0)
|
||||
ChannelLayout5Point1 = newChannelLayoutFromC(C.astiavChannelLayout5Point1)
|
||||
ChannelLayout5Point0Back = newChannelLayoutFromC(C.astiavChannelLayout5Point0Back)
|
||||
ChannelLayout5Point1Back = newChannelLayoutFromC(C.astiavChannelLayout5Point1Back)
|
||||
ChannelLayout6Point0 = newChannelLayoutFromC(C.astiavChannelLayout6Point0)
|
||||
ChannelLayout6Point0Front = newChannelLayoutFromC(C.astiavChannelLayout6Point0Front)
|
||||
ChannelLayoutHexagonal = newChannelLayoutFromC(C.astiavChannelLayoutHexagonal)
|
||||
ChannelLayout3Point1Point2 = newChannelLayoutFromC(C.astiavChannelLayout3Point1Point2)
|
||||
ChannelLayout6Point1 = newChannelLayoutFromC(C.astiavChannelLayout6Point1)
|
||||
ChannelLayout6Point1Back = newChannelLayoutFromC(C.astiavChannelLayout6Point1Back)
|
||||
ChannelLayout6Point1Front = newChannelLayoutFromC(C.astiavChannelLayout6Point1Front)
|
||||
ChannelLayout7Point0 = newChannelLayoutFromC(C.astiavChannelLayout7Point0)
|
||||
ChannelLayout7Point0Front = newChannelLayoutFromC(C.astiavChannelLayout7Point0Front)
|
||||
ChannelLayout7Point1 = newChannelLayoutFromC(C.astiavChannelLayout7Point1)
|
||||
ChannelLayout7Point1Wide = newChannelLayoutFromC(C.astiavChannelLayout7Point1Wide)
|
||||
ChannelLayout7Point1WideBack = newChannelLayoutFromC(C.astiavChannelLayout7Point1WideBack)
|
||||
ChannelLayout5Point1Point2Back = newChannelLayoutFromC(C.astiavChannelLayout5Point1Point2Back)
|
||||
ChannelLayoutOctagonal = newChannelLayoutFromC(C.astiavChannelLayoutOctagonal)
|
||||
ChannelLayoutCube = newChannelLayoutFromC(C.astiavChannelLayoutCube)
|
||||
ChannelLayout5Point1Point4Back = newChannelLayoutFromC(C.astiavChannelLayout5Point1Point4Back)
|
||||
ChannelLayout7Point1Point2 = newChannelLayoutFromC(C.astiavChannelLayout7Point1Point2)
|
||||
ChannelLayout7Point1Point4Back = newChannelLayoutFromC(C.astiavChannelLayout7Point1Point4Back)
|
||||
ChannelLayoutHexadecagonal = newChannelLayoutFromC(C.astiavChannelLayoutHexadecagonal)
|
||||
ChannelLayoutStereoDownmix = newChannelLayoutFromC(C.astiavChannelLayoutStereoDownmix)
|
||||
ChannelLayout22Point2 = newChannelLayoutFromC(C.astiavChannelLayout22Point2)
|
||||
ChannelLayout7Point1TopBack = newChannelLayoutFromC(C.astiavChannelLayout7Point1TopBack)
|
||||
)
|
||||
|
||||
type ChannelLayout struct {
|
||||
c *C.struct_AVChannelLayout
|
||||
c *C.AVChannelLayout
|
||||
}
|
||||
|
||||
func newChannelLayoutFromC(c *C.struct_AVChannelLayout) ChannelLayout {
|
||||
func newChannelLayoutFromC(c *C.AVChannelLayout) ChannelLayout {
|
||||
return ChannelLayout{c: c}
|
||||
}
|
||||
|
||||
@@ -135,12 +93,12 @@ func (l ChannelLayout) Equal(l2 ChannelLayout) bool {
|
||||
return v
|
||||
}
|
||||
|
||||
func (l ChannelLayout) copy(dst *C.struct_AVChannelLayout) error {
|
||||
func (l ChannelLayout) copy(dst *C.AVChannelLayout) error {
|
||||
return newError(C.av_channel_layout_copy(dst, l.c))
|
||||
}
|
||||
|
||||
func (l ChannelLayout) clone() (ChannelLayout, error) {
|
||||
var cl C.struct_AVChannelLayout
|
||||
var cl C.AVChannelLayout
|
||||
err := l.copy(&cl)
|
||||
dst := newChannelLayoutFromC(&cl)
|
||||
return dst, err
|
||||
|
40
channel_layout.h
Normal file
40
channel_layout.h
Normal file
@@ -0,0 +1,40 @@
|
||||
#include <libavutil/channel_layout.h>
|
||||
|
||||
// Calling C.AV_CHANNEL_LAYOUT_* in Go gives a "could not determine kind of name for X" error
|
||||
// therefore we need to bridge the channel layout values
|
||||
AVChannelLayout *astiavChannelLayoutMono = &(AVChannelLayout)AV_CHANNEL_LAYOUT_MONO;
|
||||
AVChannelLayout *astiavChannelLayoutStereo = &(AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO;
|
||||
AVChannelLayout *astiavChannelLayout2Point1 = &(AVChannelLayout)AV_CHANNEL_LAYOUT_2POINT1;
|
||||
AVChannelLayout *astiavChannelLayout21 = &(AVChannelLayout)AV_CHANNEL_LAYOUT_2_1;
|
||||
AVChannelLayout *astiavChannelLayoutSurround = &(AVChannelLayout)AV_CHANNEL_LAYOUT_SURROUND;
|
||||
AVChannelLayout *astiavChannelLayout3Point1 = &(AVChannelLayout)AV_CHANNEL_LAYOUT_3POINT1;
|
||||
AVChannelLayout *astiavChannelLayout4Point0 = &(AVChannelLayout)AV_CHANNEL_LAYOUT_4POINT0;
|
||||
AVChannelLayout *astiavChannelLayout4Point1 = &(AVChannelLayout)AV_CHANNEL_LAYOUT_4POINT1;
|
||||
AVChannelLayout *astiavChannelLayout22 = &(AVChannelLayout)AV_CHANNEL_LAYOUT_2_2;
|
||||
AVChannelLayout *astiavChannelLayoutQuad = &(AVChannelLayout)AV_CHANNEL_LAYOUT_QUAD;
|
||||
AVChannelLayout *astiavChannelLayout5Point0 = &(AVChannelLayout)AV_CHANNEL_LAYOUT_5POINT0;
|
||||
AVChannelLayout *astiavChannelLayout5Point1 = &(AVChannelLayout)AV_CHANNEL_LAYOUT_5POINT1;
|
||||
AVChannelLayout *astiavChannelLayout5Point0Back = &(AVChannelLayout)AV_CHANNEL_LAYOUT_5POINT0_BACK;
|
||||
AVChannelLayout *astiavChannelLayout5Point1Back = &(AVChannelLayout)AV_CHANNEL_LAYOUT_5POINT1_BACK;
|
||||
AVChannelLayout *astiavChannelLayout6Point0 = &(AVChannelLayout)AV_CHANNEL_LAYOUT_6POINT0;
|
||||
AVChannelLayout *astiavChannelLayout6Point0Front = &(AVChannelLayout)AV_CHANNEL_LAYOUT_6POINT0_FRONT;
|
||||
AVChannelLayout *astiavChannelLayoutHexagonal = &(AVChannelLayout)AV_CHANNEL_LAYOUT_HEXAGONAL;
|
||||
AVChannelLayout *astiavChannelLayout3Point1Point2 = &(AVChannelLayout)AV_CHANNEL_LAYOUT_3POINT1POINT2;
|
||||
AVChannelLayout *astiavChannelLayout6Point1 = &(AVChannelLayout)AV_CHANNEL_LAYOUT_6POINT1;
|
||||
AVChannelLayout *astiavChannelLayout6Point1Back = &(AVChannelLayout)AV_CHANNEL_LAYOUT_6POINT1_BACK;
|
||||
AVChannelLayout *astiavChannelLayout6Point1Front = &(AVChannelLayout)AV_CHANNEL_LAYOUT_6POINT1_FRONT;
|
||||
AVChannelLayout *astiavChannelLayout7Point0 = &(AVChannelLayout)AV_CHANNEL_LAYOUT_7POINT0;
|
||||
AVChannelLayout *astiavChannelLayout7Point0Front = &(AVChannelLayout)AV_CHANNEL_LAYOUT_7POINT0_FRONT;
|
||||
AVChannelLayout *astiavChannelLayout7Point1 = &(AVChannelLayout)AV_CHANNEL_LAYOUT_7POINT1;
|
||||
AVChannelLayout *astiavChannelLayout7Point1Wide = &(AVChannelLayout)AV_CHANNEL_LAYOUT_7POINT1_WIDE;
|
||||
AVChannelLayout *astiavChannelLayout7Point1WideBack = &(AVChannelLayout)AV_CHANNEL_LAYOUT_7POINT1_WIDE_BACK;
|
||||
AVChannelLayout *astiavChannelLayout5Point1Point2Back = &(AVChannelLayout)AV_CHANNEL_LAYOUT_5POINT1POINT2_BACK;
|
||||
AVChannelLayout *astiavChannelLayoutOctagonal = &(AVChannelLayout)AV_CHANNEL_LAYOUT_OCTAGONAL;
|
||||
AVChannelLayout *astiavChannelLayoutCube = &(AVChannelLayout)AV_CHANNEL_LAYOUT_CUBE;
|
||||
AVChannelLayout *astiavChannelLayout5Point1Point4Back = &(AVChannelLayout)AV_CHANNEL_LAYOUT_5POINT1POINT4_BACK;
|
||||
AVChannelLayout *astiavChannelLayout7Point1Point2 = &(AVChannelLayout)AV_CHANNEL_LAYOUT_7POINT1POINT2;
|
||||
AVChannelLayout *astiavChannelLayout7Point1Point4Back = &(AVChannelLayout)AV_CHANNEL_LAYOUT_7POINT1POINT4_BACK;
|
||||
AVChannelLayout *astiavChannelLayoutHexadecagonal = &(AVChannelLayout)AV_CHANNEL_LAYOUT_HEXADECAGONAL;
|
||||
AVChannelLayout *astiavChannelLayoutStereoDownmix = &(AVChannelLayout)AV_CHANNEL_LAYOUT_STEREO_DOWNMIX;
|
||||
AVChannelLayout *astiavChannelLayout22Point2 = &(AVChannelLayout)AV_CHANNEL_LAYOUT_22POINT2;
|
||||
AVChannelLayout *astiavChannelLayout7Point1TopBack = &(AVChannelLayout)AV_CHANNEL_LAYOUT_7POINT1_TOP_BACK;
|
22
class.c
Normal file
22
class.c
Normal file
@@ -0,0 +1,22 @@
|
||||
#include <libavutil/log.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
char* astiavClassItemName(AVClass* c, void* ptr) {
|
||||
return (char*)c->item_name(ptr);
|
||||
}
|
||||
|
||||
AVClassCategory astiavClassCategory(AVClass* c, void* ptr) {
|
||||
if (c->get_category) return c->get_category(ptr);
|
||||
return c->category;
|
||||
}
|
||||
|
||||
AVClass** astiavClassParent(AVClass* c, void* ptr) {
|
||||
if (c->parent_log_context_offset) {
|
||||
AVClass** parent = *(AVClass ***) (((uint8_t *) ptr) + c->parent_log_context_offset);
|
||||
if (parent && *parent) {
|
||||
return parent;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
29
class.go
29
class.go
@@ -1,29 +1,6 @@
|
||||
package astiav
|
||||
|
||||
//#include <libavutil/log.h>
|
||||
//#include <stdint.h>
|
||||
/*
|
||||
|
||||
static inline char* astiavClassItemName(AVClass* c, void* ptr) {
|
||||
return (char*)c->item_name(ptr);
|
||||
}
|
||||
|
||||
static inline AVClassCategory astiavClassCategory(AVClass* c, void* ptr) {
|
||||
if (c->get_category) return c->get_category(ptr);
|
||||
return c->category;
|
||||
}
|
||||
|
||||
static inline AVClass** astiavClassParent(AVClass* c, void* ptr) {
|
||||
if (c->parent_log_context_offset) {
|
||||
AVClass** parent = *(AVClass ***) (((uint8_t *) ptr) + c->parent_log_context_offset);
|
||||
if (parent && *parent) {
|
||||
return parent;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
*/
|
||||
//#include "class.h"
|
||||
import "C"
|
||||
import (
|
||||
"fmt"
|
||||
@@ -33,7 +10,7 @@ import (
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n5.0/libavutil/log.h#L66
|
||||
type Class struct {
|
||||
c *C.struct_AVClass
|
||||
c *C.AVClass
|
||||
ptr unsafe.Pointer
|
||||
}
|
||||
|
||||
@@ -41,7 +18,7 @@ func newClassFromC(ptr unsafe.Pointer) *Class {
|
||||
if ptr == nil {
|
||||
return nil
|
||||
}
|
||||
c := (**C.struct_AVClass)(ptr)
|
||||
c := (**C.AVClass)(ptr)
|
||||
if c == nil {
|
||||
return nil
|
||||
}
|
||||
|
5
class.h
Normal file
5
class.h
Normal file
@@ -0,0 +1,5 @@
|
||||
#include <libavutil/log.h>
|
||||
|
||||
char* astiavClassItemName(AVClass* c, void* ptr);
|
||||
AVClassCategory astiavClassCategory(AVClass* c, void* ptr);
|
||||
AVClass** astiavClassParent(AVClass* c, void* ptr);
|
@@ -4,8 +4,7 @@ package astiav
|
||||
import "C"
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n5.0/libavutil/log.h#L28
|
||||
// TODO Find a way to use C.enum_AVClassCategory instead of uint
|
||||
type ClassCategory uint
|
||||
type ClassCategory C.AVClassCategory
|
||||
|
||||
const (
|
||||
ClassCategoryBitstreamFilter = ClassCategory(C.AV_CLASS_CATEGORY_BITSTREAM_FILTER)
|
||||
|
6
codec.go
6
codec.go
@@ -9,10 +9,10 @@ import (
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n5.0/libavcodec/codec.h#L202
|
||||
type Codec struct {
|
||||
c *C.struct_AVCodec
|
||||
c *C.AVCodec
|
||||
}
|
||||
|
||||
func newCodecFromC(c *C.struct_AVCodec) *Codec {
|
||||
func newCodecFromC(c *C.AVCodec) *Codec {
|
||||
if c == nil {
|
||||
return nil
|
||||
}
|
||||
@@ -37,7 +37,7 @@ func (c *Codec) ChannelLayouts() (o []ChannelLayout) {
|
||||
}
|
||||
size := unsafe.Sizeof(*c.c.ch_layouts)
|
||||
for i := 0; ; i++ {
|
||||
v, _ := newChannelLayoutFromC((*C.struct_AVChannelLayout)(unsafe.Pointer(uintptr(unsafe.Pointer(c.c.ch_layouts)) + uintptr(i)*size))).clone()
|
||||
v, _ := newChannelLayoutFromC((*C.AVChannelLayout)(unsafe.Pointer(uintptr(unsafe.Pointer(c.c.ch_layouts)) + uintptr(i)*size))).clone()
|
||||
if !v.Valid() {
|
||||
break
|
||||
}
|
||||
|
22
codec_context.c
Normal file
22
codec_context.c
Normal file
@@ -0,0 +1,22 @@
|
||||
#include "codec_context.h"
|
||||
#include <libavcodec/avcodec.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
enum AVPixelFormat astiavCodecContextGetFormat(AVCodecContext *ctx, const enum AVPixelFormat *pix_fmts)
|
||||
{
|
||||
int pix_fmts_size = 0;
|
||||
while (*pix_fmts != AV_PIX_FMT_NONE) {
|
||||
pix_fmts_size++;
|
||||
pix_fmts++;
|
||||
}
|
||||
pix_fmts -= pix_fmts_size;
|
||||
return goAstiavCodecContextGetFormat(ctx, (enum AVPixelFormat*)(pix_fmts), pix_fmts_size);
|
||||
}
|
||||
void astiavSetCodecContextGetFormat(AVCodecContext *ctx)
|
||||
{
|
||||
ctx->get_format = astiavCodecContextGetFormat;
|
||||
}
|
||||
void astiavResetCodecContextGetFormat(AVCodecContext *ctx)
|
||||
{
|
||||
ctx->get_format = NULL;
|
||||
}
|
@@ -1,30 +1,6 @@
|
||||
package astiav
|
||||
|
||||
//#include <libavcodec/avcodec.h>
|
||||
//#include <libavutil/frame.h>
|
||||
/*
|
||||
extern enum AVPixelFormat goAstiavCodecContextGetFormat(AVCodecContext *ctx, enum AVPixelFormat *pix_fmts, int pix_fmts_size);
|
||||
|
||||
static inline enum AVPixelFormat astiavCodecContextGetFormat(AVCodecContext *ctx, const enum AVPixelFormat *pix_fmts)
|
||||
{
|
||||
int pix_fmts_size = 0;
|
||||
while (*pix_fmts != AV_PIX_FMT_NONE) {
|
||||
pix_fmts_size++;
|
||||
pix_fmts++;
|
||||
}
|
||||
pix_fmts -= pix_fmts_size;
|
||||
return goAstiavCodecContextGetFormat(ctx, (enum AVPixelFormat*)(pix_fmts), pix_fmts_size);
|
||||
}
|
||||
static inline void astiavSetCodecContextGetFormat(AVCodecContext *ctx)
|
||||
{
|
||||
ctx->get_format = astiavCodecContextGetFormat;
|
||||
}
|
||||
static inline void astiavResetCodecContextGetFormat(AVCodecContext *ctx)
|
||||
{
|
||||
ctx->get_format = NULL;
|
||||
}
|
||||
|
||||
*/
|
||||
//#include "codec_context.h"
|
||||
import "C"
|
||||
import (
|
||||
"sync"
|
||||
@@ -33,12 +9,12 @@ import (
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n5.0/libavcodec/avcodec.h#L383
|
||||
type CodecContext struct {
|
||||
c *C.struct_AVCodecContext
|
||||
c *C.AVCodecContext
|
||||
// We need to store this to unref it properly
|
||||
hdc *HardwareDeviceContext
|
||||
}
|
||||
|
||||
func newCodecContextFromC(c *C.struct_AVCodecContext) *CodecContext {
|
||||
func newCodecContextFromC(c *C.AVCodecContext) *CodecContext {
|
||||
if c == nil {
|
||||
return nil
|
||||
}
|
||||
@@ -50,7 +26,7 @@ func newCodecContextFromC(c *C.struct_AVCodecContext) *CodecContext {
|
||||
var _ Classer = (*CodecContext)(nil)
|
||||
|
||||
func AllocCodecContext(c *Codec) *CodecContext {
|
||||
var cc *C.struct_AVCodec
|
||||
var cc *C.AVCodec
|
||||
if c != nil {
|
||||
cc = c.c
|
||||
}
|
||||
@@ -275,7 +251,7 @@ func (cc *CodecContext) SetWidth(width int) {
|
||||
}
|
||||
|
||||
func (cc *CodecContext) Open(c *Codec, d *Dictionary) error {
|
||||
var dc **C.struct_AVDictionary
|
||||
var dc **C.AVDictionary
|
||||
if d != nil {
|
||||
dc = &d.c
|
||||
}
|
||||
@@ -283,7 +259,7 @@ func (cc *CodecContext) Open(c *Codec, d *Dictionary) error {
|
||||
}
|
||||
|
||||
func (cc *CodecContext) ReceivePacket(p *Packet) error {
|
||||
var pc *C.struct_AVPacket
|
||||
var pc *C.AVPacket
|
||||
if p != nil {
|
||||
pc = p.c
|
||||
}
|
||||
@@ -291,7 +267,7 @@ func (cc *CodecContext) ReceivePacket(p *Packet) error {
|
||||
}
|
||||
|
||||
func (cc *CodecContext) SendPacket(p *Packet) error {
|
||||
var pc *C.struct_AVPacket
|
||||
var pc *C.AVPacket
|
||||
if p != nil {
|
||||
pc = p.c
|
||||
}
|
||||
@@ -299,7 +275,7 @@ func (cc *CodecContext) SendPacket(p *Packet) error {
|
||||
}
|
||||
|
||||
func (cc *CodecContext) ReceiveFrame(f *Frame) error {
|
||||
var fc *C.struct_AVFrame
|
||||
var fc *C.AVFrame
|
||||
if f != nil {
|
||||
fc = f.c
|
||||
}
|
||||
@@ -307,7 +283,7 @@ func (cc *CodecContext) ReceiveFrame(f *Frame) error {
|
||||
}
|
||||
|
||||
func (cc *CodecContext) SendFrame(f *Frame) error {
|
||||
var fc *C.struct_AVFrame
|
||||
var fc *C.AVFrame
|
||||
if f != nil {
|
||||
fc = f.c
|
||||
}
|
||||
@@ -343,7 +319,7 @@ func (cc *CodecContext) SetExtraHardwareFrames(n int) {
|
||||
type CodecContextPixelFormatCallback func(pfs []PixelFormat) PixelFormat
|
||||
|
||||
var (
|
||||
codecContextPixelFormatCallbacks = make(map[*C.struct_AVCodecContext]CodecContextPixelFormatCallback)
|
||||
codecContextPixelFormatCallbacks = make(map[*C.AVCodecContext]CodecContextPixelFormatCallback)
|
||||
codecContextPixelFormatCallbacksMutex = &sync.Mutex{}
|
||||
)
|
||||
|
||||
@@ -363,7 +339,7 @@ func (cc *CodecContext) SetPixelFormatCallback(c CodecContextPixelFormatCallback
|
||||
}
|
||||
|
||||
//export goAstiavCodecContextGetFormat
|
||||
func goAstiavCodecContextGetFormat(cc *C.struct_AVCodecContext, pfsCPtr *C.enum_AVPixelFormat, pfsCSize C.int) C.enum_AVPixelFormat {
|
||||
func goAstiavCodecContextGetFormat(cc *C.AVCodecContext, pfsCPtr *C.enum_AVPixelFormat, pfsCSize C.int) C.enum_AVPixelFormat {
|
||||
// Lock
|
||||
codecContextPixelFormatCallbacksMutex.Lock()
|
||||
defer codecContextPixelFormatCallbacksMutex.Unlock()
|
||||
|
6
codec_context.h
Normal file
6
codec_context.h
Normal file
@@ -0,0 +1,6 @@
|
||||
#include <libavcodec/avcodec.h>
|
||||
|
||||
extern enum AVPixelFormat goAstiavCodecContextGetFormat(AVCodecContext *ctx, enum AVPixelFormat *pix_fmts, int pix_fmts_size);
|
||||
enum AVPixelFormat astiavCodecContextGetFormat(AVCodecContext *ctx, const enum AVPixelFormat *pix_fmts);
|
||||
void astiavSetCodecContextGetFormat(AVCodecContext *ctx);
|
||||
void astiavResetCodecContextGetFormat(AVCodecContext *ctx);
|
@@ -5,10 +5,10 @@ import "C"
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n5.0/libavcodec/codec.h#L460
|
||||
type CodecHardwareConfig struct {
|
||||
c *C.struct_AVCodecHWConfig
|
||||
c *C.AVCodecHWConfig
|
||||
}
|
||||
|
||||
func newCodecHardwareConfigFromC(c *C.struct_AVCodecHWConfig) CodecHardwareConfig {
|
||||
func newCodecHardwareConfigFromC(c *C.AVCodecHWConfig) CodecHardwareConfig {
|
||||
return CodecHardwareConfig{c: c}
|
||||
}
|
||||
|
||||
|
@@ -5,14 +5,14 @@ import "C"
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n5.0/libavcodec/codec_par.h#L52
|
||||
type CodecParameters struct {
|
||||
c *C.struct_AVCodecParameters
|
||||
c *C.AVCodecParameters
|
||||
}
|
||||
|
||||
func AllocCodecParameters() *CodecParameters {
|
||||
return newCodecParametersFromC(C.avcodec_parameters_alloc())
|
||||
}
|
||||
|
||||
func newCodecParametersFromC(c *C.struct_AVCodecParameters) *CodecParameters {
|
||||
func newCodecParametersFromC(c *C.AVCodecParameters) *CodecParameters {
|
||||
if c == nil {
|
||||
return nil
|
||||
}
|
||||
|
@@ -10,14 +10,14 @@ import (
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n5.0/libavutil/dict.h#L84
|
||||
type Dictionary struct {
|
||||
c *C.struct_AVDictionary
|
||||
c *C.AVDictionary
|
||||
}
|
||||
|
||||
func NewDictionary() *Dictionary {
|
||||
return &Dictionary{}
|
||||
}
|
||||
|
||||
func newDictionaryFromC(c *C.struct_AVDictionary) *Dictionary {
|
||||
func newDictionaryFromC(c *C.AVDictionary) *Dictionary {
|
||||
if c == nil {
|
||||
return nil
|
||||
}
|
||||
@@ -45,7 +45,7 @@ func (d *Dictionary) ParseString(i, keyValSep, pairsSep string, flags Dictionary
|
||||
func (d *Dictionary) Get(key string, prev *DictionaryEntry, flags DictionaryFlags) *DictionaryEntry {
|
||||
ck := C.CString(key)
|
||||
defer C.free(unsafe.Pointer(ck))
|
||||
var cp *C.struct_AVDictionaryEntry
|
||||
var cp *C.AVDictionaryEntry
|
||||
if prev != nil {
|
||||
cp = prev.c
|
||||
}
|
||||
|
@@ -5,10 +5,10 @@ import "C"
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n5.0/libavutil/dict.h#L79
|
||||
type DictionaryEntry struct {
|
||||
c *C.struct_AVDictionaryEntry
|
||||
c *C.AVDictionaryEntry
|
||||
}
|
||||
|
||||
func newDictionaryEntryFromC(c *C.struct_AVDictionaryEntry) *DictionaryEntry {
|
||||
func newDictionaryEntryFromC(c *C.AVDictionaryEntry) *DictionaryEntry {
|
||||
return &DictionaryEntry{c: c}
|
||||
}
|
||||
|
||||
|
@@ -6,10 +6,10 @@ import "unsafe"
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n5.0/libavfilter/avfilter.h#L165
|
||||
type Filter struct {
|
||||
c *C.struct_AVFilter
|
||||
c *C.AVFilter
|
||||
}
|
||||
|
||||
func newFilterFromC(c *C.struct_AVFilter) *Filter {
|
||||
func newFilterFromC(c *C.AVFilter) *Filter {
|
||||
if c == nil {
|
||||
return nil
|
||||
}
|
||||
|
@@ -12,10 +12,10 @@ import (
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n5.0/libavfilter/avfilter.h#L67
|
||||
type FilterContext struct {
|
||||
c *C.struct_AVFilterContext
|
||||
c *C.AVFilterContext
|
||||
}
|
||||
|
||||
func newFilterContext(c *C.struct_AVFilterContext) *FilterContext {
|
||||
func newFilterContext(c *C.AVFilterContext) *FilterContext {
|
||||
if c == nil {
|
||||
return nil
|
||||
}
|
||||
@@ -32,7 +32,7 @@ func (fc *FilterContext) Free() {
|
||||
}
|
||||
|
||||
func (fc *FilterContext) BuffersrcAddFrame(f *Frame, fs BuffersrcFlags) error {
|
||||
var cf *C.struct_AVFrame
|
||||
var cf *C.AVFrame
|
||||
if f != nil {
|
||||
cf = f.c
|
||||
}
|
||||
@@ -40,7 +40,7 @@ func (fc *FilterContext) BuffersrcAddFrame(f *Frame, fs BuffersrcFlags) error {
|
||||
}
|
||||
|
||||
func (fc *FilterContext) BuffersinkGetFrame(f *Frame, fs BuffersinkFlags) error {
|
||||
var cf *C.struct_AVFrame
|
||||
var cf *C.AVFrame
|
||||
if f != nil {
|
||||
cf = f.c
|
||||
}
|
||||
@@ -60,7 +60,7 @@ func (fc *FilterContext) NbOutputs() int {
|
||||
}
|
||||
|
||||
func (fc *FilterContext) Inputs() (ls []*FilterLink) {
|
||||
lcs := (*[(math.MaxInt32 - 1) / unsafe.Sizeof((*C.struct_AVFilterLink)(nil))](*C.struct_AVFilterLink))(unsafe.Pointer(fc.c.inputs))
|
||||
lcs := (*[(math.MaxInt32 - 1) / unsafe.Sizeof((*C.AVFilterLink)(nil))](*C.AVFilterLink))(unsafe.Pointer(fc.c.inputs))
|
||||
for i := 0; i < fc.NbInputs(); i++ {
|
||||
ls = append(ls, newFilterLinkFromC(lcs[i]))
|
||||
}
|
||||
@@ -68,7 +68,7 @@ func (fc *FilterContext) Inputs() (ls []*FilterLink) {
|
||||
}
|
||||
|
||||
func (fc *FilterContext) Outputs() (ls []*FilterLink) {
|
||||
lcs := (*[(math.MaxInt32 - 1) / unsafe.Sizeof((*C.struct_AVFilterLink)(nil))](*C.struct_AVFilterLink))(unsafe.Pointer(fc.c.outputs))
|
||||
lcs := (*[(math.MaxInt32 - 1) / unsafe.Sizeof((*C.AVFilterLink)(nil))](*C.AVFilterLink))(unsafe.Pointer(fc.c.outputs))
|
||||
for i := 0; i < fc.NbOutputs(); i++ {
|
||||
ls = append(ls, newFilterLinkFromC(lcs[i]))
|
||||
}
|
||||
|
@@ -9,10 +9,10 @@ import (
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n5.0/libavfilter/avfilter.h#L861
|
||||
type FilterGraph struct {
|
||||
c *C.struct_AVFilterGraph
|
||||
c *C.AVFilterGraph
|
||||
}
|
||||
|
||||
func newFilterGraphFromC(c *C.struct_AVFilterGraph) *FilterGraph {
|
||||
func newFilterGraphFromC(c *C.AVFilterGraph) *FilterGraph {
|
||||
if c == nil {
|
||||
return nil
|
||||
}
|
||||
@@ -76,7 +76,7 @@ func (g *FilterGraph) NewFilterContext(f *Filter, name string, args FilterArgs)
|
||||
}
|
||||
cn := C.CString(name)
|
||||
defer C.free(unsafe.Pointer(cn))
|
||||
var c *C.struct_AVFilterContext
|
||||
var c *C.AVFilterContext
|
||||
if err := newError(C.avfilter_graph_create_filter(&c, f.c, cn, ca, nil, g.c)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -86,11 +86,11 @@ func (g *FilterGraph) NewFilterContext(f *Filter, name string, args FilterArgs)
|
||||
func (g *FilterGraph) Parse(content string, inputs, outputs *FilterInOut) error {
|
||||
cc := C.CString(content)
|
||||
defer C.free(unsafe.Pointer(cc))
|
||||
var ic **C.struct_AVFilterInOut
|
||||
var ic **C.AVFilterInOut
|
||||
if inputs != nil {
|
||||
ic = &inputs.c
|
||||
}
|
||||
var oc **C.struct_AVFilterInOut
|
||||
var oc **C.AVFilterInOut
|
||||
if outputs != nil {
|
||||
oc = &outputs.c
|
||||
}
|
||||
|
@@ -5,10 +5,10 @@ import "C"
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n5.0/libavfilter/avfilter.h#L1021
|
||||
type FilterInOut struct {
|
||||
c *C.struct_AVFilterInOut
|
||||
c *C.AVFilterInOut
|
||||
}
|
||||
|
||||
func newFilterInOutFromC(c *C.struct_AVFilterInOut) *FilterInOut {
|
||||
func newFilterInOutFromC(c *C.AVFilterInOut) *FilterInOut {
|
||||
if c == nil {
|
||||
return nil
|
||||
}
|
||||
@@ -28,7 +28,7 @@ func (i *FilterInOut) SetName(n string) {
|
||||
}
|
||||
|
||||
func (i *FilterInOut) SetFilterContext(c *FilterContext) {
|
||||
i.c.filter_ctx = (*C.struct_AVFilterContext)(c.c)
|
||||
i.c.filter_ctx = (*C.AVFilterContext)(c.c)
|
||||
}
|
||||
|
||||
func (i *FilterInOut) SetPadIdx(idx int) {
|
||||
@@ -36,7 +36,7 @@ func (i *FilterInOut) SetPadIdx(idx int) {
|
||||
}
|
||||
|
||||
func (i *FilterInOut) SetNext(n *FilterInOut) {
|
||||
var nc *C.struct_AVFilterInOut
|
||||
var nc *C.AVFilterInOut
|
||||
if n != nil {
|
||||
nc = n.c
|
||||
}
|
||||
|
@@ -5,10 +5,10 @@ import "C"
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n5.0/libavfilter/avfilter.h#L471
|
||||
type FilterLink struct {
|
||||
c *C.struct_AVFilterLink
|
||||
c *C.AVFilterLink
|
||||
}
|
||||
|
||||
func newFilterLinkFromC(c *C.struct_AVFilterLink) *FilterLink {
|
||||
func newFilterLinkFromC(c *C.AVFilterLink) *FilterLink {
|
||||
if c == nil {
|
||||
return nil
|
||||
}
|
||||
|
@@ -10,10 +10,10 @@ import (
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n5.0/libavformat/avformat.h#L1202
|
||||
type FormatContext struct {
|
||||
c *C.struct_AVFormatContext
|
||||
c *C.AVFormatContext
|
||||
}
|
||||
|
||||
func newFormatContextFromC(c *C.struct_AVFormatContext) *FormatContext {
|
||||
func newFormatContextFromC(c *C.AVFormatContext) *FormatContext {
|
||||
if c == nil {
|
||||
return nil
|
||||
}
|
||||
@@ -39,11 +39,11 @@ func AllocOutputFormatContext(of *OutputFormat, formatName, filename string) (*F
|
||||
finc = C.CString(filename)
|
||||
defer C.free(unsafe.Pointer(finc))
|
||||
}
|
||||
var ofc *C.struct_AVOutputFormat
|
||||
var ofc *C.AVOutputFormat
|
||||
if of != nil {
|
||||
ofc = of.c
|
||||
}
|
||||
var fcc *C.struct_AVFormatContext
|
||||
var fcc *C.AVFormatContext
|
||||
if err := newError(C.avformat_alloc_output_context2(&fcc, ofc, fonc, finc)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -137,7 +137,7 @@ func (fc *FormatContext) Pb() *IOContext {
|
||||
}
|
||||
|
||||
func (fc *FormatContext) Programs() (ps []*Program) {
|
||||
pcs := (*[(math.MaxInt32 - 1) / unsafe.Sizeof((*C.struct_AVProgram)(nil))](*C.struct_AVProgram))(unsafe.Pointer(fc.c.programs))
|
||||
pcs := (*[(math.MaxInt32 - 1) / unsafe.Sizeof((*C.AVProgram)(nil))](*C.AVProgram))(unsafe.Pointer(fc.c.programs))
|
||||
for i := 0; i < fc.NbPrograms(); i++ {
|
||||
ps = append(ps, newProgramFromC(pcs[i], fc))
|
||||
}
|
||||
@@ -153,7 +153,7 @@ func (fc *FormatContext) StartTime() int64 {
|
||||
}
|
||||
|
||||
func (fc *FormatContext) Streams() (ss []*Stream) {
|
||||
scs := (*[(math.MaxInt32 - 1) / unsafe.Sizeof((*C.struct_AVStream)(nil))](*C.struct_AVStream))(unsafe.Pointer(fc.c.streams))
|
||||
scs := (*[(math.MaxInt32 - 1) / unsafe.Sizeof((*C.AVStream)(nil))](*C.AVStream))(unsafe.Pointer(fc.c.streams))
|
||||
for i := 0; i < fc.NbStreams(); i++ {
|
||||
ss = append(ss, newStreamFromC(scs[i]))
|
||||
}
|
||||
@@ -174,11 +174,11 @@ func (fc *FormatContext) OpenInput(url string, fmt *InputFormat, d *Dictionary)
|
||||
urlc = C.CString(url)
|
||||
defer C.free(unsafe.Pointer(urlc))
|
||||
}
|
||||
var dc **C.struct_AVDictionary
|
||||
var dc **C.AVDictionary
|
||||
if d != nil {
|
||||
dc = &d.c
|
||||
}
|
||||
var fmtc *C.struct_AVInputFormat
|
||||
var fmtc *C.AVInputFormat
|
||||
if fmt != nil {
|
||||
fmtc = fmt.c
|
||||
}
|
||||
@@ -206,7 +206,7 @@ func (fc *FormatContext) NewProgram(id int) *Program {
|
||||
}
|
||||
|
||||
func (fc *FormatContext) NewStream(c *Codec) *Stream {
|
||||
var cc *C.struct_AVCodec
|
||||
var cc *C.AVCodec
|
||||
if c != nil {
|
||||
cc = c.c
|
||||
}
|
||||
@@ -214,7 +214,7 @@ func (fc *FormatContext) NewStream(c *Codec) *Stream {
|
||||
}
|
||||
|
||||
func (fc *FormatContext) FindStreamInfo(d *Dictionary) error {
|
||||
var dc **C.struct_AVDictionary
|
||||
var dc **C.AVDictionary
|
||||
if d != nil {
|
||||
dc = &d.c
|
||||
}
|
||||
@@ -222,7 +222,7 @@ func (fc *FormatContext) FindStreamInfo(d *Dictionary) error {
|
||||
}
|
||||
|
||||
func (fc *FormatContext) ReadFrame(p *Packet) error {
|
||||
var pc *C.struct_AVPacket
|
||||
var pc *C.AVPacket
|
||||
if p != nil {
|
||||
pc = p.c
|
||||
}
|
||||
@@ -238,7 +238,7 @@ func (fc *FormatContext) Flush() error {
|
||||
}
|
||||
|
||||
func (fc *FormatContext) WriteHeader(d *Dictionary) error {
|
||||
var dc **C.struct_AVDictionary
|
||||
var dc **C.AVDictionary
|
||||
if d != nil {
|
||||
dc = &d.c
|
||||
}
|
||||
@@ -246,7 +246,7 @@ func (fc *FormatContext) WriteHeader(d *Dictionary) error {
|
||||
}
|
||||
|
||||
func (fc *FormatContext) WriteFrame(p *Packet) error {
|
||||
var pc *C.struct_AVPacket
|
||||
var pc *C.AVPacket
|
||||
if p != nil {
|
||||
pc = p.c
|
||||
}
|
||||
@@ -254,7 +254,7 @@ func (fc *FormatContext) WriteFrame(p *Packet) error {
|
||||
}
|
||||
|
||||
func (fc *FormatContext) WriteInterleavedFrame(p *Packet) error {
|
||||
var pc *C.struct_AVPacket
|
||||
var pc *C.AVPacket
|
||||
if p != nil {
|
||||
pc = p.c
|
||||
}
|
||||
@@ -266,7 +266,7 @@ func (fc *FormatContext) WriteTrailer() error {
|
||||
}
|
||||
|
||||
func (fc *FormatContext) GuessSampleAspectRatio(s *Stream, f *Frame) Rational {
|
||||
var cf *C.struct_AVFrame
|
||||
var cf *C.AVFrame
|
||||
if f != nil {
|
||||
cf = f.c
|
||||
}
|
||||
@@ -274,7 +274,7 @@ func (fc *FormatContext) GuessSampleAspectRatio(s *Stream, f *Frame) Rational {
|
||||
}
|
||||
|
||||
func (fc *FormatContext) GuessFrameRate(s *Stream, f *Frame) Rational {
|
||||
var cf *C.struct_AVFrame
|
||||
var cf *C.AVFrame
|
||||
if f != nil {
|
||||
cf = f.c
|
||||
}
|
||||
@@ -287,7 +287,7 @@ func (fc *FormatContext) SDPCreate() (string, error) {
|
||||
|
||||
func sdpCreate(fcs []*FormatContext) (string, error) {
|
||||
return stringFromC(1024, func(buf *C.char, size C.size_t) error {
|
||||
fccs := []*C.struct_AVFormatContext{}
|
||||
fccs := []*C.AVFormatContext{}
|
||||
for _, fc := range fcs {
|
||||
fccs = append(fccs, fc.c)
|
||||
}
|
||||
|
4
frame.go
4
frame.go
@@ -14,10 +14,10 @@ const NumDataPointers = uint(C.AV_NUM_DATA_POINTERS)
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n5.0/libavutil/frame.h#L317
|
||||
type Frame struct {
|
||||
c *C.struct_AVFrame
|
||||
c *C.AVFrame
|
||||
}
|
||||
|
||||
func newFrameFromC(c *C.struct_AVFrame) *Frame {
|
||||
func newFrameFromC(c *C.AVFrame) *Frame {
|
||||
if c == nil {
|
||||
return nil
|
||||
}
|
||||
|
@@ -1,13 +1,7 @@
|
||||
package astiav
|
||||
|
||||
//#include <libavutil/imgutils.h>
|
||||
//#include <stdint.h>
|
||||
/*
|
||||
ptrdiff_t astiavFFAlign(int i, int align)
|
||||
{
|
||||
return FFALIGN(i, align);
|
||||
}
|
||||
*/
|
||||
//#include "macros.h"
|
||||
import "C"
|
||||
import (
|
||||
"errors"
|
||||
|
@@ -9,10 +9,10 @@ import (
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n5.0/libavutil/frame.h#L223
|
||||
type FrameSideData struct {
|
||||
c *C.struct_AVFrameSideData
|
||||
c *C.AVFrameSideData
|
||||
}
|
||||
|
||||
func newFrameSideDataFromC(c *C.struct_AVFrameSideData) *FrameSideData {
|
||||
func newFrameSideDataFromC(c *C.AVFrameSideData) *FrameSideData {
|
||||
if c == nil {
|
||||
return nil
|
||||
}
|
||||
|
@@ -9,7 +9,7 @@ import (
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n5.0/libavutil/hwcontext.h#L61
|
||||
type HardwareDeviceContext struct {
|
||||
c *C.struct_AVBufferRef
|
||||
c *C.AVBufferRef
|
||||
}
|
||||
|
||||
func CreateHardwareDeviceContext(t HardwareDeviceType, device string, options *Dictionary) (*HardwareDeviceContext, error) {
|
||||
@@ -19,7 +19,7 @@ func CreateHardwareDeviceContext(t HardwareDeviceType, device string, options *D
|
||||
deviceC = C.CString(device)
|
||||
defer C.free(unsafe.Pointer(deviceC))
|
||||
}
|
||||
optionsC := (*C.struct_AVDictionary)(nil)
|
||||
optionsC := (*C.AVDictionary)(nil)
|
||||
if options != nil {
|
||||
optionsC = options.c
|
||||
}
|
||||
|
@@ -6,10 +6,10 @@ import "unsafe"
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n5.0/libavformat/avformat.h#L650
|
||||
type InputFormat struct {
|
||||
c *C.struct_AVInputFormat
|
||||
c *C.AVInputFormat
|
||||
}
|
||||
|
||||
func newInputFormatFromC(c *C.struct_AVInputFormat) *InputFormat {
|
||||
func newInputFormatFromC(c *C.AVInputFormat) *InputFormat {
|
||||
if c == nil {
|
||||
return nil
|
||||
}
|
||||
|
8
int_read_write.c
Normal file
8
int_read_write.c
Normal file
@@ -0,0 +1,8 @@
|
||||
#include <libavutil/intreadwrite.h>
|
||||
|
||||
uint32_t astiavRL32(uint8_t *i) {
|
||||
return AV_RL32(i);
|
||||
}
|
||||
uint32_t astiavRL32WithOffset(uint8_t *i, int o) {
|
||||
return AV_RL32(i+o);
|
||||
}
|
@@ -1,14 +1,6 @@
|
||||
package astiav
|
||||
|
||||
//#include <libavutil/intreadwrite.h>
|
||||
/*
|
||||
uint32_t astiavRL32(uint8_t *i) {
|
||||
return AV_RL32(i);
|
||||
}
|
||||
uint32_t astiavRL32WithOffset(uint8_t *i, int o) {
|
||||
return AV_RL32(i+o);
|
||||
}
|
||||
*/
|
||||
//#include "int_read_write.h"
|
||||
import "C"
|
||||
import "unsafe"
|
||||
|
||||
|
4
int_read_write.h
Normal file
4
int_read_write.h
Normal file
@@ -0,0 +1,4 @@
|
||||
#include <stdint.h>
|
||||
|
||||
uint32_t astiavRL32(uint8_t *i);
|
||||
uint32_t astiavRL32WithOffset(uint8_t *i, int o);
|
@@ -12,11 +12,11 @@ import (
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n5.0/libavformat/avio.h#L161
|
||||
type IOContext struct {
|
||||
c *C.struct_AVIOContext
|
||||
c *C.AVIOContext
|
||||
handlerID unsafe.Pointer
|
||||
}
|
||||
|
||||
func newIOContextFromC(c *C.struct_AVIOContext) *IOContext {
|
||||
func newIOContextFromC(c *C.AVIOContext) *IOContext {
|
||||
if c == nil {
|
||||
return nil
|
||||
}
|
||||
@@ -109,7 +109,7 @@ func AllocIOContext(bufferSize int, writable bool, readFunc IOContextReadFunc, s
|
||||
func OpenIOContext(filename string, flags IOContextFlags) (*IOContext, error) {
|
||||
cfi := C.CString(filename)
|
||||
defer C.free(unsafe.Pointer(cfi))
|
||||
var c *C.struct_AVIOContext
|
||||
var c *C.AVIOContext
|
||||
if err := newError(C.avio_open(&c, cfi, C.int(flags))); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
12
io_interrupter.c
Normal file
12
io_interrupter.c
Normal file
@@ -0,0 +1,12 @@
|
||||
#include <libavformat/avio.h>
|
||||
|
||||
int astiavInterruptCallback(void *ret)
|
||||
{
|
||||
return *((int*)ret);
|
||||
}
|
||||
|
||||
AVIOInterruptCB astiavNewInterruptCallback(int *ret)
|
||||
{
|
||||
AVIOInterruptCB c = { astiavInterruptCallback, ret };
|
||||
return c;
|
||||
}
|
@@ -1,17 +1,6 @@
|
||||
package astiav
|
||||
|
||||
//#include <libavformat/avio.h>
|
||||
/*
|
||||
int astiavInterruptCallback(void *ret)
|
||||
{
|
||||
return *((int*)ret);
|
||||
}
|
||||
AVIOInterruptCB astiavNewInterruptCallback(int *ret)
|
||||
{
|
||||
AVIOInterruptCB c = { astiavInterruptCallback, ret };
|
||||
return c;
|
||||
}
|
||||
*/
|
||||
//#include "io_interrupter.h"
|
||||
import "C"
|
||||
|
||||
type IOInterrupter interface {
|
||||
@@ -20,7 +9,7 @@ type IOInterrupter interface {
|
||||
}
|
||||
|
||||
type defaultIOInterrupter struct {
|
||||
c C.struct_AVIOInterruptCB
|
||||
c C.AVIOInterruptCB
|
||||
i C.int
|
||||
}
|
||||
|
||||
|
4
io_interrupter.h
Normal file
4
io_interrupter.h
Normal file
@@ -0,0 +1,4 @@
|
||||
#include <libavformat/avio.h>
|
||||
|
||||
int astiavInterruptCallback(void *ret);
|
||||
AVIOInterruptCB astiavNewInterruptCallback(int *ret);
|
26
log.c
Normal file
26
log.c
Normal file
@@ -0,0 +1,26 @@
|
||||
#include "log.h"
|
||||
#include <libavutil/log.h>
|
||||
#include <stdio.h>
|
||||
|
||||
void astiavLogCallback(void *ptr, int level, const char *fmt, va_list vl)
|
||||
{
|
||||
if (level > av_log_get_level()) return;
|
||||
char msg[1024];
|
||||
vsprintf(msg, fmt, vl);
|
||||
goAstiavLogCallback(ptr, level, (char*)(fmt), msg);
|
||||
}
|
||||
|
||||
void astiavSetLogCallback()
|
||||
{
|
||||
av_log_set_callback(astiavLogCallback);
|
||||
}
|
||||
|
||||
void astiavResetLogCallback()
|
||||
{
|
||||
av_log_set_callback(av_log_default_callback);
|
||||
}
|
||||
|
||||
void astiavLog(void* ptr, int level, const char *fmt, char* arg)
|
||||
{
|
||||
av_log(ptr, level, fmt, arg);
|
||||
}
|
25
log.go
25
log.go
@@ -1,31 +1,8 @@
|
||||
package astiav
|
||||
|
||||
//#include "log.h"
|
||||
//#include <libavutil/log.h>
|
||||
//#include <stdio.h>
|
||||
//#include <stdlib.h>
|
||||
/*
|
||||
extern void goAstiavLogCallback(void* ptr, int level, char* fmt, char* msg);
|
||||
|
||||
static inline void astiavLogCallback(void *ptr, int level, const char *fmt, va_list vl)
|
||||
{
|
||||
if (level > av_log_get_level()) return;
|
||||
char msg[1024];
|
||||
vsprintf(msg, fmt, vl);
|
||||
goAstiavLogCallback(ptr, level, (char*)(fmt), msg);
|
||||
}
|
||||
static inline void astiavSetLogCallback()
|
||||
{
|
||||
av_log_set_callback(astiavLogCallback);
|
||||
}
|
||||
static inline void astiavResetLogCallback()
|
||||
{
|
||||
av_log_set_callback(av_log_default_callback);
|
||||
}
|
||||
static inline void astiavLog(void* ptr, int level, const char *fmt, char* arg)
|
||||
{
|
||||
av_log(ptr, level, fmt, arg);
|
||||
}
|
||||
*/
|
||||
import "C"
|
||||
import (
|
||||
"unsafe"
|
||||
|
7
log.h
Normal file
7
log.h
Normal file
@@ -0,0 +1,7 @@
|
||||
#include <stdarg.h>
|
||||
|
||||
extern void goAstiavLogCallback(void* ptr, int level, char* fmt, char* msg);
|
||||
void astiavLogCallback(void *ptr, int level, const char *fmt, va_list vl);
|
||||
void astiavSetLogCallback();
|
||||
void astiavResetLogCallback();
|
||||
void astiavLog(void* ptr, int level, const char *fmt, char* arg);
|
7
macros.c
Normal file
7
macros.c
Normal file
@@ -0,0 +1,7 @@
|
||||
#include <libavutil/macros.h>
|
||||
#include <stddef.h>
|
||||
|
||||
ptrdiff_t astiavFFAlign(int i, int align)
|
||||
{
|
||||
return FFALIGN(i, align);
|
||||
}
|
3
macros.h
Normal file
3
macros.h
Normal file
@@ -0,0 +1,3 @@
|
||||
#include <stddef.h>
|
||||
|
||||
ptrdiff_t astiavFFAlign(int i, int align);
|
@@ -6,10 +6,10 @@ import "unsafe"
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n5.0/libavformat/avformat.h#L503
|
||||
type OutputFormat struct {
|
||||
c *C.struct_AVOutputFormat
|
||||
c *C.AVOutputFormat
|
||||
}
|
||||
|
||||
func newOutputFormatFromC(c *C.struct_AVOutputFormat) *OutputFormat {
|
||||
func newOutputFormatFromC(c *C.AVOutputFormat) *OutputFormat {
|
||||
if c == nil {
|
||||
return nil
|
||||
}
|
||||
|
@@ -9,10 +9,10 @@ import (
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n5.0/libavcodec/packet.h#L350
|
||||
type Packet struct {
|
||||
c *C.struct_AVPacket
|
||||
c *C.AVPacket
|
||||
}
|
||||
|
||||
func newPacketFromC(c *C.struct_AVPacket) *Packet {
|
||||
func newPacketFromC(c *C.AVPacket) *Packet {
|
||||
if c == nil {
|
||||
return nil
|
||||
}
|
||||
|
@@ -9,11 +9,11 @@ import (
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n6.1.1/libavcodec/packet.h#L342
|
||||
type PacketSideData struct {
|
||||
sd **C.struct_AVPacketSideData
|
||||
sd **C.AVPacketSideData
|
||||
size *C.int
|
||||
}
|
||||
|
||||
func newPacketSideDataFromC(sd **C.struct_AVPacketSideData, size *C.int) *PacketSideData {
|
||||
func newPacketSideDataFromC(sd **C.AVPacketSideData, size *C.int) *PacketSideData {
|
||||
return &PacketSideData{
|
||||
sd: sd,
|
||||
size: size,
|
||||
|
@@ -8,11 +8,11 @@ import (
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n7.0/libavformat/avformat.h#L1181
|
||||
type Program struct {
|
||||
c *C.struct_AVProgram
|
||||
c *C.AVProgram
|
||||
fc *FormatContext
|
||||
}
|
||||
|
||||
func newProgramFromC(c *C.struct_AVProgram, fc *FormatContext) *Program {
|
||||
func newProgramFromC(c *C.AVProgram, fc *FormatContext) *Program {
|
||||
if c == nil {
|
||||
return nil
|
||||
}
|
||||
|
@@ -6,10 +6,10 @@ import "strconv"
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n5.0/libavutil/rational.h#L58
|
||||
type Rational struct {
|
||||
c C.struct_AVRational
|
||||
c C.AVRational
|
||||
}
|
||||
|
||||
func newRationalFromC(c C.struct_AVRational) Rational {
|
||||
func newRationalFromC(c C.AVRational) Rational {
|
||||
return Rational{c: c}
|
||||
}
|
||||
|
||||
|
@@ -5,10 +5,10 @@ import "C"
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n5.0/libavformat/avformat.h#L937
|
||||
type Stream struct {
|
||||
c *C.struct_AVStream
|
||||
c *C.AVStream
|
||||
}
|
||||
|
||||
func newStreamFromC(c *C.struct_AVStream) *Stream {
|
||||
func newStreamFromC(c *C.AVStream) *Stream {
|
||||
if c == nil {
|
||||
return nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user