]> git.sesse.net Git - nageru/commitdiff
Use the new has_signal flag.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Sat, 27 Feb 2016 12:32:09 +0000 (13:32 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Sat, 27 Feb 2016 12:32:09 +0000 (13:32 +0100)
bmusb
decklink_capture.cpp
mixer.cpp
pbo_frame_allocator.cpp
pbo_frame_allocator.h
theme.cpp
theme.lua

diff --git a/bmusb b/bmusb
index bb575c1ac8b1496394732800898c27a3a812f0a9..b3aaee8df3039891d79f4f673e6a8050d3fb65b5 160000 (submodule)
--- a/bmusb
+++ b/bmusb
@@ -1 +1 @@
-Subproject commit bb575c1ac8b1496394732800898c27a3a812f0a9
+Subproject commit b3aaee8df3039891d79f4f673e6a8050d3fb65b5
index 3243788d4a8c58936e365dded918b9ce9b852922..e7f8eba0a16531c7341619be0cb2e8f7541b583a 100644 (file)
@@ -151,11 +151,7 @@ HRESULT STDMETHODCALLTYPE DeckLinkCapture::VideoInputFrameArrived(
        VideoFormat video_format;
 
        if (video_frame) {
-               if (video_frame->GetFlags() & bmdFrameHasNoInputSource) {
-                       // TODO: Make a way to propagate this flag down to the theme code,
-                       // independent of the signal resolution.
-                       fprintf(stderr, "Warning: No input signal detected\n");
-               }
+               video_format.has_signal = !(video_frame->GetFlags() & bmdFrameHasNoInputSource);
 
                int width = video_frame->GetWidth();
                int height = video_frame->GetHeight();
index 436b761d3efd433a2b6addf93c315c05faeaf35c..3b602bfb07597d41fefc0e213b66d496799a5a23 100644 (file)
--- a/mixer.cpp
+++ b/mixer.cpp
@@ -430,6 +430,7 @@ void Mixer::bm_frame(unsigned card_index, uint16_t timecode,
                clock_gettime(CLOCK_MONOTONIC, &frame_upload_start);
        }
        userdata->last_interlaced = video_format.interlaced;
+       userdata->last_has_signal = video_format.has_signal;
        userdata->last_frame_rate_nom = video_format.frame_rate_nom;
        userdata->last_frame_rate_den = video_format.frame_rate_den;
        RefCountedFrame new_frame(video_frame);
index 8c92ec3ce29c42be7bf86a983a13f0db6221572d..3d4f8cf09321230a39c471164e9740fa99a92e84 100644 (file)
@@ -44,6 +44,7 @@ PBOFrameAllocator::PBOFrameAllocator(size_t frame_size, GLuint width, GLuint hei
                userdata[i].last_width[1] = 0;
                userdata[i].last_height[1] = 0;
                userdata[i].last_interlaced = false;
+               userdata[i].last_has_signal = false;
                for (unsigned field = 0; field < 2; ++field) {
                        glBindTexture(GL_TEXTURE_2D, userdata[i].tex_y[field]);
                        check_error();
index afb20a19268cb1c9785de8cb060d93db3da0d629..5dba2fc7ccf1c37ea84d0c596d1596638b31d7bd 100644 (file)
@@ -32,7 +32,7 @@ public:
                // The second set is only used for the second field of interlaced inputs.
                GLuint tex_y[2], tex_cbcr[2];
                GLuint last_width[2], last_height[2];
-               bool last_interlaced;
+               bool last_interlaced, last_has_signal;
                unsigned last_frame_rate_nom, last_frame_rate_den;
        };
 
index 7e69f91e5d5feccca50a88bf32a7ea44080b7830..35b777e76d79c6ea3afe309e57b0ae5333be9b2e 100644 (file)
--- a/theme.cpp
+++ b/theme.cpp
@@ -44,7 +44,7 @@ struct InputStateInfo {
        InputStateInfo(const InputState& input_state);
 
        unsigned last_width[MAX_CARDS], last_height[MAX_CARDS];
-       bool last_interlaced[MAX_CARDS];
+       bool last_interlaced[MAX_CARDS], last_has_signal[MAX_CARDS];
        unsigned last_frame_rate_nom[MAX_CARDS], last_frame_rate_den[MAX_CARDS];
 };
 
@@ -55,12 +55,14 @@ InputStateInfo::InputStateInfo(const InputState &input_state)
                if (frame.frame == nullptr) {
                        last_width[signal_num] = last_height[signal_num] = 0;
                        last_interlaced[signal_num] = false;
+                       last_has_signal[signal_num] = false;
                        continue;
                }
                const PBOFrameAllocator::Userdata *userdata = (const PBOFrameAllocator::Userdata *)frame.frame->userdata;
                last_width[signal_num] = userdata->last_width[frame.field_number];
                last_height[signal_num] = userdata->last_height[frame.field_number];
                last_interlaced[signal_num] = userdata->last_interlaced;
+               last_has_signal[signal_num] = userdata->last_has_signal;
                last_frame_rate_nom[signal_num] = userdata->last_frame_rate_nom;
                last_frame_rate_den[signal_num] = userdata->last_frame_rate_den;
        }
@@ -359,6 +361,16 @@ int InputStateInfo_get_interlaced(lua_State* L)
        return 1;
 }
 
+int InputStateInfo_get_has_signal(lua_State* L)
+{
+       assert(lua_gettop(L) == 2);
+       InputStateInfo *input_state_info = get_input_state_info(L, 1);
+       Theme *theme = get_theme_updata(L);
+       int signal_num = theme->map_signal(luaL_checknumber(L, 2));
+       lua_pushboolean(L, input_state_info->last_has_signal[signal_num]);
+       return 1;
+}
+
 int InputStateInfo_get_frame_rate_nom(lua_State* L)
 {
        assert(lua_gettop(L) == 2);
@@ -526,6 +538,7 @@ const luaL_Reg InputStateInfo_funcs[] = {
        { "get_width", InputStateInfo_get_width },
        { "get_height", InputStateInfo_get_height },
        { "get_interlaced", InputStateInfo_get_interlaced },
+       { "get_has_signal", InputStateInfo_get_has_signal },
        { "get_frame_rate_nom", InputStateInfo_get_frame_rate_nom },
        { "get_frame_rate_den", InputStateInfo_get_frame_rate_den },
        { NULL, NULL }
index c2014141c3e94a6597dc650d92256c35bf51cc45..aca8c4e7ee9decbfdfb73b89ad6b67ab968c70b4 100644 (file)
--- a/theme.lua
+++ b/theme.lua
@@ -31,7 +31,7 @@ local STATIC_SIGNAL_NUM = 3
 -- to the next.
 local FADE_SIGNAL_NUM = 4
 
--- Last width/height/resolution for each channel, if we have it.
+-- Last width/height/frame rate for each channel, if we have it.
 -- Note that unlike the values we get from Nageru, the resolution is per
 -- frame and not per field, since we deinterlace.
 local last_resolution = {}
@@ -269,8 +269,7 @@ end
 -- Helper function to write e.g. “720p60”.
 function get_channel_resolution(signal_num)
        if last_resolution[signal_num] then
-               if last_resolution[signal_num].height == 0 or
-                  last_resolution[signal_num].height == 525 then
+               if not last_resolution[signal_num].has_signal then
                        return "no signal"
                elseif last_resolution[signal_num].interlaced then
                        return last_resolution[signal_num].height .. "i" .. get_frame_rate(signal_num)
@@ -496,6 +495,7 @@ function get_chain(num, t, width, height, signals)
                        width = signals:get_width(signal_num),
                        height = signals:get_height(signal_num),
                        interlaced = signals:get_interlaced(signal_num),
+                       has_signal = signals:get_has_signal(signal_num),
                        frame_rate_nom = signals:get_frame_rate_nom(signal_num),
                        frame_rate_den = signals:get_frame_rate_den(signal_num)
                }