Skip to content

Commit 18dcdc4

Browse files
author
Clement Champetier
committed
FilterGraph: updated process method to specify input/output
The buffer could be different.
1 parent 7f979d6 commit 18dcdc4

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

src/AvTranscoder/filter/FilterGraph.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ FilterGraph::~FilterGraph()
3535
avfilter_graph_free(&_graph);
3636
}
3737

38-
void FilterGraph::process(Frame& frame)
38+
void FilterGraph::process(const Frame& inputFrame, Frame& outputFrame)
3939
{
4040
if(!hasFilters())
4141
{
@@ -45,10 +45,10 @@ void FilterGraph::process(Frame& frame)
4545

4646
// init filter graph
4747
if(!_isInit)
48-
init(frame);
48+
init(inputFrame, outputFrame);
4949

5050
// setup source frame
51-
int ret = av_buffersrc_write_frame(_filters.at(0)->getAVFilterContext(), &frame.getAVFrame());
51+
int ret = av_buffersrc_write_frame(_filters.at(0)->getAVFilterContext(), &inputFrame.getAVFrame());
5252
if(ret < 0)
5353
{
5454
throw std::runtime_error("Error when adding a frame to the source buffer used to start to process filters: " +
@@ -58,7 +58,7 @@ void FilterGraph::process(Frame& frame)
5858
// pull filtered data from the filter graph
5959
for(;;)
6060
{
61-
ret = av_buffersink_get_frame(_filters.at(_filters.size() - 1)->getAVFilterContext(), &frame.getAVFrame());
61+
ret = av_buffersink_get_frame(_filters.at(_filters.size() - 1)->getAVFilterContext(), &outputFrame.getAVFrame());
6262
if(ret == AVERROR_EOF || ret == AVERROR(EAGAIN))
6363
break;
6464
if(ret < 0)
@@ -77,15 +77,15 @@ Filter& FilterGraph::addFilter(const std::string& filterName, const std::string&
7777
return *_filters.back();
7878
}
7979

80-
void FilterGraph::init(const Frame& frame)
80+
void FilterGraph::init(const Frame& inputFrame, Frame& outputFrame)
8181
{
8282
// push filters to the graph
83-
pushInBuffer(frame);
83+
pushInBuffer(inputFrame);
8484
for(size_t i = 1; i < _filters.size(); ++i)
8585
{
8686
pushFilter(*_filters.at(i));
8787
}
88-
pushOutBuffer(frame);
88+
pushOutBuffer(outputFrame);
8989

9090
// connect filters
9191
for(size_t index = 0; index < _filters.size() - 1; ++index)

src/AvTranscoder/filter/FilterGraph.hpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,11 @@ class AvExport FilterGraph
4444

4545
/**
4646
* @brief Pull filtered data from the filter graph, and put result to the given frame.
47-
* @param frame: both input and output data of the method.
47+
* @param inputFrame: input data.
48+
* @param inputFrame: output data.
4849
* @note Do nothing if there was no filter added.
4950
*/
50-
void process(Frame& frame);
51+
void process(const Frame& inputFrame, Frame& outputFrame);
5152

5253
private:
5354
/**
@@ -61,7 +62,7 @@ class AvExport FilterGraph
6162
* @see pushInBuffer
6263
* @see pushOutBuffer
6364
*/
64-
void init(const Frame& frame);
65+
void init(const Frame& inputFrame, Frame& outputFrame);
6566

6667
/**
6768
* @brief Push the given Filter to the graph.

src/AvTranscoder/transcoder/StreamTranscoder.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ bool StreamTranscoder::processTranscode()
491491
if(decodingStatus)
492492
{
493493
LOG_DEBUG("Filtering")
494-
_filterGraph->process(*_sourceBuffers.at(0));
494+
_filterGraph->process(*_sourceBuffers.at(0), *_sourceBuffers.at(0));
495495

496496
LOG_DEBUG("Convert")
497497
_transform->convert(*_sourceBuffers.at(0), *_frameBuffers.at(0));

0 commit comments

Comments
 (0)