Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GUI] option to display source (reference) time in time display #528

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions avidemux/cli/ADM_userInterfaces/ADM_gui2/gui_none.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,9 @@ void UI_setMarkers(uint64_t a,uint64_t b)
void UI_setTotalTime(uint64_t t)
{
}
void UI_setCurrentRefInfo(uint64_t refPts, uint32_t refVideo)
{
}
void UI_setSegments(uint32_t numOfSegs, uint64_t * segPts)
{
}
Expand Down
1 change: 1 addition & 0 deletions avidemux/common/ADM_commonUI/GUI_ui.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ void UI_setFrameCount(uint32_t curFrame,uint32_t total);

void UI_setCurrentTime(uint64_t pts);
void UI_setTotalTime(uint64_t curTime);
void UI_setCurrentRefInfo(uint64_t refPts, uint32_t refVideo);
void UI_setSegments(uint32_t numOfSegs, uint64_t * segPts);
double UI_readScale( void );
void UI_setScale( double val );
Expand Down
2 changes: 2 additions & 0 deletions avidemux/common/ADM_editor/src/ADM_edRender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ int64_t t=(int64_t)*time;
*/
bool ADM_Composer::updateImageTiming(_SEGMENT *seg,ADMImage *image)
{
image->refPts = image->Pts;
image->refVideo = seg->_reference;
recalibrate(&(image->Pts),seg);
// recalibrate(&(image->Dts),seg);
return true;
Expand Down
2 changes: 2 additions & 0 deletions avidemux/common/ADM_preview.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ class admPreview
static void cleanUp(void);
static ADMImage *getBuffer(void);
static uint64_t getCurrentPts(void);
static uint64_t getRefPts(void);
static uint32_t getRefVideo(void);
static bool nextKeyFrame(void);
static bool previousKeyFrame(void);
static bool previousFrame(void);
Expand Down
18 changes: 18 additions & 0 deletions avidemux/common/ADM_previewNavigate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,24 @@ uint64_t admPreview::getCurrentPts(void)
if(rdrImage) return rdrImage->Pts;
return 0LL;
}
/**
\fn getRefPts
\brief returns the reference PTS in us of the last displayed frame
*/
uint64_t admPreview::getRefPts(void)
{
if(rdrImage) return rdrImage->refPts;
return 0LL;
}
/**
\fn getRefVideo
\brief returns the reference Video of the last displayed frame
*/
uint32_t admPreview::getRefVideo(void)
{
if(rdrImage) return rdrImage->refVideo;
return 0LL;
}
/**
\fn admPreview::seekToTime
\brief Seek to any given frame
Expand Down
3 changes: 3 additions & 0 deletions avidemux/common/gui_navigate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ static int ignore_change=0;
ADM_warning("Scale: Seeking to intra at %" PRIu64" ms failed\n",pts/1000);
}
UI_setCurrentTime(pts);
UI_setCurrentRefInfo(admPreview::getRefPts(), admPreview::getRefVideo());
UI_purge();
ignore_change--;
}
Expand Down Expand Up @@ -159,6 +160,7 @@ static int ignore_change=0;
video_body->rewind(); // go to the first frame then
admPreview::samePicture();
UI_setCurrentTime(pts);
UI_setCurrentRefInfo(admPreview::getRefPts(), admPreview::getRefVideo());
UI_purge();
ignore_change--;
}
Expand Down Expand Up @@ -582,6 +584,7 @@ void GUI_setCurrentFrameAndTime(uint64_t offset)
double len;

UI_setCurrentTime(pts);
UI_setCurrentRefInfo(admPreview::getRefPts(), admPreview::getRefVideo());
len=pts;
len*=ADM_SCALE_SIZE;
len/=video_body->getVideoDuration();
Expand Down
178 changes: 142 additions & 36 deletions avidemux/qt4/ADM_userInterfaces/ADM_gui/Q_gui2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -725,25 +725,9 @@ MainWindow::MainWindow(const vector<IScriptEngine*>& scriptEngines) : _scriptEng
connect(ui.checkBox_TimeShift,SIGNAL(stateChanged(int)),this,SLOT(checkChanged(int)));
connect(ui.spinBox_TimeValue,SIGNAL(valueChanged(int)),this,SLOT(timeChanged(int)));
connect(ui.spinBox_TimeValue, SIGNAL(editingFinished()), this, SLOT(timeChangeFinished()));
#if 0 /* it is read-only */
QRegExp timeRegExp("^[0-9]{2}:[0-5][0-9]:[0-5][0-9]\\.[0-9]{3}$");
QRegExpValidator *timeValidator = new QRegExpValidator(timeRegExp, this);
ui.currentTime->setValidator(timeValidator);
ui.currentTime->setInputMask("99:99:99.999");
#endif
// set the size of the current time display to fit the content
QString text = "00:00:00.000"; // Don't translate this.
#ifdef USE_CUSTOM_TIME_DISPLAY_FONT
ui.currentTime->setFont(QFont("ADM7SEG"));
#endif
ui.currentTime->setText(text); // Override ui translations to make sure we use point as decimal separator.
QRect ctrect = ui.currentTime->fontMetrics().boundingRect(text);
ui.currentTime->setFixedSize(1.15 * ctrect.width(), ui.currentTime->height());

text = QString("/ ") + text;
ui.totalTime->setText(text); // Override ui translations here too.

//connect(ui.currentTime, SIGNAL(editingFinished()), this, SLOT(currentTimeChanged()));


timeDisplayInit();

// Build file,... menu
addScriptEnginesToFileMenu(myMenuFile);
Expand Down Expand Up @@ -814,8 +798,6 @@ MainWindow::MainWindow(const vector<IScriptEngine*>& scriptEngines) : _scriptEng
this->installEventFilter(this);
slider->installEventFilter(this);

//ui.currentTime->installEventFilter(this);

this->setFocus(Qt::OtherFocusReason);

setAcceptDrops(true);
Expand Down Expand Up @@ -1981,6 +1963,127 @@ void MainWindow::setDarkThemeSlot(bool b)
}
}

void MainWindow::timeDisplaySetCurrentPts(uint64_t t)
{
timeDisplayCurrentPts = t;
if (timeDisplayMode == 0)
timeDisplayUpdate();
}

void MainWindow::timeDisplaySetTotalTime(uint64_t t)
{
timeDisplayTotalTime = t;
if (t == 0) timeDisplayMode = 0;
if (timeDisplayMode == 0)
timeDisplayUpdate();
}

void MainWindow::timeDisplaySetRefInfo(uint64_t t, uint64_t v)
{
timeDisplayRefPts = t;
timeDisplayRefVideo = v;
if (timeDisplayMode == 1)
timeDisplayUpdate();
}

void MainWindow::timeDisplayUpdate(void)
{
char text[80];
uint32_t mm,hh,ss,ms, shorty;

switch(timeDisplayMode)
{
case 1:
{
shorty=(uint32_t)(timeDisplayRefPts/1000);
ms2time(shorty,&hh,&mm,&ss,&ms);
sprintf(text, "%02d:%02d:%02d.%03d", hh, mm, ss, ms);
ui.currentTime->setText(text);

QString s = QString(QT_TRANSLATE_NOOP("qgui2","/ Ref %1")).arg(timeDisplayRefVideo);
ui.totalTime->setText(s);
}
break;
default:
{
shorty=(uint32_t)(timeDisplayCurrentPts/1000);
ms2time(shorty,&hh,&mm,&ss,&ms);
sprintf(text, "%02d:%02d:%02d.%03d", hh, mm, ss, ms);
ui.currentTime->setText(text);

shorty=(uint32_t)(timeDisplayTotalTime/1000);
ms2time(shorty,&hh,&mm,&ss,&ms);
sprintf(text, "/ %02d:%02d:%02d.%03d", hh, mm, ss, ms);
ui.totalTime->setText(text);
}
break;
}
}

void MainWindow::timeDisplayInit(void)
{
timeDisplayMode = 0;

#if 0 /* it is read-only */
QRegExp timeRegExp("^[0-9]{2}:[0-5][0-9]:[0-5][0-9]\\.[0-9]{3}$");
QRegExpValidator *timeValidator = new QRegExpValidator(timeRegExp, this);
ui.currentTime->setValidator(timeValidator);
ui.currentTime->setInputMask("99:99:99.999");
#endif
// set the size of the current time display to fit the content
QString text = "00:00:00.000"; // Don't translate this.
#ifdef USE_CUSTOM_TIME_DISPLAY_FONT
ui.currentTime->setFont(QFont("ADM7SEG"));
#endif
ui.currentTime->setText(text); // Override ui translations to make sure we use point as decimal separator.
QRect ctrect = ui.currentTime->fontMetrics().boundingRect(text);
ui.currentTime->setFixedSize(1.15 * ctrect.width(), ui.currentTime->height());

text = QString("/ ") + text;
ui.totalTime->setText(text); // Override ui translations here too.

//connect(ui.currentTime, SIGNAL(editingFinished()), this, SLOT(currentTimeChanged()));

ui.currentTime->installEventFilter(this);
}

void MainWindow::timeDisplayContextMenu(QPoint pos)
{
if (!avifileinfo) return;

QMenu * menu = new QMenu();
QAction * selectEditorTimeAction = menu->addAction(QT_TRANSLATE_NOOP("qgui2","Editor time"));
selectEditorTimeAction->setCheckable(true);
selectEditorTimeAction->setChecked(timeDisplayMode==0);
QAction * selectRefTimeAction = menu->addAction(QT_TRANSLATE_NOOP("qgui2","Source time"));
selectRefTimeAction->setCheckable(true);
selectRefTimeAction->setChecked(timeDisplayMode==1);
menu->addSeparator();
QAction * copyTimestampAction = menu->addAction(QT_TRANSLATE_NOOP("qgui2","Copy timestamp"));

QAction* choosedAction = menu->exec(pos);

if (choosedAction)
{
if (choosedAction == selectEditorTimeAction)
{
timeDisplayMode = 0;
timeDisplayUpdate();
} else
if (choosedAction == selectRefTimeAction)
{
timeDisplayMode = 1;
timeDisplayUpdate();
} else
if (choosedAction == copyTimestampAction)
{
currentTimeToClipboard();
}
}

delete menu;
}

/**
* \fn checkChanged
* \brief the checkbox protecting timeshift value has changed
Expand Down Expand Up @@ -2228,6 +2331,14 @@ bool MainWindow::eventFilter(QObject* watched, QEvent* event)
}
}
break;
case QEvent::ContextMenu:
if (watched == ui.currentTime)
{
const QContextMenuEvent* const contextMenuEvent = static_cast<const QContextMenuEvent*>( event );
timeDisplayContextMenu(contextMenuEvent->globalPos());
return true;
}
break;
default:
break;
}
Expand Down Expand Up @@ -3278,14 +3389,7 @@ admUITaskBarProgress *UI_getTaskBarProgress()
*/
void UI_setCurrentTime(uint64_t curTime)
{
char text[80];
uint32_t mm,hh,ss,ms;
uint32_t shorty=(uint32_t)(curTime/1000);

ms2time(shorty,&hh,&mm,&ss,&ms);
sprintf(text, "%02d:%02d:%02d.%03d", hh, mm, ss, ms);
WIDGET(currentTime)->setText(text);

((MainWindow *)QuiMainWindows)->timeDisplaySetCurrentPts(curTime);
}

/**
Expand All @@ -3294,14 +3398,16 @@ void UI_setCurrentTime(uint64_t curTime)
*/
void UI_setTotalTime(uint64_t curTime)
{
char text[80];
uint32_t mm,hh,ss,ms;
uint32_t shorty=(uint32_t)(curTime/1000);

ms2time(shorty,&hh,&mm,&ss,&ms);
sprintf(text, "/ %02d:%02d:%02d.%03d", hh, mm, ss, ms);
WIDGET(totalTime)->setText(text);
slider->setTotalDuration(curTime);
((MainWindow *)QuiMainWindows)->timeDisplaySetTotalTime(curTime);
}
/**
\fn UI_setCurrentRefInfo
\brief Set the current reference PTS and video of the displayed video
*/
void UI_setCurrentRefInfo(uint64_t refPts, uint32_t refVideo)
{
((MainWindow *)QuiMainWindows)->timeDisplaySetRefInfo(refPts, refVideo);
}
/**
\fn UI_setSegments
Expand Down
11 changes: 11 additions & 0 deletions avidemux/qt4/ADM_userInterfaces/ADM_gui/Q_gui2.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,11 @@ class MainWindow : public QMainWindow

void setLightTheme(void);
void setDarkTheme(void);

void timeDisplaySetCurrentPts(uint64_t t);
void timeDisplaySetTotalTime(uint64_t t);
void timeDisplaySetRefInfo(uint64_t t, uint64_t v);


static void updateCheckDone(int version, const std::string &date, const std::string &downloadLink);
static MainWindow *mainWindowSingleton;
Expand Down Expand Up @@ -223,6 +228,12 @@ class MainWindow : public QMainWindow
QLabel * statusBarMessage;
int statusBarInfo_Zoom;
QString statusBarInfo_Display, statusBarInfo_Decoder;

int timeDisplayMode;
uint64_t timeDisplayCurrentPts, timeDisplayTotalTime, timeDisplayRefPts, timeDisplayRefVideo;
void timeDisplayInit(void);
void timeDisplayUpdate(void);
void timeDisplayContextMenu(QPoint pos);

private slots:
void timeChanged(int);
Expand Down
2 changes: 2 additions & 0 deletions avidemux_core/ADM_coreImage/include/ADM_image.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ class ADM_COREIMAGE6_EXPORT ADMImage
uint32_t _Qp; /// Average quantizer for this image
uint32_t flags; /// Flags for this image (AVI_KEY_FRAME/AVI_B_FRAME)
uint64_t Pts; /// Presentation time in us
uint64_t refPts;
uint32_t refVideo;
ADM_IMAGE_TYPE _imageType; /// Plain image or reference or vdpau wrapper
ADM_pixelFormat _pixfrmt; /// Pixel format we are moving, default is YV12
ADM_colorRange _range; /// MPEG or JPEG
Expand Down
2 changes: 2 additions & 0 deletions avidemux_core/ADM_coreImage/src/ADM_image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ ADMImage::ADMImage(uint32_t width, uint32_t height,ADM_IMAGE_TYPE type)
_colorTrc=ADM_COL_TRC_BT709;
_colorSpace=ADM_COL_SPC_BT709;
Pts=0;
refPts=0;
refVideo=0;
_imageType=type;
quant=NULL;
_qStride=0;
Expand Down
2 changes: 2 additions & 0 deletions avidemux_core/ADM_coreImage/src/ADM_imageOperation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ bool ADMImage::copyInfo(ADMImage *src)
flags=src->flags;
_aspect=src->_aspect;
Pts=src->Pts;
refPts=src->refPts;
refVideo=src->refVideo;
_range=src->_range;
_colorPrim=src->_colorPrim;
_colorTrc=src->_colorTrc;
Expand Down