Skip to content

Commit 27cf448

Browse files
author
Valentin NOEL
committed
FilterGraph: refactoring of getMinInputFrameSize() private method
Add a new getAvailableFrameSize() private method
1 parent 380f238 commit 27cf448

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

src/AvTranscoder/filter/FilterGraph.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,17 +132,25 @@ FilterGraph::~FilterGraph()
132132
avfilter_graph_free(&_graph);
133133
}
134134

135+
size_t FilterGraph::getAvailableFrameSize(const std::vector<IFrame*>& inputs, const size_t& index)
136+
{
137+
size_t frameSize = inputs.at(index)->getDataSize();
138+
if(frameSize == 0)
139+
frameSize = _inputFramesBuffer.at(index).getDataSize();
140+
return frameSize;
141+
}
142+
135143
size_t FilterGraph::getMinInputFrameSize(const std::vector<IFrame*>& inputs)
136144
{
137145
if(!inputs.size())
138146
return 0;
139147

140-
int minFrameSize = inputs.at(0)->getDataSize();
148+
size_t minFrameSize = getAvailableFrameSize(inputs, 0);
141149
for(size_t index = 1; index < inputs.size(); ++index)
142150
{
143-
// if the input frame is shorter, and if there is no data enough into the corresponding frame buffer
144-
if(minFrameSize > inputs.at(index)->getDataSize() && minFrameSize > _inputFramesBuffer.at(index).getDataSize())
145-
minFrameSize = inputs.at(index)->getDataSize();
151+
const size_t availableFrameSize = getAvailableFrameSize(inputs, index);
152+
if(minFrameSize > availableFrameSize)
153+
minFrameSize = availableFrameSize;
146154
}
147155
return minFrameSize;
148156
}

src/AvTranscoder/filter/FilterGraph.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,15 @@ class AvExport FilterGraph
127127
void addOutBuffer(const IFrame& output);
128128
//@}
129129

130+
/**
131+
* @brief Return the input frame size if not null, or the available size into the corresponding frame buffer
132+
*/
133+
size_t getAvailableFrameSize(const std::vector<IFrame*>& inputs, const size_t& index);
134+
/**
135+
* @brief Get the minimum size between input frames, or available frame buffers
136+
*/
130137
size_t getMinInputFrameSize(const std::vector<IFrame*>& inputs);
138+
131139
bool areInputFrameSizeEqual(const std::vector<IFrame*>& inputs);
132140
bool areFrameBuffersEmpty();
133141

0 commit comments

Comments
 (0)