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

bool Impala::Core::Stream::Lavc::VideoAccessStrategy::PacketTraceMatchesFrame ( const PacketTrace trace,
int  frameNr 
) const [inline, private]

Checks the packet table to see whether the specified trace matches the packet context for the specified frame.

The matching algorithm used (empirically established) :

Matching is based on packet size, packet flags, file pointer position after reading the packet, and the packet's source stream. If the specified trace contains more than one video stream packet, the first one is not required to match on either size or flags. The same goes for the first but not only non-video packet. File positions need not match exactly, but they may not exceed the next first key frame's post-read file position.

Definition at line 742 of file VideoAccessStrategy.h.

References Impala::Core::Table::TableTem< Col1T, Col2T, Col3T, Col4T, Col5T, Col6T, Col7T, Col8T, Col9T >::Get1(), Impala::Core::Table::TableTem< Col1T, Col2T, Col3T, Col4T, Col5T, Col6T, Col7T, Col8T, Col9T >::Get2(), Impala::Core::Table::TableTem< Col1T, Col2T, Col3T, Col4T, Col5T, Col6T, Col7T, Col8T, Col9T >::Get3(), Impala::Core::Table::TableTem< Col1T, Col2T, Col3T, Col4T, Col5T, Col6T, Col7T, Col8T, Col9T >::Get4(), ILOG_DEBUG, mFrames, mPackets, and Impala::Core::Table::Table::Size().

Referenced by CurrentFrameMatchesFrame().

00743     {
00744         const int nrOfFrames = mFrames->Size();
00745         if (frameNr < 0 || frameNr >= nrOfFrames)
00746             return false;
00747 
00748         //if (!FrameIsKey(frameNr))
00749         //    return false;
00750 
00751         const int traceLen = trace.Size();
00752 
00753         int nrOfVideoPackets = 0;
00754         for (int t = 0; t < traceLen; t++)
00755             if (trace.Get4(t))
00756                 nrOfVideoPackets++;
00757         int nrOfNonVideoPackets = traceLen - nrOfVideoPackets;
00758 
00759         int packetIdx = mFrames->Get2(frameNr);
00760         for (int t = traceLen - 1; t >= 0; t--)
00761         {
00762             if (packetIdx < 0)
00763                 return false;
00764 
00765             const int sizeFromPackets = mPackets->Get2(packetIdx);
00766             const int sizeFromTrace = trace.Get1(t);
00767             const int flagsFromPackets = mPackets->Get3(packetIdx);
00768             const int flagsFromTrace = trace.Get2(t);
00769             bool sizeAndFlagsMatch = 
00770                 (sizeFromPackets == sizeFromTrace &&
00771                 flagsFromPackets == flagsFromTrace);
00772 
00773             if (trace.Get4(t)) // from video stream?
00774             {
00775                 if (--nrOfVideoPackets <= 0)
00776                     sizeAndFlagsMatch = true;
00777             }
00778             else
00779                 if (--nrOfNonVideoPackets <= 0)
00780                     sizeAndFlagsMatch = true;
00781 
00782             if (!sizeAndFlagsMatch)
00783             {
00784                 ILOG_DEBUG("Size and/or flags don't match at trace pos " << t << 
00785                     " of " << traceLen << " : " << sizeFromPackets <<
00786                     " vs. " << sizeFromTrace << " ; " << flagsFromPackets <<
00787                     " vs. " << flagsFromTrace);
00788                 return false;
00789             }
00790 
00791             packetIdx--;
00792 
00793             // SK: trace matching appears not to be trivial; use only last trace entry 
00794             break; 
00795         }
00796 
00797         // test match for post-read file position 
00798         packetIdx = mFrames->Get2(frameNr);
00799         const UInt64 postReadPosOfFrame = mPackets->Get4(packetIdx);
00800         const UInt64 lastPosOfTrace = trace.Get3(traceLen - 1);
00801         if (lastPosOfTrace > postReadPosOfFrame)
00802         {
00803             // locate next key frame
00804             int nextKeyFrame = frameNr + 1;
00805             for ( ; nextKeyFrame < nrOfFrames; nextKeyFrame++)
00806                 if (mFrames->Get4(nextKeyFrame)) // is key frame?
00807                     break; 
00808             if (nextKeyFrame >= nrOfFrames) 
00809                 return true; // assume a match if no more key frames
00810 
00811             // check current (post-read) file position against 
00812             // post-read-position of next key frame
00813             packetIdx = mFrames->Get2(nextKeyFrame);
00814             const UInt64 nextKeyFramesFilePos = mPackets->Get4(packetIdx);
00815             if (lastPosOfTrace > nextKeyFramesFilePos)
00816                 return false;
00817         }
00818 
00819         return true;
00820     }

Here is the call graph for this function:


Generated on Thu Jan 13 09:20:40 2011 for ImpalaSrc by  doxygen 1.5.1