From e14ad07a2671015da955d1083391a327cfa59e1f Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Fri, 6 Feb 2015 11:41:15 -0600 Subject: [PATCH] FS-7500: move function to core --- src/include/switch_core_video.h | 1 + src/mod/applications/mod_fsv/mod_fsv.c | 55 +------------------------- src/switch_core_video.c | 55 ++++++++++++++++++++++++++ 3 files changed, 57 insertions(+), 54 deletions(-) diff --git a/src/include/switch_core_video.h b/src/include/switch_core_video.h index 51f4dd6ffe..880af749e5 100644 --- a/src/include/switch_core_video.h +++ b/src/include/switch_core_video.h @@ -176,6 +176,7 @@ SWITCH_DECLARE(void) switch_img_flip(switch_image_t *img); */ SWITCH_DECLARE(void) switch_img_free(switch_image_t **img); +SWITCH_DECLARE(void) switch_img_add_text(void *buffer, int w, int x, int y, char *s); /** @} */ diff --git a/src/mod/applications/mod_fsv/mod_fsv.c b/src/mod/applications/mod_fsv/mod_fsv.c index 74ecae7c21..8f703e8776 100644 --- a/src/mod/applications/mod_fsv/mod_fsv.c +++ b/src/mod/applications/mod_fsv/mod_fsv.c @@ -481,59 +481,6 @@ SWITCH_STANDARD_APP(play_fsv_function) switch_core_session_video_reset(session); } -uint8_t art[14][16] = { - {0x00, 0x7E, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x7E, 0x00}, - {0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00}, - {0x00, 0x7E, 0x02, 0x02, 0x02, 0x02, 0x02, 0x7E, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x7E, 0x00}, - {0x00, 0x7E, 0x02, 0x02, 0x02, 0x02, 0x02, 0x7E, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x7E, 0x00}, - {0x00, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x7E, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00}, - {0x00, 0x7E, 0x40, 0x40, 0x40, 0x40, 0x40, 0x7E, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x7E, 0x00}, - {0x00, 0x7E, 0x40, 0x40, 0x40, 0x40, 0x40, 0x7E, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x7E, 0x00}, - {0x00, 0x7E, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00}, - {0x00, 0x7E, 0x42, 0x42, 0x42, 0x42, 0x42, 0x7E, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x7E, 0x00}, - {0x00, 0x7E, 0x42, 0x42, 0x42, 0x42, 0x42, 0x7E, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x7E, 0x00}, - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00}, /*.*/ - {0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*:*/ - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-*/ - {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* */ -}; - -void tag(void *buffer, int w, int x, int y, uint8_t n) -{ - int i = 0, j=0; - uint8_t *p = buffer; - - if (n < 0 || n > 13) return; - - for(i=0; i<8; i++) { - for (j=0; j<16; j++) { - *( p + (y + j) * w + (x + i)) = (art[n][j] & 0x80 >> i) ? 0xFF : 0x00; - } - } -} - -void text(void *buffer, int w, int x, int y, char *s) -{ - while (*s) { - int index; - - if (x > w - 8) break; - - switch (*s) { - case '.': index = 10; break; - case ':': index = 11; break; - case '-': index = 12; break; - case ' ': index = 13; break; - default: - index = *s - 0x30; - } - - tag(buffer, w, x, y, index); - x += 8; - s++; - } -} - /* \brief play YUV file in I420 (YV12) format */ @@ -653,7 +600,7 @@ SWITCH_STANDARD_APP(play_yuv_function) if (read_frame) switch_core_session_write_frame(session, read_frame, SWITCH_IO_FLAG_NONE, 0); sprintf(ts_str, "%" SWITCH_TIME_T_FMT, switch_micro_time_now() / 1000); - text(img->planes[SWITCH_PLANE_PACKED], width, 20, 20, ts_str); + switch_img_add_text(img->planes[SWITCH_PLANE_PACKED], width, 20, 20, ts_str); vid_frame.img = img; switch_core_session_write_video_frame(session, &vid_frame, SWITCH_IO_FLAG_NONE, 0); } diff --git a/src/switch_core_video.c b/src/switch_core_video.c index 2e90ae73a3..9d9b1618f9 100644 --- a/src/switch_core_video.c +++ b/src/switch_core_video.c @@ -136,6 +136,61 @@ SWITCH_DECLARE(void) switch_img_copy(switch_image_t *img, switch_image_t **new_i } + +static uint8_t scv_art[14][16] = { + {0x00, 0x7E, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x7E, 0x00}, + {0x00, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00}, + {0x00, 0x7E, 0x02, 0x02, 0x02, 0x02, 0x02, 0x7E, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x7E, 0x00}, + {0x00, 0x7E, 0x02, 0x02, 0x02, 0x02, 0x02, 0x7E, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x7E, 0x00}, + {0x00, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x7E, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00}, + {0x00, 0x7E, 0x40, 0x40, 0x40, 0x40, 0x40, 0x7E, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x7E, 0x00}, + {0x00, 0x7E, 0x40, 0x40, 0x40, 0x40, 0x40, 0x7E, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x7E, 0x00}, + {0x00, 0x7E, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x00}, + {0x00, 0x7E, 0x42, 0x42, 0x42, 0x42, 0x42, 0x7E, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x7E, 0x00}, + {0x00, 0x7E, 0x42, 0x42, 0x42, 0x42, 0x42, 0x7E, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x7E, 0x00}, + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00}, /*.*/ + {0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*:*/ + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /*-*/ + {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, /* */ +}; + +static void scv_tag(void *buffer, int w, int x, int y, uint8_t n) +{ + int i = 0, j=0; + uint8_t *p = buffer; + + if (n < 0 || n > 13) return; + + for(i=0; i<8; i++) { + for (j=0; j<16; j++) { + *( p + (y + j) * w + (x + i)) = (scv_art[n][j] & 0x80 >> i) ? 0xFF : 0x00; + } + } +} + +SWITCH_DECLARE(void) switch_img_add_text(void *buffer, int w, int x, int y, char *s) +{ + while (*s) { + int index; + + if (x > w - 8) break; + + switch (*s) { + case '.': index = 10; break; + case ':': index = 11; break; + case '-': index = 12; break; + case ' ': index = 13; break; + default: + index = *s - 0x30; + } + + scv_tag(buffer, w, x, y, index); + x += 8; + s++; + } +} + + /* For Emacs: * Local Variables: * mode:c