From de6e563245cdfabc5bd3890d05b7e54bdbf16eb4 Mon Sep 17 00:00:00 2001 From: zhangmeng <775834166@qq.com> Date: 星期三, 09 十月 2019 16:36:16 +0800 Subject: [PATCH] add resize format --- csrc/wrapper.cpp | 10 +++------- csrc/wrapper.hpp | 2 +- cffmpeg.h | 2 +- goconv.go | 12 ++++++++---- libcffmpeg.c | 4 ++-- csrc/cffmpeg.cpp | 4 ++-- libcffmpeg.h | 4 ++-- 7 files changed, 19 insertions(+), 19 deletions(-) diff --git a/cffmpeg.h b/cffmpeg.h index ccc21a6..3128ee1 100644 --- a/cffmpeg.h +++ b/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); diff --git a/csrc/cffmpeg.cpp b/csrc/cffmpeg.cpp index 9ade6f9..824b2a7 100644 --- a/csrc/cffmpeg.cpp +++ b/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){ diff --git a/csrc/wrapper.cpp b/csrc/wrapper.cpp index 5d63805..0e847bf 100644 --- a/csrc/wrapper.cpp +++ b/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)); diff --git a/csrc/wrapper.hpp b/csrc/wrapper.hpp index 13d5f7d..bd9d24f 100644 --- a/csrc/wrapper.hpp +++ b/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); diff --git a/goconv.go b/goconv.go index a120b2a..ebf4ea8 100644 --- a/goconv.go +++ b/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 diff --git a/libcffmpeg.c b/libcffmpeg.c index 2414a16..8f9bd3f 100644 --- a/libcffmpeg.c +++ b/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){ diff --git a/libcffmpeg.h b/libcffmpeg.h index 44d82b2..13be006 100644 --- a/libcffmpeg.h +++ b/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); -- Gitblit v1.8.0