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
8412d94d
Commit
8412d94d
authored
Jul 27, 2016
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
decoder/ffmpeg: add GetCodecParameters()
Preparing for FFmpeg 3.1 support.
parent
d1c5bb95
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
6 deletions
+21
-6
FfmpegDecoderPlugin.cxx
src/decoder/plugins/FfmpegDecoderPlugin.cxx
+21
-6
No files found.
src/decoder/plugins/FfmpegDecoderPlugin.cxx
View file @
8412d94d
...
...
@@ -77,10 +77,24 @@ ffmpeg_init(gcc_unused const config_param ¶m)
}
gcc_pure
static
const
AVCodecContext
&
GetCodecParameters
(
const
AVStream
&
stream
)
{
return
*
stream
.
codec
;
}
gcc_pure
static
AVSampleFormat
GetSampleFormat
(
const
AVCodecContext
&
codec_context
)
{
return
codec_context
.
sample_fmt
;
}
gcc_pure
static
bool
IsAudio
(
const
AVStream
&
stream
)
{
return
stream
.
codec
->
codec_type
==
AVMEDIA_TYPE_AUDIO
;
return
GetCodecParameters
(
stream
).
codec_type
==
AVMEDIA_TYPE_AUDIO
;
}
gcc_pure
...
...
@@ -411,10 +425,11 @@ ffmpeg_decode(Decoder &decoder, InputStream &input)
AVStream
&
av_stream
=
*
format_context
->
streams
[
audio_stream
];
AVCodecContext
*
codec_context
=
av_stream
.
codec
;
const
auto
&
codec_params
=
GetCodecParameters
(
av_stream
);
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(54, 25, 0)
const
AVCodecDescriptor
*
codec_descriptor
=
avcodec_descriptor_get
(
codec_
context
->
codec_id
);
avcodec_descriptor_get
(
codec_
params
.
codec_id
);
if
(
codec_descriptor
!=
nullptr
)
FormatDebug
(
ffmpeg_domain
,
"codec '%s'"
,
codec_descriptor
->
name
);
...
...
@@ -424,7 +439,7 @@ ffmpeg_decode(Decoder &decoder, InputStream &input)
codec_context
->
codec_name
);
#endif
AVCodec
*
codec
=
avcodec_find_decoder
(
codec_
context
->
codec_id
);
AVCodec
*
codec
=
avcodec_find_decoder
(
codec_
params
.
codec_id
);
if
(
!
codec
)
{
LogError
(
ffmpeg_domain
,
"Unsupported audio codec"
);
...
...
@@ -433,7 +448,7 @@ ffmpeg_decode(Decoder &decoder, InputStream &input)
}
const
SampleFormat
sample_format
=
ffmpeg_sample_format
(
codec_context
->
sample_fmt
);
ffmpeg_sample_format
(
GetSampleFormat
(
codec_params
)
);
if
(
sample_format
==
SampleFormat
::
UNDEFINED
)
{
// (error message already done by ffmpeg_sample_format())
avformat_close_input
(
&
format_context
);
...
...
@@ -443,9 +458,9 @@ ffmpeg_decode(Decoder &decoder, InputStream &input)
Error
error
;
AudioFormat
audio_format
;
if
(
!
audio_format_init_checked
(
audio_format
,
codec_
context
->
sample_rate
,
codec_
params
.
sample_rate
,
sample_format
,
codec_
context
->
channels
,
error
))
{
codec_
params
.
channels
,
error
))
{
LogError
(
error
);
avformat_close_input
(
&
format_context
);
return
;
...
...
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