From c5a6240a2b9a00f9cec2a5435ce9b803507f9315 Mon Sep 17 00:00:00 2001 From: adam Date: Sun, 29 Sep 2024 23:10:42 +0200 Subject: [PATCH 1/6] [ADMImage] add refPts and refVideo info fields --- avidemux_core/ADM_coreImage/include/ADM_image.h | 2 ++ avidemux_core/ADM_coreImage/src/ADM_image.cpp | 2 ++ avidemux_core/ADM_coreImage/src/ADM_imageOperation.cpp | 2 ++ 3 files changed, 6 insertions(+) diff --git a/avidemux_core/ADM_coreImage/include/ADM_image.h b/avidemux_core/ADM_coreImage/include/ADM_image.h index 8b0c57d5c..63f191aa4 100644 --- a/avidemux_core/ADM_coreImage/include/ADM_image.h +++ b/avidemux_core/ADM_coreImage/include/ADM_image.h @@ -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 diff --git a/avidemux_core/ADM_coreImage/src/ADM_image.cpp b/avidemux_core/ADM_coreImage/src/ADM_image.cpp index 971c70086..107814fa6 100644 --- a/avidemux_core/ADM_coreImage/src/ADM_image.cpp +++ b/avidemux_core/ADM_coreImage/src/ADM_image.cpp @@ -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; diff --git a/avidemux_core/ADM_coreImage/src/ADM_imageOperation.cpp b/avidemux_core/ADM_coreImage/src/ADM_imageOperation.cpp index 240e5bb65..739d4bdb7 100644 --- a/avidemux_core/ADM_coreImage/src/ADM_imageOperation.cpp +++ b/avidemux_core/ADM_coreImage/src/ADM_imageOperation.cpp @@ -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; From 0f841f4c37c012a62d8099514b5d0875efd064a4 Mon Sep 17 00:00:00 2001 From: adam Date: Sun, 29 Sep 2024 23:15:38 +0200 Subject: [PATCH 2/6] [ADM_edRender] set reference info of decoded image --- avidemux/common/ADM_editor/src/ADM_edRender.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/avidemux/common/ADM_editor/src/ADM_edRender.cpp b/avidemux/common/ADM_editor/src/ADM_edRender.cpp index 055cc07ed..caf6a542f 100644 --- a/avidemux/common/ADM_editor/src/ADM_edRender.cpp +++ b/avidemux/common/ADM_editor/src/ADM_edRender.cpp @@ -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; From bad391f9ae9c040bb429622a44a554b2b2972c23 Mon Sep 17 00:00:00 2001 From: adam Date: Sun, 29 Sep 2024 23:19:15 +0200 Subject: [PATCH 3/6] [ADM_preview] reference info getters --- avidemux/common/ADM_preview.h | 2 ++ avidemux/common/ADM_previewNavigate.cpp | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/avidemux/common/ADM_preview.h b/avidemux/common/ADM_preview.h index 6d59d2c5e..1ac6778bb 100644 --- a/avidemux/common/ADM_preview.h +++ b/avidemux/common/ADM_preview.h @@ -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); diff --git a/avidemux/common/ADM_previewNavigate.cpp b/avidemux/common/ADM_previewNavigate.cpp index 5e5c87c71..467f99038 100644 --- a/avidemux/common/ADM_previewNavigate.cpp +++ b/avidemux/common/ADM_previewNavigate.cpp @@ -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 From b75a7423a3f81a1cb4d05d73052190ec1179e80d Mon Sep 17 00:00:00 2001 From: adam Date: Sun, 29 Sep 2024 23:54:15 +0200 Subject: [PATCH 4/6] [Q_gui2] pass reference info to the GUI --- avidemux/cli/ADM_userInterfaces/ADM_gui2/gui_none.cpp | 3 +++ avidemux/common/ADM_commonUI/GUI_ui.h | 1 + avidemux/common/gui_navigate.cpp | 3 +++ avidemux/qt4/ADM_userInterfaces/ADM_gui/Q_gui2.cpp | 8 ++++++++ 4 files changed, 15 insertions(+) diff --git a/avidemux/cli/ADM_userInterfaces/ADM_gui2/gui_none.cpp b/avidemux/cli/ADM_userInterfaces/ADM_gui2/gui_none.cpp index 715dbf0f0..379a8f781 100644 --- a/avidemux/cli/ADM_userInterfaces/ADM_gui2/gui_none.cpp +++ b/avidemux/cli/ADM_userInterfaces/ADM_gui2/gui_none.cpp @@ -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) { } diff --git a/avidemux/common/ADM_commonUI/GUI_ui.h b/avidemux/common/ADM_commonUI/GUI_ui.h index 8a30ea90f..212109189 100644 --- a/avidemux/common/ADM_commonUI/GUI_ui.h +++ b/avidemux/common/ADM_commonUI/GUI_ui.h @@ -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 ); diff --git a/avidemux/common/gui_navigate.cpp b/avidemux/common/gui_navigate.cpp index 96bbddfd1..fcffd0547 100644 --- a/avidemux/common/gui_navigate.cpp +++ b/avidemux/common/gui_navigate.cpp @@ -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--; } @@ -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--; } @@ -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(); diff --git a/avidemux/qt4/ADM_userInterfaces/ADM_gui/Q_gui2.cpp b/avidemux/qt4/ADM_userInterfaces/ADM_gui/Q_gui2.cpp index e8e406284..32acfd0e6 100644 --- a/avidemux/qt4/ADM_userInterfaces/ADM_gui/Q_gui2.cpp +++ b/avidemux/qt4/ADM_userInterfaces/ADM_gui/Q_gui2.cpp @@ -3303,6 +3303,14 @@ void UI_setTotalTime(uint64_t curTime) WIDGET(totalTime)->setText(text); slider->setTotalDuration(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) +{ + //TODO +} /** \fn UI_setSegments \brief SEt segments boundaries From a30c82e5e51b7d39c6ce0e04e7ffa341671533ab Mon Sep 17 00:00:00 2001 From: adam Date: Mon, 30 Sep 2024 22:04:36 +0200 Subject: [PATCH 5/6] [Q_gui2] timeDisplay methods --- .../qt4/ADM_userInterfaces/ADM_gui/Q_gui2.cpp | 124 +++++++++++++----- .../qt4/ADM_userInterfaces/ADM_gui/Q_gui2.h | 10 ++ 2 files changed, 99 insertions(+), 35 deletions(-) diff --git a/avidemux/qt4/ADM_userInterfaces/ADM_gui/Q_gui2.cpp b/avidemux/qt4/ADM_userInterfaces/ADM_gui/Q_gui2.cpp index 32acfd0e6..2982dd86e 100644 --- a/avidemux/qt4/ADM_userInterfaces/ADM_gui/Q_gui2.cpp +++ b/avidemux/qt4/ADM_userInterfaces/ADM_gui/Q_gui2.cpp @@ -725,25 +725,9 @@ MainWindow::MainWindow(const vector& 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); @@ -1981,6 +1965,89 @@ 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())); +} + + /** * \fn checkChanged * \brief the checkbox protecting timeshift value has changed @@ -3278,14 +3345,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); } /** @@ -3294,14 +3354,8 @@ 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 @@ -3309,7 +3363,7 @@ void UI_setTotalTime(uint64_t curTime) */ void UI_setCurrentRefInfo(uint64_t refPts, uint32_t refVideo) { - //TODO + ((MainWindow *)QuiMainWindows)->timeDisplaySetRefInfo(refPts, refVideo); } /** \fn UI_setSegments diff --git a/avidemux/qt4/ADM_userInterfaces/ADM_gui/Q_gui2.h b/avidemux/qt4/ADM_userInterfaces/ADM_gui/Q_gui2.h index e369f04d7..c03644b27 100644 --- a/avidemux/qt4/ADM_userInterfaces/ADM_gui/Q_gui2.h +++ b/avidemux/qt4/ADM_userInterfaces/ADM_gui/Q_gui2.h @@ -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; @@ -223,6 +228,11 @@ 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); private slots: void timeChanged(int); From 63e920c7365b10c6ab01280f07a9353948e0c7c2 Mon Sep 17 00:00:00 2001 From: adam Date: Wed, 2 Oct 2024 20:01:14 +0200 Subject: [PATCH 6/6] [Q_gui2] customize time display context menu; add time display mode and simplified timestamp copy --- .../qt4/ADM_userInterfaces/ADM_gui/Q_gui2.cpp | 48 ++++++++++++++++++- .../qt4/ADM_userInterfaces/ADM_gui/Q_gui2.h | 1 + 2 files changed, 47 insertions(+), 2 deletions(-) diff --git a/avidemux/qt4/ADM_userInterfaces/ADM_gui/Q_gui2.cpp b/avidemux/qt4/ADM_userInterfaces/ADM_gui/Q_gui2.cpp index 2982dd86e..108f0ae22 100644 --- a/avidemux/qt4/ADM_userInterfaces/ADM_gui/Q_gui2.cpp +++ b/avidemux/qt4/ADM_userInterfaces/ADM_gui/Q_gui2.cpp @@ -798,8 +798,6 @@ MainWindow::MainWindow(const vector& scriptEngines) : _scriptEng this->installEventFilter(this); slider->installEventFilter(this); - //ui.currentTime->installEventFilter(this); - this->setFocus(Qt::OtherFocusReason); setAcceptDrops(true); @@ -2045,8 +2043,46 @@ void MainWindow::timeDisplayInit(void) 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 @@ -2295,6 +2331,14 @@ bool MainWindow::eventFilter(QObject* watched, QEvent* event) } } break; + case QEvent::ContextMenu: + if (watched == ui.currentTime) + { + const QContextMenuEvent* const contextMenuEvent = static_cast( event ); + timeDisplayContextMenu(contextMenuEvent->globalPos()); + return true; + } + break; default: break; } diff --git a/avidemux/qt4/ADM_userInterfaces/ADM_gui/Q_gui2.h b/avidemux/qt4/ADM_userInterfaces/ADM_gui/Q_gui2.h index c03644b27..024bbac7d 100644 --- a/avidemux/qt4/ADM_userInterfaces/ADM_gui/Q_gui2.h +++ b/avidemux/qt4/ADM_userInterfaces/ADM_gui/Q_gui2.h @@ -233,6 +233,7 @@ class MainWindow : public QMainWindow uint64_t timeDisplayCurrentPts, timeDisplayTotalTime, timeDisplayRefPts, timeDisplayRefVideo; void timeDisplayInit(void); void timeDisplayUpdate(void); + void timeDisplayContextMenu(QPoint pos); private slots: void timeChanged(int);