From 0560a8fce4c9d005655fce5025bc0fda8c58bff8 Mon Sep 17 00:00:00 2001 From: zhangmeng <775834166@qq.com> Date: 星期一, 02 十二月 2019 16:15:47 +0800 Subject: [PATCH] update --- libcffmpeg.c | 58 +++++++++++++++++++--------------------------------------- 1 files changed, 19 insertions(+), 39 deletions(-) diff --git a/libcffmpeg.c b/libcffmpeg.c index edc7b5c..3e9490a 100644 --- a/libcffmpeg.c +++ b/libcffmpeg.c @@ -63,6 +63,14 @@ fn_run(h, input); } +int wrap_fn_fps(void *lib, const cffmpeg h){ + if(!fn_fps){ + fn_fps = (lib_cffmpeg_fps)dlsym(lib, "c_ffmpeg_get_fps"); + if (!fn_fps) return 25; + } + return fn_fps(h); +} + void wrap_fn_run_gb28181(void *lib, const cffmpeg h){ if (!fn_gb28181){ fn_gb28181 = (lib_cffmpeg_gb28181)dlsym(lib, "c_ffmpeg_run_gb28181"); @@ -127,6 +135,14 @@ return fn_decoder_pic(h, wid, hei, format, length, id); } +void wrap_fn_close_stream(void *lib, const cffmpeg h){ + if (!fn_close_stream){ + fn_close_stream = (lib_cffmpeg_close_stream)dlsym(lib, "c_ffmpeg_close_stream"); + if (!fn_close_stream) return; + } + fn_close_stream(h); +} + void* wrap_fn_get_avpacket(void *lib, const cffmpeg h, int* size, int* key){ if(!fn_get_avpacket){ fn_get_avpacket = (lib_cffmpeg_avpacket)dlsym(lib, "c_ffmpeg_get_avpacket"); @@ -135,22 +151,13 @@ return fn_get_avpacket(h, size, key); } -// return val: -1 open error; -2, find stream error; -3, converter create error -void* wrap_fn_decode(void *lib, const char* file, const int gb, int* wid, int* hei){ - if (!fn_decode){ - fn_decode = (lib_cffmpeg_decode)dlsym(lib, "c_ffmpeg_decode"); - release_if_err(fn_decode, lib); - } - return fn_decode(file, gb, wid, hei); -} - // for encoder -cencoder wrap_fn_create_encoder(void *lib, const int w, const int h, const int fps, const int br, const int scale_flag, const int gi){ +cencoder wrap_fn_create_encoder(void *lib, const int w, const int h, const int fps, const int br, const int pix_fmt, const int scale_flag, const int gi){ if (!fn_create_encoder){ fn_create_encoder = (lib_cffmpeg_create_encoder)dlsym(lib, "c_ffmpeg_create_encoder"); release_if_err(fn_create_encoder, lib); } - return fn_create_encoder(w, h, fps, br, scale_flag, gi); + return fn_create_encoder(w, h, fps, br, pix_fmt, scale_flag, gi); } void wrap_fn_destroy_encoder(void *lib, const cencoder h){ @@ -169,37 +176,10 @@ uint8_t *out = NULL; const int flag = fn_encode(hdl, (uint8_t*)in, w, h, &out, out_size, key); - if (flag > 0 && out != NULL) { + if (flag == 0 && out != NULL) { return out; } *out_size = 0; *key = 0; return NULL; -} - -// for conv -cconv wrap_fn_create_conv(void *lib, const int srcW, const int srcH, const int srcFormat, - const int dstW, const int dstH, const int dstFormat, const int flag){ - if (!fn_create_conv){ - fn_create_conv = (lib_cffmpeg_create_conv)dlsym(lib, "c_ffmpeg_create_conv"); - release_if_err(fn_create_conv, lib); - } - return fn_create_conv(srcW, srcH, srcFormat, dstW, dstH, dstFormat, flag); -} - -void wrap_fn_destroy_conv(void *lib, const cconv h){ - if (!fn_destroy_conv){ - fn_destroy_conv = (lib_cffmpeg_destroy_conv)dlsym(lib, "c_ffmpeg_destroy_conv"); - if(!fn_destroy_conv) return; - } - fn_destroy_conv(h); -} - -void* wrap_fn_conv(void *lib, const cconv h, uint8_t *in){ - if (!fn_conv){ - fn_conv = (lib_cffmpeg_conv)dlsym(lib, "c_ffmpeg_conv"); - release_if_err(fn_conv, lib); - } - - return fn_conv(h, in); } -- Gitblit v1.8.0