Home || Architecture || Video Search || Visual Search || Scripts || Applications || Important Messages || OGL || Src

virtual bool Impala::Core::Stream::Lavc::StrategyUsingNativeIndex::ScanProtected (  )  [inline, protected, virtual]

Implements Impala::Core::Stream::Lavc::VideoAccessStrategy.

Definition at line 48 of file StrategyUsingNativeIndex.h.

References Impala::Core::Stream::Lavc::VideoAccessStrategy::DecodeNextValidFrame(), FrameIsBadInNativeIndex(), Impala::Core::Stream::Lavc::VideoAccessObject::FrameIsKey(), ILOG_DEBUG, ILOG_ERROR, ILOG_INFO, ILOG_WARN, Impala::Core::Stream::Lavc::VideoAccessStrategy::mBadFrameCount, Impala::Core::Stream::Lavc::VideoAccessStrategy::mLeadingBadFrameCount, Impala::Core::Stream::Lavc::VideoAccessStrategy::mVao, Impala::Core::Stream::Lavc::VideoAccessObject::NativeIndexEntries(), Impala::Core::Stream::Lavc::VideoAccessObject::NativeIndexSize(), Impala::Core::Stream::Lavc::VideoAccessStrategy::ProcessFrame(), and Impala::Core::Stream::Lavc::VideoAccessObject::Seek().

00049     {
00050         const AVIndexEntry* const nativeIndex = mVao->NativeIndexEntries();
00051         const int nativeIndexSize = mVao->NativeIndexSize();
00052         ILOG_INFO("Native index has size " << nativeIndexSize);
00053 
00054 
00055         // debug logging
00056         int offset = 0;
00057         for (int e = offset; e <= offset + 10 && e <= nativeIndexSize; e++)
00058             ILOG_DEBUG("index entry " << e << ": size=" << 
00059             nativeIndex[e].size << ", flags=" << nativeIndex[e].flags << 
00060             ", timestamp=" << nativeIndex[e].timestamp << ", pos=" << 
00061             nativeIndex[e].pos << ", min_distance=" << 
00062             nativeIndex[e].min_distance << ")"); 
00063 
00064 
00065         int nrOfBadFrames = 0;
00066         int nrOfLeadingBadFrames = 0;
00067         for (int indexPos = 0; indexPos < nativeIndexSize; indexPos++)
00068         //int debugMax = 320;
00069         //for (int indexPos = 0; indexPos < debugMax; indexPos++)
00070         //for (int indexPos = nativeIndexSize - 1; indexPos >= 0; indexPos--)
00071         {
00072             if (indexPos % 250 == 0)
00073                 ILOG_DEBUG("Scanning using native index entry " << indexPos);
00074 
00075             const int indexFlags = nativeIndex[indexPos].flags;
00076             const bool isKeyFrameAccToIndex = (indexFlags == AVINDEX_KEYFRAME);
00077 
00078             if (FrameIsBadInNativeIndex(indexPos))
00079             {
00080                 // don't attempt reading the frame since it cannot be 'seen'
00081                 ProcessFrame(false, false, indexPos);
00082                 nrOfBadFrames++;
00083                 if (indexPos < nrOfBadFrames)
00084                     nrOfLeadingBadFrames++;
00085                 continue;
00086             }
00087 
00088             if (isKeyFrameAccToIndex)
00089             {
00090                 const UInt64& pts = nativeIndex[indexPos].timestamp;
00091                 if (!mVao->Seek(pts, AVSEEK_FLAG_ANY))
00092                 {
00093                     ILOG_ERROR("Failed on PTS based seek for frame " << 
00094                         indexPos << "; native index flags: " << indexFlags << ")");
00095                     return false;
00096                 }
00097             }
00098 
00099             //bool isValidFrame = false; // value not used
00100             //bool isKeyFrame = false;  // value not used
00101             bool isValidFrame = true;
00102             bool isKeyFrame = isKeyFrameAccToIndex;
00103             //const int result = mVao->DecodeNextFrame(&isValidFrame, &isKeyFrame);
00104             //if (result < 0)
00105             //{
00106             //    ILOG_DEBUG("Frame " << indexPos << " is invalid");
00107             //    EvalFrame(false, false);
00108             //    continue;
00109             //}
00110             if (!DecodeNextValidFrame(isKeyFrameAccToIndex, 0))
00111             {
00112                 ILOG_ERROR("Failed to read valid frame " << indexPos);
00113                 return false;
00114             }
00115             if (!isKeyFrameAccToIndex && mVao->FrameIsKey())
00116             {
00117                 ILOG_WARN("Frame read is a key frame but not expected to be: " <<
00118                     indexPos);
00119                 //return false;
00120             }
00121 
00122             if (isValidFrame)
00123             {
00124                 if (isKeyFrameAccToIndex && !isKeyFrame)
00125                 {
00126                     ILOG_ERROR("Key frame " << indexPos << 
00127                         " according to native index, appears not to be " << 
00128                         "a key frame upon decoding");
00129                     return false;
00130                 }
00131 
00132                 if (!isKeyFrameAccToIndex && isKeyFrame)
00133                 {
00134                     ILOG_ERROR("Non-key frame " << indexPos << 
00135                         " according to native index, appears to be " << 
00136                         "a key frame upon decoding");
00137                     return false;
00138                 }
00139             }
00140 
00141             ProcessFrame(isValidFrame, isKeyFrame, indexPos);
00142         }
00143 
00144         ILOG_DEBUG("Bad frames according to native index: " << 
00145             nrOfBadFrames << " (of which are " <<
00146             "leading: " << nrOfLeadingBadFrames << ")");
00147         mBadFrameCount = nrOfBadFrames;
00148         mLeadingBadFrameCount = nrOfLeadingBadFrames;
00149         return true;
00150     }

Here is the call graph for this function:


Generated on Fri Mar 19 11:18:16 2010 for ImpalaSrc by  doxygen 1.5.1