summaryrefslogtreecommitdiff
path: root/rotord/libavwrapper.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'rotord/libavwrapper.cpp')
-rwxr-xr-xrotord/libavwrapper.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/rotord/libavwrapper.cpp b/rotord/libavwrapper.cpp
index d5ee9cf..43c20f4 100755
--- a/rotord/libavwrapper.cpp
+++ b/rotord/libavwrapper.cpp
@@ -222,9 +222,9 @@ bool libav::decoder::openUsingInitializedContainer(enum PixelFormat formatParam)
//numFrames = (int)(( container->duration / (double)AV_TIME_BASE ) * pCtx->time_base.den + 0.5);
//this approach just seems wrong!
-
- numFrames=container->streams[videoStream]->nb_frames-2;
+
+ numFrames=container->streams[videoStream]->nb_frames-1;
if (numFrames<1){
//some codecs don't keep this info in the header
@@ -234,7 +234,7 @@ bool libav::decoder::openUsingInitializedContainer(enum PixelFormat formatParam)
//could alternatively just redefine the length if the reader fails
}
-
+
init_buffers_and_scaler();
@@ -321,15 +321,15 @@ bool libav::decoder::fetchFrame(int targetFrameIndex)
if ((targetFrameIndex < 0) || (targetFrameIndex > numFrames))
return false;
if (targetFrameIndex == (previousFrameIndex + 1)) {
- if (! readNextFrame(targetFrameIndex))
+ if (! readNextFrame(targetFrameIndex+1)) //frame indexing starts at 1
return false;
}
else {
- int64_t response=seekToFrame(targetFrameIndex);
+ int64_t response=seekToFrame(targetFrameIndex+1); //frame indexing starts at 1
if (response < 0)
return false;
- if (response!=targetFrameIndex){
- cerr<<"libav::decoder asked for "<<targetFrameIndex<<", got "<<response<<endl; //does not seem to be aware of wrong frame
+ if (response!=targetFrameIndex+1) {
+ cerr<<"libav::decoder asked for "<<targetFrameIndex<<", got "<<(response-1)<<endl; //does not seem to be aware of wrong frame
}
}
previousFrameIndex = targetFrameIndex;
@@ -410,7 +410,7 @@ bool libav::decoder::readNextFrameWithPacket(int targetFrameIndex, AVPacket& pac
//throw std::runtime_error("");
//why does it want to throw an error here, isn't the frame succesfully decoded?
//
- //when we allow these packets through we get
+ //when we allow these packets through we get
//[swscaler @ 0x9ef0c80] bad src image pointers
//trying to ignore timestamp below
if (packet.size == 0) // packet.size==0 usually means EOF