video analysis2.0拆分,ffmpeg封装go接口库
zhangmeng
2019-05-13 b0914c9c39bd1226f1789cc3b53b05cb87797527
shrink scale buffer
1个文件已修改
12 ■■■■■ 已修改文件
csrc/wrapper.cpp 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
csrc/wrapper.cpp
@@ -84,11 +84,12 @@
                auto dec_ctx = in->getCodecContext();
                if(bridge_)delete bridge_;
                scale_w_ = scale_w_ > dec_ctx->width ? dec_ctx->width : scale_w_;
                scale_h_ = scale_h_ > dec_ctx->height ? dec_ctx->height : scale_h_;
                AVPixelFormat pix_fmt = AV_PIX_FMT_BGR24;
                bridge_ = new cvbridge(
                        dec_ctx->width, dec_ctx->height, dec_ctx->pix_fmt,
                        scale_w_?scale_w_:dec_ctx->width, scale_h_?scale_h_:dec_ctx->height, pix_fmt,
                        scale_f_);
                        scale_w_, scale_h_, pix_fmt, scale_f_);
    
            }
            if (!flag){
@@ -235,11 +236,12 @@
        pic_bgr24 pic;
        if(bridge_){
            AVFrame *frm = frame->getAVFrame();
            unsigned char *data = (unsigned char*)malloc(frm->width * frm->height * 3);
            pic.w = scale_w_;
            pic.h = scale_h_;
            unsigned char *data = (unsigned char*)malloc(pic.w * pic.h * 3);
            bridge_->copyPicture(data, frm);
            pic.data = data;
            pic.w = scale_w_ ? scale_w_ : frm->width;
            pic.h = scale_h_ ? scale_h_ : frm->height;
        }
        if(func_dec_){
            func_dec_(pic.data, pic.w, pic.h);