video analysis2.0拆分,ffmpeg封装go接口库
zhangmeng
2019-10-09 77c5d18916638c54a3866ccb6848cb608b211382
add resize
2个文件已修改
29 ■■■■■ 已修改文件
csrc/wrapper.cpp 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
goconv.go 25 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
csrc/wrapper.cpp
@@ -437,6 +437,10 @@
    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;
        }
        auto bridge = new cvbridge(
                srcW, srcH, srcFormat,
                dstW, dstH, pix_fmt, flag);
goconv.go
@@ -64,6 +64,23 @@
    }
}
// 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)
    if c == nil {
        return nil
    }
    return &GoConv{
        srcW,
        srcH,
        dstW,
        dstH,
        c,
    }
}
// Free free
func (c *GoConv) Free() {
    if c.conv != nil {
@@ -90,6 +107,14 @@
    return nil
}
// Resize resize
func (c *GoConv) Resize(src []byte) []byte {
    if c.srcW == c.dstW && c.srcH == c.dstH {
        return src
    }
    return c.ConvToPicture(src)
}
/////////////// for conv
// ConvGPU conv gpu resize