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
065926d6
Commit
065926d6
authored
Sep 23, 2020
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
decoder/ffmpeg: support album art
Closes
https://github.com/MusicPlayerDaemon/MPD/issues/892
parent
85bab670
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
0 deletions
+50
-0
FfmpegDecoderPlugin.cxx
src/decoder/plugins/FfmpegDecoderPlugin.cxx
+50
-0
No files found.
src/decoder/plugins/FfmpegDecoderPlugin.cxx
View file @
065926d6
...
...
@@ -121,6 +121,49 @@ ffmpeg_find_audio_stream(const AVFormatContext &format_context) noexcept
return
-
1
;
}
gcc_pure
static
bool
IsPicture
(
const
AVStream
&
stream
)
noexcept
{
return
stream
.
codecpar
->
codec_type
==
AVMEDIA_TYPE_VIDEO
&&
(
stream
.
disposition
&
AV_DISPOSITION_ATTACHED_PIC
)
!=
0
&&
stream
.
attached_pic
.
size
>
0
;
}
static
const
AVStream
*
FindPictureStream
(
const
AVFormatContext
&
format_context
)
noexcept
{
for
(
unsigned
i
=
0
;
i
<
format_context
.
nb_streams
;
++
i
)
if
(
IsPicture
(
*
format_context
.
streams
[
i
]))
return
format_context
.
streams
[
i
];
return
nullptr
;
}
static
const
char
*
GetMimeType
(
const
AVCodecDescriptor
&
codec
)
noexcept
{
return
codec
.
mime_types
!=
nullptr
?
*
codec
.
mime_types
:
nullptr
;
}
static
const
char
*
GetMimeType
(
const
AVStream
&
stream
)
noexcept
{
const
auto
*
codec
=
avcodec_descriptor_get
(
stream
.
codecpar
->
codec_id
);
if
(
codec
!=
nullptr
)
return
GetMimeType
(
*
codec
);
return
nullptr
;
}
static
ConstBuffer
<
void
>
ToConstBuffer
(
const
AVPacket
&
packet
)
noexcept
{
return
{
packet
.
data
,
size_t
(
packet
.
size
)};
}
/**
* Accessor for AVStream::start_time that replaces AV_NOPTS_VALUE with
* zero. We can't use AV_NOPTS_VALUE in calculations, and we simply
...
...
@@ -625,6 +668,13 @@ FfmpegScanStream(AVFormatContext &format_context, TagHandler &handler)
FfmpegScanMetadata
(
format_context
,
audio_stream
,
handler
);
if
(
handler
.
WantPicture
())
{
const
auto
*
picture_stream
=
FindPictureStream
(
format_context
);
if
(
picture_stream
!=
nullptr
)
handler
.
OnPicture
(
GetMimeType
(
*
picture_stream
),
ToConstBuffer
(
picture_stream
->
attached_pic
));
}
return
true
;
}
...
...
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