Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
433e18b2
Commit
433e18b2
authored
Aug 13, 2019
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
decoder/{opus,vorbis}: support embedded pictures (METADATA_BLOCK_PICTURE)
More for
https://github.com/MusicPlayerDaemon/MPD/issues/42
parent
2b837277
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
212 additions
and
0 deletions
+212
-0
OpusTags.cxx
src/decoder/plugins/OpusTags.cxx
+5
-0
meson.build
src/decoder/plugins/meson.build
+1
-0
VorbisComments.cxx
src/lib/xiph/VorbisComments.cxx
+7
-0
VorbisPicture.cxx
src/lib/xiph/VorbisPicture.cxx
+56
-0
VorbisPicture.hxx
src/lib/xiph/VorbisPicture.hxx
+29
-0
meson.build
src/lib/xiph/meson.build
+1
-0
Id3Picture.cxx
src/tag/Id3Picture.cxx
+80
-0
Id3Picture.hxx
src/tag/Id3Picture.hxx
+32
-0
meson.build
src/tag/meson.build
+1
-0
No files found.
src/decoder/plugins/OpusTags.cxx
View file @
433e18b2
...
...
@@ -19,6 +19,7 @@
#include "OpusTags.hxx"
#include "OpusReader.hxx"
#include "lib/xiph/VorbisPicture.hxx"
#include "lib/xiph/XiphTags.hxx"
#include "tag/Handler.hxx"
#include "tag/ParseName.hxx"
...
...
@@ -45,6 +46,10 @@ ScanOneOpusTag(StringView name, StringView value,
ReplayGainInfo
*
rgi
,
TagHandler
&
handler
)
noexcept
{
if
(
handler
.
WantPicture
()
&&
name
.
EqualsIgnoreCase
(
"METADATA_BLOCK_PICTURE"
))
return
ScanVorbisPicture
(
value
,
handler
);
if
(
value
.
size
>=
4096
)
/* ignore large values */
return
;
...
...
src/decoder/plugins/meson.build
View file @
433e18b2
...
...
@@ -192,6 +192,7 @@ decoder_plugins = static_library(
decoder_plugins_dep = declare_dependency(
link_with: decoder_plugins,
dependencies: [
crypto_base64_dep,
decoder_api_dep,
pcm_dep,
],
...
...
src/lib/xiph/VorbisComments.cxx
View file @
433e18b2
...
...
@@ -18,6 +18,7 @@
*/
#include "VorbisComments.hxx"
#include "VorbisPicture.hxx"
#include "XiphTags.hxx"
#include "tag/Table.hxx"
#include "tag/Handler.hxx"
...
...
@@ -84,6 +85,12 @@ vorbis_copy_comment(StringView comment,
static
void
vorbis_scan_comment
(
StringView
comment
,
TagHandler
&
handler
)
noexcept
{
const
auto
picture_b64
=
handler
.
WantPicture
()
?
GetVorbisCommentValue
(
comment
,
"METADATA_BLOCK_PICTURE"
)
:
nullptr
;
if
(
!
picture_b64
.
IsNull
())
return
ScanVorbisPicture
(
picture_b64
,
handler
);
if
(
handler
.
WantPair
())
{
const
auto
split
=
comment
.
Split
(
'='
);
if
(
!
split
.
first
.
empty
()
&&
!
split
.
second
.
IsNull
())
...
...
src/lib/xiph/VorbisPicture.cxx
0 → 100644
View file @
433e18b2
/*
* Copyright 2003-2019 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "VorbisPicture.hxx"
#include "lib/crypto/Base64.hxx"
#include "tag/Id3Picture.hxx"
#include "tag/Handler.hxx"
#include "util/StringView.hxx"
#include "util/WritableBuffer.hxx"
#include "config.h"
#include <memory>
void
ScanVorbisPicture
(
StringView
value
,
TagHandler
&
handler
)
noexcept
{
#ifdef HAVE_BASE64
if
(
value
.
size
>
1024
*
1024
)
/* ignore image files which are too huge */
return
;
size_t
debase64_size
=
CalculateBase64OutputSize
(
value
.
size
);
std
::
unique_ptr
<
uint8_t
[]
>
debase64_buffer
;
debase64_buffer
.
reset
(
new
uint8_t
[
debase64_size
]);
try
{
debase64_size
=
DecodeBase64
({
debase64_buffer
.
get
(),
debase64_size
},
value
);
}
catch
(...)
{
// TODO: log?
return
;
}
return
ScanId3Apic
({
debase64_buffer
.
get
(),
debase64_size
},
handler
);
#else
(
void
)
value
;
(
void
)
handler
;
#endif
}
src/lib/xiph/VorbisPicture.hxx
0 → 100644
View file @
433e18b2
/*
* Copyright 2003-2019 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef MPD_VORBIS_PICTURE_HXX
#define MPD_VORBIS_PICTURE_HXX
struct
StringView
;
class
TagHandler
;
void
ScanVorbisPicture
(
StringView
value
,
TagHandler
&
handler
)
noexcept
;
#endif
src/lib/xiph/meson.build
View file @
433e18b2
...
...
@@ -47,6 +47,7 @@ endif
xiph = static_library(
'xiph',
'VorbisComments.cxx',
'VorbisPicture.cxx',
'XiphTags.cxx',
include_directories: inc,
)
...
...
src/tag/Id3Picture.cxx
0 → 100644
View file @
433e18b2
/*
* Copyright 2003-2019 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "Id3Picture.hxx"
#include "Handler.hxx"
#include "util/ByteOrder.hxx"
#include "util/ConstBuffer.hxx"
#include "util/StringView.hxx"
#include <string>
#include <stdint.h>
static
StringView
ReadString
(
ConstBuffer
<
uint8_t
>
&
src
)
noexcept
{
if
(
src
.
size
<
4
)
return
nullptr
;
const
size_t
length
=
FromBE32
(
*
(
const
uint32_t
*
)
src
.
data
);
src
.
skip_front
(
4
);
if
(
src
.
size
<
length
)
return
nullptr
;
StringView
result
((
const
char
*
)
src
.
data
,
length
);
src
.
skip_front
(
length
);
return
result
;
}
void
ScanId3Apic
(
ConstBuffer
<
void
>
_buffer
,
TagHandler
&
handler
)
noexcept
{
auto
buffer
=
ConstBuffer
<
uint8_t
>::
FromVoid
(
_buffer
);
if
(
buffer
.
size
<
4
)
return
;
buffer
.
skip_front
(
4
);
/* picture type */
const
auto
mime_type
=
ReadString
(
buffer
);
if
(
mime_type
.
IsNull
())
return
;
/* description */
if
(
ReadString
(
buffer
).
IsNull
())
return
;
if
(
buffer
.
size
<
20
)
return
;
buffer
.
skip_front
(
16
);
const
size_t
image_size
=
FromBE32
(
*
(
const
uint32_t
*
)
buffer
.
data
);
buffer
.
skip_front
(
4
);
if
(
buffer
.
size
<
image_size
)
return
;
ConstBuffer
<
void
>
image
(
buffer
.
data
,
image_size
);
// TODO: don't copy MIME type, pass StringView to TagHandler::OnPicture()
handler
.
OnPicture
(
std
::
string
(
mime_type
.
data
,
mime_type
.
size
).
c_str
(),
image
);
}
src/tag/Id3Picture.hxx
0 → 100644
View file @
433e18b2
/*
* Copyright 2003-2019 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef MPD_TAG_ID3_PICTURE_HXX
#define MPD_TAG_ID3_PICTURE_HXX
template
<
typename
T
>
struct
ConstBuffer
;
class
TagHandler
;
/**
* Scan an "APIC" value and call TagHandler::OnPicture().
*/
void
ScanId3Apic
(
ConstBuffer
<
void
>
buffer
,
TagHandler
&
handler
)
noexcept
;
#endif
src/tag/meson.build
View file @
433e18b2
...
...
@@ -15,6 +15,7 @@ tag_sources = [
'MixRamp.cxx',
'Generic.cxx',
'Id3MusicBrainz.cxx',
'Id3Picture.cxx',
'ApeLoader.cxx',
'ApeReplayGain.cxx',
'ApeTag.cxx',
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment