From 18abaab9799a54c60d4da020db821654722a8201 Mon Sep 17 00:00:00 2001 From: Francois Cartegnie <fcvlcdev@free.fr> Date: Mon, 6 May 2019 18:55:56 +0200 Subject: [PATCH] sout: sdi: refactor image loading --- modules/stream_out/Makefile.am | 2 + modules/stream_out/sdi/DBMSDIOutput.cpp | 36 +------------- modules/stream_out/sdi/DBMSDIOutput.hpp | 1 - modules/stream_out/sdi/SDIGenerator.cpp | 65 +++++++++++++++++++++++++ modules/stream_out/sdi/SDIGenerator.hpp | 34 +++++++++++++ 5 files changed, 103 insertions(+), 35 deletions(-) create mode 100644 modules/stream_out/sdi/SDIGenerator.cpp create mode 100644 modules/stream_out/sdi/SDIGenerator.hpp diff --git a/modules/stream_out/Makefile.am b/modules/stream_out/Makefile.am index 599735c01c17..900dbfeabc20 100644 --- a/modules/stream_out/Makefile.am +++ b/modules/stream_out/Makefile.am @@ -65,6 +65,8 @@ libstream_out_sdi_plugin_la_SOURCES = stream_out/sdi/sdiout.cpp \ stream_out/sdi/DBMSDIOutput.hpp \ stream_out/sdi/SDIAudioMultiplex.cpp \ stream_out/sdi/SDIAudioMultiplex.hpp \ + stream_out/sdi/SDIGenerator.cpp \ + stream_out/sdi/SDIGenerator.hpp \ stream_out/sdi/SDIOutput.cpp \ stream_out/sdi/SDIOutput.hpp \ stream_out/sdi/SDIStream.cpp \ diff --git a/modules/stream_out/sdi/DBMSDIOutput.cpp b/modules/stream_out/sdi/DBMSDIOutput.cpp index a0fd48781078..482fe8e24e93 100644 --- a/modules/stream_out/sdi/DBMSDIOutput.cpp +++ b/modules/stream_out/sdi/DBMSDIOutput.cpp @@ -26,13 +26,13 @@ #include <vlc_es.h> #include <vlc_picture.h> #include <vlc_interrupt.h> -#include <vlc_image.h> #include <vlc_decklink.h> #include "DBMHelper.hpp" #include "DBMSDIOutput.hpp" #include "SDIStream.hpp" #include "SDIAudioMultiplex.hpp" +#include "SDIGenerator.hpp" #include "Ancillary.hpp" #include "V210.hpp" @@ -377,7 +377,7 @@ int DBMSDIOutput::ConfigureVideo(const video_format_t *vfmt) char *psz_file = var_InheritString(p_stream, CFG_PREFIX "nosignal-image"); if(psz_file) { - video.pic_nosignal = CreateNoSignalPicture(psz_file, fmt); + video.pic_nosignal = sdi::Generator::Picture(VLC_OBJECT(p_stream), psz_file, fmt); if (!video.pic_nosignal) msg_Err(p_stream, "Could not create no signal picture"); free(psz_file); @@ -646,35 +646,3 @@ void DBMSDIOutput::checkClockDrift() } } } - -picture_t * DBMSDIOutput::CreateNoSignalPicture(const char *psz_file, const video_format_t *fmt) -{ - picture_t *p_pic = NULL; - image_handler_t *img = image_HandlerCreate(p_stream); - if (img) - { - video_format_t in; - video_format_Init(&in, 0); - video_format_Setup(&in, 0, - fmt->i_width, fmt->i_height, - fmt->i_width, fmt->i_height, 1, 1); - - picture_t *png = image_ReadUrl(img, psz_file, &in); - if (png) - { - video_format_t dummy; - video_format_Copy(&dummy, fmt); - p_pic = image_Convert(img, png, &in, &dummy); - if(!video_format_IsSimilar(&dummy, fmt)) - { - picture_Release(p_pic); - p_pic = NULL; - } - picture_Release(png); - video_format_Clean(&dummy); - } - image_HandlerDelete(img); - video_format_Clean(&in); - } - return p_pic; -} diff --git a/modules/stream_out/sdi/DBMSDIOutput.hpp b/modules/stream_out/sdi/DBMSDIOutput.hpp index 91550d3e2a52..09a614186bbe 100644 --- a/modules/stream_out/sdi/DBMSDIOutput.hpp +++ b/modules/stream_out/sdi/DBMSDIOutput.hpp @@ -61,7 +61,6 @@ namespace sdi_sout bool b_running; int Start(vlc_tick_t); int doProcessVideo(picture_t *, block_t *); - picture_t * CreateNoSignalPicture(const char*, const video_format_t *); void checkClockDrift(); }; } diff --git a/modules/stream_out/sdi/SDIGenerator.cpp b/modules/stream_out/sdi/SDIGenerator.cpp new file mode 100644 index 000000000000..726587431b95 --- /dev/null +++ b/modules/stream_out/sdi/SDIGenerator.cpp @@ -0,0 +1,65 @@ +/***************************************************************************** + * SDIGenerator.cpp: SDI Image and sound generators + ***************************************************************************** + * Copyright © 2014-2016 VideoLAN and VideoLAN Authors + * 2018-2019 VideoLabs + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. + *****************************************************************************/ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include <vlc_common.h> +#include <vlc_es.h> +#include <vlc_picture.h> +#include <vlc_image.h> + +#include "SDIGenerator.hpp" + +using namespace sdi; + +picture_t * Generator::Picture(vlc_object_t *obj, const char *psz_file, + const video_format_t *fmt) +{ + picture_t *p_pic = NULL; + image_handler_t *img = image_HandlerCreate(obj); + if (img) + { + video_format_t in; + video_format_Init(&in, 0); + video_format_Setup(&in, 0, + fmt->i_width, fmt->i_height, + fmt->i_width, fmt->i_height, 1, 1); + + picture_t *png = image_ReadUrl(img, psz_file, &in); + if (png) + { + video_format_t dummy; + video_format_Copy(&dummy, fmt); + p_pic = image_Convert(img, png, &in, &dummy); + if(!video_format_IsSimilar(&dummy, fmt)) + { + picture_Release(p_pic); + p_pic = NULL; + } + picture_Release(png); + video_format_Clean(&dummy); + } + image_HandlerDelete(img); + video_format_Clean(&in); + } + return p_pic; +} diff --git a/modules/stream_out/sdi/SDIGenerator.hpp b/modules/stream_out/sdi/SDIGenerator.hpp new file mode 100644 index 000000000000..2310ba45dfb4 --- /dev/null +++ b/modules/stream_out/sdi/SDIGenerator.hpp @@ -0,0 +1,34 @@ +/***************************************************************************** + * SDIGenerator.hpp: SDI Image and sound generators + ***************************************************************************** + * Copyright © 2014-2016 VideoLAN and VideoLAN Authors + * 2018-2019 VideoLabs + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. + *****************************************************************************/ +#ifndef SDIGENERATOR_HPP +#define SDIGENERATOR_HPP + +namespace sdi +{ + class Generator + { + public: + static picture_t * Picture(vlc_object_t *, const char*, + const video_format_t *); + }; +} + +#endif -- GitLab