Commit ec04db28 authored by Rafaël Carré's avatar Rafaël Carré

Specify nosignal picture with an image file

parent d1114a9d
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
#include <vlc_picture_pool.h> #include <vlc_picture_pool.h>
#include <vlc_block.h> #include <vlc_block.h>
#include <vlc_image.h>
#include <vlc_atomic.h> #include <vlc_atomic.h>
#include <vlc_aout.h> #include <vlc_aout.h>
#include <arpa/inet.h> #include <arpa/inet.h>
...@@ -72,6 +73,9 @@ static const int pi_channels_maps[CHANNELS_MAX+1] = ...@@ -72,6 +73,9 @@ static const int pi_channels_maps[CHANNELS_MAX+1] =
"After this delay we black out the video."\ "After this delay we black out the video."\
) )
#define NOSIGNAL_IMAGE_TEXT N_("Picture to display on input signal loss.")
#define NOSIGNAL_IMAGE_LONGTEXT NOSIGNAL_IMAGE_TEXT
#define CARD_INDEX_TEXT N_("Output card") #define CARD_INDEX_TEXT N_("Output card")
#define CARD_INDEX_LONGTEXT N_(\ #define CARD_INDEX_LONGTEXT N_(\
"DeckLink output card, if multiple exist. " \ "DeckLink output card, if multiple exist. " \
...@@ -132,6 +136,7 @@ struct vout_display_sys_t ...@@ -132,6 +136,7 @@ struct vout_display_sys_t
picture_pool_t *pool; picture_pool_t *pool;
bool tenbits; bool tenbits;
int nosignal_delay; int nosignal_delay;
picture_t *pic_nosignal;
}; };
/* Only one audio output module and one video output module /* Only one audio output module and one video output module
...@@ -200,6 +205,8 @@ vlc_module_begin() ...@@ -200,6 +205,8 @@ vlc_module_begin()
VIDEO_TENBITS_TEXT, VIDEO_TENBITS_LONGTEXT, true) VIDEO_TENBITS_TEXT, VIDEO_TENBITS_LONGTEXT, true)
add_integer(VIDEO_CFG_PREFIX "nosignal-delay", 5, add_integer(VIDEO_CFG_PREFIX "nosignal-delay", 5,
NOSIGNAL_INDEX_TEXT, NOSIGNAL_INDEX_LONGTEXT, true) NOSIGNAL_INDEX_TEXT, NOSIGNAL_INDEX_LONGTEXT, true)
add_loadfile(VIDEO_CFG_PREFIX "nosignal-image", NULL,
NOSIGNAL_IMAGE_TEXT, NOSIGNAL_IMAGE_LONGTEXT, true)
add_submodule () add_submodule ()
...@@ -615,23 +622,29 @@ static void DisplayVideo(vout_display_t *vd, picture_t *picture, subpicture_t *) ...@@ -615,23 +622,29 @@ static void DisplayVideo(vout_display_t *vd, picture_t *picture, subpicture_t *)
if (!picture) if (!picture)
return; return;
picture_t *orig_picture = picture;
if (now - picture->date > sys->nosignal_delay * CLOCK_FREQ) { if (now - picture->date > sys->nosignal_delay * CLOCK_FREQ) {
msg_Dbg(vd, "no signal"); msg_Dbg(vd, "no signal");
if (sys->tenbits) { // I422_10L if (sys->pic_nosignal) {
plane_t *y = &picture->p[0]; picture = sys->pic_nosignal;
memset(y->p_pixels, 0x0, y->i_lines * y->i_pitch); } else {
for (int i = 1; i < picture->i_planes; i++) { if (sys->tenbits) { // I422_10L
plane_t *p = &picture->p[i]; plane_t *y = &picture->p[0];
size_t len = p->i_lines * p->i_pitch / 2; memset(y->p_pixels, 0x0, y->i_lines * y->i_pitch);
int16_t *data = (int16_t*)p->p_pixels; for (int i = 1; i < picture->i_planes; i++) {
for (size_t j = 0; j < len; j++) // XXX: SIMD plane_t *p = &picture->p[i];
data[j] = 0x200; size_t len = p->i_lines * p->i_pitch / 2;
} int16_t *data = (int16_t*)p->p_pixels;
} else { // UYVY for (size_t j = 0; j < len; j++) // XXX: SIMD
size_t len = picture->p[0].i_lines * picture->p[0].i_pitch; data[j] = 0x200;
for (size_t i = 0; i < len; i+= 2) { // XXX: SIMD }
picture->p[0].p_pixels[i+0] = 0x80; } else { // UYVY
picture->p[0].p_pixels[i+1] = 0; size_t len = picture->p[0].i_lines * picture->p[0].i_pitch;
for (size_t i = 0; i < len; i+= 2) { // XXX: SIMD
picture->p[0].p_pixels[i+0] = 0x80;
picture->p[0].p_pixels[i+1] = 0;
}
} }
} }
picture->date = now; picture->date = now;
...@@ -695,7 +708,7 @@ static void DisplayVideo(vout_display_t *vd, picture_t *picture, subpicture_t *) ...@@ -695,7 +708,7 @@ static void DisplayVideo(vout_display_t *vd, picture_t *picture, subpicture_t *)
end: end:
if (pDLVideoFrame) if (pDLVideoFrame)
pDLVideoFrame->Release(); pDLVideoFrame->Release();
picture_Release(picture); picture_Release(orig_picture);
} }
static int ControlVideo(vout_display_t *vd, int query, va_list args) static int ControlVideo(vout_display_t *vd, int query, va_list args)
...@@ -724,9 +737,12 @@ static int OpenVideo(vlc_object_t *p_this) ...@@ -724,9 +737,12 @@ static int OpenVideo(vlc_object_t *p_this)
sys->tenbits = var_InheritBool(p_this, VIDEO_CFG_PREFIX "tenbits"); sys->tenbits = var_InheritBool(p_this, VIDEO_CFG_PREFIX "tenbits");
sys->nosignal_delay = var_InheritInteger(p_this, VIDEO_CFG_PREFIX "nosignal-delay"); sys->nosignal_delay = var_InheritInteger(p_this, VIDEO_CFG_PREFIX "nosignal-delay");
sys->pic_nosignal = NULL;
decklink_sys = OpenDecklink(vd); decklink_sys = OpenDecklink(vd);
if (!decklink_sys) { if (!decklink_sys) {
if (sys->pic_nosignal)
picture_Release(sys->pic_nosignal);
free(sys); free(sys);
return VLC_EGENERIC; return VLC_EGENERIC;
} }
...@@ -741,6 +757,36 @@ static int OpenVideo(vlc_object_t *p_this) ...@@ -741,6 +757,36 @@ static int OpenVideo(vlc_object_t *p_this)
vd->fmt.i_width = decklink_sys->i_width; vd->fmt.i_width = decklink_sys->i_width;
vd->fmt.i_height = decklink_sys->i_height; vd->fmt.i_height = decklink_sys->i_height;
char *pic_file = var_InheritString(p_this, VIDEO_CFG_PREFIX "nosignal-image");
if (pic_file) {
image_handler_t *img = image_HandlerCreate(p_this);
if (!img) {
msg_Err(p_this, "Could not create image converter");
} else {
video_format_t in, dummy;
video_format_Init(&in, 0);
video_format_Setup(&in, 0, vd->fmt.i_width, vd->fmt.i_height, 1, 1);
video_format_Init(&dummy, 0);
picture_t *png = image_ReadUrl(img, pic_file, &dummy, &in);
if (png) {
msg_Err(p_this, "Converting");
sys->pic_nosignal = image_Convert(img, png, &in, &vd->fmt);
picture_Release(png);
}
image_HandlerDelete(img);
}
free(pic_file);
if (!sys->pic_nosignal) {
CloseVideo(p_this);
msg_Err(p_this, "Could not create no signal picture");
return VLC_EGENERIC;
}
}
vd->info.has_hide_mouse = true; vd->info.has_hide_mouse = true;
vd->pool = PoolVideo; vd->pool = PoolVideo;
vd->prepare = NULL; vd->prepare = NULL;
...@@ -760,6 +806,9 @@ static void CloseVideo(vlc_object_t *p_this) ...@@ -760,6 +806,9 @@ static void CloseVideo(vlc_object_t *p_this)
if (sys->pool) if (sys->pool)
picture_pool_Delete(sys->pool); picture_pool_Delete(sys->pool);
if (sys->pic_nosignal)
picture_Release(sys->pic_nosignal);
free(sys); free(sys);
ReleaseDLSys(p_this); ReleaseDLSys(p_this);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment