提交 91d62b7c authored 作者: Anthony Minessale's avatar Anthony Minessale

FS-10050 polish

上级 be245edf
...@@ -412,12 +412,12 @@ if test "x${ax_cv_c_compiler_vendor}" = "xsun" ; then ...@@ -412,12 +412,12 @@ if test "x${ax_cv_c_compiler_vendor}" = "xsun" ; then
LIBS="$LIBS -m64" LIBS="$LIBS -m64"
fi fi
elif test "x${ax_cv_c_compiler_vendor}" = "xclang" ; then elif test "x${ax_cv_c_compiler_vendor}" = "xclang" ; then
APR_ADDTO(SWITCH_AM_CFLAGS, -fPIC) APR_ADDTO(SWITCH_AM_CFLAGS, -fPIC -ffast-math)
APR_ADDTO(SWITCH_AM_CXXFLAGS, -fPIC) APR_ADDTO(SWITCH_AM_CXXFLAGS, -fPIC -ffast-math)
APR_ADDTO(SWITCH_AM_CFLAGS, -Werror) APR_ADDTO(SWITCH_AM_CFLAGS, -Werror)
elif test "x${ax_cv_c_compiler_vendor}" = "xgnu" ; then elif test "x${ax_cv_c_compiler_vendor}" = "xgnu" ; then
APR_ADDTO(SWITCH_AM_CFLAGS, -fPIC) APR_ADDTO(SWITCH_AM_CFLAGS, -fPIC -ffast-math)
APR_ADDTO(SWITCH_AM_CXXFLAGS, -fPIC) APR_ADDTO(SWITCH_AM_CXXFLAGS, -fPIC -ffast-math)
AC_SUBST([AM_MOD_AVMD_CXXFLAGS], [-std=gnu99]) # FS-8809, needed for MAP_POPULATE AC_SUBST([AM_MOD_AVMD_CXXFLAGS], [-std=gnu99]) # FS-8809, needed for MAP_POPULATE
if test "$ac_cv_gcc_supports_w_no_unused_result" = yes; then if test "$ac_cv_gcc_supports_w_no_unused_result" = yes; then
APR_ADDTO(SWITCH_AM_CFLAGS, -Werror) APR_ADDTO(SWITCH_AM_CFLAGS, -Werror)
......
...@@ -77,6 +77,24 @@ typedef struct switch_rgb_color_s { ...@@ -77,6 +77,24 @@ typedef struct switch_rgb_color_s {
uint8_t b; uint8_t b;
} switch_rgb_color_t; } switch_rgb_color_t;
typedef struct switch_hsl_color_s {
double h;
double s;
double l;
} switch_hsl_color_t;
typedef struct {
double l;
double a;
double b;
} switch_lab_color_t;
typedef struct {
double x;
double y;
double z;
} switch_xyz_color_t;
/**\brief Representation of a rectangle on a surface */ /**\brief Representation of a rectangle on a surface */
typedef struct switch_image_rect { typedef struct switch_image_rect {
unsigned int x; /**< leftmost column */ unsigned int x; /**< leftmost column */
...@@ -391,7 +409,7 @@ SWITCH_DECLARE(switch_status_t) switch_I420_copy2(uint8_t *src_planes[], int src ...@@ -391,7 +409,7 @@ SWITCH_DECLARE(switch_status_t) switch_I420_copy2(uint8_t *src_planes[], int src
/*!\brief chromakey an img, img must be RGBA and return modified img */ /*!\brief chromakey an img, img must be RGBA and return modified img */
SWITCH_DECLARE(void) switch_img_chromakey(switch_image_t *img, switch_rgb_color_t *mask, int threshold); SWITCH_DECLARE(void) switch_img_chromakey(switch_image_t *img, switch_rgb_color_t *mask, int threshold);
SWITCH_DECLARE(void) switch_img_chromakey_multi(switch_image_t *img, switch_rgb_color_t *mask, int *thresholds, int count); SWITCH_DECLARE(void) switch_img_chromakey_multi(switch_image_t *img, switch_image_t *cache_img, switch_rgb_color_t *mask, int *thresholds, int count);
SWITCH_END_EXTERN_C SWITCH_END_EXTERN_C
......
...@@ -43,8 +43,10 @@ SWITCH_MODULE_DEFINITION(mod_video_filter, mod_video_filter_load, mod_video_filt ...@@ -43,8 +43,10 @@ SWITCH_MODULE_DEFINITION(mod_video_filter, mod_video_filter_load, mod_video_filt
typedef struct chromakey_context_s { typedef struct chromakey_context_s {
int threshold; int threshold;
switch_image_t *bgimg; switch_image_t *bgimg;
switch_image_t *backup_img;
switch_image_t *bgimg_scaled; switch_image_t *bgimg_scaled;
switch_image_t *last_img;
void *data;
switch_size_t datalen;
switch_file_handle_t vfh; switch_file_handle_t vfh;
switch_rgb_color_t bgcolor; switch_rgb_color_t bgcolor;
switch_rgb_color_t mask[MAX_MASK]; switch_rgb_color_t mask[MAX_MASK];
...@@ -69,6 +71,9 @@ static void uninit_context(chromakey_context_t *context) ...@@ -69,6 +71,9 @@ static void uninit_context(chromakey_context_t *context)
switch_core_file_close(&context->vfh); switch_core_file_close(&context->vfh);
memset(&context->vfh, 0, sizeof(context->vfh)); memset(&context->vfh, 0, sizeof(context->vfh));
} }
switch_img_free(&context->last_img);
switch_safe_free(context->data);
} }
static void parse_params(chromakey_context_t *context, int start, int argc, char **argv, const char **function, switch_media_bug_flag_t *flags) static void parse_params(chromakey_context_t *context, int start, int argc, char **argv, const char **function, switch_media_bug_flag_t *flags)
...@@ -76,6 +81,9 @@ static void parse_params(chromakey_context_t *context, int start, int argc, char ...@@ -76,6 +81,9 @@ static void parse_params(chromakey_context_t *context, int start, int argc, char
int n = argc - start; int n = argc - start;
int i = start; int i = start;
switch_core_session_request_video_refresh(context->session);
switch_core_media_gen_key_frame(context->session);
switch_mutex_lock(context->command_mutex); switch_mutex_lock(context->command_mutex);
if (n > 0 && argv[i]) { // color if (n > 0 && argv[i]) { // color
...@@ -183,7 +191,7 @@ static switch_status_t video_thread_callback(switch_core_session_t *session, swi ...@@ -183,7 +191,7 @@ static switch_status_t video_thread_callback(switch_core_session_t *session, swi
chromakey_context_t *context = (chromakey_context_t *)user_data; chromakey_context_t *context = (chromakey_context_t *)user_data;
switch_channel_t *channel = switch_core_session_get_channel(session); switch_channel_t *channel = switch_core_session_get_channel(session);
switch_image_t *img = NULL; switch_image_t *img = NULL;
void *data = NULL; switch_size_t bytes;
if (!switch_channel_ready(channel)) { if (!switch_channel_ready(channel)) {
return SWITCH_STATUS_FALSE; return SWITCH_STATUS_FALSE;
...@@ -194,17 +202,27 @@ static switch_status_t video_thread_callback(switch_core_session_t *session, swi ...@@ -194,17 +202,27 @@ static switch_status_t video_thread_callback(switch_core_session_t *session, swi
} }
if (switch_mutex_trylock(context->command_mutex) != SWITCH_STATUS_SUCCESS) { if (switch_mutex_trylock(context->command_mutex) != SWITCH_STATUS_SUCCESS) {
switch_img_patch(frame->img, context->backup_img, 0, 0); switch_img_patch(frame->img, context->last_img, 0, 0);
return SWITCH_STATUS_SUCCESS; return SWITCH_STATUS_SUCCESS;
} }
data = malloc(frame->img->d_w * frame->img->d_h * 4); bytes = frame->img->d_w * frame->img->d_h * 4;
switch_assert(data);
if (bytes > context->datalen) {
context->data = realloc(context->data, bytes);
context->datalen = bytes;
}
switch_assert(context->data);
switch_img_to_raw(frame->img, context->data, frame->img->d_w * 4, SWITCH_IMG_FMT_ARGB);
img = switch_img_wrap(NULL, SWITCH_IMG_FMT_ARGB, frame->img->d_w, frame->img->d_h, 1, context->data);
switch_img_to_raw(frame->img, data, frame->img->d_w * 4, SWITCH_IMG_FMT_ARGB);
img = switch_img_wrap(NULL, SWITCH_IMG_FMT_ARGB, frame->img->d_w, frame->img->d_h, 1, data);
switch_assert(img); switch_assert(img);
switch_img_chromakey_multi(img, context->mask, context->thresholds, context->mask_len); switch_img_chromakey_multi(img, context->last_img, context->mask, context->thresholds, context->mask_len);
switch_img_free(&context->last_img);
switch_img_copy(img, &context->last_img);
if (context->bgimg) { if (context->bgimg) {
if (context->bgimg_scaled && (context->bgimg_scaled->d_w != frame->img->d_w || context->bgimg_scaled->d_h != frame->img->d_h)) { if (context->bgimg_scaled && (context->bgimg_scaled->d_w != frame->img->d_w || context->bgimg_scaled->d_h != frame->img->d_h)) {
...@@ -261,10 +279,7 @@ static switch_status_t video_thread_callback(switch_core_session_t *session, swi ...@@ -261,10 +279,7 @@ static switch_status_t video_thread_callback(switch_core_session_t *session, swi
} }
switch_img_patch(frame->img, img, 0, 0); switch_img_patch(frame->img, img, 0, 0);
switch_img_free(&context->backup_img);
switch_img_copy(frame->img, &context->backup_img);
switch_img_free(&img); switch_img_free(&img);
free(data);
switch_mutex_unlock(context->command_mutex); switch_mutex_unlock(context->command_mutex);
...@@ -313,7 +328,7 @@ SWITCH_STANDARD_APP(chromakey_start_function) ...@@ -313,7 +328,7 @@ SWITCH_STANDARD_APP(chromakey_start_function)
char *argv[4] = { 0 }; char *argv[4] = { 0 };
int argc; int argc;
char *lbuf; char *lbuf;
switch_media_bug_flag_t flags = SMBF_READ_VIDEO_PING | SMBF_READ_VIDEO_PATCH; switch_media_bug_flag_t flags = SMBF_READ_VIDEO_PING;// SMBF_READ_VIDEO_PATCH;
const char *function = "chromakey"; const char *function = "chromakey";
chromakey_context_t *context; chromakey_context_t *context;
......
差异被折叠。
...@@ -6672,12 +6672,12 @@ static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_ ...@@ -6672,12 +6672,12 @@ static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_
} }
if (rtp_session->flags[SWITCH_RTP_FLAG_VIDEO] && !rtp_session->flags[SWITCH_RTP_FLAG_PROXY_MEDIA]) { if (rtp_session->flags[SWITCH_RTP_FLAG_VIDEO] && !rtp_session->flags[SWITCH_RTP_FLAG_PROXY_MEDIA]) {
pt = 200000; pt = 100000;
} }
if (rtp_session->vb) { if (rtp_session->vb) {
if (switch_jb_poll(rtp_session->vb)) { if (switch_jb_poll(rtp_session->vb)) {
pt = 0; pt = 1000;
} }
} }
...@@ -6687,7 +6687,6 @@ static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_ ...@@ -6687,7 +6687,6 @@ static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_
poll_status = switch_poll(rtp_session->read_pollfd, 1, &fdr, pt); poll_status = switch_poll(rtp_session->read_pollfd, 1, &fdr, pt);
if (!rtp_session->flags[SWITCH_RTP_FLAG_VIDEO] && rtp_session->dtmf_data.out_digit_dur > 0) { if (!rtp_session->flags[SWITCH_RTP_FLAG_VIDEO] && rtp_session->dtmf_data.out_digit_dur > 0) {
return_cng_frame(); return_cng_frame();
} }
...@@ -6709,8 +6708,8 @@ static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_ ...@@ -6709,8 +6708,8 @@ static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_
if (read_pretriggered) { if (read_pretriggered) {
read_pretriggered = 0; read_pretriggered = 0;
} else { } else {
status = read_rtp_packet(rtp_session, &bytes, flags, pmapP, poll_status, SWITCH_TRUE); status = read_rtp_packet(rtp_session, &bytes, flags, pmapP, poll_status, SWITCH_TRUE);
if (status == SWITCH_STATUS_GENERR) { if (status == SWITCH_STATUS_GENERR) {
ret = -1; ret = -1;
...@@ -7196,7 +7195,10 @@ static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_ ...@@ -7196,7 +7195,10 @@ static int rtp_common_read(switch_rtp_t *rtp_session, switch_payload_t *payload_
do_continue: do_continue:
if (!bytes && !rtp_session->flags[SWITCH_RTP_FLAG_USE_TIMER]) { if (!bytes && !rtp_session->flags[SWITCH_RTP_FLAG_USE_TIMER]) {
switch_yield(sleep_mss);
if (sleep_mss) {
switch_yield(sleep_mss);
}
} }
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论