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
08272cde
Commit
08272cde
authored
Nov 04, 2018
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
decoder/ffmpeg: require FFmpeg 3.1 or later
Drop some compatibility code.
parent
b14a5141
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
80 deletions
+8
-80
NEWS
NEWS
+2
-0
FfmpegDecoderPlugin.cxx
src/decoder/plugins/FfmpegDecoderPlugin.cxx
+3
-77
meson.build
src/lib/ffmpeg/meson.build
+3
-3
No files found.
NEWS
View file @
08272cde
ver 0.21.2 (not yet released)
* decoder
- ffmpeg: require FFmpeg 3.1 or later
ver 0.21.1 (2018/11/04)
* protocol
...
...
src/decoder/plugins/FfmpegDecoderPlugin.cxx
View file @
08272cde
...
...
@@ -105,15 +105,6 @@ ffmpeg_finish() noexcept
av_dict_free
(
&
avformat_options
);
}
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 25, 0)
/* FFmpeg 3.1 */
gcc_pure
static
const
AVCodecParameters
&
GetCodecParameters
(
const
AVStream
&
stream
)
noexcept
{
return
*
stream
.
codecpar
;
}
gcc_pure
static
AVSampleFormat
GetSampleFormat
(
const
AVCodecParameters
&
codec_params
)
noexcept
...
...
@@ -121,29 +112,11 @@ GetSampleFormat(const AVCodecParameters &codec_params) noexcept
return
AVSampleFormat
(
codec_params
.
format
);
}
#else
gcc_pure
static
const
AVCodecContext
&
GetCodecParameters
(
const
AVStream
&
stream
)
noexcept
{
return
*
stream
.
codec
;
}
gcc_pure
static
AVSampleFormat
GetSampleFormat
(
const
AVCodecContext
&
codec_context
)
noexcept
{
return
codec_context
.
sample_fmt
;
}
#endif
gcc_pure
static
bool
IsAudio
(
const
AVStream
&
stream
)
noexcept
{
return
GetCodecParameters
(
stream
).
codec_type
==
AVMEDIA_TYPE_AUDIO
;
return
stream
.
codecpar
->
codec_type
==
AVMEDIA_TYPE_AUDIO
;
}
gcc_pure
...
...
@@ -278,8 +251,6 @@ FfmpegSendFrame(DecoderClient &client, InputStream &is,
codec_context
.
bit_rate
/
1000
);
}
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 37, 0)
static
DecoderCommand
FfmpegReceiveFrames
(
DecoderClient
&
client
,
InputStream
&
is
,
AVCodecContext
&
codec_context
,
...
...
@@ -324,8 +295,6 @@ FfmpegReceiveFrames(DecoderClient &client, InputStream &is,
}
}
#endif
/**
* Decode an #AVPacket and send the resulting PCM data to the decoder
* API.
...
...
@@ -357,7 +326,6 @@ ffmpeg_send_packet(DecoderClient &client, InputStream &is,
stream
.
time_base
));
}
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 37, 0)
bool
eof
=
false
;
int
err
=
avcodec_send_packet
(
&
codec_context
,
&
packet
);
...
...
@@ -386,30 +354,6 @@ ffmpeg_send_packet(DecoderClient &client, InputStream &is,
if
(
eof
)
cmd
=
DecoderCommand
::
STOP
;
#else
DecoderCommand
cmd
=
DecoderCommand
::
NONE
;
while
(
packet
.
size
>
0
&&
cmd
==
DecoderCommand
::
NONE
)
{
int
got_frame
=
0
;
int
len
=
avcodec_decode_audio4
(
&
codec_context
,
&
frame
,
&
got_frame
,
&
packet
);
if
(
len
<
0
)
{
/* if error, we skip the frame */
LogFfmpegError
(
len
,
"decoding failed, frame skipped"
);
break
;
}
packet
.
data
+=
len
;
packet
.
size
-=
len
;
if
(
!
got_frame
||
frame
.
nb_samples
<=
0
)
continue
;
cmd
=
FfmpegSendFrame
(
client
,
is
,
codec_context
,
frame
,
skip_bytes
,
buffer
);
}
#endif
return
cmd
;
}
...
...
@@ -585,11 +529,7 @@ FfmpegDecode(DecoderClient &client, InputStream &input,
AVStream
&
av_stream
=
*
format_context
.
streams
[
audio_stream
];
#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(57, 5, 0)
AVCodecContext
*
codec_context
=
av_stream
.
codec
;
#endif
const
auto
&
codec_params
=
GetCodecParameters
(
av_stream
);
const
auto
&
codec_params
=
*
av_stream
.
codecpar
;
const
AVCodecDescriptor
*
codec_descriptor
=
avcodec_descriptor_get
(
codec_params
.
codec_id
);
...
...
@@ -604,7 +544,6 @@ FfmpegDecode(DecoderClient &client, InputStream &input,
return
;
}
#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(57, 5, 0)
AVCodecContext
*
codec_context
=
avcodec_alloc_context3
(
codec
);
if
(
codec_context
==
nullptr
)
{
LogError
(
ffmpeg_domain
,
"avcodec_alloc_context3() failed"
);
...
...
@@ -615,10 +554,7 @@ FfmpegDecode(DecoderClient &client, InputStream &input,
avcodec_free_context
(
&
codec_context
);
};
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 25, 0)
/* FFmpeg 3.1 */
avcodec_parameters_to_context
(
codec_context
,
av_stream
.
codecpar
);
#endif
#endif
const
SampleFormat
sample_format
=
ffmpeg_sample_format
(
GetSampleFormat
(
codec_params
));
...
...
@@ -642,12 +578,6 @@ FfmpegDecode(DecoderClient &client, InputStream &input,
return
;
}
#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(57, 5, 0)
AtScopeExit
(
codec_context
)
{
avcodec_close
(
codec_context
);
};
#endif
const
SignedSongTime
total_time
=
av_stream
.
duration
!=
(
int64_t
)
AV_NOPTS_VALUE
?
FromFfmpegTimeChecked
(
av_stream
.
duration
,
av_stream
.
time_base
)
...
...
@@ -711,11 +641,7 @@ FfmpegDecode(DecoderClient &client, InputStream &input,
}
else
cmd
=
client
.
GetCommand
();
#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(56, 25, 100)
av_packet_unref
(
&
packet
);
#else
av_free_packet
(
&
packet
);
#endif
}
}
...
...
@@ -769,7 +695,7 @@ FfmpegScanStream(AVFormatContext &format_context,
handler
.
OnDuration
(
FromFfmpegTime
(
format_context
.
duration
,
AV_TIME_BASE_Q
));
const
auto
&
codec_params
=
GetCodecParameters
(
stream
)
;
const
auto
&
codec_params
=
*
stream
.
codecpar
;
try
{
handler
.
OnAudioFormat
(
CheckAudioFormat
(
codec_params
.
sample_rate
,
ffmpeg_sample_format
(
GetSampleFormat
(
codec_params
)),
...
...
src/lib/ffmpeg/meson.build
View file @
08272cde
libavformat_dep = dependency('libavformat', version: '>= 5
6.1
', required: get_option('ffmpeg'))
libavcodec_dep = dependency('libavcodec', version: '>= 5
6.1
', required: get_option('ffmpeg'))
libavutil_dep = dependency('libavutil', version: '>= 5
4.3
', required: get_option('ffmpeg'))
libavformat_dep = dependency('libavformat', version: '>= 5
7.40
', required: get_option('ffmpeg'))
libavcodec_dep = dependency('libavcodec', version: '>= 5
7.48
', required: get_option('ffmpeg'))
libavutil_dep = dependency('libavutil', version: '>= 5
5.27
', required: get_option('ffmpeg'))
enable_ffmpeg = libavformat_dep.found() and libavcodec_dep.found() and libavutil_dep.found()
conf.set('ENABLE_FFMPEG', enable_ffmpeg)
...
...
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