diff --git a/.github/workflows/Build.yml b/.github/workflows/Build.yml index 056775f9e..889c5c237 100644 --- a/.github/workflows/Build.yml +++ b/.github/workflows/Build.yml @@ -1,6 +1,10 @@ name: CI build -on: [push, release] +on: + push: + release: + types: + - created jobs: build-unix: @@ -77,7 +81,8 @@ jobs: cd build/YUViewApp # Zip zip -r ${{matrix.ARTIFACT_NAME}} YUView.app/ - cp ${{matrix.ARTIFACT_NAME}} $GITHUB_WORKSPACE/artifacts + mkdir $GITHUB_WORKSPACE/artifacts + cp ${{matrix.ARTIFACT_NAME}} $GITHUB_WORKSPACE/artifacts/ if: matrix.os == 'macos-10.15' - name: Build Appimage (Linux) run: | @@ -85,7 +90,12 @@ jobs: make INSTALL_ROOT=appdir install $GITHUB_WORKSPACE/linuxdeployqt-6-x86_64.AppImage YUViewApp/appdir/usr/local/share/applications/de.rwth_aachen.ient.YUView.desktop -appimage -bundle-non-qt-libs -verbose=2 mv YUView-*.AppImage YUView.AppImage - cp YUView.AppImage $GITHUB_WORKSPACE/artifacts + mkdir $GITHUB_WORKSPACE/artifacts + cp YUView.AppImage $GITHUB_WORKSPACE/artifacts/ + cd $GITHUB_WORKSPACE + ls -l + cd $GITHUB_WORKSPACE/artifacts + ls -l if: matrix.os == 'ubuntu-16.04' - name: Upload Artifact uses: actions/upload-artifact@v2 @@ -93,6 +103,16 @@ jobs: name: ${{matrix.ARTIFACT_NAME}} path: artifacts if: matrix.os != 'ubuntu-18.04' + - name: Upload Release + uses: actions/upload-release-asset@v1.0.1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ github.event.release.upload_url }} + asset_path: artifacts/${{matrix.ARTIFACT_NAME}} + asset_name: ${{matrix.ARTIFACT_NAME}} + asset_content_type: application/zip + if: github.event_name == 'release' && matrix.os != 'ubuntu-18.04' build-windows: runs-on: ${{ matrix.os }} strategy: @@ -107,7 +127,6 @@ jobs: steps: - uses: actions/checkout@v2 - run: git fetch --prune --unshallow - - uses: Dovyski/payload-info-action@master - name: Install Qt base run: | cd ../../ @@ -196,16 +215,28 @@ jobs: name: YUViewSetup.msi path: ./YUViewSetup.msi if: matrix.auto_update == true - - name: Upload Release + - name: Upload Windows zip to Release uses: actions/upload-release-asset@v1.0.1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ github.event.release.upload_url }} asset_path: artifacts/YUView-Win.zip - asset_name: YUView-Win.zip - asset_content_type: binary/octet-stream + asset_name: ${{matrix.ARTIFACT_NAME}} + asset_content_type: application/zip if: github.event_name == 'release' + - name: Upload Windows installer to Release + uses: actions/upload-release-asset@v1.0.1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ github.event.release.upload_url }} + asset_path: YUViewSetup.msi + asset_name: YUViewSetup.msi + asset_content_type: application/zip + if: github.event_name == 'release' && matrix.auto_update == true # How to upload files to the release: - # https://github.com/Blacksmoke16/oq/pull/47/files#diff-082c28d748ad2e3eecc5508d740d9417R9-R29 \ No newline at end of file + # https://github.com/Blacksmoke16/oq/pull/47/files#diff-082c28d748ad2e3eecc5508d740d9417R9-R29 + # Mime type list + # https://www.iana.org/assignments/media-types/media-types.xhtml diff --git a/YUViewLib/src/parser/common/SubByteReader.cpp b/YUViewLib/src/parser/common/SubByteReader.cpp index b8873a6c3..bea04310e 100644 --- a/YUViewLib/src/parser/common/SubByteReader.cpp +++ b/YUViewLib/src/parser/common/SubByteReader.cpp @@ -115,24 +115,24 @@ uint64_t SubByteReader::readBits64(int nrBits, QString &bitsRead) QByteArray SubByteReader::readBytes(int nrBytes) { - if (skipEmulationPrevention) - throw std::logic_error("Reading bytes with emulation prevention active is not supported."); if (posInBuffer_bits != 0 && posInBuffer_bits != 8) throw std::logic_error("When reading bytes from the bitstream, it should be byte alligned."); if (posInBuffer_bits == 8) - if (!gotoNextByte()) + if (!this->gotoNextByte()) // We are at the end of the buffer but we need to read more. Error. throw std::logic_error("Error while reading annexB file. Trying to read over buffer boundary."); QByteArray retArray; for (int i = 0; i < nrBytes; i++) { - if (posInBuffer_bytes >= (unsigned int)byteArray.size()) - throw std::logic_error("Error while reading annexB file. Trying to read over buffer boundary."); - retArray.append(byteArray[posInBuffer_bytes]); - posInBuffer_bytes++; + + if (!this->gotoNextByte()) + { + if (i < nrBytes - 1) + throw std::logic_error("Error while reading annexB file. Trying to read over buffer boundary."); + } } return retArray; @@ -322,7 +322,7 @@ bool SubByteReader::gotoNextByte() if (posInBuffer_bytes >= (unsigned int)byteArray.size()) // The next byte is outside of the current buffer. Error. - return false; + return false; if (skipEmulationPrevention) { diff --git a/YUViewLib/src/parser/parserAVFormat.cpp b/YUViewLib/src/parser/parserAVFormat.cpp index 6277815f8..675c621f0 100644 --- a/YUViewLib/src/parser/parserAVFormat.cpp +++ b/YUViewLib/src/parser/parserAVFormat.cpp @@ -622,7 +622,7 @@ bool parserAVFormat::runParsingOfFile(QString compressedFilePath) { // Open the file but don't parse it yet. QScopedPointer ffmpegFile(new fileSourceFFmpegFile()); - if (!ffmpegFile->openFile(compressedFilePath, nullptr, nullptr, false)) + if (!ffmpegFile->openFile(compressedFilePath, nullptr, nullptr, false)) { emit backgroundParsingDone("Error opening the ffmpeg file."); return false; @@ -650,12 +650,26 @@ bool parserAVFormat::runParsingOfFile(QString compressedFilePath) // ffmpegFile->seekFileToBeginning(); // First get the extradata and push it to the parser - QByteArray extradata = ffmpegFile->getExtradata(); - parseExtradata(extradata); - - // Parse the metadata - QStringPairList metadata = ffmpegFile->getMetadata(); - parseMetadata(metadata); + try + { + QByteArray extradata = ffmpegFile->getExtradata(); + parseExtradata(extradata); + } + catch (...) + { + emit backgroundParsingDone("Error parsing Extradata from container"); + return false; + } + try + { + QStringPairList metadata = ffmpegFile->getMetadata(); + parseMetadata(metadata); + } + catch (...) + { + emit backgroundParsingDone("Error parsing Metadata from container"); + return false; + } // After opening the file, we can get information on it streamInfoAllStreams = ffmpegFile->getFileInfoForAllStreams(); diff --git a/YUViewLib/src/ui/bitstreamAnalysisWidget.cpp b/YUViewLib/src/ui/bitstreamAnalysisWidget.cpp index 7d4284d37..23a9be567 100644 --- a/YUViewLib/src/ui/bitstreamAnalysisWidget.cpp +++ b/YUViewLib/src/ui/bitstreamAnalysisWidget.cpp @@ -184,7 +184,6 @@ void BitstreamAnalysisWidget::restartParsingOfCurrentItem() this->ui.streamInfoTreeWidget->clear(); this->ui.dataTreeView->setModel(nullptr); this->ui.plotViewWidget->setModel(nullptr); - this->parser.reset(); return; } diff --git a/YUViewLib/src/ui/views/MoveAndZoomableView.h b/YUViewLib/src/ui/views/MoveAndZoomableView.h index 4440c17a0..2f2e29ac4 100644 --- a/YUViewLib/src/ui/views/MoveAndZoomableView.h +++ b/YUViewLib/src/ui/views/MoveAndZoomableView.h @@ -148,6 +148,8 @@ protected slots: const QPen ZOOM_RECT_PEN = QPen(QColor(50, 50, 255, 150)); const QBrush ZOOM_RECT_BRUSH = QBrush(QColor(50, 50, 255, 50)); + virtual void getStateFromMaster(); + private: QPoint viewDraggingMousePosStart; QPoint viewDraggingStartOffset; @@ -161,5 +163,4 @@ protected slots: void slaveSetZoomFactor(double zoom); //void slaveSetPinchValues(double scaleFactor, QPointF centerPointOffset); void slaveUpdateWidget(); - void getStateFromMaster(); }; diff --git a/YUViewLib/src/ui/views/splitViewWidget.cpp b/YUViewLib/src/ui/views/splitViewWidget.cpp index abca50043..ff5723ba9 100644 --- a/YUViewLib/src/ui/views/splitViewWidget.cpp +++ b/YUViewLib/src/ui/views/splitViewWidget.cpp @@ -183,10 +183,8 @@ void splitViewWidget::paintEvent(QPaintEvent *paint_event) painter.fillRect(boxRect,Qt::white); painter.drawRect(boxRect); - // Draw the text painter.drawText(textRect, Qt::AlignCenter, text); - // Update the mouse cursor MoveAndZoomableView::updateMouseCursor(); return; @@ -480,7 +478,6 @@ void splitViewWidget::paintEvent(QPaintEvent *paint_event) painter.drawPixmap(pos, waitingForCachingPixmap); } - // Update the mouse cursor MoveAndZoomableView::updateMouseCursor(); if (testMode) @@ -540,6 +537,7 @@ void splitViewWidget::updatePixelPositions() // We now have the pixel difference value for the item under the cursor. // We now draw one zoom box per view const auto viewNum = (isSplitting() && item[1]) ? 2 : 1; + QPoint positions[2]; for (int view = 0; view < viewNum; view++) { // Get the size of the item @@ -556,12 +554,26 @@ void splitViewWidget::updatePixelPositions() if (pixelPoxY < 0) pixelPoxY -= 1; - zoomBoxPixelUnderCursor[view] = QPoint(pixelPosX, pixelPoxY); + positions[view] = QPoint(pixelPosX, pixelPoxY); } } + + setZoomBoxPixelUnderCursor(positions[0], positions[1], true); } } +void splitViewWidget::setZoomBoxPixelUnderCursor(QPoint posA, QPoint posB, bool setOtherViewIfLinked, bool callUpdate) +{ + if (this->enableLink && setOtherViewIfLinked) + this->getOtherWidget()->setZoomBoxPixelUnderCursor(posA, posB, false, true); + + this->zoomBoxPixelUnderCursor[0] = posA; + this->zoomBoxPixelUnderCursor[1] = posB; + + if (callUpdate) + update(); +} + void splitViewWidget::paintZoomBox(int view, QPainter &painter, int xSplit, const QPoint &drawArea_botR, playlistItem *item, int frame, const QPoint &pixelPos, bool pixelPosInItem, double zoomFactor, bool playing) { if (!this->drawZoomBox) @@ -688,6 +700,20 @@ void splitViewWidget::paintZoomBox(int view, QPainter &painter, int xSplit, cons } } +void splitViewWidget::setDrawZoomBox(bool drawZoomBox, bool setOtherViewIfLinked, bool callUpdate) +{ + if (this->enableLink && setOtherViewIfLinked) + this->getOtherWidget()->setDrawZoomBox(drawZoomBox, false, callUpdate); + + this->drawZoomBox = drawZoomBox; + QSignalBlocker actionZoomBoxBlocker(this->actionZoomBox); + this->actionZoomBox.setChecked(drawZoomBox); + this->updateMouseTracking(); + + if (callUpdate) + update(); +} + void splitViewWidget::paintRegularGrid(QPainter *painter, playlistItem *item) { if (regularGridSize == 0) @@ -864,6 +890,8 @@ void splitViewWidget::mouseMoveEvent(QMouseEvent *mouse_event) update(); } + + MoveAndZoomableView::updateMouseCursor(); } void splitViewWidget::mousePressEvent(QMouseEvent *mouse_event) @@ -1002,6 +1030,14 @@ void splitViewWidget::setZoomFactor(double zoom) } } +void splitViewWidget::updateMouseTracking() +{ + if (isViewFrozen) + this->setMouseTracking(false); + else + this->setMouseTracking(viewSplitMode != DISABLED || this->drawZoomBox); +} + bool splitViewWidget::updateMouseCursor(const QPoint &mousePos) { if (!MoveAndZoomableView::updateMouseCursor(mousePos)) @@ -1061,10 +1097,8 @@ void splitViewWidget::gridSetCustom(bool checked) void splitViewWidget::toggleZoomBox(bool checked) { - Q_UNUSED(checked); - this->drawZoomBox = !this->drawZoomBox; - this->setMouseTracking(this->drawZoomBox); - update(); + Q_UNUSED(checked); + this->setDrawZoomBox(!this->drawZoomBox, true, true); } void splitViewWidget::toggleSeparateWindow(bool checked) @@ -1197,6 +1231,8 @@ void splitViewWidget::setViewSplitMode(ViewSplitMode mode, bool setOtherViewIfLi QSignalBlocker actionSplitViewBlocker(actionSplitView[i]); actionSplitView[i].setChecked(viewSplitMode == ViewSplitMode(i)); } + + this->updateMouseTracking(); if (callUpdate) update(); @@ -1408,7 +1444,7 @@ void splitViewWidget::freezeView(bool freeze) { // View is frozen and should be unfrozen isViewFrozen = false; - setMouseTracking(true); + this->updateMouseTracking(); update(); } if (!isViewFrozen && freeze) @@ -1418,7 +1454,7 @@ void splitViewWidget::freezeView(bool freeze) if (this->isMasterView && isSeparateViewEnabled && !playbackPrimary) { isViewFrozen = true; - setMouseTracking(false); + this->updateMouseTracking(); update(); } } @@ -1792,3 +1828,17 @@ QPointer splitViewWidget::getOtherWidget() const return QPointer(qobject_cast(this->masterView)); } } + +void splitViewWidget::getStateFromMaster() +{ + const auto mainView = this->getOtherWidget(); + this->setViewSplitMode(mainView->viewSplitMode, false); + this->setSplittingPoint(mainView->splittingPoint, false); + this->setRegularGridSize(mainView->regularGridSize, false); + this->setDrawZoomBox(mainView->drawZoomBox, false); + + this->updateMouseTracking(); + update(); + + MoveAndZoomableView::getStateFromMaster(); +} diff --git a/YUViewLib/src/ui/views/splitViewWidget.h b/YUViewLib/src/ui/views/splitViewWidget.h index a33967e2b..3d8b75229 100644 --- a/YUViewLib/src/ui/views/splitViewWidget.h +++ b/YUViewLib/src/ui/views/splitViewWidget.h @@ -172,6 +172,7 @@ private slots: QAction actionSeparateViewPlaybackBoth; QAction actionZoomBox; + void updateMouseTracking(); virtual bool updateMouseCursor(const QPoint &srcMousePos) override; // When the splitView is set as a center widget this will assert that after the adding operation the widget will have a @@ -202,9 +203,11 @@ private slots: QPoint zoomBoxMousePosition; //!< If we are drawing the zoom box(es) we have to know where the mouse currently is. QColor zoomBoxBackgroundColor; //!< The color of the zoom box background (read from settings) void paintZoomBox(int view, QPainter &painter, int xSplit, const QPoint &drawArea_botR, playlistItem *item, int frame, const QPoint &pixelPos, bool pixelPosInItem, double zoomFactor, bool playing); + void setDrawZoomBox(bool drawZoomBox, bool setOtherViewIfLinked = true, bool callUpdate = false); //!< Using the current mouse position, calculate the position in the items under the mouse (per view) void updatePixelPositions(); + void setZoomBoxPixelUnderCursor(QPoint posA, QPoint posB, bool setOtherViewIfLinked = true, bool callUpdate = false); QPoint zoomBoxPixelUnderCursor[2]; //!< The above function will update this. (The position of the pixel under the cursor (per item)) // Regular grid @@ -264,6 +267,7 @@ private slots: void testFinished(bool canceled); //< Report the test results and stop the testProgrssUpdateTimer QPointer getOtherWidget() const; + void getStateFromMaster() override; }; #endif // SPLITVIEWWIDGET_H diff --git a/YUViewLib/src/video/videoHandlerRGB.cpp b/YUViewLib/src/video/videoHandlerRGB.cpp index faa73a62a..5241e3a40 100644 --- a/YUViewLib/src/video/videoHandlerRGB.cpp +++ b/YUViewLib/src/video/videoHandlerRGB.cpp @@ -1023,15 +1023,15 @@ QImage videoHandlerRGB::calculateDifference(frameHandler *item2, const int frame unsigned short *srcR1, *srcG1, *srcB1; if (srcPixelFormat.planar) { - srcR1 = (unsigned short*)rgbItem2->currentFrameRawData.data() + (srcPixelFormat.posR * frameSize.width() * frameSize.height()); - srcG1 = (unsigned short*)rgbItem2->currentFrameRawData.data() + (srcPixelFormat.posG * frameSize.width() * frameSize.height()); - srcB1 = (unsigned short*)rgbItem2->currentFrameRawData.data() + (srcPixelFormat.posB * frameSize.width() * frameSize.height()); + srcR1 = (unsigned short*)rgbItem2->currentFrameRawData.data() + (rgbItem2->srcPixelFormat.posR * rgbItem2->frameSize.width() * rgbItem2->frameSize.height()); + srcG1 = (unsigned short*)rgbItem2->currentFrameRawData.data() + (rgbItem2->srcPixelFormat.posG * rgbItem2->frameSize.width() * rgbItem2->frameSize.height()); + srcB1 = (unsigned short*)rgbItem2->currentFrameRawData.data() + (rgbItem2->srcPixelFormat.posB * rgbItem2->frameSize.width() * rgbItem2->frameSize.height()); } else { - srcR1 = (unsigned short*)rgbItem2->currentFrameRawData.data() + srcPixelFormat.posR; - srcG1 = (unsigned short*)rgbItem2->currentFrameRawData.data() + srcPixelFormat.posG; - srcB1 = (unsigned short*)rgbItem2->currentFrameRawData.data() + srcPixelFormat.posB; + srcR1 = (unsigned short*)rgbItem2->currentFrameRawData.data() + rgbItem2->srcPixelFormat.posR; + srcG1 = (unsigned short*)rgbItem2->currentFrameRawData.data() + rgbItem2->srcPixelFormat.posG; + srcB1 = (unsigned short*)rgbItem2->currentFrameRawData.data() + rgbItem2->srcPixelFormat.posB; } for (int y = 0; y < height; y++) @@ -1096,15 +1096,15 @@ QImage videoHandlerRGB::calculateDifference(frameHandler *item2, const int frame unsigned char *srcR1, *srcG1, *srcB1; if (srcPixelFormat.planar) { - srcR1 = (unsigned char*)rgbItem2->currentFrameRawData.data() + (srcPixelFormat.posR * frameSize.width() * frameSize.height()); - srcG1 = (unsigned char*)rgbItem2->currentFrameRawData.data() + (srcPixelFormat.posG * frameSize.width() * frameSize.height()); - srcB1 = (unsigned char*)rgbItem2->currentFrameRawData.data() + (srcPixelFormat.posB * frameSize.width() * frameSize.height()); + srcR1 = (unsigned char*)rgbItem2->currentFrameRawData.data() + (rgbItem2->srcPixelFormat.posR * rgbItem2->frameSize.width() * rgbItem2->frameSize.height()); + srcG1 = (unsigned char*)rgbItem2->currentFrameRawData.data() + (rgbItem2->srcPixelFormat.posG * rgbItem2->frameSize.width() * rgbItem2->frameSize.height()); + srcB1 = (unsigned char*)rgbItem2->currentFrameRawData.data() + (rgbItem2->srcPixelFormat.posB * rgbItem2->frameSize.width() * rgbItem2->frameSize.height()); } else { - srcR1 = (unsigned char*)rgbItem2->currentFrameRawData.data() + srcPixelFormat.posR; - srcG1 = (unsigned char*)rgbItem2->currentFrameRawData.data() + srcPixelFormat.posG; - srcB1 = (unsigned char*)rgbItem2->currentFrameRawData.data() + srcPixelFormat.posB; + srcR1 = (unsigned char*)rgbItem2->currentFrameRawData.data() + rgbItem2->srcPixelFormat.posR; + srcG1 = (unsigned char*)rgbItem2->currentFrameRawData.data() + rgbItem2->srcPixelFormat.posG; + srcB1 = (unsigned char*)rgbItem2->currentFrameRawData.data() + rgbItem2->srcPixelFormat.posB; } for (int y = 0; y < height; y++) diff --git a/YUViewLib/src/video/videoHandlerYUV.cpp b/YUViewLib/src/video/videoHandlerYUV.cpp index 0c3788a1a..fc2d0eaaa 100644 --- a/YUViewLib/src/video/videoHandlerYUV.cpp +++ b/YUViewLib/src/video/videoHandlerYUV.cpp @@ -34,7 +34,9 @@ #include #include +#if SSE_CONVERSION_420_ALT #include +#endif #include #include