Skip to content

Commit 571ec23

Browse files
author
Clement Champetier
committed
IReader: readFrameAt returns NULL if there is no next frame
1 parent b37684b commit 571ec23

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

src/AvTranscoder/reader/IReader.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,10 @@ Frame* IReader::readFrameAt(const size_t frame)
8181
{
8282
_generator->decodeNextFrame(*_srcFrame);
8383
}
84-
// or return an empty frame
84+
// or return NULL
8585
else
8686
{
87-
_dstFrame->clear();
88-
return _dstFrame;
87+
return NULL;
8988
}
9089
}
9190
// transform

src/AvTranscoder/reader/IReader.hpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,20 @@ class AvExport IReader
3535

3636
/**
3737
* @return Get next frame after decoding
38+
* @see readFrameAt
3839
*/
3940
Frame* readNextFrame();
4041

4142
/**
4243
* @return Get previous frame after decoding
44+
* @see readFrameAt
4345
*/
4446
Frame* readPrevFrame();
4547

4648
/**
4749
* @return Get indicated frame after decoding
50+
* @warn Returns NULL if there is no more frame to read.
51+
* @see continueWithGenerator
4852
*/
4953
Frame* readFrameAt(const size_t frame);
5054

test/pyTest/testReader.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ def testVideoReaderCreateNewInputFile():
2727
bytesPerPixel = reader.getOutputBitDepth() / 8
2828
assert_equals( frame.getSize(), reader.getOutputWidth() * reader.getOutputHeight() * bytesPerPixel )
2929

30-
# check if the next frame is empty
31-
frame = av.VideoFrame(reader.readNextFrame())
32-
assert_equals( frame.getSize(), 0 )
30+
# check if there is no next frame
31+
frame = reader.readNextFrame()
32+
assert_equals( reader.readNextFrame(), None )
3333

3434

3535
def testVideoReaderReferenceInputFile():
@@ -47,9 +47,8 @@ def testVideoReaderReferenceInputFile():
4747
bytesPerPixel = reader.getOutputBitDepth() / 8
4848
assert_equals( frame.getSize(), reader.getOutputWidth() * reader.getOutputHeight() * bytesPerPixel )
4949

50-
# check if the next frame is empty
51-
frame = av.VideoFrame(reader.readNextFrame())
52-
assert_equals( frame.getSize(), 0 )
50+
# check if there is no next frame
51+
assert_equals( reader.readNextFrame(), None )
5352

5453

5554
def testAudioReaderChannelsExtraction():

0 commit comments

Comments
 (0)