Implements Impala::Core::Stream::Lavc::VideoAccessStrategy. Definition at line 59 of file StrategyUsingNativeIndex.h. References Impala::Core::Stream::Lavc::VideoAccessStrategy::DecodeNextValidFrame(), FrameIsBadInNativeIndex(), Impala::Core::Stream::Lavc::VideoAccessObject::FrameIsKey(), GetJumpFlags(), 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(). 00060 { 00061 const AVIndexEntry* const nativeIndex = mVao->NativeIndexEntries(); 00062 const int nativeIndexSize = mVao->NativeIndexSize(); 00063 ILOG_INFO("Native index has size " << nativeIndexSize); 00064 00065 00067 //int offset = 0; 00068 //for (int e = offset; e <= offset + 10 && e <= nativeIndexSize; e++) 00069 // ILOG_DEBUG("index entry " << e << ": size=" << 00070 // nativeIndex[e].size << ", flags=" << nativeIndex[e].flags << 00071 // ", timestamp=" << nativeIndex[e].timestamp << ", pos=" << 00072 // nativeIndex[e].pos << ", min_distance=" << 00073 // nativeIndex[e].min_distance << ")"); 00074 00075 00076 int nrOfBadFrames = 0; 00077 int nrOfLeadingBadFrames = 0; 00078 for (int indexPos = 0; indexPos < nativeIndexSize; indexPos++) 00079 //int debugMax = 50; 00080 //for (int indexPos = 0; indexPos < debugMax; indexPos++) 00081 //for (int indexPos = nativeIndexSize - 1; indexPos >= 0; indexPos--) 00082 { 00083 if (indexPos % 250 == 0) 00084 ILOG_DEBUG("Scanning using native index entry " << indexPos); 00085 00086 const int indexFlags = nativeIndex[indexPos].flags; 00087 const bool isKeyFrameAccToIndex = (indexFlags == AVINDEX_KEYFRAME); 00088 00089 bool isValidFrame = !FrameIsBadInNativeIndex(indexPos); 00090 //if (isValidFrame) 00091 //{ 00092 // // don't attempt reading the frame since the codec ignores it 00093 // ProcessFrame(false, false, indexPos); 00094 // nrOfBadFrames++; 00095 // if (indexPos < nrOfBadFrames) 00096 // nrOfLeadingBadFrames++; 00097 // continue; 00098 //} 00099 00100 if (isValidFrame && isKeyFrameAccToIndex) 00101 { 00102 const UInt64& pts = nativeIndex[indexPos].timestamp; 00103 if (!mVao->Seek(pts, GetJumpFlags())) 00104 { 00105 ILOG_ERROR("Failed on PTS based seek for frame " << 00106 indexPos << "; native index flags: " << indexFlags << ")"); 00107 return false; 00108 } 00109 } 00110 00111 if (isValidFrame && !DecodeNextValidFrame(isKeyFrameAccToIndex, 0)) 00112 { 00113 //ILOG_ERROR("Failed to read valid frame " << indexPos); 00114 ILOG_WARN("Failed to read valid frame according to native index: " << 00115 indexPos); 00116 isValidFrame = false; 00117 //return false; 00118 } 00119 00120 bool treatAsKeyFrame = isKeyFrameAccToIndex; 00121 00122 if (isValidFrame) 00123 { 00124 if (isKeyFrameAccToIndex && !mVao->FrameIsKey()) 00125 { 00126 ILOG_WARN("Key frame " << indexPos << 00127 " according to native index, appears not to be " << 00128 "a key frame upon decoding"); 00129 //return false; 00130 treatAsKeyFrame = false; 00131 } 00132 else if (!isKeyFrameAccToIndex && mVao->FrameIsKey()) 00133 { 00134 ILOG_WARN("Non-key frame " << indexPos << 00135 " according to native index, appears to be " << 00136 "a key frame upon decoding"); 00137 //return false; 00138 treatAsKeyFrame = false; 00139 } 00140 } 00141 else 00142 { 00143 nrOfBadFrames++; 00144 if (indexPos < nrOfBadFrames) 00145 nrOfLeadingBadFrames++; 00146 } 00147 00148 ProcessFrame(isValidFrame, treatAsKeyFrame, indexPos); 00149 } 00150 00151 ILOG_DEBUG("Bad frames according to native index: " << 00152 nrOfBadFrames << " (of which are " << 00153 "leading: " << nrOfLeadingBadFrames << ")"); 00154 mBadFrameCount = nrOfBadFrames; 00155 mLeadingBadFrameCount = nrOfLeadingBadFrames; 00156 return true; 00157 }
Here is the call graph for this function:
|