[PATCH 3/6] Implement picture support for MP4
- From: Santtu Lakkala <inz inz fi>
- To: easytag-list gnome org
- Subject: [PATCH 3/6] Implement picture support for MP4
- Date: Thu, 10 Apr 2014 08:32:30 +0300
Adds support for saving cover image into MP4 files, and show the images tab
for them as well.
---
src/easytag.c | 2 +-
src/mp4_tag.cc | 41 ++++++++++++++++++++++++++++++++++++++++-
2 files changed, 41 insertions(+), 2 deletions(-)
diff --git a/src/easytag.c b/src/easytag.c
index 05a6998..44ce8a4 100644
--- a/src/easytag.c
+++ b/src/easytag.c
@@ -4118,7 +4118,7 @@ void Tag_Area_Display_Controls (ET_File *ETFile)
gtk_widget_hide(GTK_WIDGET(URLEntry));
gtk_widget_show (GTK_WIDGET (EncodedByLabel));
gtk_widget_show (GTK_WIDGET (EncodedByEntry));
- et_tag_notebook_hide_images_tab (TagNoteBook);
+ et_tag_notebook_show_images_tab (TagNoteBook);
break;
#endif
diff --git a/src/mp4_tag.cc b/src/mp4_tag.cc
index a52c2fa..f051c7f 100644
--- a/src/mp4_tag.cc
+++ b/src/mp4_tag.cc
@@ -167,7 +167,20 @@ gboolean Mp4tag_Read_File_Tag (gchar *filename, File_Tag *FileTag)
/***********
* Picture *
***********/
- /* TODO: No encode_by support in the TagLib C API! */
+ if (extra_tag.contains ("covr"))
+ {
+ const TagLib::MP4::Item cover = extra_tag["covr"];
+ const TagLib::MP4::CoverArt &art = cover.toCoverArtList ().front ();
+
+ FileTag->picture = Picture_Allocate ();
+
+ FileTag->picture->size = art.data ().size ();
+ FileTag->picture->data = (guchar *)g_memdup (art.data ().data (), art.data ().size ());
+ }
+ else
+ {
+ FileTag->picture = NULL;
+ }
return TRUE;
}
@@ -306,6 +319,32 @@ gboolean Mp4tag_Write_File_Tag (ET_File *ETFile)
/***********
* Picture *
***********/
+ if (FileTag->picture)
+ {
+ Picture_Format pf = Picture_Format_From_Data (FileTag->picture);
+ TagLib::MP4::CoverArt::Format f;
+ switch (pf)
+ {
+ case PICTURE_FORMAT_JPEG:
+ f = TagLib::MP4::CoverArt::JPEG;
+ break;
+ case PICTURE_FORMAT_PNG:
+ f = TagLib::MP4::CoverArt::PNG;
+ break;
+ case PICTURE_FORMAT_GIF:
+ f = TagLib::MP4::CoverArt::GIF;
+ break;
+ default:
+ g_warning("Unknown format");
+ f = TagLib::MP4::CoverArt::JPEG;
+ break;
+ }
+ TagLib::MP4::CoverArt art(f, TagLib::ByteVector((char *)FileTag->picture->data,
+ FileTag->picture->size));
+
+ extra_tag.insert("covr",
+ TagLib::MP4::Item(TagLib::MP4::CoverArtList().append(art)));
+ }
/* FIXME: Add support to TagLib. */
// tag->setProperties (extra_tag);
--
1.8.3.2
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]