Definition at line 952 of file RgbDataSrcLavc_old.h. References ILOG_DEBUG, ILOG_ERROR, and ILOG_INFO. 00953 { 00954 ILOG_INFO("Timestamp Based Indexing for AVI started!"); 00955 00956 if (mBlankFrames > 0) 00957 { 00958 // for AVI lavc is not expected to actually try to read invalid frames 00959 ILOG_ERROR("Did not expect blank frames to have been registered here"); 00960 return; 00961 } 00962 00963 const AVIndexEntry * const idx = mVideoStream->index_entries; 00964 if (!idx) 00965 { 00966 ILOG_ERROR("Stream contains no index"); 00967 mFrameCnt = 0; 00968 mLastFrame = -1; 00969 return; 00970 } 00971 00972 mFrameCnt = mVideoStream->nb_index_entries; 00973 mLastFrame = mFrameCnt - 1; 00974 ILOG_INFO("FrameCount from Index: " << mFrameCnt); 00975 00976 for (int e = 0; e <= 20; e++) 00977 ILOG_DEBUG("index entry " << e << ": size=" << idx[e].size << ", flags=" << idx[e].flags << ", timestamp=" << idx[e].timestamp << ", pos=" << idx[e].pos << ", min_distance=" << idx[e].min_distance << ")"); 00978 00979 // add dummy index entries for all leading bad frames; 00980 // note that the currently cached frame is the first valid key-frame, 00981 // and that leading bad frames may already have been marked as such; 00982 int indexPos = 0; 00983 while (indexPos < mFrameCnt && 00984 (idx[indexPos].size <= 0 || // assumed to indicate frame validity 00985 idx[indexPos].flags != AVINDEX_KEYFRAME)) 00986 { 00987 MarkBadFrame(indexPos); 00988 AddIndex(indexPos, -1, -1, DUMMY_FRAME_HASH); 00989 ILOG_DEBUG(indexPos << " -1 -1 " << DUMMY_FRAME_HASH << " (idx[indexPos].size=" << idx[indexPos].size << ", idx[indexPos].flags=" << idx[indexPos].flags << ", idx[indexPos].timestamp=" << idx[indexPos].timestamp << ")"); 00990 indexPos++; 00991 } 00992 00993 if (indexPos > 0) 00994 { 00995 mBlankFrames = mBufferedFrameNr = mCurrentFrameNr = indexPos; 00996 ILOG_INFO("Stream starts with " << mBlankFrames << " bad frame(s)"); 00997 } 00998 00999 // reset in order to make jumping back to the head of file reproducable also for mpeg4 files; 01000 // (without using the index) 01001 const int posZero = 0; 01002 const int flush = 2; 01003 const int no_sync = 1; 01004 const int sync = 2; 01005 Jump(posZero, mJumpFlags, flush, no_sync); 01006 Jump(mBlankFrames, mJumpFlags, flush, sync); 01007 ILOG_DEBUG("Jumped to head of file"); 01008 01009 int lastKeyPos = -1; 01010 int64_t keyPts = -1; 01011 for (; indexPos < mFrameCnt; indexPos++) 01012 //for (; indexPos < 100; indexPos++) 01013 { 01014 if (idx[indexPos].size <= 0) 01015 { 01016 ILOG_INFO("Bad frame at index position: " << indexPos << " (idx[indexPos].size=" << idx[indexPos].size << ", idx[indexPos].flags=" << idx[indexPos].flags << ", idx[indexPos].timestamp=" << idx[indexPos].timestamp << ")"); 01017 AddIndex(indexPos, -1, -1, DUMMY_FRAME_HASH); 01018 ILOG_DEBUG(indexPos << " -1 -1 " << DUMMY_FRAME_HASH); 01019 MarkBadFrame(indexPos); 01020 mCurrentFrameNr++; 01021 mBufferedFrameNr++; 01022 continue; 01023 } 01024 01025 if (indexPos > mBlankFrames) // the first valid (key-) frame is currently in the frame cache 01026 NextFrame(); 01027 01028 String frameHash; 01029 if (FrameValid(mCurrentFrameNr)) 01030 { 01031 if (idx[indexPos].flags == AVINDEX_KEYFRAME ) 01032 { 01033 lastKeyPos = indexPos; 01034 keyPts = idx[lastKeyPos].timestamp; 01035 } 01036 frameHash = CalcHash(); 01037 } 01038 else 01039 frameHash = DUMMY_FRAME_HASH; 01040 01041 AddIndex(indexPos, lastKeyPos, keyPts, frameHash); 01042 ILOG_DEBUG(indexPos << " " << lastKeyPos 01043 << " " << keyPts << " " << frameHash); 01044 } 01045 01046 mIndexExists = true; 01047 }
|