<div dir="ltr">Hi Remi,<div><br></div><div>Agree, that was major mishap at my side.</div><div>WIll fix it.</div><div><br></div><div>Thanks,</div><div>Vikram</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Jun 28, 2020 at 8:16 PM 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 28. kesäkuuta 2020, 15.36.39 EEST Vikram Fugro a écrit :<br>
> Add fourcc conversion support to convert from<br>
> gstreamer reresentation to vlc representation,<br>
> especially for the ones that are greater than<br>
> length 4.<br>
> ---<br>
>  modules/codec/gstreamer/gstdecode.c           |  2 +<br>
>  .../gstreamer/gstvlcpictureplaneallocator.c   | 51 +++++++++++++++++--<br>
>  .../gstreamer/gstvlcpictureplaneallocator.h   |  1 +<br>
>  3 files changed, 51 insertions(+), 3 deletions(-)<br>
> <br>
> diff --git a/modules/codec/gstreamer/gstdecode.c<br>
> b/modules/codec/gstreamer/gstdecode.c index 61cb95f4a6..c7003bd6d2 100644<br>
> --- a/modules/codec/gstreamer/gstdecode.c<br>
> +++ b/modules/codec/gstreamer/gstdecode.c<br>
> @@ -336,6 +336,8 @@ static void vlc_gst_init_once(void)<br>
>      vlc_gst_registered = gst_plugin_register_static( 1, 0, "videolan",<br>
>                  "VLC Gstreamer plugins", vlc_gst_plugin_init,<br>
>                  "1.0.0", "LGPL", "NA", "vlc", "NA" );<br>
> +<br>
> +    vlc_gst_build_fourcc_table();<br>
>  }<br>
> <br>
>  /* gst_init( ) is not thread-safe, hence a thread-safe wrapper */<br>
> diff --git a/modules/codec/gstreamer/gstvlcpictureplaneallocator.c<br>
> b/modules/codec/gstreamer/gstvlcpictureplaneallocator.c index<br>
> 2245ee551a..580a9f931b 100644<br>
> --- a/modules/codec/gstreamer/gstvlcpictureplaneallocator.c<br>
> +++ b/modules/codec/gstreamer/gstvlcpictureplaneallocator.c<br>
> @@ -30,6 +30,8 @@<br>
> <br>
>  #include <vlc_common.h><br>
> <br>
> +static GHashTable* p_fourcc_map = NULL;<br>
> +<br>
>  #define gst_vlc_picture_plane_allocator_parent_class parent_class<br>
>  G_DEFINE_TYPE (GstVlcPicturePlaneAllocator,<br>
> gst_vlc_picture_plane_allocator, \ GST_TYPE_ALLOCATOR);<br>
> @@ -130,6 +132,36 @@ static GstMemory* gst_vlc_picture_plane_copy(<br>
>      return NULL;<br>
>  }<br>
> <br>
> +void vlc_gst_build_fourcc_table ( void )<br>
> +{<br>
> +    p_fourcc_map = g_hash_table_new( g_str_hash, g_str_equal );<br>
> +<br>
> +    g_hash_table_insert( p_fourcc_map, "I420_9LE",  "I09L");<br>
> +    g_hash_table_insert( p_fourcc_map, "I420_9BE",  "I09B");<br>
> +    g_hash_table_insert( p_fourcc_map, "I420_10LE", "I0AL");<br>
> +    g_hash_table_insert( p_fourcc_map, "I420_10BE", "I0AB");<br>
> +    g_hash_table_insert( p_fourcc_map, "I420_12LE", "I0CL");<br>
> +    g_hash_table_insert( p_fourcc_map, "I420_12BE", "I0CB");<br>
> +    g_hash_table_insert( p_fourcc_map, "I420_16LE", "I0FL");<br>
> +    g_hash_table_insert( p_fourcc_map, "I420_16BE", "I0FB");<br>
> +    g_hash_table_insert( p_fourcc_map, "I422_9LE",  "I29L");<br>
> +    g_hash_table_insert( p_fourcc_map, "I422_9BE",  "I29B");<br>
> +    g_hash_table_insert( p_fourcc_map, "I422_10LE", "I2AL");<br>
> +    g_hash_table_insert( p_fourcc_map, "I422_10BE", "I2AB");<br>
> +    g_hash_table_insert( p_fourcc_map, "I422_12LE", "I2CL");<br>
> +    g_hash_table_insert( p_fourcc_map, "I422_12BE", "I2CB");<br>
> +    g_hash_table_insert( p_fourcc_map, "I422_16LE", "I2FL");<br>
> +    g_hash_table_insert( p_fourcc_map, "I422_16BE", "I2FB");<br>
> +    g_hash_table_insert( p_fourcc_map, "I444_9LE",  "I49L");<br>
> +    g_hash_table_insert( p_fourcc_map, "I444_9BE",  "I49B");<br>
> +    g_hash_table_insert( p_fourcc_map, "I444_10LE", "I4AL");<br>
> +    g_hash_table_insert( p_fourcc_map, "I444_10BE", "I4AB");<br>
> +    g_hash_table_insert( p_fourcc_map, "I444_12LE", "I4CL");<br>
> +    g_hash_table_insert( p_fourcc_map, "I444_12BE", "I4CB");<br>
> +    g_hash_table_insert( p_fourcc_map, "I444_16LE", "I4FL");<br>
> +    g_hash_table_insert( p_fourcc_map, "I444_16BE", "I4FB");<br>
> +}<br>
> +<br>
<br>
I don't really see the benefit of hash table with only static content. You <br>
might as well have a static constant table and do a binary search.<br>
<br>
>  void gst_vlc_picture_plane_allocator_release(<br>
>      GstVlcPicturePlaneAllocator *p_allocator, GstBuffer *p_buffer )<br>
>  {<br>
> @@ -221,9 +253,22 @@ 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>
> +    char* psz_fourcc = gst_structure_get_string(p_str, "format");<br>
> +    if( psz_fourcc )<br>
> +    {<br>
> +        if( strlen( psz_fourcc ) != 4 )<br>
> +            psz_fourcc = g_hash_table_lookup( p_fourcc_map, psz_fourcc );<br>
> +<br>
> +        i_chroma = p_outfmt->i_codec = vlc_fourcc_GetCodecFromString(<br>
> +            VIDEO_ES, psz_fourcc );<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 )<br>
>      {<br>
>          msg_Err( p_dec, "video chroma type not supported" );<br>
> diff --git a/modules/codec/gstreamer/gstvlcpictureplaneallocator.h<br>
> b/modules/codec/gstreamer/gstvlcpictureplaneallocator.h index<br>
> 7607b4adf5..4f4d6e6446 100644<br>
> --- a/modules/codec/gstreamer/gstvlcpictureplaneallocator.h<br>
> +++ b/modules/codec/gstreamer/gstvlcpictureplaneallocator.h<br>
> @@ -88,4 +88,5 @@ void gst_vlc_picture_plane_allocator_release(<br>
>  bool gst_vlc_picture_plane_allocator_alloc(<br>
>          GstVlcPicturePlaneAllocator *p_allocator,<br>
>          GstBuffer *p_buffer );<br>
> +void vlc_gst_build_fourcc_table( void );<br>
>  #endif<br>
<br>
<br>
-- <br>
雷米‧德尼-库尔蒙<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>