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
e88667e0
Commit
e88667e0
authored
Mar 18, 2019
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lib/ffmpeg/Filter: add MakeAudioBuffer{Source,Sink}()
parent
fb96907b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
97 additions
and
0 deletions
+97
-0
Filter.cxx
src/lib/ffmpeg/Filter.cxx
+75
-0
Filter.hxx
src/lib/ffmpeg/Filter.hxx
+16
-0
meson.build
src/lib/ffmpeg/meson.build
+6
-0
No files found.
src/lib/ffmpeg/Filter.cxx
0 → 100644
View file @
e88667e0
/*
* 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 "Filter.hxx"
#include "SampleFormat.hxx"
#include "AudioFormat.hxx"
#include "util/RuntimeError.hxx"
#include <stdio.h>
namespace
Ffmpeg
{
static
const
auto
&
RequireFilterByName
(
const
char
*
name
)
{
const
auto
*
filter
=
avfilter_get_by_name
(
name
);
if
(
filter
==
nullptr
)
throw
FormatRuntimeError
(
"No such FFmpeg filter: '%s'"
,
name
);
return
*
filter
;
}
FilterContext
FilterContext
::
MakeAudioBufferSource
(
AudioFormat
&
audio_format
,
AVFilterGraph
&
graph_ctx
)
{
AVSampleFormat
src_format
=
ToFfmpegSampleFormat
(
audio_format
.
format
);
if
(
src_format
==
AV_SAMPLE_FMT_NONE
)
{
switch
(
audio_format
.
format
)
{
case
SampleFormat
:
:
S24_P32
:
audio_format
.
format
=
SampleFormat
::
S32
;
src_format
=
AV_SAMPLE_FMT_S32
;
break
;
default
:
audio_format
.
format
=
SampleFormat
::
S16
;
src_format
=
AV_SAMPLE_FMT_S16
;
break
;
}
}
char
abuffer_args
[
256
];
sprintf
(
abuffer_args
,
"sample_rate=%u:sample_fmt=%s:channels=%u:time_base=1/%u"
,
audio_format
.
sample_rate
,
av_get_sample_fmt_name
(
src_format
),
audio_format
.
channels
,
audio_format
.
sample_rate
);
return
{
RequireFilterByName
(
"abuffer"
),
"abuffer"
,
abuffer_args
,
nullptr
,
graph_ctx
};
}
FilterContext
FilterContext
::
MakeAudioBufferSink
(
AVFilterGraph
&
graph_ctx
)
{
return
{
RequireFilterByName
(
"abuffersink"
),
"abuffersink"
,
graph_ctx
};
}
}
// namespace Ffmpeg
src/lib/ffmpeg/Filter.hxx
View file @
e88667e0
...
...
@@ -28,6 +28,8 @@ extern "C" {
#include <utility>
struct
AudioFormat
;
namespace
Ffmpeg
{
class
FilterInOut
{
...
...
@@ -106,6 +108,20 @@ public:
return
*
this
;
}
/**
* Create an "abuffer" filter.
*
* @param the input audio format; may be modified by the
* function to ask the caller to do format conversion
*/
static
FilterContext
MakeAudioBufferSource
(
AudioFormat
&
audio_format
,
AVFilterGraph
&
graph_ctx
);
/**
* Create an "abuffersink" filter.
*/
static
FilterContext
MakeAudioBufferSink
(
AVFilterGraph
&
graph_ctx
);
auto
&
operator
*
()
noexcept
{
return
*
context
;
}
...
...
src/lib/ffmpeg/meson.build
View file @
e88667e0
...
...
@@ -17,6 +17,11 @@ if not enable_ffmpeg
subdir_done()
endif
ffmpeg_sources = []
if libavfilter_dep.found()
ffmpeg_sources += 'Filter.cxx'
endif
ffmpeg = static_library(
'ffmpeg',
'Init.cxx',
...
...
@@ -24,6 +29,7 @@ ffmpeg = static_library(
'LogCallback.cxx',
'Error.cxx',
'Domain.cxx',
ffmpeg_sources,
include_directories: inc,
dependencies: [
libavformat_dep,
...
...
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