Skip to content

Commit

Permalink
1. fix #7
Browse files Browse the repository at this point in the history
2. switch YUV refactor (not complete)
  • Loading branch information
lheric committed Oct 31, 2013
1 parent d3e2c1d commit 01fe21e
Show file tree
Hide file tree
Showing 18 changed files with 166 additions and 92 deletions.
4 changes: 3 additions & 1 deletion src/commands/decodebitstreamcommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ bool DecodeBitstreamCommand::execute( GitlCommandParameter& rcInputArg, GitlComm

//TODO BUG Memory Leaking when exception happens
ComSequence* pcSequence = new ComSequence();
pcSequence->init();
pcSequence->init();
pcSequence->setFileName(strFilename);

/// *****STEP 1 : Use the special decoder to parse bitstream*****
/// call decoder process to decode bitstream to YUV and output text info
Expand Down Expand Up @@ -219,6 +220,7 @@ bool DecodeBitstreamCommand::execute( GitlCommandParameter& rcInputArg, GitlComm
///*****STEP 3 : Open decoded YUV sequence*****

pModel->getSequenceManager().addSequence(pcSequence);
pcSequence->setYUVRole(YUV_RECONSTRUCTED); /// display the recon. by default
GitlIvkCmdEvt cSwitchSeq("switch_sequence");
cSwitchSeq.setParameter("command_name", "switch_sequence");
cSwitchSeq.setParameter("sequence", QVariant::fromValue((void*)pcSequence));
Expand Down
50 changes: 41 additions & 9 deletions src/commands/switchyuvcommand.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
#include "switchyuvcommand.h"
#include "model/modellocator.h"
#include <QDebug>

static struct YUVInfo
{
YUVRole eRole;
QString strRoleName;
QString strYUVName;
bool bIs16Bit;
}s_aYUVInfo[] =
{
{YUV_PREDICTED, "predicted", "pred_yuv.yuv"},
{YUV_RESIDUAL, "residual", "resi_yuv.yuv"},
{YUV_RECONSTRUCTED, "reconstructed","decoder_yuv.yuv"},
{YUV_NONE, "", ""} /// end mark
};



SwitchYUVCommand::SwitchYUVCommand(QObject *parent) :
GitlAbstractCommand(parent)
{
Expand All @@ -9,14 +26,19 @@ SwitchYUVCommand::SwitchYUVCommand(QObject *parent) :

bool SwitchYUVCommand::execute( GitlCommandParameter& rcInputArg, GitlCommandParameter& rcOutputArg )
{
bool bIs16Bit = false;
if(rcInputArg.hasParameter("is_16_bit"))
{
bIs16Bit = rcInputArg.getParameter("is_16_bit").toBool();
}
bool bIs16Bit = false;
// if(rcInputArg.hasParameter("is_16_bit"))
// {
// bIs16Bit = rcInputArg.getParameter("is_16_bit").toBool();
// }

// QString strYUVFilename = rcInputArg.getParameter("YUV_filename").toString();

QString strYUVFilename = rcInputArg.getParameter("YUV_filename").toString();
//TODO YUV Role should be passed as arg, not changed outside this command
ComSequence* pcSequence = (ComSequence*)rcInputArg.getParameter("sequence").value<void*>();
QString strYUVFilename = xGetYUVFilenameByRole(pcSequence->getYUVRole());
if(pcSequence->getYUVRole() == YUV_RESIDUAL)
bIs16Bit = true;
ModelLocator* pModel = ModelLocator::getInstance();
if( pcSequence != &(pModel->getSequenceManager().getCurrentSequence()) )
{
Expand All @@ -42,8 +64,18 @@ bool SwitchYUVCommand::execute( GitlCommandParameter& rcInputArg, GitlCommandPar
rcOutputArg.setParameter("picture", QVariant::fromValue((void*)(pcFramePixmap)));
rcOutputArg.setParameter("current_frame_poc", iPoc);
rcOutputArg.setParameter("total_frame_num", pModel->getSequenceManager().getCurrentSequence().getTotalFrames());



return true;
}

QString SwitchYUVCommand::xGetYUVFilenameByRole(YUVRole eRole)
{
YUVInfo*p = s_aYUVInfo;
while(p->eRole != YUV_NONE)
{
if(p->eRole == eRole)
return p->strYUVName;
p++;
}
qWarning() << "Invalid YUV Role";
return QString();
}
5 changes: 4 additions & 1 deletion src/commands/switchyuvcommand.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
#ifndef SWITCHYUVCOMMAND_H
#define SWITCHYUVCOMMAND_H
#include "gitlabstractcommand.h"

#include "model/common/comsequence.h"
class SwitchYUVCommand : public GitlAbstractCommand
{
Q_OBJECT
public:
Q_INVOKABLE explicit SwitchYUVCommand(QObject *parent = 0);
Q_INVOKABLE virtual bool execute(GitlCommandParameter &rcInputArg, GitlCommandParameter &rcOutputArg);

private:
QString xGetYUVFilenameByRole(YUVRole eRole);

signals:

public slots:
Expand Down
4 changes: 4 additions & 0 deletions src/model/common/comsequence.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "comsequence.h"


ComSequence::ComSequence()
{
init();
Expand Down Expand Up @@ -32,6 +33,9 @@ void ComSequence::init()
m_iMinTUDepth = -1;
m_iMaxTUDepth = -1;

/*! YUV Info -- Currently Displaying YUV*/
m_eYUVRole = YUV_NONE;


/*!
* Optional info
Expand Down
11 changes: 11 additions & 0 deletions src/model/common/comsequence.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@

#include "comframe.h"

enum YUVRole
{
YUV_NONE,
YUV_PREDICTED,
YUV_RESIDUAL,
YUV_RECONSTRUCTED
};

/*!
* \brief This class represents a video sequence
*/
Expand Down Expand Up @@ -37,6 +45,9 @@ class ComSequence
/*! Decoded File Location */
ADD_CLASS_FIELD( QString, strDeocdingFolder, getDecodingFolder, setDecodingFolder)

/*! Currently Displaying YUV (Predicted, Residual or Reconstructed)*/
ADD_CLASS_FIELD( YUVRole, eYUVRole, getYUVRole, setYUVRole)


/*!
* Optional info
Expand Down
1 change: 1 addition & 0 deletions src/model/io/yuv420rgbbuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <QFile>
#include <QDebug>


YUV420RGBBuffer::YUV420RGBBuffer()
{

Expand Down
6 changes: 6 additions & 0 deletions src/model/io/yuv420rgbbuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@
#include <QObject>
#include <QPixmap>
#include <QFile>
#include <QMap>
#include "ioyuv.h"
#include "gitldef.h"




class YUV420RGBBuffer : public QObject
{
Q_OBJECT
Expand All @@ -30,6 +34,8 @@ class YUV420RGBBuffer : public QObject
ADD_CLASS_FIELD_PRIVATE(uchar*, puhRGBBuffer)
ADD_CLASS_FIELD_PRIVATE(IOYUV, cIOYUV)



protected:
bool xReadFrame(int iPoc);
void xYuv2rgb(uchar* puhYUV, uchar* puhRGB, int iWidth, int iHeight);
Expand Down
44 changes: 1 addition & 43 deletions src/model/modellocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,56 +4,14 @@
#include <QDataStream>
#include <QPixmap>
#include "gitlmodual.h"
#include "sequencemanager.h"
#include "io/yuv420rgbbuffer.h"
#include "drawengine/drawengine.h"
#include "preferences.h"
#include "parsers/encodergeneralparser.h"
#include "parsers/decodergeneralparser.h"
#include "parsers/cupuparser.h"
#include "exceptions/nosequencefoundexception.h"
/*!
* \brief The SequenceManager class
* This class contains serveral sequences, in order to support multi-sequence analysis (difference comparasion, etc.)
*/

class SequenceManager
{
public:
explicit SequenceManager(){ m_pcCurrentSequence = NULL; }
~SequenceManager()
{
while(!m_apSequences.empty())
{
delete m_apSequences.back();
m_apSequences.pop_back();
}
}

ComSequence& getCurrentSequence()
{
if(m_pcCurrentSequence == NULL)
throw NoSequenceFoundException();
return *m_pcCurrentSequence;
}

void setCurrentSequence(ComSequence* pcSequence)
{
m_pcCurrentSequence = pcSequence;
}

void addSequence(ComSequence* pcSequence)
{
m_apSequences.push_back(pcSequence);
}

QVector<ComSequence*>& getAllSequences()
{
return m_apSequences;
}
ADD_CLASS_FIELD_PRIVATE(ComSequence*, pcCurrentSequence)
ADD_CLASS_FIELD_PRIVATE(QVector<ComSequence*>, apSequences)
};


/*!
* \brief The ModelLocator class
Expand Down
5 changes: 5 additions & 0 deletions src/model/sequencemanager.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include "sequencemanager.h"

SequenceManager::SequenceManager()
{
}
60 changes: 60 additions & 0 deletions src/model/sequencemanager.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#ifndef SEQUENCEMANAGER_H
#define SEQUENCEMANAGER_H
#include "gitldef.h"
#include "common/comsequence.h"
#include "exceptions/nosequencefoundexception.h"
#include <QVector>
/*!
* \brief The SequenceManager class
* This class contains serveral sequences, in order to support multi-sequence analysis (difference comparasion, etc.)
*/

class SequenceManager
{
public:
explicit SequenceManager(){ m_pcCurrentSequence = NULL; }
~SequenceManager()
{
while(!m_apSequences.empty())
{
delete m_apSequences.back();
m_apSequences.pop_back();
}
}

ComSequence& getCurrentSequence()
{
if(m_pcCurrentSequence == NULL)
throw NoSequenceFoundException();
return *m_pcCurrentSequence;
}

void setCurrentSequence(ComSequence* pcSequence)
{
m_pcCurrentSequence = pcSequence;
}

void addSequence(ComSequence* pcSequence)
{
m_apSequences.push_back(pcSequence);
}

QVector<ComSequence*>& getAllSequences()
{
return m_apSequences;
}

ComSequence* getSequenceByFilename(const QString& strFilename)
{
foreach(ComSequence* p, m_apSequences)
{
if(p->getFileName() == strFilename)
return p;
}
return NULL;
}

ADD_CLASS_FIELD_PRIVATE(ComSequence*, pcCurrentSequence)
ADD_CLASS_FIELD_PRIVATE(QVector<ComSequence*>, apSequences)
};
#endif // SEQUENCEMANAGER_H
1 change: 0 additions & 1 deletion src/parsers/bitstreamparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ bool BitstreamParser::parseFile(QString strDecoderFolder,

m_cStdOutputFile.close();

pcSequence->setFileName(strBitstreamFilePath);
pcSequence->setDecodingFolder(strOutputPath);

return (m_cDecoderProcess.exitCode() == 0);
Expand Down
6 changes: 4 additions & 2 deletions src/src.pro
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ SOURCES += main.cpp \
views/timelineview.cpp \
parsers/bitparser.cpp \
views/timelineframeitem.cpp \
views/timelineindicatoritem.cpp
views/timelineindicatoritem.cpp \
model/sequencemanager.cpp


HEADERS += \
Expand Down Expand Up @@ -145,7 +146,8 @@ HEADERS += \
views/timelineview.h \
parsers/bitparser.h \
views/timelineframeitem.h \
views/timelineindicatoritem.h
views/timelineindicatoritem.h \
model/sequencemanager.h


#include & libs
Expand Down
5 changes: 3 additions & 2 deletions src/views/messageviewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@ struct MessageSwitchItem

MessageViewer::MessageViewer(QWidget *parent) :
QWidget(parent),
m_cWarningBox(this),
ui(new Ui::MessageViewer)
{
ui->setupUi(this);

m_cWarningBox.setModal(false);
m_cDefalutTextColor = ui->msgTextBrowser->palette().foreground().color();

listenToParams(QStringList()<<"msg_detail"<<"msg_level",
Expand All @@ -37,8 +40,6 @@ void MessageViewer::onMessageArrived(GitlUpdateUIEvt &rcEvt)
{QtMsgType(-1), NULL} /// end mark
};


/// TODO FIX BUG #7
QVariant vValue = rcEvt.getParameter("msg_detail");
QString strMsg = vValue.toString();
QtMsgType eMsgLevel = (QtMsgType)rcEvt.getParameter("msg_level").toInt();
Expand Down
17 changes: 6 additions & 11 deletions src/views/sequencelist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ void SequenceList::onSequenceChanged(GitlUpdateUIEvt &rcEvt)
pcItem->setSizeHint(seqRadioBtn->sizeHint());
setItemWidget(pcItem, seqRadioBtn);

connect(seqRadioBtn, SIGNAL(sequenceRadioButtonClicked(ComSequence*, QString, bool)),
this, SLOT(sequenceRadioButtonClicked(ComSequence*, QString, bool)));
connect(seqRadioBtn, SIGNAL(yuvSelectionBoxChanged(ComSequence*,QString,bool)),
this, SLOT(yuvSelectionBoxChanged(ComSequence*,QString,bool)) );
connect(seqRadioBtn, SIGNAL(sequenceRadioButtonClicked(ComSequence*)),
this, SLOT(sequenceRadioButtonClicked(ComSequence*)) );
connect(seqRadioBtn, SIGNAL(yuvSelectionBoxChanged(ComSequence*)),
this, SLOT(yuvSelectionBoxChanged(ComSequence*)) );

}
}
Expand All @@ -84,21 +84,16 @@ void SequenceList::onSequenceChanged(GitlUpdateUIEvt &rcEvt)

}

void SequenceList::sequenceRadioButtonClicked(ComSequence* pcSequence, QString strYUVFileName, bool bIs16Bit)
void SequenceList::sequenceRadioButtonClicked(ComSequence* pcSequence)
{
GitlIvkCmdEvt cRequest("switch_sequence");
cRequest.setParameter("command_name", "switch_sequence");
cRequest.setParameter("sequence", QVariant::fromValue((void*)pcSequence));
cRequest.setParameter("YUV_filename", strYUVFileName);
cRequest.setParameter("is_16_bit", bIs16Bit);
cRequest.dispatch();
}

void SequenceList::yuvSelectionBoxChanged(ComSequence* pcSequence, QString strYUVFileName, bool bIs16Bit)
void SequenceList::yuvSelectionBoxChanged(ComSequence* pcSequence)
{
GitlIvkCmdEvt cRequest("switch_yuv");
cRequest.setParameter("sequence", QVariant::fromValue((void*)pcSequence));
cRequest.setParameter("YUV_filename", strYUVFileName);
cRequest.setParameter("is_16_bit", bIs16Bit);
cRequest.dispatch();
}
Loading

0 comments on commit 01fe21e

Please sign in to comment.