00001 #ifndef Impala_Core_Trec_ThreadTime_h 00002 #define Impala_Core_Trec_ThreadTime_h 00003 00004 #include "Core/Trec/Thread.h" 00005 #include "Core/VideoSet/Segmentation.h" 00006 00007 namespace Impala 00008 { 00009 namespace Core 00010 { 00011 namespace Trec 00012 { 00013 00014 00015 class ThreadTime : public Thread 00016 { 00017 public: 00018 00019 ThreadTime(VideoSet::Segmentation* segmentation) : Thread("time") 00020 { 00021 mSegmentation = segmentation; 00022 mVid = -1; 00023 } 00024 00025 virtual void 00026 SetOrigin(int shot) 00027 { 00028 mVid = -1; 00029 if ((shot < 0) || (shot >= mSegmentation->GetNrShots())) 00030 return; 00031 mVid = mSegmentation->GetVideoId(shot); 00032 mFirst = mSegmentation->GetFirstShotVideo(mVid); 00033 mNrShots = mSegmentation->GetNrShotsVideo(mVid); 00034 } 00035 00036 virtual int 00037 GetShot(int position) 00038 { 00039 if (mVid == -1) 00040 return -1; 00041 if ((position < 0) || (position >= mNrShots)) 00042 return -1; 00043 return mFirst + position; 00044 } 00045 00046 virtual int 00047 GetLength() 00048 { 00049 if (mVid == -1) 00050 return -1; 00051 return mNrShots; 00052 } 00053 00054 virtual int 00055 GetShotAt(int shot, int offset) 00056 { 00057 // SetOrigin(shot); // is this what we want?? 00058 if (mVid == -1) 00059 return -1; 00060 int dst = shot + offset; 00061 if ((dst < mFirst) || (dst >= mFirst + mNrShots)) 00062 return -1; 00063 return dst; 00064 } 00065 00066 virtual int 00067 GetShotPosition(int shot) 00068 { 00069 if (mVid == -1) 00070 return -1; 00071 return shot - mFirst; 00072 } 00073 00074 virtual int 00075 GetType() 00076 { 00077 return TIME; 00078 } 00079 00080 private: 00081 00082 VideoSet::Segmentation* mSegmentation; 00083 int mVid; 00084 int mFirst; 00085 int mNrShots; 00086 00087 }; 00088 00089 } // namespace Trec 00090 } // namespace Core 00091 } // namespace Impala 00092 00093 #endif