<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, 27 Sep 2020 at 16:16, Rémi Denis-Courmont <<a href="mailto:remi@remlab.net">remi@remlab.net</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Le sunnuntaina 27. syyskuuta 2020, 12.12.58 EEST Vikram Fugro a écrit :<br>
> Add raw video fourcc conversion support to convert<br>
> from gstreamer representation (for strings that are<br>
> not equal to length 4) to vlc representation.<br>
> ---<br>
>  modules/codec/Makefile.am                     |  4 +-<br>
>  modules/codec/gstreamer/fourcc.c              | 84 +++++++++++++++++++<br>
>  modules/codec/gstreamer/gstvlc.h              | 34 ++++++++<br>
>  .../gstreamer/gstvlcpictureplaneallocator.c   | 25 +++++-<br>
>  4 files changed, 142 insertions(+), 5 deletions(-)<br>
>  create mode 100644 modules/codec/gstreamer/fourcc.c<br>
>  create mode 100644 modules/codec/gstreamer/gstvlc.h<br>
> <br>
> diff --git a/modules/codec/Makefile.am b/modules/codec/Makefile.am<br>
> index f8ff8b35bc..cd61920831 100644<br>
> --- a/modules/codec/Makefile.am<br>
> +++ b/modules/codec/Makefile.am<br>
> @@ -604,7 +604,9 @@ libgstdecode_plugin_la_SOURCES =<br>
> codec/gstreamer/gstdecode.c \ codec/gstreamer/gstvlcvideopool.c \<br>
>                                                               <br>
 codec/gstreamer/gstvlcvideopool.h \<br>
>                                                               <br>
 codec/gstreamer/gstvlcvideosink.c \<br>
> -                                                             <br>
 codec/gstreamer/gstvlcvideosink.h<br>
> +                                                             <br>
 codec/gstreamer/gstvlcvideosink.h \<br>
> +                                                             <br>
 codec/gstreamer/fourcc.c \<br>
> +                                                             <br>
 codec/gstreamer/gstvlc.h<br>
>  libgstdecode_plugin_la_CFLAGS = $(AM_CFLAGS) $(GST_VIDEO_CFLAGS)<br>
> $(GST_APP_CFLAGS) libgstdecode_plugin_la_LIBADD = $(GST_VIDEO_LIBS)<br>
> $(GST_APP_LIBS) if HAVE_GST_DECODE<br>
> diff --git a/modules/codec/gstreamer/fourcc.c<br>
> b/modules/codec/gstreamer/fourcc.c new file mode 100644<br>
> index 0000000000..8602fc3bb2<br>
> --- /dev/null<br>
> +++ b/modules/codec/gstreamer/fourcc.c<br>
> @@ -0,0 +1,84 @@<br>
> +<br>
> +/**************************************************************************<br>
> *** + * fourcc.c: convert between gst <->  vlc formats<br>
> +<br>
> ***************************************************************************<br>
> ** + * Copyright (C) 2020 VLC authors and VideoLAN<br>
> + * $Id:<br>
> + *<br>
> + * Author: Vikram Fugro <<a href="mailto:vikram.fugro@gmail.com" target="_blank">vikram.fugro@gmail.com</a>><br>
> + *<br>
> + * This library is free software; you can redistribute it and/or<br>
> + * modify it under the terms of the GNU Library General Public<br>
> + * License as published by the Free Software Foundation; either<br>
> + * version 2.1 of the License, or (at your option) any later version.<br>
> + *<br>
> + * This library is distributed in the hope that it will be useful,<br>
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of<br>
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU<br>
> + * Lesser General Public License for more details.<br>
> + *<br>
> + * You should have received a copy of the GNU Library General Public<br>
> + * License along with this library; if not, write to the Free Software<br>
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA <br>
> 02110-1301 USA +<br>
> ***************************************************************************<br>
> **/ +<br>
> +/**************************************************************************<br>
> *** + * Preamble<br>
> +<br>
> ***************************************************************************<br>
> **/ +<br>
> +#include "gstvlc.h"<br>
> +<br>
> +struct gst_vlc_rawvideo_fourcc<br>
> +{<br>
> +    char gst [32];<br>
<br>
Seems like it could be smaller. You'll get a warning if it's too small anyway.<br>
<br>
> +    vlc_fourcc_t i_fourcc;<br>
> +};<br>
> +<br>
> +/*<br>
> + * Raw Video Formats<br>
> + */<br>
> +static const struct gst_vlc_rawvideo_fourcc raw_video_fmts[] =<br>
> +{<br>
> +    { "I420_9LE", VLC_CODEC_I420_9L },<br>
> +    { "I420_9BE", VLC_CODEC_I420_9B },<br>
> +    { "I420_10LE", VLC_CODEC_I420_10L },<br>
> +    { "I420_10BE", VLC_CODEC_I420_10B },<br>
> +    { "I420_12LE", VLC_CODEC_I420_12L },<br>
> +    { "I420_12BE", VLC_CODEC_I420_12B },<br>
> +    { "I420_16LE", VLC_CODEC_I420_16L },<br>
> +    { "I420_16BE", VLC_CODEC_I420_16B },<br>
> +    { "I422_9LE", VLC_CODEC_I422_9L },<br>
> +    { "I422_9BE", VLC_CODEC_I422_9B },<br>
> +    { "I422_10LE", VLC_CODEC_I422_10L },<br>
> +    { "I422_10BE", VLC_CODEC_I422_10B },<br>
> +    { "I422_12LE", VLC_CODEC_I422_12L },<br>
> +    { "I422_12BE", VLC_CODEC_I422_12B },<br>
> +    { "I422_16LE", VLC_CODEC_I422_16L },<br>
> +    { "I422_16BE", VLC_CODEC_I422_16B },<br>
> +    { "I444_9LE", VLC_CODEC_I444_9L },<br>
> +    { "I444_9BE", VLC_CODEC_I444_9B },<br>
> +    { "I444_10LE", VLC_CODEC_I444_10L },<br>
> +    { "I444_10BE", VLC_CODEC_I444_10B },<br>
> +    { "I444_12LE", VLC_CODEC_I444_12L },<br>
> +    { "I444_12BE", VLC_CODEC_I444_12B },<br>
> +    { "I444_16LE", VLC_CODEC_I444_16L },<br>
> +    { "I444_16BE", VLC_CODEC_I444_16B },<br>
> +};<br>
> +<br>
> +vlc_fourcc_t GetGstVLCFourcc( const char* gst )<br>
> +{<br>
> +    if( !gst )<br>
> +    {<br>
> +        return VLC_CODEC_UNKNOWN;<br>
> +    }<br>
> +<br>
> +    for( size_t i = 0; i < ARRAY_SIZE(raw_video_fmts); i++ )<br>
> +    {<br>
> +        if( !strcmp( gst, raw_video_fmts[i].gst ))<br>
> +        {<br>
> +            return raw_video_fmts[i].i_fourcc;<br>
> +        }<br>
> +    }<br>
<br>
Maybe sort alphabetically and use bsearch() ?<br></blockquote><div>    Do you mean autogenerate a header file first with sorted entries, precompilation ? </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
> +<br>
> +    return VLC_CODEC_UNKNOWN;<br>
> +}<br>
> diff --git a/modules/codec/gstreamer/gstvlc.h<br>
> b/modules/codec/gstreamer/gstvlc.h new file mode 100644<br>
> index 0000000000..f99b827d8f<br>
> --- /dev/null<br>
> +++ b/modules/codec/gstreamer/gstvlc.h<br>
> @@ -0,0 +1,34 @@<br>
> +/**************************************************************************<br>
> *** + * gst.h:<br>
> +<br>
> ***************************************************************************<br>
> ** + * Copyright (C) 2020 VLC authors and VideoLAN<br>
> + *<br>
> + * Author: Vikram Fugro <<a href="mailto:vikram.fugro@gmail.com" target="_blank">vikram.fugro@gmail.com</a>><br>
> + *<br>
> + * This library is free software; you can redistribute it and/or<br>
> + * modify it under the terms of the GNU Library General Public<br>
> + * License as published by the Free Software Foundation; either<br>
> + * version 2.1 of the License, or (at your option) any later version.<br>
> + *<br>
> + * This library is distributed in the hope that it will be useful,<br>
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of<br>
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU<br>
> + * Lesser General Public License for more details.<br>
> + *<br>
> + * You should have received a copy of the GNU Library General Public<br>
> + * License along with this library; if not, write to the Free Software<br>
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA <br>
> 02110-1301 USA +<br>
> ***************************************************************************<br>
> **/ +<br>
> +/**************************************************************************<br>
> *** + * Preamble<br>
> +<br>
> ***************************************************************************<br>
> **/ +#ifndef VLC_GST_H_<br>
> +#define VLC_GST_H_<br>
> +<br>
> +#include <vlc_common.h><br>
> +#include <vlc_codec.h><br>
> +<br>
> +vlc_fourcc_t GetGstVLCFourcc( const char* );<br>
> +<br>
> +#endif /* VLC_GST_H_ */<br>
> diff --git a/modules/codec/gstreamer/gstvlcpictureplaneallocator.c<br>
> b/modules/codec/gstreamer/gstvlcpictureplaneallocator.c index<br>
> 2245ee551a..31a27a7ce7 100644<br>
> --- a/modules/codec/gstreamer/gstvlcpictureplaneallocator.c<br>
> +++ b/modules/codec/gstreamer/gstvlcpictureplaneallocator.c<br>
> @@ -27,6 +27,7 @@<br>
>  #include <gst/gst.h><br>
> <br>
>  #include "gstvlcpictureplaneallocator.h"<br>
> +#include "gstvlc.h"<br>
> <br>
>  #include <vlc_common.h><br>
> <br>
> @@ -221,10 +222,26 @@ bool gst_vlc_set_vout_fmt( GstVideoInfo *p_info,<br>
> GstVideoAlignment *p_align, vlc_fourcc_t i_chroma;<br>
>      int i_padded_width, i_padded_height;<br>
> <br>
> -    i_chroma = p_outfmt->i_codec = vlc_fourcc_GetCodecFromString(<br>
> -            VIDEO_ES,<br>
> -            gst_structure_get_string( p_str, "format" ) );<br>
> -    if( !i_chroma )<br>
> +    const char* psz_fourcc = gst_structure_get_string( p_str, "format" );<br>
> +    if( psz_fourcc )<br>
> +    {<br>
> +        if( strlen( psz_fourcc ) != 4 )<br>
> +        {<br>
> +            i_chroma = p_outfmt->i_codec = GetGstVLCFourcc( psz_fourcc );<br>
> +        }<br>
> +        else<br>
> +        {<br>
> +            i_chroma = p_outfmt->i_codec = vlc_fourcc_GetCodecFromString(<br>
> +                VIDEO_ES, psz_fourcc );<br>
<br>
Could probably move that into the new function.<br>
<br>
> +        }<br>
> +    }<br>
> +    else<br>
> +    {<br>
> +        msg_Err( p_dec, "video chroma type not found in output caps" );<br>
> +        return false;<br>
> +    }<br>
> +<br>
> +    if( !i_chroma || i_chroma == VLC_CODEC_UNKNOWN )<br>
>      {<br>
>          msg_Err( p_dec, "video chroma type not supported" );<br>
>          return false;<br>
<br>
<br>
-- <br>
Rémi Denis-Courmont<br>
<a href="http://www.remlab.net/" rel="noreferrer" target="_blank">http://www.remlab.net/</a><br>
<br>
<br>
<br>
_______________________________________________<br>
vlc-devel mailing list<br>
To unsubscribe or modify your subscription options:<br>
<a href="https://mailman.videolan.org/listinfo/vlc-devel" rel="noreferrer" target="_blank">https://mailman.videolan.org/listinfo/vlc-devel</a></blockquote></div></div>