From d405d0a34ed79fda08c5c0597108be33bf238a83 Mon Sep 17 00:00:00 2001 From: Matt Dawkins Date: Tue, 17 May 2022 01:03:04 -0400 Subject: [PATCH 1/4] Fix build --- arrows/klv/klv_demuxer.h | 6 ++++++ arrows/vxl/vidl_ffmpeg_video_input.cxx | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/arrows/klv/klv_demuxer.h b/arrows/klv/klv_demuxer.h index bc35687a5a..55b78ec74c 100644 --- a/arrows/klv/klv_demuxer.h +++ b/arrows/klv/klv_demuxer.h @@ -10,6 +10,10 @@ namespace kwiver { namespace arrows { + +namespace vxl { + class vidl_ffmpeg_video_input; +} //end namespace vxl namespace klv { @@ -77,6 +81,8 @@ class KWIVER_ALGO_KLV_EXPORT klv_demuxer uint64_t m_prev_frame_timestamp; std::multimap< klv_timeline::key_t, uint64_t > m_cancel_points; klv_timeline& m_timeline; + + friend kwiver::arrows::vxl::vidl_ffmpeg_video_input; }; } // namespace klv diff --git a/arrows/vxl/vidl_ffmpeg_video_input.cxx b/arrows/vxl/vidl_ffmpeg_video_input.cxx index 8e4e2ad0c2..bd80c27bf7 100644 --- a/arrows/vxl/vidl_ffmpeg_video_input.cxx +++ b/arrows/vxl/vidl_ffmpeg_video_input.cxx @@ -26,6 +26,7 @@ #include +#include #include #include #include @@ -179,7 +180,7 @@ class vidl_ffmpeg_video_input::priv klv::KLV_PACKET_MISB_1108_LOCAL_SET ) { auto const timestamp = klv::klv_packet_timestamp( packet ); - m_curr_misp_timestamp = std::max( m_curr_misp_timestamp, timestamp ); + m_curr_misp_timestamp = std::max( m_curr_misp_timestamp, timestamp.value() ); } m_klv_demuxer.demux_packet( packet ); From 7e747569d99a07de7cc08d360a8416ccf7f62c31 Mon Sep 17 00:00:00 2001 From: Matt Dawkins Date: Fri, 20 May 2022 21:47:49 -0400 Subject: [PATCH 2/4] Fix build --- arrows/vxl/vidl_ffmpeg_video_input.cxx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/arrows/vxl/vidl_ffmpeg_video_input.cxx b/arrows/vxl/vidl_ffmpeg_video_input.cxx index bd80c27bf7..7bc4960cb1 100644 --- a/arrows/vxl/vidl_ffmpeg_video_input.cxx +++ b/arrows/vxl/vidl_ffmpeg_video_input.cxx @@ -199,8 +199,7 @@ class vidl_ffmpeg_video_input::priv // Get the vital metadata structure for the current frame auto result = - klv::klv_to_vital_metadata( m_klv_timeline, { m_prev_misp_timestamp, - m_curr_misp_timestamp } ); + klv::klv_to_vital_metadata( m_klv_timeline, m_curr_misp_timestamp ); // Add the frame timestamp to the metadata kwiver::vital::timestamp frame_timestamp; @@ -303,7 +302,8 @@ class vidl_ffmpeg_video_input::priv { auto const packet_data = d_video_stream.current_packet_data(); auto it = kwiver::arrows::klv::find_misp_timestamp( packet_data.cbegin(), - packet_data.cend() ); + packet_data.cend(), + klv::MISP_TIMESTAMP_TAG_STRING ); if ( it != packet_data.cend() ) { meta_ts = kwiver::arrows::klv::read_misp_timestamp( it ).timestamp; From 045d711600e0092f6a62886d2645ff6dea6a8204 Mon Sep 17 00:00:00 2001 From: Matt Dawkins Date: Wed, 30 Nov 2022 14:41:37 -0500 Subject: [PATCH 3/4] Update for latest metadata changes --- arrows/vxl/vidl_ffmpeg_video_input.cxx | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/arrows/vxl/vidl_ffmpeg_video_input.cxx b/arrows/vxl/vidl_ffmpeg_video_input.cxx index 7bc4960cb1..efd36f5043 100644 --- a/arrows/vxl/vidl_ffmpeg_video_input.cxx +++ b/arrows/vxl/vidl_ffmpeg_video_input.cxx @@ -158,13 +158,13 @@ class vidl_ffmpeg_video_input::priv m_prev_misp_timestamp = m_curr_misp_timestamp; - auto it = md_buffer.cbegin(); - while( it != md_buffer.cend() ) + auto it = &*md_buffer.cbegin(); + while( it != &*md_buffer.cend() ) { klv::klv_packet packet; try { - packet = klv::klv_read_packet( it, std::distance( it, md_buffer.cend() ) ); + packet = klv::klv_read_packet( it, std::distance( it, &*md_buffer.cend() ) ); } catch( kwiver::vital::metadata_buffer_overflow const& e ) { @@ -194,7 +194,8 @@ class vidl_ffmpeg_video_input::priv std::next( md_buffer.begin(), std::distance( md_buffer.cbegin(), it ) ) ); #else - md_buffer.erase( md_buffer.cbegin(), it ); + md_buffer.erase( md_buffer.begin(), + md_buffer.begin() + std::distance( &*md_buffer.cbegin(), it ) ); #endif // Get the vital metadata structure for the current frame @@ -301,12 +302,12 @@ class vidl_ffmpeg_video_input::priv do { auto const packet_data = d_video_stream.current_packet_data(); - auto it = kwiver::arrows::klv::find_misp_timestamp( packet_data.cbegin(), - packet_data.cend(), + auto it = kwiver::arrows::klv::find_misp_timestamp( &*packet_data.cbegin(), + &*packet_data.cend(), klv::MISP_TIMESTAMP_TAG_STRING ); - if ( it != packet_data.cend() ) + if ( it != &*packet_data.cend() ) { - meta_ts = kwiver::arrows::klv::read_misp_timestamp( it ).timestamp; + meta_ts = kwiver::arrows::klv::read_misp_timestamp( it ).microseconds().count(); LOG_DEBUG( this->d_logger, "Found MISP frame time:" << meta_ts ); d_have_abs_frame_time = true; From 04af80708d765acee32e5ebdc8310eea03311209 Mon Sep 17 00:00:00 2001 From: Daniel Riehm Date: Tue, 6 Dec 2022 16:40:56 -0500 Subject: [PATCH 4/4] Use send_frame() --- arrows/klv/klv_demuxer.h | 6 ------ arrows/vxl/vidl_ffmpeg_video_input.cxx | 9 ++++++--- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/arrows/klv/klv_demuxer.h b/arrows/klv/klv_demuxer.h index 55b78ec74c..bc35687a5a 100644 --- a/arrows/klv/klv_demuxer.h +++ b/arrows/klv/klv_demuxer.h @@ -10,10 +10,6 @@ namespace kwiver { namespace arrows { - -namespace vxl { - class vidl_ffmpeg_video_input; -} //end namespace vxl namespace klv { @@ -81,8 +77,6 @@ class KWIVER_ALGO_KLV_EXPORT klv_demuxer uint64_t m_prev_frame_timestamp; std::multimap< klv_timeline::key_t, uint64_t > m_cancel_points; klv_timeline& m_timeline; - - friend kwiver::arrows::vxl::vidl_ffmpeg_video_input; }; } // namespace klv diff --git a/arrows/vxl/vidl_ffmpeg_video_input.cxx b/arrows/vxl/vidl_ffmpeg_video_input.cxx index efd36f5043..30c58ff045 100644 --- a/arrows/vxl/vidl_ffmpeg_video_input.cxx +++ b/arrows/vxl/vidl_ffmpeg_video_input.cxx @@ -158,13 +158,15 @@ class vidl_ffmpeg_video_input::priv m_prev_misp_timestamp = m_curr_misp_timestamp; + std::vector< klv::klv_packet > packets; auto it = &*md_buffer.cbegin(); while( it != &*md_buffer.cend() ) { - klv::klv_packet packet; try { - packet = klv::klv_read_packet( it, std::distance( it, &*md_buffer.cend() ) ); + auto packet = + klv::klv_read_packet( it, std::distance( it, &*md_buffer.cend() ) ); + packets.emplace_back( std::move( packet ) ); } catch( kwiver::vital::metadata_buffer_overflow const& e ) { @@ -176,6 +178,7 @@ class vidl_ffmpeg_video_input::priv LOG_ERROR( d_logger, "error while parsing KLV packet: " << e.what() ); } + auto const& packet = packets.back(); if( klv::klv_lookup_packet_traits().by_uds_key( packet.key ).tag() != klv::KLV_PACKET_MISB_1108_LOCAL_SET ) { @@ -183,7 +186,7 @@ class vidl_ffmpeg_video_input::priv m_curr_misp_timestamp = std::max( m_curr_misp_timestamp, timestamp.value() ); } - m_klv_demuxer.demux_packet( packet ); + m_klv_demuxer.send_frame( packets, m_curr_misp_timestamp ); } // Erase the bytes we just used