00001 #ifndef Impala_Core_VideoSet_FrameHashes_h
00002 #define Impala_Core_VideoSet_FrameHashes_h
00003
00004 #include "Core/Table/TableTem.h"
00005 #include "Core/Column/FixedStringColumn.h"
00006
00007 namespace Impala
00008 {
00009 namespace Core
00010 {
00011 namespace VideoSet
00012 {
00013
00014
00015 typedef Table::TableTem< Column::ColumnTem<Int32>,
00016 Column::FixedStringColumn,
00017 Column::FixedStringColumn > FrameHashesBaseType;
00018
00019 class FrameHashes : public FrameHashesBaseType
00020 {
00021 public:
00022
00023 FrameHashes(int size) : FrameHashesBaseType(size)
00024 {
00025 }
00026
00027 FrameHashes(const Column::ColumnTem<Int32>& c1,
00028 const Column::FixedStringColumn& c2,
00029 const Column::FixedStringColumn& c3)
00030 : FrameHashesBaseType(c1, c2, c3)
00031 {
00032 }
00033
00034 int
00035 Diff(FrameHashes* arg) const
00036 {
00037 int nDiffAll = 0;
00038 int framesToCompare = Size();
00039 if (Size() != arg->Size())
00040 {
00041 ILOG_ERROR("Frame count differs: " << Size() << " vs. " <<
00042 arg->Size());
00043 nDiffAll++;
00044 framesToCompare = Impala::Min(Size(), arg->Size());
00045 }
00046
00047 int nDiffPre = 0;
00048 int nDiffPost = 0;
00049 for (int i = 0 ; i < framesToCompare ; i++)
00050 {
00051 bool foundDiff = false;
00052 int frameNr = Get1(i);
00053 if (arg->Get1(i) != frameNr)
00054 {
00055
00056 ILOG_ERROR("Frame nr. different for entry " << i <<
00057 ": " << frameNr << " vs. " << arg->Get1(i));
00058 foundDiff = true;
00059 }
00060
00061 bool diffPre = !Get2(i).Equals(arg->Get2(i));
00062 bool diffPost = !Get3(i).Equals(arg->Get3(i));
00063 if (diffPre)
00064 {
00065 nDiffPre++;
00066 ILOG_DEBUG("Frame " << frameNr << ", before conversion: " <<
00067 Get2(i) << " vs. " << arg->Get2(i));
00068 }
00069 else if (diffPost)
00070 {
00071 nDiffPost++;
00072 ILOG_DEBUG("Frame " << frameNr << ", after conversion: " <<
00073 Get3(i) << " vs. " << arg->Get3(i));
00074 }
00075 foundDiff = foundDiff || diffPre || diffPost;
00076 if (foundDiff)
00077 nDiffAll++;
00078 }
00079 if (nDiffAll > 0)
00080 {
00081 ILOG_ERROR("Found " << nDiffAll << " differences");
00082 ILOG_ERROR(" Of which " << nDiffPre << " relate to pre-RGB-conversion hashes");
00083 ILOG_ERROR(" and " << nDiffPost << " relate to post-RGB-conversion hashes");
00084 }
00085 return nDiffAll;
00086 }
00087
00088
00089 private:
00090
00091 ILOG_VAR_DECL;
00092 };
00093
00094 ILOG_VAR_INIT(FrameHashes, Impala.Core.Table);
00095
00096 }
00097 }
00098 }
00099
00100 #endif