[vlc-devel] [PATCH 1/4] gstdecode: handle fourcc mismatch between gst vlc
Rémi Denis-Courmont
remi at remlab.net
Sun Jun 28 16:46:03 CEST 2020
Le sunnuntaina 28. kesäkuuta 2020, 15.36.39 EEST Vikram Fugro a écrit :
> Add fourcc conversion support to convert from
> gstreamer reresentation to vlc representation,
> especially for the ones that are greater than
> length 4.
> ---
> modules/codec/gstreamer/gstdecode.c | 2 +
> .../gstreamer/gstvlcpictureplaneallocator.c | 51 +++++++++++++++++--
> .../gstreamer/gstvlcpictureplaneallocator.h | 1 +
> 3 files changed, 51 insertions(+), 3 deletions(-)
>
> diff --git a/modules/codec/gstreamer/gstdecode.c
> b/modules/codec/gstreamer/gstdecode.c index 61cb95f4a6..c7003bd6d2 100644
> --- a/modules/codec/gstreamer/gstdecode.c
> +++ b/modules/codec/gstreamer/gstdecode.c
> @@ -336,6 +336,8 @@ static void vlc_gst_init_once(void)
> vlc_gst_registered = gst_plugin_register_static( 1, 0, "videolan",
> "VLC Gstreamer plugins", vlc_gst_plugin_init,
> "1.0.0", "LGPL", "NA", "vlc", "NA" );
> +
> + vlc_gst_build_fourcc_table();
> }
>
> /* gst_init( ) is not thread-safe, hence a thread-safe wrapper */
> diff --git a/modules/codec/gstreamer/gstvlcpictureplaneallocator.c
> b/modules/codec/gstreamer/gstvlcpictureplaneallocator.c index
> 2245ee551a..580a9f931b 100644
> --- a/modules/codec/gstreamer/gstvlcpictureplaneallocator.c
> +++ b/modules/codec/gstreamer/gstvlcpictureplaneallocator.c
> @@ -30,6 +30,8 @@
>
> #include <vlc_common.h>
>
> +static GHashTable* p_fourcc_map = NULL;
> +
> #define gst_vlc_picture_plane_allocator_parent_class parent_class
> G_DEFINE_TYPE (GstVlcPicturePlaneAllocator,
> gst_vlc_picture_plane_allocator, \ GST_TYPE_ALLOCATOR);
> @@ -130,6 +132,36 @@ static GstMemory* gst_vlc_picture_plane_copy(
> return NULL;
> }
>
> +void vlc_gst_build_fourcc_table ( void )
> +{
> + p_fourcc_map = g_hash_table_new( g_str_hash, g_str_equal );
> +
> + g_hash_table_insert( p_fourcc_map, "I420_9LE", "I09L");
> + g_hash_table_insert( p_fourcc_map, "I420_9BE", "I09B");
> + g_hash_table_insert( p_fourcc_map, "I420_10LE", "I0AL");
> + g_hash_table_insert( p_fourcc_map, "I420_10BE", "I0AB");
> + g_hash_table_insert( p_fourcc_map, "I420_12LE", "I0CL");
> + g_hash_table_insert( p_fourcc_map, "I420_12BE", "I0CB");
> + g_hash_table_insert( p_fourcc_map, "I420_16LE", "I0FL");
> + g_hash_table_insert( p_fourcc_map, "I420_16BE", "I0FB");
> + g_hash_table_insert( p_fourcc_map, "I422_9LE", "I29L");
> + g_hash_table_insert( p_fourcc_map, "I422_9BE", "I29B");
> + g_hash_table_insert( p_fourcc_map, "I422_10LE", "I2AL");
> + g_hash_table_insert( p_fourcc_map, "I422_10BE", "I2AB");
> + g_hash_table_insert( p_fourcc_map, "I422_12LE", "I2CL");
> + g_hash_table_insert( p_fourcc_map, "I422_12BE", "I2CB");
> + g_hash_table_insert( p_fourcc_map, "I422_16LE", "I2FL");
> + g_hash_table_insert( p_fourcc_map, "I422_16BE", "I2FB");
> + g_hash_table_insert( p_fourcc_map, "I444_9LE", "I49L");
> + g_hash_table_insert( p_fourcc_map, "I444_9BE", "I49B");
> + g_hash_table_insert( p_fourcc_map, "I444_10LE", "I4AL");
> + g_hash_table_insert( p_fourcc_map, "I444_10BE", "I4AB");
> + g_hash_table_insert( p_fourcc_map, "I444_12LE", "I4CL");
> + g_hash_table_insert( p_fourcc_map, "I444_12BE", "I4CB");
> + g_hash_table_insert( p_fourcc_map, "I444_16LE", "I4FL");
> + g_hash_table_insert( p_fourcc_map, "I444_16BE", "I4FB");
> +}
> +
I don't really see the benefit of hash table with only static content. You
might as well have a static constant table and do a binary search.
> void gst_vlc_picture_plane_allocator_release(
> GstVlcPicturePlaneAllocator *p_allocator, GstBuffer *p_buffer )
> {
> @@ -221,9 +253,22 @@ bool gst_vlc_set_vout_fmt( GstVideoInfo *p_info,
> GstVideoAlignment *p_align, vlc_fourcc_t i_chroma;
> int i_padded_width, i_padded_height;
>
> - i_chroma = p_outfmt->i_codec = vlc_fourcc_GetCodecFromString(
> - VIDEO_ES,
> - gst_structure_get_string( p_str, "format" ) );
> + char* psz_fourcc = gst_structure_get_string(p_str, "format");
> + if( psz_fourcc )
> + {
> + if( strlen( psz_fourcc ) != 4 )
> + psz_fourcc = g_hash_table_lookup( p_fourcc_map, psz_fourcc );
> +
> + i_chroma = p_outfmt->i_codec = vlc_fourcc_GetCodecFromString(
> + VIDEO_ES, psz_fourcc );
> +
> + }
> + else
> + {
> + msg_Err( p_dec, "video chroma type not found in output caps" );
> + return false;
> + }
> +
> if( !i_chroma )
> {
> msg_Err( p_dec, "video chroma type not supported" );
> diff --git a/modules/codec/gstreamer/gstvlcpictureplaneallocator.h
> b/modules/codec/gstreamer/gstvlcpictureplaneallocator.h index
> 7607b4adf5..4f4d6e6446 100644
> --- a/modules/codec/gstreamer/gstvlcpictureplaneallocator.h
> +++ b/modules/codec/gstreamer/gstvlcpictureplaneallocator.h
> @@ -88,4 +88,5 @@ void gst_vlc_picture_plane_allocator_release(
> bool gst_vlc_picture_plane_allocator_alloc(
> GstVlcPicturePlaneAllocator *p_allocator,
> GstBuffer *p_buffer );
> +void vlc_gst_build_fourcc_table( void );
> #endif
--
雷米‧德尼-库尔蒙
http://www.remlab.net/
More information about the vlc-devel
mailing list