From 3ca00b80b7446f2237ef530d135988db3ef7a2a0 Mon Sep 17 00:00:00 2001 From: Maxime Gervais Date: Mon, 3 Jun 2024 11:02:15 +0200 Subject: [PATCH] DeckLink Input: Add frame saturation statistics Signed-off-by: Maxime Gervais --- Project/GNU/CLI/Makefile.am | 9 +- Project/MSVC2017/CLI/DVRescue.vcxproj | 2 + Project/MSVC2019/CLI/DVRescue.vcxproj | 2 + Project/MSVC2022/CLI/DVRescue.vcxproj | 2 + Source/Common/DecklinkWrapper.cpp | 28 +++++ Source/Common/Merge.h | 1 + Source/Common/Output_Xml.cpp | 62 ++++++++++- Source/Common/Output_Xml.h | 5 + Source/Common/ProcessFile.cpp | 1 + Source/Common/ProcessFile.h | 10 ++ Source/Common/ProcessFileWrapper.cpp | 20 +++- Source/Common/ProcessFileWrapper.h | 5 +- Source/Common/SignalStats.cpp | 151 ++++++++++++++++++++++++++ Source/Common/SignalStats.h | 37 +++++++ Source/Common/SimulatorWrapper.cpp | 24 ++++ tools/dvrescue.xsd | 38 +++++++ 16 files changed, 387 insertions(+), 10 deletions(-) create mode 100644 Source/Common/SignalStats.cpp create mode 100644 Source/Common/SignalStats.h diff --git a/Project/GNU/CLI/Makefile.am b/Project/GNU/CLI/Makefile.am index 72cc22e7..dee9e8b0 100644 --- a/Project/GNU/CLI/Makefile.am +++ b/Project/GNU/CLI/Makefile.am @@ -53,14 +53,17 @@ if BUILD_AVFCTL endif if BUILD_DECKLINK - dvrescue_SOURCES += ../../../Source/Common/DecklinkWrapper.cpp + dvrescue_SOURCES += ../../../Source/Common/DecklinkWrapper.cpp \ + ../../../Source/Common/Output_Mkv.cpp \ + ../../../Source/Common/SignalStats.cpp endif if BUILD_DECKLINK - dvrescue_SOURCES += ../../../Source/Common/Output_Mkv.cpp + else if BUILD_SIMULATOR - dvrescue_SOURCES += ../../../Source/Common/Output_Mkv.cpp + dvrescue_SOURCES += ../../../Source/Common/Output_Mkv.cpp \ + ../../../Source/Common/SignalStats.cpp endif endif diff --git a/Project/MSVC2017/CLI/DVRescue.vcxproj b/Project/MSVC2017/CLI/DVRescue.vcxproj index 7d5cb63b..aab516bc 100644 --- a/Project/MSVC2017/CLI/DVRescue.vcxproj +++ b/Project/MSVC2017/CLI/DVRescue.vcxproj @@ -161,6 +161,7 @@ + @@ -184,6 +185,7 @@ + diff --git a/Project/MSVC2019/CLI/DVRescue.vcxproj b/Project/MSVC2019/CLI/DVRescue.vcxproj index 65106f7a..a5a792f4 100644 --- a/Project/MSVC2019/CLI/DVRescue.vcxproj +++ b/Project/MSVC2019/CLI/DVRescue.vcxproj @@ -162,6 +162,7 @@ + @@ -185,6 +186,7 @@ + diff --git a/Project/MSVC2022/CLI/DVRescue.vcxproj b/Project/MSVC2022/CLI/DVRescue.vcxproj index beebcf95..94dbd8f6 100644 --- a/Project/MSVC2022/CLI/DVRescue.vcxproj +++ b/Project/MSVC2022/CLI/DVRescue.vcxproj @@ -162,6 +162,7 @@ + @@ -185,6 +186,7 @@ + diff --git a/Source/Common/DecklinkWrapper.cpp b/Source/Common/DecklinkWrapper.cpp index dfd1a982..0981bcc3 100644 --- a/Source/Common/DecklinkWrapper.cpp +++ b/Source/Common/DecklinkWrapper.cpp @@ -43,6 +43,17 @@ static uint32_t decklink_audio_sources[Decklink_Audio_Source_Max] = bmdAudioConnectionMicrophone }; +//--------------------------------------------------------------------------- +static uint32_t decklink_pixel_formats[Decklink_Pixel_Format_Max] = +{ + bmdFormatUnspecified, + bmdFormat8BitYUV, + bmdFormat10BitYUV, + bmdFormat8BitARGB, + bmdFormat8BitBGRA, + bmdFormat10BitRGB +}; + //--------------------------------------------------------------------------- static uint32_t decklink_timecode_formats[Decklink_Timecode_Format_Max] = { @@ -129,9 +140,26 @@ HRESULT DecklinkWrapper::CaptureDelegate::VideoInputFrameArrived(IDeckLinkVideoI } } + uint8_t PixelFormat = (uint8_t)Decklink_Pixel_Format_Unspecified; + switch (VideoFrame->GetPixelFormat()) + { + case bmdFormat8BitYUV: + PixelFormat = (uint8_t)Decklink_Pixel_Format_8BitYUV; break; + case bmdFormat10BitYUV: + PixelFormat = (uint8_t)Decklink_Pixel_Format_10BitYUV; break; + case bmdFormat8BitARGB: + PixelFormat = (uint8_t)Decklink_Pixel_Format_8BitARGB; break; + case bmdFormat8BitBGRA: + PixelFormat = (uint8_t)Decklink_Pixel_Format_8BitBGRA; break; + case bmdFormat10BitRGB: + PixelFormat = (uint8_t)Decklink_Pixel_Format_10BitRGB; break; + default:; + } + decklink_frame Buffer = { .Width = (uint32_t)VideoFrame->GetWidth(), .Height = (uint32_t)VideoFrame->GetHeight(), + .Pixel_Format = PixelFormat, .Video_Buffer = (uint8_t*)VideoBuffer, .Video_Buffer_Size = VideoBufferSize, .Audio_Buffer = (uint8_t*)AudioBuffer, diff --git a/Source/Common/Merge.h b/Source/Common/Merge.h index 0255a742..39012cd2 100644 --- a/Source/Common/Merge.h +++ b/Source/Common/Merge.h @@ -28,6 +28,7 @@ extern const char* Control_Port; extern uint8_t DeckLinkVideoMode; extern uint8_t DeckLinkVideoSource; extern uint8_t DeckLinkAudioSource; +extern uint8_t DeckLinkPixelFormat; extern uint8_t DeckLinkTimecodeFormat; #endif extern size_t Merge_Rewind_Count; diff --git a/Source/Common/Output_Xml.cpp b/Source/Common/Output_Xml.cpp index b8ce44cc..aeef607e 100644 --- a/Source/Common/Output_Xml.cpp +++ b/Source/Common/Output_Xml.cpp @@ -136,7 +136,7 @@ static void Aud_Element(string& Text, size_t o, size_t n, vector Audio #if defined(ENABLE_DECKLINK) || defined(ENABLE_SIMULATOR) //--------------------------------------------------------------------------- -static string decklink_videosource_to_string(uint8_t value) +string decklink_videosource_to_string(uint8_t value) { string ToReturn; switch (value) @@ -153,7 +153,7 @@ static string decklink_videosource_to_string(uint8_t value) } //--------------------------------------------------------------------------- -static string decklink_audiosource_to_string(uint8_t value) +string decklink_audiosource_to_string(uint8_t value) { string ToReturn; switch (value) @@ -170,7 +170,23 @@ static string decklink_audiosource_to_string(uint8_t value) } //--------------------------------------------------------------------------- -static string decklink_timecodeformat_to_string(uint8_t value) +string decklink_pixelformat_to_string(uint8_t value) +{ + string ToReturn; + switch (value) + { + case (uint8_t)Decklink_Pixel_Format_8BitYUV: ToReturn = "uyvy"; break; + case (uint8_t)Decklink_Pixel_Format_10BitYUV: ToReturn = "v210"; break; + case (uint8_t)Decklink_Pixel_Format_8BitARGB: ToReturn = "argb"; break; + case (uint8_t)Decklink_Pixel_Format_8BitBGRA: ToReturn = "bgra"; break; + case (uint8_t)Decklink_Pixel_Format_10BitRGB: ToReturn = "r210"; break; + default:; + } + return ToReturn; +} + +//--------------------------------------------------------------------------- +string decklink_timecodeformat_to_string(uint8_t value) { string ToReturn; switch (value) @@ -359,6 +375,14 @@ return_value Output_Xml(ostream& Out, std::vector& PerFile, bitset