Skip to content

Commit

Permalink
1. Add time line
Browse files Browse the repository at this point in the history
2. Add bit count for frame
3. fix compile error under vs2012
  • Loading branch information
lheric committed Oct 19, 2013
1 parent 78ac45b commit 17b637f
Show file tree
Hide file tree
Showing 18 changed files with 383 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

#include <list>
#include <algorithm>

#include <functional>
#include "TEncTop.h"
#include "TEncGOP.h"
#include "TEncAnalyze.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@

#include <time.h>
#include <math.h>
#include <functional>

using namespace std;

Expand Down
4 changes: 2 additions & 2 deletions libplugins/libbitdisplayfilter/bitdisplayfilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ bool BitDisplayFilter::init(FilterContext* pcContext)

foreach( ComFrame* pcFrame, rcSeq.getFrames())
foreach( ComCU* pcCU, pcFrame->getLCUs() )
m_iLCUAvgBit += pcCU->getTotalBits();
m_iLCUAvgBit += pcCU->getBitCount();

return true;

Expand All @@ -23,7 +23,7 @@ bool BitDisplayFilter::init(FilterContext* pcContext)
bool BitDisplayFilter::drawCTU (FilterContext *pcContext, QPainter *pcPainter,
ComCU *pcCTU, double dScale, QRect *pcScaledArea)
{
int iClip = VALUE_CLIP(0,240,pcCTU->getTotalBits());
int iClip = VALUE_CLIP(0,240,pcCTU->getBitCount());

QColor cFill;
double dHue = (240-iClip)/360.0;
Expand Down
6 changes: 0 additions & 6 deletions src/commands/decodebitstreamcommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,5 @@ bool DecodeBitstreamCommand::execute( GitlCommandParameter& rcInputArg, GitlComm
cSwitchSeq.setParameter("sequence", QVariant::fromValue((void*)pcSequence));
cSwitchSeq.dispatch();


/// nofity sequence list to update
QVector<ComSequence*>* ppcSequences = &(pModel->getSequenceManager().getAllSequences());
rcOutputArg.setParameter("sequences",QVariant::fromValue((void*)ppcSequences));
rcOutputArg.setParameter("current_sequence",QVariant::fromValue((void*)pcSequence));

return bSuccess;
}
6 changes: 4 additions & 2 deletions src/commands/switchsequencecommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,14 @@ bool SwitchSequenceCommand::execute( GitlCommandParameter& rcInputArg, GitlComma
pModel->getDrawEngine().getFilterLoader().reinitAllFilters();
pcFramePixmap = pModel->getDrawEngine().drawFrame(&(pModel->getSequenceManager().getCurrentSequence()), iPoc, pcFramePixmap); ///< Draw Frame Buffer

///
///notify
rcOutputArg.setParameter("picture", QVariant::fromValue((void*)(pcFramePixmap)));
rcOutputArg.setParameter("current_frame_poc", iPoc);
rcOutputArg.setParameter("total_frame_num", pModel->getSequenceManager().getCurrentSequence().getTotalFrames());


QVector<ComSequence*>* ppcSequences = &(pModel->getSequenceManager().getAllSequences());
rcOutputArg.setParameter("sequences",QVariant::fromValue((void*)ppcSequences));
rcOutputArg.setParameter("current_sequence",QVariant::fromValue((void*)pcSequence));

return true;
}
2 changes: 1 addition & 1 deletion src/model/common/comcu.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class ComCU
/*!
* Bit info (only for LCU)
*/
ADD_CLASS_FIELD(int, iTotalBits, getTotalBits, setTotalBits) ///< Bits comsumed by this LCU
ADD_CLASS_FIELD(int, iBitCount, getBitCount, setBitCount) ///< Bits comsumed by this LCU

public:
static int getPUNum( PartSize ePartSize );
Expand Down
1 change: 1 addition & 0 deletions src/model/common/comframe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ ComFrame::ComFrame(ComSequence* pcParent)
{
m_pcSequence = pcParent;
m_iPoc = -1;
m_iBitCount = 0;
m_dPSNR = -1;
m_dBitrate = -1;
m_dTotalEncTime = -1;
Expand Down
3 changes: 3 additions & 0 deletions src/model/common/comframe.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ class ComFrame
/*! Decoding time comsumed*/
ADD_CLASS_FIELD(double, dTotalDecTime, getTotalDecTime, setTotalDecTime)

/*! Bit comsumed */
ADD_CLASS_FIELD(int, iBitCount, getBitCount, setBitCount)

/*! Obsolescent
*/
ADD_CLASS_FIELD(double, dPSNR, getPSNR, setPSNR)
Expand Down
4 changes: 3 additions & 1 deletion src/parsers/bitparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ bool BitParser::parseFile(QTextStream* pcInputStream, ComSequence* pcSequence)

///
QString strBitInfo = cMatchTarget.cap(3);
pcLCU->setTotalBits(strBitInfo.toInt());
int iLCUBit = strBitInfo.toInt();
pcLCU->setBitCount(iLCUBit);
pcFrame->getBitCount() += iLCUBit;

}

Expand Down
12 changes: 10 additions & 2 deletions src/src.pro
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,11 @@ SOURCES += main.cpp \
commands/querypreferencescommand.cpp \
commands/switchthemecommand.cpp \
views/messageviewer.cpp \
parsers/bitparser.cpp
views/timelineview.cpp \
parsers/bitparser.cpp \
views/timelineframeitem.cpp \
views/timelineindicatoritem.cpp


HEADERS += \
model/common/comsequence.h \
Expand Down Expand Up @@ -138,7 +142,11 @@ HEADERS += \
commands/querypreferencescommand.h \
commands/switchthemecommand.h \
views/messageviewer.h \
parsers/bitparser.h
views/timelineview.h \
parsers/bitparser.h \
views/timelineframeitem.h \
views/timelineindicatoritem.h


#include & libs
INCLUDEPATH += .\
Expand Down
3 changes: 1 addition & 2 deletions src/views/frameview.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
#include <QGraphicsView>
#include <QGraphicsPixmapItem>
#include <QGraphicsScene>
#include "gitlmodual.h"
#include "gitldef.h"

class FrameView : public QGraphicsView, public GitlModual
class FrameView : public QGraphicsView
{
Q_OBJECT
public:
Expand Down
27 changes: 27 additions & 0 deletions src/views/mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,28 @@
</layout>
</widget>
</item>
<item>
<widget class="TimeLineView" name="timelineView">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>180</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>180</height>
</size>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QDockWidget" name="sequencesListDockWidget">
Expand Down Expand Up @@ -500,6 +522,11 @@
<header>views/messageviewer.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>TimeLineView</class>
<extends>QGraphicsView</extends>
<header>views/timelineview.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
Expand Down
90 changes: 90 additions & 0 deletions src/views/timelineframeitem.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
#include "timelineframeitem.h"
#include <QDebug>
#include <QPen>
#include <QFont>
#include <QBrush>
#include <QColor>
TimeLineFrameItem::TimeLineFrameItem(int iPercent, int iPOC)
{
m_iMaxWidth = 20;
m_iMaxHeight = 50;
m_iPOC = iPOC;

/// layout
m_cFrameBar.setRect(0,0,m_iMaxWidth,m_iMaxHeight);

m_cHitArea.setRect(0,-m_iMaxHeight*1.5,m_iMaxWidth,m_iMaxHeight*3);
m_cHitArea.setPen(Qt::NoPen);

m_cPocText.setPos(0,0);

QFont cFont;
cFont.setPointSize(12);
cFont.setBold(true);
m_cPocText.setFont(cFont);
m_cPocText.setBrush(QBrush(QColor(Qt::gray)));
m_cPocText.setText(QString("#%1").arg(m_iPOC));
m_cPocText.setPos(19,10);
m_cPocText.setRotation(90);


/// change frame bar height
setHeightPercent(iPercent);

/// group
this->addToGroup(&m_cFrameBar);
this->addToGroup(&m_cHitArea);
this->addToGroup(&m_cPocText);

///
setAcceptHoverEvents(true);
}

void TimeLineFrameItem::mousePressEvent(QGraphicsSceneMouseEvent * event)
{
if(m_iPOC < 0)
{
qWarning() << QString("Frame Bar With Invalid POC Num %1").arg(m_iPOC);
return;
}
emit barClick(m_iPOC);
}

void TimeLineFrameItem::hoverEnterEvent(QGraphicsSceneHoverEvent * event)
{
m_cHitArea.setBrush(QBrush(QColor(0,255,0,50)));
m_cHitArea.update(m_cHitArea.rect());
}

void TimeLineFrameItem::hoverLeaveEvent(QGraphicsSceneHoverEvent * event)
{
m_cHitArea.setBrush(QBrush(QColor(0,255,0,0)));
m_cHitArea.update(m_cHitArea.rect());
}


void TimeLineFrameItem::setHeightPercent(int iPercent)
{
if(iPercent < 0 || iPercent > 100)
{
qWarning() << QString("Invalid Timeline Frame Bar Height Percentage %1").arg(iPercent);
return;
}
m_iHeightPercent = iPercent;
QRectF cRect= m_cFrameBar.rect();
cRect.setHeight(-m_iMaxHeight*iPercent/100);
m_cFrameBar.setRect(cRect);

/// set fill color according to height
m_cFrameBar.setPen(QPen(QColor(255,255,255,128)));
QColor cFillColor;

int iClip = VALUE_CLIP(0, 240, iPercent*240/100);
double dHue = (240-iClip)/360.0;
cFillColor.setHsvF(dHue, 1.0, 1.0, 0.6);
m_cFrameBar.setBrush(QBrush(cFillColor));


}


34 changes: 34 additions & 0 deletions src/views/timelineframeitem.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#ifndef TIMELINEFRAMEITEM_H
#define TIMELINEFRAMEITEM_H

#include <QGraphicsItemGroup>
#include <QGraphicsRectItem>
#include <QGraphicsSimpleTextItem>
#include <QObject>
#include "gitldef.h"

class TimeLineFrameItem : public QObject, public QGraphicsItemGroup
{
Q_OBJECT
public:
explicit TimeLineFrameItem(int iPercent = 0, int iPOC = -1);
void setHeightPercent(int iPercent);
protected:
void mousePressEvent(QGraphicsSceneMouseEvent * event);
void hoverEnterEvent(QGraphicsSceneHoverEvent * event);
void hoverLeaveEvent(QGraphicsSceneHoverEvent * event);
signals:
void barClick(int iPOC);


ADD_CLASS_FIELD(int, iPOC, getPOC, setPOC)
ADD_CLASS_FIELD_NOSETTER(int, iHeightPercent, getHeightPercent)
ADD_CLASS_FIELD(int, iMaxHeight, getMaxHeight, setMaxHeight)
ADD_CLASS_FIELD(int, iMaxWidth, getMaxWidth, setMaxWidth)

ADD_CLASS_FIELD_PRIVATE(QGraphicsRectItem, cFrameBar)
ADD_CLASS_FIELD_PRIVATE(QGraphicsRectItem, cHitArea)
ADD_CLASS_FIELD_PRIVATE(QGraphicsSimpleTextItem, cPocText)
};

#endif // TIMELINEFRAMEITEM_H
21 changes: 21 additions & 0 deletions src/views/timelineindicatoritem.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include "timelineindicatoritem.h"
#include <QColor>
#include <QPen>
#include <QBrush>
TimelineIndicatorItem::TimelineIndicatorItem()
{

m_cRectTop.setRect(0,0,10,16);
m_cRectTop.setPen(QColor(255,255,255,128));
m_cRectTop.setBrush(QColor(255,0,0,255));
addToGroup(&m_cRectTop);


QRectF cUpperRect = m_cRectTop.rect();
QPointF cBL = (cUpperRect.bottomLeft()+cUpperRect.bottomRight())/2;

m_cRectBar.setRect(cBL.x()-1,cBL.y(),3,65);
m_cRectBar.setPen(Qt::NoPen);
m_cRectBar.setBrush(QColor(255,0,0,255));
addToGroup(&m_cRectBar);
}
21 changes: 21 additions & 0 deletions src/views/timelineindicatoritem.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#ifndef TIMELINEINDICATORITEM_H
#define TIMELINEINDICATORITEM_H

#include <QGraphicsItemGroup>
#include <QGraphicsPolygonItem>
#include <QGraphicsRectItem>
#include "gitldef.h"

class TimelineIndicatorItem : public QGraphicsItemGroup
{
public:
TimelineIndicatorItem();



ADD_CLASS_FIELD_PRIVATE(QGraphicsRectItem, cRectTop)
ADD_CLASS_FIELD_PRIVATE(QGraphicsRectItem, cRectBar)

};

#endif // TIMELINEINDICATORITEM_H
Loading

0 comments on commit 17b637f

Please sign in to comment.