| | |
| | | |
| | | // conv cpu |
| | | void *c_ffmpeg_create_conv(const int srcW, const int srcH, const int srcFormat, |
| | | const int dstW, const int dstH, const int flag); |
| | | const int dstW, const int dstH, const int dstFormat, const int flag); |
| | | void c_ffmpeg_destroy_conv(void *h); |
| | | void *c_ffmpeg_conv(void *h, uint8_t *in); |
| | | |
| | |
| | | } |
| | | |
| | | void *c_ffmpeg_create_conv(const int srcW, const int srcH, const int srcFormat, |
| | | const int dstW, const int dstH, const int flag){ |
| | | return CreateConvertor(srcW, srcH, srcFormat, dstW, dstH, flag); |
| | | const int dstW, const int dstH, const int dstFormat, const int flag){ |
| | | return CreateConvertor(srcW, srcH, srcFormat, dstW, dstH, dstFormat, flag); |
| | | } |
| | | |
| | | void *c_ffmpeg_conv(void *h, uint8_t *in){ |
| | |
| | | }Conv; |
| | | |
| | | void *CreateConvertor(const int srcW, const int srcH, const int srcFormat, |
| | | const int dstW, const int dstH, const int flag){ |
| | | AVPixelFormat pix_fmt = AV_PIX_FMT_BGR24; |
| | | // just resize |
| | | if (flag == 0){ |
| | | pix_fmt = (AVPixelFormat)srcFormat; |
| | | } |
| | | const int dstW, const int dstH, const int dstFormat, const int flag){ |
| | | |
| | | auto bridge = new cvbridge( |
| | | srcW, srcH, srcFormat, |
| | | dstW, dstH, pix_fmt, flag); |
| | | dstW, dstH, dstFormat, flag); |
| | | if (!bridge) return NULL; |
| | | |
| | | Conv *c = (Conv*)malloc(sizeof(Conv)); |
| | |
| | | int Encode(void *hdl, uint8_t *in, const int w, const int h, uint8_t **out, int *size, int *key); |
| | | |
| | | void *CreateConvertor(const int srcW, const int srcH, const int srcFormat, |
| | | const int dstW, const int dstH, const int flag); |
| | | const int dstW, const int dstH, const int dstFormat, const int flag); |
| | | uint8_t *Convert(void *h, uint8_t *src); |
| | | void DestoryConvertor(void *h); |
| | | |
| | |
| | | ) |
| | | |
| | | // SrcFormat format |
| | | const srcFormat = 23 |
| | | const SrcFormat = 23 |
| | | |
| | | // DstFormat format |
| | | const DstFormat = 3 |
| | | |
| | | // GoConv conv |
| | | type GoConv struct { |
| | |
| | | |
| | | // 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)) |
| | | c := C.wrap_fn_create_conv(C.int(srcW), C.int(srcH), C.int(SrcFormat), |
| | | C.int(dstW), C.int(dstH), C.int(DstFormat), C.int(scaleFlag)) |
| | | |
| | | if c == nil { |
| | | return nil |
| | |
| | | } |
| | | |
| | | // NewResizer resize |
| | | func NewResizer(srcW, srcH, dstW, dstH int) *GoConv { |
| | | c := C.wrap_fn_create_conv(C.int(srcW), C.int(srcH), C.int(srcFormat), C.int(dstW), C.int(dstH), ScaleNone) |
| | | func NewResizer(srcW, srcH, format, dstW, dstH int) *GoConv { |
| | | c := C.wrap_fn_create_conv(C.int(srcW), C.int(srcH), C.int(format), C.int(dstW), C.int(dstH), C.int(format), ScaleNone) |
| | | |
| | | if c == nil { |
| | | return nil |
| | |
| | | |
| | | // for conv |
| | | cconv wrap_fn_create_conv(const int srcW, const int srcH, const int srcFormat, |
| | | const int dstW, const int dstH, const int flag){ |
| | | return fn_create_conv(srcW, srcH, srcFormat, dstW, dstH, flag); |
| | | const int dstW, const int dstH, const int dstFormat, const int flag){ |
| | | return fn_create_conv(srcW, srcH, srcFormat, dstW, dstH, dstFormat, flag); |
| | | } |
| | | |
| | | void wrap_fn_destroy_conv(const cconv h){ |
| | |
| | | |
| | | // for conv |
| | | typedef void *cconv; |
| | | typedef cconv (*lib_cffmpeg_create_conv)(const int, const int, const int, const int, const int, const int); |
| | | typedef cconv (*lib_cffmpeg_create_conv)(const int, const int, const int, const int, const int, const int, const int); |
| | | typedef void* (*lib_cffmpeg_conv)(const cconv, uint8_t *in); |
| | | typedef void (*lib_cffmpeg_destroy_conv)(const cconv); |
| | | |
| | |
| | | static lib_cffmpeg_conv fn_conv = NULL; |
| | | |
| | | cconv wrap_fn_create_conv(const int srcW, const int srcH, const int srcFormat, |
| | | const int dstW, const int dstH, const int flag); |
| | | const int dstW, const int dstH, const int dstFormat, const int flag); |
| | | void wrap_fn_destroy_conv(const cconv h); |
| | | void* wrap_fn_conv(const cconv h, uint8_t *in); |
| | | |