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
61120d20
Commit
61120d20
authored
Mar 24, 2019
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
filter/ffmpeg: use only one AVFrame
The two were never used at the same time, and merging them saves one allocation.
parent
cc182281
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
12 deletions
+12
-12
FfmpegFilter.cxx
src/filter/plugins/FfmpegFilter.cxx
+11
-11
FfmpegFilter.hxx
src/filter/plugins/FfmpegFilter.hxx
+1
-1
No files found.
src/filter/plugins/FfmpegFilter.cxx
View file @
61120d20
...
...
@@ -50,25 +50,25 @@ FfmpegFilter::FilterPCM(ConstBuffer<void> src)
{
/* submit source data into the FFmpeg audio buffer source */
in_
frame
.
Unref
();
in_
frame
->
format
=
in_format
;
in_
frame
->
sample_rate
=
in_sample_rate
;
in_
frame
->
channels
=
in_channels
;
in_
frame
->
nb_samples
=
src
.
size
/
in_audio_frame_size
;
frame
.
Unref
();
frame
->
format
=
in_format
;
frame
->
sample_rate
=
in_sample_rate
;
frame
->
channels
=
in_channels
;
frame
->
nb_samples
=
src
.
size
/
in_audio_frame_size
;
in_
frame
.
GetBuffer
();
frame
.
GetBuffer
();
memcpy
(
in_
frame
.
GetData
(
0
),
src
.
data
,
src
.
size
);
memcpy
(
frame
.
GetData
(
0
),
src
.
data
,
src
.
size
);
int
err
=
av_buffersrc_add_frame
(
buffer_src
.
get
(),
in_
frame
.
get
());
int
err
=
av_buffersrc_add_frame
(
buffer_src
.
get
(),
frame
.
get
());
if
(
err
<
0
)
throw
MakeFfmpegError
(
err
,
"av_buffersrc_write_frame() failed"
);
/* collect filtered data from the FFmpeg audio buffer sink */
out_
frame
.
Unref
();
frame
.
Unref
();
err
=
av_buffersink_get_frame
(
buffer_sink
.
get
(),
out_
frame
.
get
());
err
=
av_buffersink_get_frame
(
buffer_sink
.
get
(),
frame
.
get
());
if
(
err
<
0
)
{
if
(
err
==
AVERROR
(
EAGAIN
)
||
err
==
AVERROR_EOF
)
return
nullptr
;
...
...
@@ -79,5 +79,5 @@ FfmpegFilter::FilterPCM(ConstBuffer<void> src)
/* TODO: call av_buffersink_get_frame() repeatedly? Not
possible with MPD's current Filter API */
return
{
out_frame
.
GetData
(
0
),
out_
frame
->
nb_samples
*
GetOutAudioFormat
().
GetFrameSize
()};
return
{
frame
.
GetData
(
0
),
frame
->
nb_samples
*
GetOutAudioFormat
().
GetFrameSize
()};
}
src/filter/plugins/FfmpegFilter.hxx
View file @
61120d20
...
...
@@ -30,7 +30,7 @@
class
FfmpegFilter
final
:
public
Filter
{
Ffmpeg
::
FilterGraph
graph
;
Ffmpeg
::
FilterContext
buffer_src
,
buffer_sink
;
Ffmpeg
::
Frame
in_frame
,
out_
frame
;
Ffmpeg
::
Frame
frame
;
const
int
in_format
,
in_sample_rate
,
in_channels
;
...
...
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