00001 00002 #include "YUVGOP.hpp" 00003 #include "YUVFrame.hpp" 00004 #include "YUVStream.hpp" 00005 00006 YUVGOP::YUVGOP(Stream* s, unsigned int pat_i) : GOP(s, pat_i) { 00007 psnr = 0.0; 00008 modsAdded = false; 00009 hasOrg = false; 00010 } 00011 00012 YUVGOP::YUVGOP(Stream* s, unsigned int mod_i, unsigned int pat_i):GOP(s, mod_i, pat_i) { 00013 psnr = 0.0; 00014 modsAdded = false; 00015 hasOrg = false; 00016 } 00017 00018 00019 YUVGOP::~YUVGOP(){}; 00020 00021 00022 YUVGOP* YUVGOP::getOrgGOP() { 00023 return orgGOP; 00024 } 00025 00026 00027 bool YUVGOP::hasOriginal() { 00028 return hasOrg; 00029 } 00030 00031 00032 void YUVGOP::setCompressedByteSize(uint size) { 00033 compressedByteSize = size; 00034 } 00035 00036 00037 uint YUVGOP::getCompressedByteSize() { 00038 return compressedByteSize; 00039 } 00040 00041 00042 void YUVGOP::setCompressedBaselayerSize(uint size) { 00043 compressedBaselayerSize = size; 00044 } 00045 00046 00047 uint YUVGOP::getCompressedBaselayerSize() { 00048 return compressedBaselayerSize; 00049 } 00050 00051 00052 QString YUVGOP::getFramesInGOP() { 00053 QString frStr = ""; 00054 YUVFrame* fr; 00055 YUVFrame* frprev; 00056 FrameType type; 00057 00058 fr = (YUVFrame*)frameList.first(); 00059 frprev = NULL; 00060 00061 while (fr != NULL) { 00062 type = fr->getType(); 00063 00064 if ( (frprev != NULL) && (frprev == fr)) // modification dropped frame 00065 frStr.append('-'); 00066 else if (type == I_VOP) 00067 frStr.append('I'); 00068 else if (type == P_VOP) 00069 frStr.append('P'); 00070 else if (type == B_VOP) 00071 frStr.append('B'); 00072 else 00073 frStr.append('U'); 00074 00075 frprev = fr; 00076 fr = (YUVFrame*)frameList.next(); 00077 } 00078 return frStr; 00079 } 00080 00081 00082 void YUVGOP::setOrgGOP(YUVGOP* org) { 00083 this->orgGOP = org; 00084 this->hasOrg = true; 00085 } 00086 00087 00088 void YUVGOP::setPSNRmp(double value) { 00089 if (isMaster()) 00090 psnr = value; 00091 } 00092 00093 00094 double YUVGOP::computePSNR(YUVGOP* p) { 00095 00096 unsigned int frameCount = getFrameCount(); 00097 double sumPSNR = 0.0; 00098 YUVFrame* fr1; 00099 YUVFrame* fr2; 00100 YUVFrame* frprev = NULL; 00101 00102 for (unsigned int i = 0; i < frameCount; i++) { 00103 fr1 = (YUVFrame*)getFrame(i); 00104 00105 if ((frprev != NULL) && (frprev == fr1)) { 00106 // dropped frame -> compute PSNR 00107 fr2 = (YUVFrame*)p->getFrame(i); 00108 sumPSNR+= fr1->computePSNR(fr2); 00109 } 00110 else { 00111 fr2 = (YUVFrame*)p->getFrame(i); 00112 sumPSNR += fr1->computePSNR(fr2); 00113 } 00114 frprev = fr1; 00115 } 00116 psnr = sumPSNR/frameCount; 00117 return psnr; 00118 } 00119 00120 00121 QPtrList<YUVGOP>* YUVGOP::expand(YUVGOP* yg) { 00122 return NULL; 00123 }