cosmetics and cleanup of unused code in video_provider_lavc.cpp
Originally committed to SVN as r2255.
This commit is contained in:
parent
904873f0d9
commit
a836b89476
|
@ -331,18 +331,8 @@ const AegiVideoFrame LAVCVideoProvider::GetFrame(int n,int formatType) {
|
||||||
if (frameNumber < 0)
|
if (frameNumber < 0)
|
||||||
frameNumber = 0;
|
frameNumber = 0;
|
||||||
|
|
||||||
// Following frame, just get it
|
// Find closest keyframe to the frame we want
|
||||||
/* if (n == frameNumber+1) {
|
int closestKeyFrame = FindClosestKeyframe(n);
|
||||||
int64_t temp = -1;
|
|
||||||
GetNextFrame(&temp);
|
|
||||||
} */
|
|
||||||
|
|
||||||
// Needs to seek
|
|
||||||
// else {
|
|
||||||
// Prepare seek
|
|
||||||
// int64_t seekTo;
|
|
||||||
// int result = 0;
|
|
||||||
int closestKeyFrame = FindClosestKeyframe(n);
|
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
// Get time to seek to
|
// Get time to seek to
|
||||||
|
@ -380,58 +370,42 @@ const AegiVideoFrame LAVCVideoProvider::GetFrame(int n,int formatType) {
|
||||||
// Constant frame rate
|
// Constant frame rate
|
||||||
else {
|
else {
|
||||||
#endif
|
#endif
|
||||||
// seekTo = closestKeyFrame;
|
bool hasSeeked = false;
|
||||||
bool hasSeeked = false;
|
|
||||||
|
|
||||||
// do we really need to seek?
|
// do we really need to seek?
|
||||||
// 10 frames is used as a margin to prevent excessive seeking since the predicted best keyframe isn't always selected by avformat
|
// 10 frames is used as a margin to prevent excessive seeking since the predicted best keyframe isn't always selected by avformat
|
||||||
if (n < frameNumber || closestKeyFrame > frameNumber+10) {
|
if (n < frameNumber || closestKeyFrame > frameNumber+10) {
|
||||||
// do it
|
// turns out we did need it, just do it
|
||||||
av_seek_frame(lavcfile->fctx, vidStream, framesData[closestKeyFrame].DTS, AVSEEK_FLAG_BACKWARD);
|
av_seek_frame(lavcfile->fctx, vidStream, framesData[closestKeyFrame].DTS, AVSEEK_FLAG_BACKWARD);
|
||||||
avcodec_flush_buffers(codecContext);
|
avcodec_flush_buffers(codecContext);
|
||||||
hasSeeked = true;
|
hasSeeked = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// regardless of whether we sekeed or not, decode frames until we have the one we want
|
||||||
|
do {
|
||||||
|
int64_t startTime;
|
||||||
|
GetNextFrame(&startTime);
|
||||||
|
|
||||||
|
if (hasSeeked) {
|
||||||
|
hasSeeked = false;
|
||||||
|
|
||||||
|
// is the seek destination known? does it belong to a frame?
|
||||||
|
if (startTime < 0 || (frameNumber = FrameFromDTS(startTime)) < 0) {
|
||||||
|
// guessing destination, may be unsafe
|
||||||
|
if (allowUnsafeSeeking)
|
||||||
|
frameNumber = ClosestFrameFromDTS(startTime);
|
||||||
|
else
|
||||||
|
throw _T("ffmpeg video provider: frame accurate seeking failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
// decode frames until we have the one we want
|
}
|
||||||
do {
|
|
||||||
int64_t startTime;
|
|
||||||
GetNextFrame(&startTime);
|
|
||||||
|
|
||||||
if (hasSeeked) {
|
frameNumber++;
|
||||||
hasSeeked = false;
|
} while (frameNumber <= n);
|
||||||
|
|
||||||
// is the seek destination known? does it belong to a frame?
|
|
||||||
if (startTime < 0 || (frameNumber = FrameFromDTS(startTime)) < 0) {
|
|
||||||
if (allowUnsafeSeeking)
|
|
||||||
frameNumber = ClosestFrameFromDTS(startTime);
|
|
||||||
else
|
|
||||||
throw _T("ffmpeg video provider: frame accurate seeking failed");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
frameNumber++;
|
|
||||||
} while (frameNumber <= n);
|
|
||||||
|
|
||||||
// Seek to keyframe
|
|
||||||
/* if (result == 0) {
|
|
||||||
avcodec_flush_buffers(codecContext);
|
|
||||||
|
|
||||||
// Seek until final frame
|
|
||||||
bool ok = true;
|
|
||||||
do {
|
|
||||||
ok = GetNextFrame();
|
|
||||||
} while (lastDecodeTime <= n && ok);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Failed seeking
|
|
||||||
else {
|
|
||||||
GetNextFrame();
|
|
||||||
}*/
|
|
||||||
#if 0
|
#if 0
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
//}
|
|
||||||
|
|
||||||
|
|
||||||
// Get aegisub frame
|
// Get aegisub frame
|
||||||
|
|
Loading…
Reference in a new issue