From: Steinar H. Gunderson Date: Sat, 27 Feb 2016 12:32:09 +0000 (+0100) Subject: Use the new has_signal flag. X-Git-Tag: 1.2.0~59 X-Git-Url: https://git.sesse.net/?p=nageru;a=commitdiff_plain;h=3e8c584c42ae8a53e2cf335ff6c986f1b87f3f5e Use the new has_signal flag. --- diff --git a/bmusb b/bmusb index bb575c1..b3aaee8 160000 --- a/bmusb +++ b/bmusb @@ -1 +1 @@ -Subproject commit bb575c1ac8b1496394732800898c27a3a812f0a9 +Subproject commit b3aaee8df3039891d79f4f673e6a8050d3fb65b5 diff --git a/decklink_capture.cpp b/decklink_capture.cpp index 3243788..e7f8eba 100644 --- a/decklink_capture.cpp +++ b/decklink_capture.cpp @@ -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(); diff --git a/mixer.cpp b/mixer.cpp index 436b761..3b602bf 100644 --- 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); diff --git a/pbo_frame_allocator.cpp b/pbo_frame_allocator.cpp index 8c92ec3..3d4f8cf 100644 --- a/pbo_frame_allocator.cpp +++ b/pbo_frame_allocator.cpp @@ -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(); diff --git a/pbo_frame_allocator.h b/pbo_frame_allocator.h index afb20a1..5dba2fc 100644 --- a/pbo_frame_allocator.h +++ b/pbo_frame_allocator.h @@ -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; }; diff --git a/theme.cpp b/theme.cpp index 7e69f91..35b777e 100644 --- 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 } diff --git a/theme.lua b/theme.lua index c201414..aca8c4e 100644 --- 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) }