#11813 Language detection acording to MKV Specification

Feature requests for VLC.
DuKeTHeReaL
New Cone
New Cone
Posts: 2
Joined: 28 Jul 2014 02:17

#11813 Language detection acording to MKV Specification

Postby DuKeTHeReaL » 28 Jul 2014 02:50

Hi,

I want to help solving a ticket opened by myself: https://trac.videolan.org/vlc/ticket/11813#ticket

It's about implementing the mkv specification of languages correctly. I guess that language detection is not handled seperatly for every codec and just parsed there and resolved globally. I also think that this extension of codec recognition would serve all codecs and not harm another one, so that this would not disturb if it's implemented globally.

After reviewing the code a bit (looking into it for the first time), I found lines in the code, that implemented language detection like I would expect it:

From http://repo.or.cz/w/vlc.git/blob/HEAD:/ ... fromtelx.c:
186 static void SetLanguage( sout_stream_t *p_stream, char *psz_language )
187 {
188 sout_stream_sys_t *p_sys = (sout_stream_sys_t *)p_stream->p_sys;
189
190 if ( strncmp( p_sys->psz_language, psz_language, 3 ) )
191 msg_Dbg( p_stream, "changing language to %s", psz_language );
192
193 strncpy( p_sys->psz_language, (const char *)psz_language, 3 );
194 }
strncmp and strncpy both get the parameter 3 and should cut a string like spa-lat after spa, shouldn't they?

I have not encountered the part of the language stream detection yet, only where the stuff is parsed. Does anyone have a hint?

I found the generally language definition in http://repo.or.cz/w/vlc.git/blob/HEAD:/include/vlc_es.h


Than I found in http://repo.or.cz/w/vlc.git/blob/HEAD:/ ... t/es_out.c following lines:
2718 /****************************************************************************
2719 * LanguageGetName: try to expend iso639 into plain name
2720 ****************************************************************************/
2721 static char *LanguageGetName( const char *psz_code )
2722 {
2723 const iso639_lang_t *pl;
2724
2725 if( psz_code == NULL || !strcmp( psz_code, "und" ) )
2726 {
2727 return strdup( "" );
2728 }
2729
2730 if( strlen( psz_code ) == 2 )
2731 {
2732 pl = GetLang_1( psz_code );
2733 }
2734 else if( strlen( psz_code ) == 3 )
2735 {
2736 pl = GetLang_2B( psz_code );
2737 if( !strcmp( pl->psz_iso639_1, "??" ) )
2738 {
2739 pl = GetLang_2T( psz_code );
2740 }
2741 }
2742 else
2743 {
2744 return strdup( psz_code );
2745 }
2746
2747 if( !strcmp( pl->psz_iso639_1, "??" ) )
2748 {
2749 return strdup( psz_code );
2750 }
2751 else
2752 {
2753 return strdup( vlc_gettext(pl->psz_eng_name) );
2754 }
2755 }
2756
2757 /* Get a 2 char code */
2758 static char *LanguageGetCode( const char *psz_lang )
2759 {
2760 const iso639_lang_t *pl;
2761
2762 if( psz_lang == NULL || *psz_lang == '\0' )
2763 return strdup("??");
2764
2765 for( pl = p_languages; pl->psz_eng_name != NULL; pl++ )
2766 {
2767 if( !strcasecmp( pl->psz_eng_name, psz_lang ) ||
2768 !strcasecmp( pl->psz_iso639_1, psz_lang ) ||
2769 !strcasecmp( pl->psz_iso639_2T, psz_lang ) ||
2770 !strcasecmp( pl->psz_iso639_2B, psz_lang ) )
2771 return strdup( pl->psz_iso639_1 );
2772 }
2773
2774 return strdup("??");
2775 }
If I see everything correct a fix would be for example checking if it contains a "-"

Thanks for the support

DuKeTHeReaL
Last edited by DuKeTHeReaL on 28 Jul 2014 19:26, edited 1 time in total.

DuKeTHeReaL
New Cone
New Cone
Posts: 2
Joined: 28 Jul 2014 02:17

Re: #11813 Language detection acording to MKV Specification

Postby DuKeTHeReaL » 28 Jul 2014 18:43

Ok,

I have it working. I will check it in soon ;D

Max

Edit: Patch sent ;)

Edit2: Here: https://mailman.videolan.org/pipermail/ ... 99124.html

What's missing there is the parsing of the TLD (If it's wanted)


Return to “VLC media player Feature Requests”

Who is online

Users browsing this forum: No registered users and 8 guests