package goffmpeg /* #include #include "libcffmpeg.h" */ import "C" import "unsafe" const ( // ScaleNone self add no scale raw frame data ScaleNone = 0 // ScaleFastBilinear SWS_FAST_BILINEAR ScaleFastBilinear = 1 // ScaleBilinear SWS_BILINEAR ScaleBilinear = 2 // ScaleBicubic SWS_BICUBIC ScaleBicubic = 4 // ScaleX SWS_X ScaleX = 8 // ScalePoint SWS_POINT ScalePoint = 0x10 // ScaleArea SWS_AREA ScaleArea = 0x20 // ScaleBicublin SWS_BICUBLIN ScaleBicublin = 0x40 // ScaleGauss SWS_GAUSS ScaleGauss = 0x80 // ScaleSinc SWS_SINC ScaleSinc = 0x100 // ScaleLancZos SWS_LANCZOS ScaleLancZos = 0x200 // ScaleSpline SWS_SPLINE ScaleSpline = 0x400 ) // SrcFormat format const srcFormat = 23 // GoConv conv type GoConv struct { srcW int srcH int dstW int dstH int conv C.cconv } // NewConv new conv func NewConv(srcW, srcH, dstW, dstH, scaleFlag int) *GoConv { c := C.wrap_fn_create_conv(C.int(srcW), C.int(srcH), C.int(srcFormat), C.int(dstW), C.int(dstH), C.int(scaleFlag)) if c == nil { return nil } return &GoConv{ srcW, srcH, dstW, dstH, c, } } // Free free func (c *GoConv) Free() { if c.conv != nil { C.wrap_fn_destroy_conv(c.conv) } } // ConvToPicture conv to pic func (c *GoConv) ConvToPicture(src []byte) []byte { if c.conv == nil { return nil } cin := C.CBytes(src) defer C.free(cin) bgr := C.wrap_fn_conv(c.conv, (*C.uchar)(cin)) defer C.free(unsafe.Pointer(bgr)) if bgr != nil { return C.GoBytes(bgr, C.int(c.dstW*c.dstH*3)) } return nil } /////////////// for conv // ConvGPU conv gpu resize func ConvGPU(in []byte, w, h, dstW, dstH int) []byte { return nil }