[vlc-commits] Parse embedded art in METADATA_BLOCK_PICTURE

Jean-Baptiste Kempf git at videolan.org
Thu Apr 5 22:53:31 CEST 2012


vlc | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Thu Apr  5 18:06:27 2012 +0200| [d00437364735e548db0f010876caf8721dd2275c] | committer: Jean-Baptiste Kempf

Parse embedded art in METADATA_BLOCK_PICTURE

Note: It is not yet passed to the demuxer or the core

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=d00437364735e548db0f010876caf8721dd2275c
---

 modules/demux/vorbis.h |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/modules/demux/vorbis.h b/modules/demux/vorbis.h
index 9770e88..949c0bf 100644
--- a/modules/demux/vorbis.h
+++ b/modules/demux/vorbis.h
@@ -22,6 +22,7 @@
  *****************************************************************************/
 
 #include <vlc_charset.h>
+#include <vlc_strings.h>
 
 static input_attachment_t* ParseFlacPicture( const uint8_t *p_data, int i_data, int i_attachments, int *i_type )
 {
@@ -73,6 +74,7 @@ static inline void vorbis_ParseComment( vlc_meta_t **pp_meta, const uint8_t *p_d
 {
     int n;
     int i_comment;
+    int i_attach = 0;
     if( i_data < 8 )
         return;
 
@@ -154,6 +156,20 @@ static inline void vorbis_ParseComment( vlc_meta_t **pp_meta, const uint8_t *p_d
         else IF_EXTRACT("DESCRIPTION=", Description )
         else IF_EXTRACT("GENRE=", Genre )
         else IF_EXTRACT("DATE=", Date )
+        else if( !strncasecmp( psz, "METADATA_BLOCK_PICTURE=", strlen("METADATA_BLOCK_PICTURE=")))
+        {
+            int i;
+            uint8_t *p_picture;
+            size_t i_size = vlc_b64_decode_binary( &p_picture, &psz[strlen("METADATA_BLOCK_PICTURE=")]);
+            input_attachment_t *p_attachment = ParseFlacPicture( p_picture, i_size, i_attach, &i );
+            if( p_attachment )
+            {
+                char psz_url[128];
+                snprintf( psz_url, sizeof(psz_url), "attachment://%s", p_attachment->psz_name );
+                vlc_meta_Set( p_meta, vlc_meta_ArtworkURL, psz_url );
+                i_attach++;
+            }
+        }
         else if( strchr( psz, '=' ) )
         {
             /* generic (PERFORMER/LICENSE/ORGANIZATION/LOCATION/CONTACT/ISRC,



More information about the vlc-commits mailing list