]> git.sesse.net Git - vlc/blobdiff - modules/demux/xiph_metadata.c
decoder: remove ARM-specific limitation
[vlc] / modules / demux / xiph_metadata.c
index e0f7439d311b58ea880a4661192f6e8b00774d4e..e4ef7674c2c9c781866a60aaddb15707f892dcd8 100644 (file)
@@ -120,6 +120,7 @@ typedef struct chapters_array_t
 
 static seekpoint_t * getChapterEntry( unsigned int i_index, chapters_array_t *p_array )
 {
+    if ( i_index > 4096 ) return NULL;
     if ( i_index >= p_array->i_size )
     {
         unsigned int i_newsize = p_array->i_size;
@@ -144,7 +145,7 @@ static seekpoint_t * getChapterEntry( unsigned int i_index, chapters_array_t *p_
     return p_array->pp_chapters[i_index];
 }
 
-void vorbis_ParseComment( vlc_meta_t **pp_meta,
+void vorbis_ParseComment( es_format_t *p_fmt, vlc_meta_t **pp_meta,
         const uint8_t *p_data, int i_data,
         int *i_attachments, input_attachment_t ***attachments,
         int *i_cover_score, int *i_cover_idx,
@@ -242,6 +243,14 @@ void vorbis_ParseComment( vlc_meta_t **pp_meta,
         has##var = true; \
     }
 
+#define IF_EXTRACT_FMT(txt,var,fmt,target) \
+    IF_EXTRACT(txt,var)\
+    if( fmt && !strncasecmp(psz_comment, txt, strlen(txt)) )\
+        {\
+            if ( fmt->target ) free( fmt->target );\
+            fmt->target = strdup(&psz_comment[strlen(txt)]);\
+        }
+
         IF_EXTRACT("TITLE=", Title )
         else IF_EXTRACT("ARTIST=", Artist )
         else IF_EXTRACT("GENRE=", Genre )
@@ -275,7 +284,7 @@ void vorbis_ParseComment( vlc_meta_t **pp_meta,
         else IF_EXTRACT("COMMENTS=", Description )
         else IF_EXTRACT("RATING=", Rating )
         else IF_EXTRACT("DATE=", Date )
-        else IF_EXTRACT("LANGUAGE=", Language )
+        else IF_EXTRACT_FMT("LANGUAGE=", Language, p_fmt, psz_language )
         else IF_EXTRACT("ORGANIZATION=", Publisher )
         else IF_EXTRACT("ENCODER=", EncodedBy )
         else if( !strncasecmp( psz_comment, "METADATA_BLOCK_PICTURE=", strlen("METADATA_BLOCK_PICTURE=")))
@@ -299,7 +308,7 @@ void vorbis_ParseComment( vlc_meta_t **pp_meta,
             char *p = strchr( psz_comment, '=' );
             char *psz_val;
             if (!p) continue;
-            if ( !strncmp(psz_comment, "REPLAYGAIN_TRACK_GAIN=", 22) )
+            if ( !strncasecmp(psz_comment, "REPLAYGAIN_TRACK_GAIN=", 22) )
             {
                 psz_val = malloc( strlen(p+1) + 1 );
                 if (!psz_val) continue;
@@ -309,7 +318,7 @@ void vorbis_ParseComment( vlc_meta_t **pp_meta,
                     free( psz_val );
                 }
             }
-            else if ( !strncmp(psz_comment, "REPLAYGAIN_ALBUM_GAIN=", 22) )
+            else if ( !strncasecmp(psz_comment, "REPLAYGAIN_ALBUM_GAIN=", 22) )
             {
                 psz_val = malloc( strlen(p+1) + 1 );
                 if (!psz_val) continue;
@@ -319,11 +328,11 @@ void vorbis_ParseComment( vlc_meta_t **pp_meta,
                     free( psz_val );
                 }
             }
-            else if ( !strncmp(psz_comment, "REPLAYGAIN_ALBUM_PEAK=", 22) )
+            else if ( !strncasecmp(psz_comment, "REPLAYGAIN_ALBUM_PEAK=", 22) )
             {
                 (*ppf_replay_peak)[AUDIO_REPLAY_GAIN_ALBUM] = us_atof( ++p );
             }
-            else if ( !strncmp(psz_comment, "REPLAYGAIN_TRACK_PEAK=", 22) )
+            else if ( !strncasecmp(psz_comment, "REPLAYGAIN_TRACK_PEAK=", 22) )
             {
                 (*ppf_replay_peak)[AUDIO_REPLAY_GAIN_TRACK] = us_atof( ++p );
             }
@@ -332,9 +341,13 @@ void vorbis_ParseComment( vlc_meta_t **pp_meta,
         {
             unsigned int i_chapt;
             seekpoint_t *p_seekpoint = NULL;
-            if( strcasestr( psz_comment, "NAME=" ) &&
-                ( sscanf( psz_comment, "CHAPTER%uNAME=", &i_chapt ) == 1 ||
-                  sscanf( psz_comment, "chapter%name=", &i_chapt ) == 1 ) )
+
+            for( int i = 0; psz_comment[i] && psz_comment[i] != '='; i++ )
+                if( psz_comment[i] >= 'a' && psz_comment[i] <= 'z' )
+                    psz_comment[i] -= 'a' - 'A';
+
+            if( strstr( psz_comment, "NAME=" ) &&
+                    sscanf( psz_comment, "CHAPTER%uNAME=", &i_chapt ) == 1 )
             {
                 char *p = strchr( psz_comment, '=' );
                 p_seekpoint = getChapterEntry( i_chapt, &chapters_array );
@@ -342,8 +355,7 @@ void vorbis_ParseComment( vlc_meta_t **pp_meta,
                 if ( ! p_seekpoint->psz_name )
                     p_seekpoint->psz_name = strdup( ++p );
             }
-            else if( sscanf( psz_comment, "CHAPTER%u=", &i_chapt ) == 1 ||
-                     sscanf( psz_comment, "chapter%u=", &i_chapt ) == 1 )
+            else if( sscanf( psz_comment, "CHAPTER%u=", &i_chapt ) == 1 )
             {
                 unsigned int h, m, s, ms;
                 char *p = strchr( psz_comment, '=' );