video analysis2.0拆分,ffmpeg封装go接口库
zhangmeng
2019-10-09 de6e563245cdfabc5bd3890d05b7e54bdbf16eb4
add resize format
7个文件已修改
38 ■■■■ 已修改文件
cffmpeg.h 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
csrc/cffmpeg.cpp 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
csrc/wrapper.cpp 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
csrc/wrapper.hpp 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
goconv.go 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
libcffmpeg.c 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
libcffmpeg.h 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
cffmpeg.h
@@ -36,7 +36,7 @@
// 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);
csrc/cffmpeg.cpp
@@ -118,8 +118,8 @@
}
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){
csrc/wrapper.cpp
@@ -435,15 +435,11 @@
    }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));
csrc/wrapper.hpp
@@ -81,7 +81,7 @@
    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);
goconv.go
@@ -35,7 +35,10 @@
)
// SrcFormat format
const srcFormat = 23
const SrcFormat = 23
// DstFormat format
const DstFormat = 3
// GoConv conv
type GoConv struct {
@@ -49,7 +52,8 @@
// 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
@@ -65,8 +69,8 @@
}
// 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
libcffmpeg.c
@@ -152,8 +152,8 @@
// 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){
libcffmpeg.h
@@ -75,7 +75,7 @@
// 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);
@@ -84,7 +84,7 @@
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);