├── .gitignore ├── .travis.yml ├── README.md ├── apache_license_2.txt ├── bundle └── linux │ ├── bdsup2sub++.desktop │ └── bdsup2subpp.png ├── src ├── Filters │ ├── bellfilter.cpp │ ├── bellfilter.h │ ├── bicubicfilter.cpp │ ├── bicubicfilter.h │ ├── bsplinefilter.cpp │ ├── bsplinefilter.h │ ├── filter.h │ ├── filterop.cpp │ ├── filterop.h │ ├── filters.cpp │ ├── filters.h │ ├── hermitefilter.cpp │ ├── hermitefilter.h │ ├── lanczos3filter.cpp │ ├── lanczos3filter.h │ ├── mitchellfilter.cpp │ ├── mitchellfilter.h │ ├── trianglefilter.cpp │ └── trianglefilter.h ├── Subtitles │ ├── bitmap.cpp │ ├── bitmap.h │ ├── erasepatch.cpp │ ├── erasepatch.h │ ├── imageobject.cpp │ ├── imageobject.h │ ├── imageobjectfragment.cpp │ ├── imageobjectfragment.h │ ├── palette.cpp │ ├── palette.h │ ├── palettebitmap.cpp │ ├── palettebitmap.h │ ├── paletteinfo.cpp │ ├── paletteinfo.h │ ├── subdvd.cpp │ ├── subdvd.h │ ├── subpicture.cpp │ ├── subpicture.h │ ├── subpicturebd.cpp │ ├── subpicturebd.h │ ├── subpicturedvd.cpp │ ├── subpicturedvd.h │ ├── subpicturehd.cpp │ ├── subpicturehd.h │ ├── subpicturexml.cpp │ ├── subpicturexml.h │ ├── substream.h │ ├── substreamdvd.cpp │ ├── substreamdvd.h │ ├── subtitleprocessor.cpp │ ├── subtitleprocessor.h │ ├── supbd.cpp │ ├── supbd.h │ ├── supdvd.cpp │ ├── supdvd.h │ ├── suphd.cpp │ ├── suphd.h │ ├── supxml.cpp │ └── supxml.h ├── Tools │ ├── bitstream.cpp │ ├── bitstream.h │ ├── filebuffer.cpp │ ├── filebuffer.h │ ├── hr_time.cpp │ ├── hr_time.h │ ├── numberutil.cpp │ ├── numberutil.h │ ├── quantizefilter.cpp │ ├── quantizefilter.h │ ├── timeutil.cpp │ └── timeutil.h ├── bdsup2sub++.pro ├── bdsup2sub.cpp ├── bdsup2sub.h ├── bdsup2sub.icns ├── bdsup2sub.ico ├── bdsup2sub.qrc ├── bdsup2sub.rc ├── bdsup2sub.ui ├── colordialog.cpp ├── colordialog.h ├── colordialog.ui ├── conversiondialog.cpp ├── conversiondialog.h ├── conversiondialog.ui ├── editdialog.cpp ├── editdialog.h ├── editdialog.ui ├── editpane.cpp ├── editpane.h ├── exportdialog.cpp ├── exportdialog.h ├── exportdialog.ui ├── framepalettedialog.cpp ├── framepalettedialog.h ├── framepalettedialog.ui ├── help.htm ├── help.ini ├── helpdialog.cpp ├── helpdialog.h ├── helpdialog.ui ├── main.cpp ├── movedialog.cpp ├── movedialog.h ├── movedialog.ui ├── progressdialog.cpp ├── progressdialog.h ├── progressdialog.ui ├── qxtcommandoptions.cpp ├── qxtcommandoptions.h ├── qxtglobal.cpp ├── qxtglobal.h ├── types.h ├── zoomableimagearea.cpp └── zoomableimagearea.h └── tools └── linuxdeployqt.AppImage /.gitignore: -------------------------------------------------------------------------------- 1 | # filename without suffix 2 | /bdsup2sub++ 3 | /src/bdsup2sub++ 4 | 5 | # Compiled Object files 6 | *.slo 7 | *.lo 8 | *.o 9 | *.obj 10 | 11 | # Precompiled Headers 12 | *.gch 13 | *.pch 14 | 15 | # Compiled Dynamic libraries 16 | *.so 17 | *.so.* 18 | *.dylib 19 | *.dll 20 | 21 | # Compiled Static libraries 22 | *.lai 23 | *.la 24 | *.a 25 | *.lib 26 | 27 | # Executables 28 | *.exe 29 | *.out 30 | *.app 31 | *.i*86 32 | *.x86_64 33 | *.hex 34 | 35 | # Backup files 36 | *~ 37 | *.bak 38 | *.old 39 | 40 | # Kate swap files 41 | .*.kate-swp 42 | .swp.* 43 | 44 | # Qt 45 | /.qmake.cache 46 | /.qmake.stash 47 | *.pro.user 48 | *.pro.user.* 49 | *.qbs.user 50 | *.qbs.user.* 51 | *.moc 52 | moc_*.cpp 53 | qrc_*.cpp 54 | ui_*.h 55 | Makefile* 56 | *-build-* 57 | *.autosave 58 | *.qmlproject.user 59 | *.qmlproject.user.* 60 | 61 | # KDE directory preferences 62 | .directory 63 | 64 | # OSX config files 65 | .DS_Store 66 | .AppleDouble 67 | .LSOverride 68 | 69 | # OSX thumbnail cache 70 | ._* 71 | 72 | # Windows image file caches 73 | Thumbs.db 74 | ehthumbs.db 75 | 76 | # Windows folder config file 77 | Desktop.ini 78 | 79 | # Windows shortcuts 80 | *.lnk 81 | 82 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: cpp 2 | compiler: gcc 3 | sudo: required 4 | dist: trusty 5 | 6 | addons: 7 | apt: 8 | sources: 9 | - ubuntu-toolchain-r-test 10 | packages: 11 | - gcc-7 12 | - g++-7 13 | 14 | before_install: 15 | - sudo add-apt-repository --yes ppa:beineri/opt-qt-5.10.1-trusty 16 | - sudo apt-get update -qq 17 | 18 | install: 19 | - sudo apt-get -y install qt510-meta-minimal 20 | 21 | script: 22 | # Link gcc-7 and g++-7 to their standard commands 23 | - sudo ln -s /usr/bin/gcc-7 /usr/local/bin/gcc 24 | - sudo ln -s /usr/bin/g++-7 /usr/local/bin/g++ 25 | # Export CC and CXX to tell cmake which compiler to use 26 | - export CC=/usr/bin/gcc-7 27 | - export CXX=/usr/bin/g++-7 28 | - source /opt/qt510/bin/qt510-env.sh 29 | - cd src 30 | - /opt/qt510/bin/qmake -project 31 | - /opt/qt510/bin/qmake bdsup2sub++.pro 32 | - make 33 | # Generate app image 34 | - if [ "$TRAVIS_OS_NAME" != "linux" ] ; then exit 0 ; fi 35 | - cd .. 36 | - mkdir dist 37 | - cp bundle/linux/* dist/ 38 | - mv src/bdsup2sub++ dist/ 39 | - chmod a+x tools/linuxdeployqt.AppImage 40 | - ./tools/linuxdeployqt.AppImage dist/bdsup2sub++ -appimage -bundle-non-qt-libs -verbose=2 41 | 42 | deploy: 43 | skip_cleanup: true 44 | provider: releases 45 | api-key: 46 | secure: ugNrU8zVluFmZfI26db09Tq4qGRDCcKjALlm5Y76Q+evTmQePKSJ4AVqzPz5TEzwuv0NVnbr7WYEMcBBglrSw1+HcXReaz33oAKZw9SVWm8XacjAU9TxHNvbtSOjDdd53o53fxxXHToaMe/m7NPJHnZBY6MAOeHUu/MNGYNniaVlpt8cE5NGJKd1KTytKMSGXmBKlPOJL/abkflFxNPs4DUXPf1JuRqVowU+RtprPtHKU0H1OrdjwCrdrfudwHPykIUDoW15JEqtdRqIQvvLfnwp+vjzK7JtOHIF3vdNcO4amDFUaDjPoZ7RAef/NHUgSG1km6srmYs0h08oTLuV1E6dANg3J/h3dlQV1WYte4H28g8hzjDhZZRPqYn2EvuQQWMo2LU7+e+e0inySLA32NRLhVZ4RdXDWvZCv/+yb3imNn4kB7nPvJnc1KP8l7bRXs7r4WEdGdMYhr5KlyhYq3iKM9CYfDwPLUx/P0+u8AlHgjsLcjftGkNZH7c9QTCNeIhtxJqlLruVerkexTX/VMkIteq70boCz8FqSyADnxIOoFfwfqnVJPNtPqD2iw7mktViGlKNz+Q0AjIU7BJCUNtb7iHirjjBvnqWiKEdhPWFOkuSHlaVKINO2HrQ8sMIYdspOMNuktpiRHvizVWg1COJ5uUF4IL5FFirql+ZSWs= 47 | file: BDSup2Sub++-x86_64.AppImage 48 | on: 49 | repo: amichaeltm/BDSup2SubPlusPlus 50 | tags: true 51 | 52 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Build Status](https://travis-ci.org/amichaeltm/BDSup2SubPlusPlus.svg?branch=master)](https://travis-ci.org/amichaeltm/BDSup2SubPlusPlus) 2 | 3 | BDSup2Sub++ 4 | =========== 5 | 6 | BDSup2Sub++ (c) 2012 is a port of the original BDSup2Sub (c) 2009 by 0xdeadbeef and incorporating enhancements from Miklos Juhasz. It is a subtitle conversion tool for image based stream formats with scaling capabilities and some other nice features. 7 | 8 | Current maintainer is paradoxic4l. 9 | -------------------------------------------------------------------------------- /bundle/linux/bdsup2sub++.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Name=BDSup2Sub++ 3 | GenericName=Bitmap subtitles editor 4 | Comment=Convert and tweak bitmap subtitles 5 | Exec=bdsup2sub++ 6 | Terminal=false 7 | StartupNotify=true 8 | Type=Application 9 | Categories=AudioVideo;AudioVideoEditing; 10 | Icon=bdsup2subpp -------------------------------------------------------------------------------- /bundle/linux/bdsup2subpp.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amichaeltm/BDSup2SubPlusPlus/5f8c159d2fed0ae1726718121f49d30e0821f398/bundle/linux/bdsup2subpp.png -------------------------------------------------------------------------------- /src/Filters/bellfilter.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * BDSup2Sub++ (C) 2012 Adam T. 3 | * Based on code from BDSup2Sub by Copyright 2009 Volker Oth (0xdeadbeef) 4 | * and Copyright 2012 Miklos Juhasz (mjuhasz) 5 | * 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #include "bellfilter.h" 21 | #include 22 | 23 | float BellFilter::value(float value) 24 | { 25 | value = std::abs(value); 26 | if (value < 0.5f) 27 | { 28 | return 0.75f - (value * value); 29 | } 30 | if (value < 1.5f) 31 | { 32 | value = value - 1.5f; 33 | return 0.5f * (value * value); 34 | } 35 | return 0.0; 36 | } 37 | -------------------------------------------------------------------------------- /src/Filters/bellfilter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BDSup2Sub++ (C) 2012 Adam T. 3 | * Based on code from BDSup2Sub by Copyright 2009 Volker Oth (0xdeadbeef) 4 | * and Copyright 2012 Miklos Juhasz (mjuhasz) 5 | * 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #ifndef BELLFILTER_H 21 | #define BELLFILTER_H 22 | 23 | #include "filter.h" 24 | 25 | class BellFilter : public Filter 26 | { 27 | public: 28 | float radius() { return 1.5f; } 29 | float value(float value); 30 | }; 31 | 32 | #endif // BELLFILTER_H 33 | -------------------------------------------------------------------------------- /src/Filters/bicubicfilter.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * BDSup2Sub++ (C) 2012 Adam T. 3 | * Based on code from BDSup2Sub by Copyright 2009 Volker Oth (0xdeadbeef) 4 | * and Copyright 2012 Miklos Juhasz (mjuhasz) 5 | * 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #include "bicubicfilter.h" 21 | #include 22 | 23 | float BiCubicFilter::value(float value) 24 | { 25 | if (value == 0.0f) 26 | { 27 | return 1.0f; 28 | } 29 | value = std::abs(value); 30 | float value_squared = value * value; 31 | if (value < 1.0f) 32 | { 33 | return (((a_plus_2 * value_squared) * value) - (a_plus_3 * value_squared)) + 1.0f; 34 | } 35 | if (value < 2.0f) 36 | { 37 | return ((a * value_squared) * value) - (a_times_5 * value_squared) + (a_times_8 * value) - a_times_4; 38 | } 39 | return 0.0f; 40 | } 41 | -------------------------------------------------------------------------------- /src/Filters/bicubicfilter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BDSup2Sub++ (C) 2012 Adam T. 3 | * Based on code from BDSup2Sub by Copyright 2009 Volker Oth (0xdeadbeef) 4 | * and Copyright 2012 Miklos Juhasz (mjuhasz) 5 | * 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #ifndef BICUBICFILTER_H 21 | #define BICUBICFILTER_H 22 | 23 | #include "filter.h" 24 | 25 | class BiCubicFilter : public Filter 26 | { 27 | public: 28 | float radius() { return 2.0f; } 29 | float value(float value); 30 | 31 | protected: 32 | static constexpr float a = -0.5; 33 | static constexpr float a_plus_2 = a + 2.0f; 34 | static constexpr float a_plus_3 = a + 3.0f; 35 | static constexpr float a_times_4 = a * 4; 36 | static constexpr float a_times_5 = a * 5; 37 | static constexpr float a_times_8 = a * 8; 38 | }; 39 | 40 | #endif // BICUBICFILTER_H 41 | -------------------------------------------------------------------------------- /src/Filters/bsplinefilter.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * BDSup2Sub++ (C) 2012 Adam T. 3 | * Based on code from BDSup2Sub by Copyright 2009 Volker Oth (0xdeadbeef) 4 | * and Copyright 2012 Miklos Juhasz (mjuhasz) 5 | * 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #include "bsplinefilter.h" 21 | #include 22 | 23 | float BSplineFilter::value(float value) 24 | { 25 | value = std::abs(value); 26 | if (value < 1.0f) 27 | { 28 | float tt = value * value; 29 | return 0.5f * tt * value - tt + (2.0f / 3.0f); 30 | } 31 | if (value < 2.0f) 32 | { 33 | value = 2.0f - value; 34 | return (1.0f / 6.0f) * value * value * value; 35 | } 36 | return 0.0f; 37 | } 38 | -------------------------------------------------------------------------------- /src/Filters/bsplinefilter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BDSup2Sub++ (C) 2012 Adam T. 3 | * Based on code from BDSup2Sub by Copyright 2009 Volker Oth (0xdeadbeef) 4 | * and Copyright 2012 Miklos Juhasz (mjuhasz) 5 | * 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #ifndef BSPLINEFILTER_H 21 | #define BSPLINEFILTER_H 22 | 23 | #include "filter.h" 24 | 25 | class BSplineFilter : public Filter 26 | { 27 | public: 28 | float radius() { return 2.0f; } 29 | float value(float value); 30 | 31 | static constexpr float two_thirds = 2.0f / 3.0f; 32 | static constexpr float one_sixth = 1.0f / 6.0f; 33 | }; 34 | 35 | #endif // BSPLINEFILTER_H 36 | -------------------------------------------------------------------------------- /src/Filters/filter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BDSup2Sub++ (C) 2012 Adam T. 3 | * Based on code from BDSup2Sub by Copyright 2009 Volker Oth (0xdeadbeef) 4 | * and Copyright 2012 Miklos Juhasz (mjuhasz) 5 | * 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #ifndef FILTER_H 21 | #define FILTER_H 22 | 23 | class Filter 24 | { 25 | public: 26 | virtual float radius() = 0; 27 | virtual float value(float value) = 0; 28 | }; 29 | 30 | #endif // FILTER_H 31 | -------------------------------------------------------------------------------- /src/Filters/filterop.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BDSup2Sub++ (C) 2012 Adam T. 3 | * Based on code from BDSup2Sub by Copyright 2009 Volker Oth (0xdeadbeef) 4 | * and Copyright 2012 Miklos Juhasz (mjuhasz) 5 | * 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #ifndef FILTEROP_H 21 | #define FILTEROP_H 22 | 23 | #include 24 | #include 25 | 26 | class Bitmap; 27 | class Filter; 28 | class Palette; 29 | class QImage; 30 | 31 | class FilterOp 32 | { 33 | public: 34 | FilterOp(Filter& filter); 35 | 36 | QVector filter(Bitmap &src, Palette &palette, int w, int h); 37 | 38 | class SubSamplingData { 39 | public: 40 | SubSamplingData() { } 41 | SubSamplingData(QVector& s, QVector& p, QVector& w, int width) : 42 | matrixWidth(width), 43 | numberOfSamples(s), 44 | pixelPositions(p), 45 | weights(w) 46 | { } 47 | int matrixWidth = 0; 48 | QVector numberOfSamples; 49 | QVector pixelPositions; 50 | QVector weights; 51 | }; 52 | 53 | private: 54 | int srcWidth = 0; 55 | int srcHeight = 0; 56 | int dstWidth = 0; 57 | int dstHeight = 0; 58 | 59 | Filter& internalFilter; 60 | 61 | SubSamplingData horizontalSubsamplingData; 62 | SubSamplingData verticalSubsamplingData; 63 | 64 | void filterVertically(QVector& src, QVector& trg); 65 | void filterHorizontally(QImage &src, QRgb *trg, const QRgb *rgba); 66 | 67 | SubSamplingData createSubSampling(int srcSize, int dstSize, float scale); 68 | }; 69 | 70 | #endif // FILTEROP_H 71 | -------------------------------------------------------------------------------- /src/Filters/filters.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * BDSup2Sub++ (C) 2012 Adam T. 3 | * Based on code from BDSup2Sub by Copyright 2009 Volker Oth (0xdeadbeef) 4 | * and Copyright 2012 Miklos Juhasz (mjuhasz) 5 | * 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #include "types.h" 21 | #include "filters.h" 22 | #include "bellfilter.h" 23 | #include "bicubicfilter.h" 24 | #include "bsplinefilter.h" 25 | #include "hermitefilter.h" 26 | #include "lanczos3filter.h" 27 | #include "mitchellfilter.h" 28 | #include "trianglefilter.h" 29 | 30 | BellFilter* bellFilter = 0; 31 | BiCubicFilter* biCubicFilter = 0; 32 | BSplineFilter* bSplineFilter = 0; 33 | HermiteFilter* hermiteFilter = 0; 34 | Lanczos3Filter* lanczos3Filter = 0; 35 | MitchellFilter* mitchellFilter = 0; 36 | TriangleFilter* triangleFilter = 0; 37 | 38 | Filter *Filters::getFilter(ScalingFilters scalingFilter) 39 | { 40 | switch (scalingFilter) 41 | { 42 | case ScalingFilters::BELL: 43 | { 44 | if (bellFilter == 0) 45 | { 46 | bellFilter = new BellFilter; 47 | } 48 | return bellFilter; 49 | } break; 50 | case ScalingFilters::BICUBIC: 51 | { 52 | if (biCubicFilter == 0) 53 | { 54 | biCubicFilter = new BiCubicFilter; 55 | } 56 | return biCubicFilter; 57 | } break; 58 | case ScalingFilters::BSPLINE: 59 | { 60 | if (bSplineFilter == 0) 61 | { 62 | bSplineFilter = new BSplineFilter; 63 | } 64 | return bSplineFilter; 65 | } break; 66 | case ScalingFilters::HERMITE: 67 | { 68 | if (hermiteFilter == 0) 69 | { 70 | hermiteFilter = new HermiteFilter; 71 | } 72 | return hermiteFilter; 73 | } break; 74 | case ScalingFilters::LANCZOS3: 75 | { 76 | if (lanczos3Filter == 0) 77 | { 78 | lanczos3Filter = new Lanczos3Filter; 79 | } 80 | return lanczos3Filter; 81 | } break; 82 | case ScalingFilters::MITCHELL: 83 | { 84 | if (mitchellFilter == 0) 85 | { 86 | mitchellFilter = new MitchellFilter; 87 | } 88 | return mitchellFilter; 89 | } break; 90 | case ScalingFilters::TRIANGLE: 91 | { 92 | if (triangleFilter == 0) 93 | { 94 | triangleFilter = new TriangleFilter; 95 | } 96 | return triangleFilter; 97 | } break; 98 | default: 99 | { 100 | return 0; 101 | } 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /src/Filters/filters.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BDSup2Sub++ (C) 2012 Adam T. 3 | * Based on code from BDSup2Sub by Copyright 2009 Volker Oth (0xdeadbeef) 4 | * and Copyright 2012 Miklos Juhasz (mjuhasz) 5 | * 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #ifndef FILTERS_H 21 | #define FILTERS_H 22 | 23 | enum class ScalingFilters : int; 24 | class Filter; 25 | 26 | class Filters 27 | { 28 | public: 29 | static Filter *getFilter(ScalingFilters scalingFilter); 30 | }; 31 | 32 | #endif // FILTERS_H 33 | -------------------------------------------------------------------------------- /src/Filters/hermitefilter.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * BDSup2Sub++ (C) 2012 Adam T. 3 | * Based on code from BDSup2Sub by Copyright 2009 Volker Oth (0xdeadbeef) 4 | * and Copyright 2012 Miklos Juhasz (mjuhasz) 5 | * 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #include "hermitefilter.h" 21 | #include 22 | 23 | float HermiteFilter::value(float value) 24 | { 25 | value = std::abs(value); 26 | return value < 1.0f ? (2.0f * value - 3.0f) * value * value + 1.0f : 0.0f; 27 | } 28 | -------------------------------------------------------------------------------- /src/Filters/hermitefilter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BDSup2Sub++ (C) 2012 Adam T. 3 | * Based on code from BDSup2Sub by Copyright 2009 Volker Oth (0xdeadbeef) 4 | * and Copyright 2012 Miklos Juhasz (mjuhasz) 5 | * 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #ifndef HERMITEFILTER_H 21 | #define HERMITEFILTER_H 22 | 23 | #include "filter.h" 24 | 25 | class HermiteFilter : public Filter 26 | { 27 | public: 28 | float radius() { return 1.0f; } 29 | float value(float value); 30 | }; 31 | 32 | #endif // HERMITEFILTER_H 33 | -------------------------------------------------------------------------------- /src/Filters/lanczos3filter.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * BDSup2Sub++ (C) 2012 Adam T. 3 | * Based on code from BDSup2Sub by Copyright 2009 Volker Oth (0xdeadbeef) 4 | * and Copyright 2012 Miklos Juhasz (mjuhasz) 5 | * 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #include "lanczos3filter.h" 21 | #include 22 | 23 | Lanczos3Filter::Lanczos3Filter() : 24 | PI_FLOAT(std::atan(1.0f) * 4) 25 | { 26 | } 27 | 28 | float Lanczos3Filter::value(float value) 29 | { 30 | if (value == 0.0f) 31 | { 32 | return 1.0f; 33 | } 34 | 35 | value = std::abs(value); 36 | if (value < 3.0f) 37 | { 38 | value *= PI_FLOAT; 39 | float value_divided_by_3 = value / 3.0f; 40 | return (std::sin(value) / value) * (std::sin(value_divided_by_3) / value_divided_by_3); 41 | } 42 | return 0.0f; 43 | } 44 | -------------------------------------------------------------------------------- /src/Filters/lanczos3filter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BDSup2Sub++ (C) 2012 Adam T. 3 | * Based on code from BDSup2Sub by Copyright 2009 Volker Oth (0xdeadbeef) 4 | * and Copyright 2012 Miklos Juhasz (mjuhasz) 5 | * 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #ifndef LANCZOS3FILTER_H 21 | #define LANCZOS3FILTER_H 22 | 23 | #include "filter.h" 24 | 25 | class Lanczos3Filter : public Filter 26 | { 27 | public: 28 | Lanczos3Filter(); 29 | 30 | float radius() { return 3.0f; } 31 | float value(float value); 32 | 33 | private: 34 | const float PI_FLOAT; 35 | }; 36 | 37 | #endif // LANCZOS3FILTER_H 38 | -------------------------------------------------------------------------------- /src/Filters/mitchellfilter.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * BDSup2Sub++ (C) 2012 Adam T. 3 | * Based on code from BDSup2Sub by Copyright 2009 Volker Oth (0xdeadbeef) 4 | * and Copyright 2012 Miklos Juhasz (mjuhasz) 5 | * 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #include "mitchellfilter.h" 21 | #include 22 | 23 | float MitchellFilter::value(float value) 24 | { 25 | value = std::abs(value); 26 | float value_square = value * value; 27 | float value_cubed = value_square * value; 28 | 29 | if (value < 1.0f) 30 | { 31 | return ((_12_minus_9B_minus_6C * value_cubed) 32 | + (_minus_18_plus_12B_plus_6C * value_square) 33 | + _6_minus_2B) * divisor; 34 | } 35 | if (value < 2.0f) 36 | { 37 | return ((_minus_B_minus_6C * value_cubed) 38 | + (_6B_plus_30C * value_square) 39 | + (_minus_12B_minus_48C * value) 40 | + _8B_plus_24C) * divisor; 41 | } 42 | return 0.0f; 43 | } 44 | -------------------------------------------------------------------------------- /src/Filters/mitchellfilter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BDSup2Sub++ (C) 2012 Adam T. 3 | * Based on code from BDSup2Sub by Copyright 2009 Volker Oth (0xdeadbeef) 4 | * and Copyright 2012 Miklos Juhasz (mjuhasz) 5 | * 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #ifndef MITCHELLFILTER_H 21 | #define MITCHELLFILTER_H 22 | 23 | #include "filter.h" 24 | 25 | class MitchellFilter : public Filter 26 | { 27 | public: 28 | float radius() { return 2.0f; } 29 | float value(float value); 30 | 31 | private: 32 | // compile time calculation of all needed values 33 | static constexpr float B = 1.0f / 3.0f; 34 | static constexpr float C = 1.0f / 3.0f; 35 | static constexpr float divisor = 1.0f / 6.0f; 36 | 37 | static constexpr float _12_minus_9B_minus_6C = 12.0f - (9.0f * B) - (6.0f * C); 38 | static constexpr float _minus_18_plus_12B_plus_6C = -18.0f + (12.0f * B) + (6.0f * C); 39 | static constexpr float _6_minus_2B = 6.0f - (2.0f * B); 40 | 41 | static constexpr float _minus_B_minus_6C = (-B) - (6.0f * C); 42 | static constexpr float _6B_plus_30C = (6.0f * B) + (30.0f * C); 43 | static constexpr float _minus_12B_minus_48C = (-12.0f * B) - (48.0f * C); 44 | static constexpr float _8B_plus_24C = (8.0f * B) + (24 * C); 45 | }; 46 | 47 | #endif // MITCHELLFILTER_H 48 | -------------------------------------------------------------------------------- /src/Filters/trianglefilter.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * BDSup2Sub++ (C) 2012 Adam T. 3 | * Based on code from BDSup2Sub by Copyright 2009 Volker Oth (0xdeadbeef) 4 | * and Copyright 2012 Miklos Juhasz (mjuhasz) 5 | * 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #include "trianglefilter.h" 21 | #include 22 | 23 | float TriangleFilter::value(float value) 24 | { 25 | value = std::abs(value); 26 | return value < 1.0f ? 1.0f - value : 0.0f; 27 | } 28 | -------------------------------------------------------------------------------- /src/Filters/trianglefilter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BDSup2Sub++ (C) 2012 Adam T. 3 | * Based on code from BDSup2Sub by Copyright 2009 Volker Oth (0xdeadbeef) 4 | * and Copyright 2012 Miklos Juhasz (mjuhasz) 5 | * 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #ifndef TRIANGLEFILTER_H 21 | #define TRIANGLEFILTER_H 22 | 23 | #include "filter.h" 24 | 25 | class TriangleFilter : public Filter 26 | { 27 | public: 28 | float radius() { return 1.0f; } 29 | float value(float value); 30 | }; 31 | 32 | #endif // TRIANGLEFILTER_H 33 | -------------------------------------------------------------------------------- /src/Subtitles/bitmap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BDSup2Sub++ (C) 2012 Adam T. 3 | * Based on code from BDSup2Sub by Copyright 2009 Volker Oth (0xdeadbeef) 4 | * and Copyright 2012 Miklos Juhasz (mjuhasz) 5 | * 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #ifndef BITMAP_H 21 | #define BITMAP_H 22 | 23 | #include 24 | 25 | template class QVector; 26 | 27 | class Filter; 28 | class Palette; 29 | class PaletteBitmap; 30 | class QRect; 31 | 32 | class Bitmap 33 | { 34 | public: 35 | Bitmap(); 36 | Bitmap(const Bitmap &other); 37 | Bitmap(const Bitmap *other); 38 | Bitmap(int width, int height); 39 | Bitmap(int width, int height, int color); 40 | Bitmap(QImage subtitleImage); 41 | 42 | void clear(int color); 43 | void fillRect(int x1, int y1, int width, int height, int color); 44 | void setImg(QImage &newImage); 45 | 46 | inline int height() { return subtitleImage.height(); } 47 | inline int width() { return subtitleImage.width(); } 48 | 49 | int highestColorIndex(Palette &palette); 50 | int primaryColorIndex(Palette &palette, int alphaThreshold); 51 | 52 | Bitmap crop(int x1, int y1, int width, int height); 53 | Bitmap convertLm(Palette &palette, int alphaThreshold, QVector &lumaThreshold); 54 | 55 | Bitmap scaleFilter(int sizeX, int sizeY, Palette &palette, Filter &filter); 56 | Bitmap scaleFilterLm(int sizeX, int sizeY, Palette &palette, 57 | int alphaThreshold, QVector &lumaThreshold, Filter& filter); 58 | Bitmap scaleBilinear(int sizeX, int sizeY, Palette &palette); 59 | Bitmap scaleBilinearLm(int sizeX, int sizeY, Palette &palette, 60 | int alphaThreshold, QVector &lumaThreshold); 61 | 62 | PaletteBitmap scaleFilter(int sizeX, int sizeY, Palette &palette, Filter &filter, bool dither); 63 | PaletteBitmap scaleBilinear(int sizeX, int sizeY, Palette &palette, bool dither); 64 | 65 | QImage &image() { return subtitleImage; } 66 | QImage image(Palette &palette); 67 | 68 | QImage toARGB(Palette &palette); 69 | 70 | QRect bounds(Palette &palette, int alphaThreshold); 71 | 72 | private: 73 | QImage subtitleImage; 74 | }; 75 | 76 | #endif // BITMAP_H 77 | -------------------------------------------------------------------------------- /src/Subtitles/erasepatch.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * BDSup2Sub++ (C) 2012 Adam T. 3 | * Based on code from BDSup2Sub by Copyright 2009 Volker Oth (0xdeadbeef) 4 | * and Copyright 2012 Miklos Juhasz (mjuhasz) 5 | * 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #include "erasepatch.h" 21 | 22 | ErasePatch::ErasePatch() 23 | { 24 | } 25 | 26 | ErasePatch::ErasePatch(const ErasePatch *other) : 27 | x1(other->x1), 28 | y1(other->y1), 29 | w(other->w), 30 | h(other->h) 31 | { 32 | } 33 | 34 | ErasePatch::ErasePatch(const ErasePatch &other) : 35 | x1(other.x1), 36 | y1(other.y1), 37 | w(other.w), 38 | h(other.h) 39 | { 40 | } 41 | 42 | ErasePatch::ErasePatch(int x, int y, int width, int height): 43 | x1(x), 44 | y1(y), 45 | w(width), 46 | h(height) 47 | { 48 | } 49 | -------------------------------------------------------------------------------- /src/Subtitles/erasepatch.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BDSup2Sub++ (C) 2012 Adam T. 3 | * Based on code from BDSup2Sub by Copyright 2009 Volker Oth (0xdeadbeef) 4 | * and Copyright 2012 Miklos Juhasz (mjuhasz) 5 | * 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #ifndef ERASEPATCH_H 21 | #define ERASEPATCH_H 22 | 23 | class ErasePatch 24 | { 25 | public: 26 | ErasePatch(); 27 | ErasePatch(const ErasePatch* other); 28 | ErasePatch(const ErasePatch& other); 29 | ErasePatch(int x, int y, int width, int height); 30 | 31 | int x() { return x1; } 32 | void setX(int x) { x1 = x; } 33 | int y() { return y1; } 34 | void setY(int y) { y1 = y; } 35 | int width() { return w; } 36 | void setWidth(int width) { w = width; } 37 | int height() { return h; } 38 | void setHeight(int height) { h = height; } 39 | 40 | private: 41 | int x1 = 0; 42 | int y1 = 0; 43 | int w = 0; 44 | int h = 0; 45 | }; 46 | 47 | #endif // ERASEPATCH_H 48 | -------------------------------------------------------------------------------- /src/Subtitles/imageobject.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * BDSup2Sub++ (C) 2012 Adam T. 3 | * Based on code from BDSup2Sub by Copyright 2009 Volker Oth (0xdeadbeef) 4 | * and Copyright 2012 Miklos Juhasz (mjuhasz) 5 | * 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #include "imageobject.h" 21 | 22 | ImageObject::ImageObject() 23 | { 24 | } 25 | 26 | ImageObject::ImageObject(const ImageObject *other) : 27 | paletteId(other->paletteId), 28 | bufSize(other->bufSize), 29 | w(other->w), 30 | h(other->h), 31 | xOfs(other->xOfs), 32 | yOfs(other->yOfs), 33 | windowId(other->windowId), 34 | forced(other->forced), 35 | objectId(other->objectId), 36 | fragments(other->fragments), 37 | objVer(other->objVer), 38 | objSeq(other->objSeq) 39 | { 40 | } 41 | 42 | ImageObject::ImageObject(const ImageObject &other) : 43 | paletteId(other.paletteId), 44 | bufSize(other.bufSize), 45 | w(other.w), 46 | h(other.h), 47 | xOfs(other.xOfs), 48 | yOfs(other.yOfs), 49 | windowId(other.windowId), 50 | forced(other.forced), 51 | objectId(other.objectId), 52 | fragments(other.fragments), 53 | objVer(other.objVer), 54 | objSeq(other.objSeq) 55 | { 56 | } 57 | -------------------------------------------------------------------------------- /src/Subtitles/imageobject.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BDSup2Sub++ (C) 2012 Adam T. 3 | * Based on code from BDSup2Sub by Copyright 2009 Volker Oth (0xdeadbeef) 4 | * and Copyright 2012 Miklos Juhasz (mjuhasz) 5 | * 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #ifndef IMAGEOBJECT_H 21 | #define IMAGEOBJECT_H 22 | 23 | #include "imageobjectfragment.h" 24 | 25 | #include 26 | 27 | class ImageObject 28 | { 29 | public: 30 | ImageObject(); 31 | ImageObject(const ImageObject* other); 32 | ImageObject(const ImageObject& other); 33 | ~ImageObject() { fragments.clear(); } 34 | 35 | int bufferSize() { return bufSize; } 36 | void setBufferSize(int size) { bufSize = size; } 37 | 38 | int width() { return w; } 39 | void setWidth(int width) { w = width; } 40 | 41 | int height() { return h; } 42 | void setHeight(int height) { h = height; } 43 | 44 | int x() { return xOfs; } 45 | void setX(int offset) { xOfs = offset; } 46 | 47 | int y() { return yOfs; } 48 | void setY(int offset) { yOfs = offset; } 49 | 50 | int windowID() { return windowId; } 51 | void setWindowID(int windowID) { windowId = windowID; } 52 | 53 | int forcedFlags() { return _forcedFlags; } 54 | void setForcedFlags(int forcedFlags) 55 | { 56 | _forcedFlags = forcedFlags; 57 | forced = ((_forcedFlags & 0x40) == 0x40); 58 | } 59 | 60 | bool isForced() { return forced; } 61 | void setForced(bool isForced) { forced = isForced; } 62 | 63 | int objectID() { return objectId; } 64 | void setObjectID(int objectID) { objectId = objectID; } 65 | 66 | int objectVersion() { return objVer; } 67 | void setObjectVersion(int objectVersion) { objVer = objectVersion; } 68 | 69 | QVector &fragmentList() { return fragments; } 70 | 71 | private: 72 | int paletteId = -1; 73 | int bufSize = 0; 74 | int w = 0; 75 | int h = 0; 76 | int xOfs = 0; 77 | int yOfs = 0; 78 | int windowId = -1; 79 | bool forced = false; 80 | int _forcedFlags = 0; 81 | int objectId = -1; 82 | int objVer = 0; 83 | int objSeq = 0; 84 | 85 | QVector fragments; 86 | }; 87 | 88 | #endif // IMAGEOBJECT_H 89 | -------------------------------------------------------------------------------- /src/Subtitles/imageobjectfragment.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * BDSup2Sub++ (C) 2012 Adam T. 3 | * Based on code from BDSup2Sub by Copyright 2009 Volker Oth (0xdeadbeef) 4 | * and Copyright 2012 Miklos Juhasz (mjuhasz) 5 | * 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #include "imageobjectfragment.h" 21 | 22 | ImageObjectFragment::ImageObjectFragment() 23 | { 24 | } 25 | -------------------------------------------------------------------------------- /src/Subtitles/imageobjectfragment.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BDSup2Sub++ (C) 2012 Adam T. 3 | * Based on code from BDSup2Sub by Copyright 2009 Volker Oth (0xdeadbeef) 4 | * and Copyright 2012 Miklos Juhasz (mjuhasz) 5 | * 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #ifndef IMAGEOBJECTFRAGMENT_H 21 | #define IMAGEOBJECTFRAGMENT_H 22 | 23 | #include 24 | 25 | class ImageObjectFragment 26 | { 27 | public: 28 | ImageObjectFragment(); 29 | ImageObjectFragment(const ImageObjectFragment& other) : 30 | packetSize(other.packetSize), 31 | bufferOfs(other.bufferOfs) 32 | { 33 | packetSize = other.packetSize; 34 | bufferOfs = other.bufferOfs; 35 | } 36 | 37 | int imagePacketSize() { return packetSize; } 38 | void setImagePacketSize(int imagePacketSize) { packetSize = imagePacketSize; } 39 | int imageBufferOffset() { return bufferOfs; } 40 | void setImageBufferOffset(int imageBufferOffset) { bufferOfs = imageBufferOffset; } 41 | 42 | private: 43 | int packetSize = 0; 44 | qint64 bufferOfs = 0; 45 | }; 46 | 47 | #endif // IMAGEOBJECTFRAGMENT_H 48 | -------------------------------------------------------------------------------- /src/Subtitles/palette.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * BDSup2Sub++ (C) 2012 Adam T. 3 | * Based on code from BDSup2Sub by Copyright 2009 Volker Oth (0xdeadbeef) 4 | * and Copyright 2012 Miklos Juhasz (mjuhasz) 5 | * 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #include "palette.h" 21 | #include 22 | 23 | Palette::Palette() 24 | { 25 | } 26 | 27 | Palette::Palette(const Palette &other) : 28 | paletteSize(other.paletteSize), 29 | useBT601(other.useBT601), 30 | colors(other.colors), 31 | y(other.y), 32 | cb(other.cb), 33 | cr(other.cr) 34 | { 35 | } 36 | 37 | Palette::Palette(const Palette *other) : 38 | paletteSize(other->paletteSize), 39 | useBT601(other->useBT601), 40 | colors(other->colors), 41 | y(other->y), 42 | cb(other->cb), 43 | cr(other->cr) 44 | { 45 | } 46 | 47 | Palette::Palette(int paletteSize, bool use601) : 48 | paletteSize(paletteSize), 49 | useBT601(use601), 50 | colors(paletteSize, 0) 51 | { 52 | QVector yCbCr; 53 | for (int i = 0; i < paletteSize; ++i) 54 | { 55 | yCbCr = Palette::RGB2YCbCr(qRgb(0, 0, 0), useBT601); 56 | y.push_back(yCbCr[0]); 57 | cb.push_back(yCbCr[1]); 58 | cr.push_back(yCbCr[2]); 59 | } 60 | } 61 | 62 | Palette::Palette(QVector inRed, QVector inGreen, QVector inBlue, QVector inAlpha, bool use601) : 63 | useBT601(use601) 64 | { 65 | for (int i = 0; i < inRed.size(); ++i) 66 | { 67 | colors.push_back(qRgba(inRed.at(i), inGreen.at(i), inBlue.at(i), inAlpha.at(i))); 68 | } 69 | 70 | QVector yCbCr; 71 | for (int i = 0; i < colors.size(); ++i) 72 | { 73 | yCbCr = RGB2YCbCr(colors.at(i), useBT601); 74 | y.push_back(yCbCr[0]); 75 | cb.push_back(yCbCr[1]); 76 | cr.push_back(yCbCr[2]); 77 | } 78 | paletteSize = colors.size(); 79 | } 80 | 81 | Palette::~Palette() 82 | { 83 | colors.clear(); 84 | y.clear(); 85 | cb.clear(); 86 | cr.clear(); 87 | } 88 | 89 | void Palette::setAlpha(int index, int alpha) 90 | { 91 | colors.replace(index, qRgba(qRed(colors.at(index)), qGreen(colors.at(index)), qBlue(colors.at(index)), alpha)); 92 | } 93 | 94 | void Palette::setRGB(int index, QRgb rgb) 95 | { 96 | colors.replace(index, qRgba(qRed(rgb), qGreen(rgb), qBlue(rgb), qAlpha(colors.at(index)))); 97 | QVector yCbCr = RGB2YCbCr(rgb, useBT601); 98 | y.replace(index, yCbCr[0]); 99 | cb.replace(index, yCbCr[1]); 100 | cr.replace(index, yCbCr[2]); 101 | } 102 | 103 | QVector Palette::RGB2YCbCr(QRgb rgb, bool use601) 104 | { 105 | QVector yCbCr; 106 | double y, cb, cr; 107 | int r = qRed(rgb); 108 | int g = qGreen(rgb); 109 | int b = qBlue(rgb); 110 | 111 | if (use601) 112 | { 113 | /* BT.601 for RGB 0..255 (PC) -> YCbCr 16..235 */ 114 | y = (((r * 0.299) * 219) / 255) + (((g * 0.587) * 219) / 255) + (((b * 0.114) * 219) / 255); 115 | cb = (((-r * 0.168736) * 224) / 255) - (((g * 0.331264) * 224) / 255) + (((b * 0.5) * 224) / 255); 116 | cr = (((r * 0.5) * 224) / 255) - (((g * 0.418688) * 224) / 255) - (((b * 0.081312) * 224) / 255); 117 | } 118 | else 119 | { 120 | /* BT.709 for RGB 0..255 (PC) -> YCbCr 16..235 */ 121 | y = (((r * 0.2126) * 219) / 255) + (((g * 0.7152) * 219) / 255) + (((b * 0.0722) * 219) / 255); 122 | cb = ((((-r * 0.2126) / 1.8556) * 224) / 255) - ((((g * 0.7152) / 1.8556) * 224) / 255) + (((b * 0.5) * 224) / 255); 123 | cr = (((r * 0.5) * 224) / 255) - ((((g * 0.7152) / 1.5748) * 224) / 255) - ((((b * 0.0722) / 1.5748) * 224) / 255); 124 | } 125 | yCbCr.push_back(16 + (int)(y + .5)); 126 | yCbCr.push_back(128 + (int)(cb + .5)); 127 | yCbCr.push_back(128 + (int)(cr + .5)); 128 | 129 | for (int i = 0; i < yCbCr.size(); ++i) 130 | { 131 | if (yCbCr[i] < 16) 132 | { 133 | yCbCr.replace(i, 16); 134 | } 135 | else 136 | { 137 | if (i == 0) 138 | { 139 | if (yCbCr[i] > 235) 140 | { 141 | yCbCr.replace(i, 235); 142 | } 143 | } 144 | else 145 | { 146 | if (yCbCr[i] > 240) 147 | { 148 | yCbCr.replace(i, 240); 149 | } 150 | } 151 | } 152 | } 153 | 154 | return yCbCr; 155 | } 156 | 157 | QRgb Palette::YCbCr2RGB(int y, int cb, int cr, bool useBT601) 158 | { 159 | double y1, r, g, b; 160 | 161 | y -= 16; 162 | cb -= 128; 163 | cr -= 128; 164 | 165 | y1 = y * 1.164383562; 166 | if (useBT601) 167 | { 168 | /* BT.601 for YCbCr 16..235 -> RGB 0..255 (PC) */ 169 | r = y1 + (cr * 1.596026317); 170 | g = y1 - (cr * 0.8129674985) - (cb * 0.3917615979); 171 | b = y1 + (cb * 2.017232218); 172 | } 173 | else 174 | { 175 | /* BT.709 for YCbCr 16..235 -> RGB 0..255 (PC) */ 176 | r = y1 + (cr * 1.792741071); 177 | g = y1 - (cr * 0.5329093286) - (cb * 0.2132486143); 178 | b = y1 + (cb * 2.112401786); 179 | } 180 | 181 | r = (int)(r + 0.5); 182 | r = std::max((int) r, 0); 183 | r = std::min((int) r, 255); 184 | 185 | g = (int)(g + 0.5); 186 | g = std::max((int) g, 0); 187 | g = std::min((int) g, 255); 188 | 189 | b = (int)(b + 0.5); 190 | b = std::max((int) b, 0); 191 | b = std::min((int) b, 255); 192 | 193 | return qRgb(r, g, b); 194 | } 195 | 196 | void Palette::setARGB(int index, QRgb inColor) 197 | { 198 | setRGB(index, inColor); 199 | setAlpha(index, qAlpha(inColor)); 200 | } 201 | 202 | int Palette::transparentIndex() 203 | { 204 | int transparentIndex = 0; 205 | int minimumAlpha = 0x100; 206 | for (int i = 0; i < paletteSize; ++i) 207 | { 208 | if (qAlpha(colors.at(i)) < minimumAlpha) 209 | { 210 | minimumAlpha = qAlpha(colors.at(i)); 211 | transparentIndex = i; 212 | if (minimumAlpha == 0) 213 | { 214 | break; 215 | } 216 | } 217 | } 218 | return transparentIndex; 219 | } 220 | 221 | void Palette::setYCbCr(int index, int yn, int cbn, int crn) 222 | { 223 | y.replace(index, (uchar)yn); 224 | cb.replace(index, (uchar)cbn); 225 | cr.replace(index, (uchar)crn); 226 | 227 | QRgb rgb = YCbCr2RGB(yn, cbn, crn, useBT601); 228 | 229 | colors.replace(index, qRgba(qRed(rgb), qGreen(rgb), qBlue(rgb), qAlpha(colors.at(index)))); 230 | } 231 | 232 | QVector Palette::YCbCr(int index) 233 | { 234 | QVector yCbCr; 235 | yCbCr.push_back(y[index] & 0xff); 236 | yCbCr.push_back(cb[index] & 0xff); 237 | yCbCr.push_back(cr[index] & 0xff); 238 | return yCbCr; 239 | } 240 | -------------------------------------------------------------------------------- /src/Subtitles/palette.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BDSup2Sub++ (C) 2012 Adam T. 3 | * Based on code from BDSup2Sub by Copyright 2009 Volker Oth (0xdeadbeef) 4 | * and Copyright 2012 Miklos Juhasz (mjuhasz) 5 | * 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #ifndef PALETTE_H 21 | #define PALETTE_H 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | class Palette 28 | { 29 | public: 30 | Palette(); 31 | Palette(const Palette& other); 32 | Palette(const Palette* other); 33 | Palette(int paletteSize, bool use601 = false); 34 | Palette(QVector r, QVector g, QVector b, QVector a, bool use601); 35 | ~Palette(); 36 | 37 | void setAlpha(int index, int alpha); 38 | void setRGB(int index, QRgb rgb); 39 | void setARGB(int index, QRgb inColor); 40 | void setColor(int index, const QColor &color) 41 | { 42 | setRGB(index, color.rgb()); 43 | setAlpha(index, color.alpha()); 44 | } 45 | void setYCbCr(int index, int yn, int cbn, int crn); 46 | 47 | int size() { return paletteSize; } 48 | int alpha(int index) { return qAlpha(colors[index]); } 49 | int transparentIndex(); 50 | 51 | QColor color(int index) { return QColor(qRed(colors[index]), qGreen(colors[index]), 52 | qBlue(colors[index]), qAlpha(colors[index])); } 53 | 54 | QRgb rgb(int index) { return qRgba(qRed(colors[index]), qGreen(colors[index]), qBlue(colors[index]), 0); } 55 | QRgb rgba(int index) { return colors[index]; } 56 | 57 | QVector Y() { return y; } 58 | QVector Cb() { return cb; } 59 | QVector Cr() { return cr; } 60 | 61 | QVector YCbCr(int index); 62 | 63 | QVector colorTable() { return colors; } 64 | 65 | static QVector RGB2YCbCr(QRgb rgb, bool use601); 66 | 67 | private: 68 | int paletteSize = 0; 69 | 70 | bool useBT601 = false; 71 | 72 | QVector colors; 73 | QVector y; 74 | QVector cb; 75 | QVector cr; 76 | 77 | QRgb YCbCr2RGB(int y, int cb, int cr, bool useBT601); 78 | }; 79 | 80 | #endif // PALETTE_H 81 | -------------------------------------------------------------------------------- /src/Subtitles/palettebitmap.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * BDSup2Sub++ (C) 2012 Adam T. 3 | * Based on code from BDSup2Sub by Copyright 2009 Volker Oth (0xdeadbeef) 4 | * and Copyright 2012 Miklos Juhasz (mjuhasz) 5 | * 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #include "palettebitmap.h" 21 | 22 | PaletteBitmap::PaletteBitmap() 23 | { 24 | } 25 | 26 | PaletteBitmap::PaletteBitmap(Bitmap &inBitmap, Palette &inPalette) : 27 | bitmap(inBitmap), 28 | palette(inPalette) 29 | { 30 | } 31 | 32 | PaletteBitmap::~PaletteBitmap() 33 | { 34 | } 35 | -------------------------------------------------------------------------------- /src/Subtitles/palettebitmap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BDSup2Sub++ (C) 2012 Adam T. 3 | * Based on code from BDSup2Sub by Copyright 2009 Volker Oth (0xdeadbeef) 4 | * and Copyright 2012 Miklos Juhasz (mjuhasz) 5 | * 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #ifndef PALETTEBITMAP_H 21 | #define PALETTEBITMAP_H 22 | 23 | #include "bitmap.h" 24 | #include "palette.h" 25 | 26 | class PaletteBitmap 27 | { 28 | public: 29 | PaletteBitmap(); 30 | PaletteBitmap(Bitmap &inBitmap, Palette &inPalette); 31 | ~PaletteBitmap(); 32 | 33 | Bitmap bitmap; 34 | Palette palette; 35 | }; 36 | 37 | #endif // PALETTEBITMAP_H 38 | -------------------------------------------------------------------------------- /src/Subtitles/paletteinfo.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * BDSup2Sub++ (C) 2012 Adam T. 3 | * Based on code from BDSup2Sub by Copyright 2009 Volker Oth (0xdeadbeef) 4 | * and Copyright 2012 Miklos Juhasz (mjuhasz) 5 | * 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #include "paletteinfo.h" 21 | 22 | PaletteInfo::PaletteInfo() 23 | { 24 | } 25 | 26 | PaletteInfo::PaletteInfo(const PaletteInfo *other) : 27 | offset(other->offset), 28 | size(other->size) 29 | { 30 | } 31 | 32 | PaletteInfo::PaletteInfo(const PaletteInfo &other) : 33 | offset(other.offset), 34 | size(other.size) 35 | { 36 | } 37 | -------------------------------------------------------------------------------- /src/Subtitles/paletteinfo.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BDSup2Sub++ (C) 2012 Adam T. 3 | * Based on code from BDSup2Sub by Copyright 2009 Volker Oth (0xdeadbeef) 4 | * and Copyright 2012 Miklos Juhasz (mjuhasz) 5 | * 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #ifndef PALETTEINFO_H 21 | #define PALETTEINFO_H 22 | 23 | class PaletteInfo 24 | { 25 | public: 26 | PaletteInfo(); 27 | PaletteInfo(const PaletteInfo* other); 28 | PaletteInfo(const PaletteInfo& other); 29 | 30 | int paletteOffset() { return offset; } 31 | void setPaletteOffset(int paletteOffset) { offset = paletteOffset; } 32 | int paletteSize() { return size; } 33 | void setPaletteSize(int paletteSize) { size = paletteSize; } 34 | 35 | private: 36 | int offset = -1; 37 | int size = -1; 38 | }; 39 | 40 | #endif // PALETTEINFO_H 41 | -------------------------------------------------------------------------------- /src/Subtitles/subdvd.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BDSup2Sub++ (C) 2012 Adam T. 3 | * Based on code from BDSup2Sub by Copyright 2009 Volker Oth (0xdeadbeef) 4 | * and Copyright 2012 Miklos Juhasz (mjuhasz) 5 | * 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #ifndef SUBDVD_H 21 | #define SUBDVD_H 22 | 23 | #include "substream.h" 24 | #include "substreamdvd.h" 25 | 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | class FileBuffer; 32 | class Palette; 33 | class SubtitleProcessor; 34 | class SubPictureDVD; 35 | 36 | class SubDVD : public QObject, public Substream, public SubstreamDVD 37 | { 38 | Q_OBJECT 39 | 40 | public: 41 | SubDVD(QString subFileName, QString idxFileName, SubtitleProcessor* subtitleProcessor); 42 | ~SubDVD(); 43 | 44 | void decode(int index); 45 | void setSrcPalette(Palette &palette); 46 | void readIdx(int idxToRead = -1); 47 | void writeIdx(QString filename, SubPicture &subPicture, QVector offsets, QVector timestamps, Palette &palette); 48 | void readSubFrame(SubPictureDVD &pic, qint64 endOfs); 49 | void readAllSubFrames(); 50 | void setTimeOffset(QString value) { timeOffset = value; } 51 | 52 | int primaryColorIndex() { return _primaryColorIndex; } 53 | int numFrames(); 54 | int numForcedFrames() { return _numForcedFrames; } 55 | int languageIdx() { return _languageIdx; } 56 | int getLanguageIdxRead() { return languageIdxRead; } 57 | 58 | qint64 endTime(int index); 59 | qint64 startTime(int index); 60 | qint64 startOffset(int index); 61 | 62 | bool isForced(int index); 63 | 64 | Bitmap &bitmap() { return _bitmap; } 65 | 66 | QImage image(); 67 | QImage image(Bitmap &bitmap); 68 | 69 | Palette &palette() { return _palette; } 70 | Palette &getSrcPalette() { return srcPalette; } 71 | Palette &decodePalette(SubPictureDVD &pic, Palette &palette); 72 | 73 | SubPicture *subPicture(int index); 74 | 75 | QVector createSubFrame(SubPictureDVD &subPicture, Bitmap &bitmap); 76 | 77 | QVector &getFrameAlpha(int index); 78 | QVector &getFramePal(int index); 79 | QVector getOriginalFrameAlpha(int index); 80 | QVector getOriginalFramePal(int index); 81 | 82 | signals: 83 | void maxProgressChanged(qint64 maxProgress); 84 | void currentProgressChanged(qint64 currentProgress); 85 | void addLanguage(const QString &message); 86 | 87 | private: 88 | int delay = -1; 89 | int streamID = 0; 90 | int languageIdxRead = -1; 91 | 92 | bool isCancelled = false; 93 | 94 | QString idxFileName; 95 | QString subFileName; 96 | QString timeOffset = ""; 97 | 98 | QVector subPictures; 99 | 100 | void decode(SubPictureDVD &pic); 101 | void decodeLine(QVector src, int srcOfs, int srcLen, QImage *trg, int trgOfs, int width, int maxPixels); 102 | 103 | QVector packHeader = { 104 | 0x00, 0x00, 0x01, 0xba, // 0: 0x000001ba - packet ID 105 | 0x44, 0x02, 0xc4, 0x82, 0x04, 0xa9, // 4: system clock reference 106 | 0x01, 0x89, 0xc3, // 10: multiplexer rate 107 | 0xf8, // 13: stuffing info 108 | }; 109 | 110 | QVector headerFirst = { // header only in first packet 111 | 0x00, 0x00, 0x01, 0xbd, // 0: 0x000001bd - sub ID 112 | 0x00, 0x00, // 4: packet length 113 | 0x81, 0x80, // 6: packet type 114 | 0x05, // 8: PTS length 115 | 0x00, 0x0, 0x00, 0x00, 0x00, // 9: PTS 116 | 0x20, // 14: stream ID 117 | 0x00, 0x00, // 15: Subpicture size in bytes 118 | 0x00, 0x00, // 17: offset to control header 119 | }; 120 | 121 | QVector headerNext = { // header in following packets 122 | 0x00, 0x00, 0x01, 0xbd, // 0: 0x000001bd - sub ID 123 | 0x00, 0x00, // 4: packet length 124 | 0x81, 0x00, // 6: packet type 125 | 0x00, // 8: PTS length = 0 126 | 0x20 // 9: Stream ID 127 | }; 128 | 129 | QVector controlHeader = { 130 | 0x00, // dummy byte (for shifting when forced) 131 | 0x00, 0x00, // 0: offset to end sequence 132 | 0x01, // 2: CMD 1: start displaying 133 | 0x03, 0x32, 0x10, // 3: CMD 3: Palette Info 134 | 0x04, 0xff, 0xff, // 6: CMD 4: Alpha Info 135 | 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 9: CMD 5: sub position 136 | 0x06, 0x00, 0x00, 0x00, 0x00, // 16: CMD 6: rle offsets 137 | 0xff, // 21: End of control header 138 | 0x00, 0x00, // 22: display duration in 90kHz/1024 139 | 0x00, 0x00, // 24: offset to end sequence (again) 140 | 0x02, 0xff, // 26: CMD 2: stop displaying 141 | }; 142 | }; 143 | 144 | #endif // SUBDVD_H 145 | -------------------------------------------------------------------------------- /src/Subtitles/subpicture.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * BDSup2Sub++ (C) 2012 Adam T. 3 | * Based on code from BDSup2Sub by Copyright 2009 Volker Oth (0xdeadbeef) 4 | * and Copyright 2012 Miklos Juhasz (mjuhasz) 5 | * 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #include "subpicture.h" 21 | 22 | SubPicture::SubPicture() 23 | { 24 | } 25 | 26 | SubPicture::SubPicture(const SubPicture &other) : 27 | erasePatch(other.erasePatch), 28 | _screenWidth(other._screenWidth), 29 | _screenHeight(other._screenHeight), 30 | start(other.start), 31 | end(other.end), 32 | compositionNumber(other.compositionNumber), 33 | numberCompObjects(other.numberCompObjects), 34 | numWindows(other.numWindows), 35 | _imageWidth(other._imageWidth), 36 | _imageHeight(other._imageHeight), 37 | xOfs(other.xOfs), 38 | yOfs(other.yOfs), 39 | forced(other.forced), 40 | decoded(other.decoded), 41 | excluded(other.excluded), 42 | scaledImageRects(other.scaledImageRects), 43 | imageRects(other.imageRects), 44 | scaledWindowRects(other.scaledWindowRects), 45 | windowRects(other.windowRects), 46 | objectIds(other.objectIds), 47 | forcedFlags(other.forcedFlags) 48 | { 49 | } 50 | 51 | SubPicture::SubPicture(const SubPicture *other) : 52 | erasePatch(other->erasePatch), 53 | _screenWidth(other->_screenWidth), 54 | _screenHeight(other->_screenHeight), 55 | start(other->start), 56 | end(other->end), 57 | compositionNumber(other->compositionNumber), 58 | numberCompObjects(other->numberCompObjects), 59 | numWindows(other->numWindows), 60 | _imageWidth(other->_imageWidth), 61 | _imageHeight(other->_imageHeight), 62 | xOfs(other->xOfs), 63 | yOfs(other->yOfs), 64 | forced(other->forced), 65 | decoded(other->decoded), 66 | excluded(other->excluded), 67 | scaledImageRects(other->scaledImageRects), 68 | imageRects(other->imageRects), 69 | scaledWindowRects(other->scaledWindowRects), 70 | windowRects(other->windowRects), 71 | objectIds(other->objectIds), 72 | forcedFlags(other->forcedFlags) 73 | { 74 | } 75 | 76 | SubPicture* SubPicture::copy() 77 | { 78 | SubPicture* sp = new SubPicture; 79 | sp->_screenHeight = _screenHeight; 80 | sp->_screenWidth = _screenWidth; 81 | sp->start = start; 82 | sp->end = end; 83 | sp->forced = forced; 84 | sp->compositionNumber = compositionNumber; 85 | sp->numberCompObjects = numberCompObjects; 86 | sp->numWindows = numWindows; 87 | sp->_imageWidth = _imageWidth; 88 | sp->_imageHeight = _imageHeight; 89 | sp->xOfs = xOfs; 90 | sp->yOfs = yOfs; 91 | sp->excluded = excluded; 92 | sp->decoded = decoded; 93 | sp->scaledImageRects = scaledImageRects; 94 | sp->imageRects = imageRects; 95 | sp->scaledWindowRects = scaledWindowRects; 96 | sp->windowRects = windowRects; 97 | sp->objectIds = objectIds; 98 | sp->forcedFlags = forcedFlags; 99 | if (!erasePatch.empty()) 100 | { 101 | for (int i = 0; i < erasePatch.size(); ++i) 102 | { 103 | sp->erasePatch.push_back(new ErasePatch(erasePatch[i])); 104 | } 105 | } 106 | 107 | return sp; 108 | } 109 | -------------------------------------------------------------------------------- /src/Subtitles/subpicture.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BDSup2Sub++ (C) 2012 Adam T. 3 | * Based on code from BDSup2Sub by Copyright 2009 Volker Oth (0xdeadbeef) 4 | * and Copyright 2012 Miklos Juhasz (mjuhasz) 5 | * 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #ifndef SUBPICTURE_H 21 | #define SUBPICTURE_H 22 | 23 | #include "erasepatch.h" 24 | 25 | #include 26 | #include 27 | #include 28 | 29 | class SubPicture 30 | { 31 | public: 32 | SubPicture(); 33 | SubPicture(const SubPicture& other); 34 | SubPicture(const SubPicture* other); 35 | virtual ~SubPicture() { } 36 | 37 | int screenWidth() { return _screenWidth; } 38 | void setScreenWidth(int width) { _screenWidth = width; } 39 | 40 | int screenHeight() { return _screenHeight; } 41 | void setScreenHeight(int height) { _screenHeight = height; } 42 | 43 | virtual int imageWidth() 44 | { 45 | int width; 46 | if (numberCompObjects == 1) 47 | { 48 | width = scaledImageRects[scaledImageRects.keys()[0]].width(); 49 | } 50 | else 51 | { 52 | int left = scaledImageRects[scaledImageRects.keys()[0]].x() < scaledImageRects[scaledImageRects.keys()[1]].x() ? 53 | scaledImageRects[scaledImageRects.keys()[0]].x() : scaledImageRects[scaledImageRects.keys()[1]].x(); 54 | int right = scaledImageRects[scaledImageRects.keys()[0]].right() > scaledImageRects[scaledImageRects.keys()[1]].right() ? 55 | scaledImageRects[scaledImageRects.keys()[0]].right() : scaledImageRects[scaledImageRects.keys()[1]].right(); 56 | width = (right - left) + 1; 57 | } 58 | return width; 59 | } 60 | 61 | virtual int imageHeight() 62 | { 63 | if (numberCompObjects == 1) 64 | { 65 | return scaledImageRects[scaledImageRects.keys()[0]].height(); 66 | } 67 | else if (scaledImageRects[scaledImageRects.keys()[0]].y() < scaledImageRects[scaledImageRects.keys()[1]].y()) 68 | { 69 | return ((scaledImageRects[scaledImageRects.keys()[1]].y() + 70 | scaledImageRects[scaledImageRects.keys()[1]].height()) - scaledImageRects[scaledImageRects.keys()[0]].y()); 71 | } 72 | else 73 | { 74 | return ((scaledImageRects[scaledImageRects.keys()[0]].y() + 75 | scaledImageRects[scaledImageRects.keys()[0]].height()) - scaledImageRects[scaledImageRects.keys()[1]].y()); 76 | } 77 | } 78 | 79 | virtual int x() 80 | { 81 | if (numberCompObjects == 1) 82 | { 83 | return scaledImageRects[scaledImageRects.keys()[0]].x(); 84 | } 85 | return scaledImageRects[scaledImageRects.keys()[0]].x() < scaledImageRects[scaledImageRects.keys()[1]].x() ? 86 | scaledImageRects[scaledImageRects.keys()[0]].x() : scaledImageRects[scaledImageRects.keys()[1]].x(); 87 | } 88 | 89 | virtual int y() 90 | { 91 | if (numberCompObjects == 1) 92 | { 93 | return scaledImageRects[scaledImageRects.keys()[0]].y(); 94 | } 95 | return scaledImageRects[scaledImageRects.keys()[0]].y() < scaledImageRects[scaledImageRects.keys()[1]].y() ? 96 | scaledImageRects[scaledImageRects.keys()[0]].y() : scaledImageRects[scaledImageRects.keys()[1]].y(); 97 | } 98 | 99 | qint64 startTime() { return start; } 100 | void setStartTime(qint64 startTime) { start = startTime; } 101 | 102 | qint64 endTime() { return end; } 103 | void setEndTime(qint64 endTime) { end = endTime; } 104 | 105 | int compNum() { return compositionNumber; } 106 | void setCompNum(int compNum) { compositionNumber = compNum; } 107 | 108 | int numCompObjects() { return numberCompObjects; } 109 | void setNumCompObjects(int numCompObjects) { numberCompObjects = numCompObjects; } 110 | 111 | int numberOfWindows() { return numWindows; } 112 | void setNumberOfWindows(int num) { numWindows = num; } 113 | 114 | virtual bool isForced() { return forced; } 115 | virtual void setForced(bool isForced) 116 | { 117 | forced = isForced; 118 | forcedFlags[0] = forced ? 0x40 : 0; 119 | forcedFlags[1] = forced ? 0x40 : 0; 120 | } 121 | 122 | bool wasDecoded() { return decoded; } 123 | void setDecoded(bool wasDecoded) { decoded = wasDecoded; } 124 | 125 | bool exclude() { return excluded; } 126 | void setExclude(bool exclude) { excluded = exclude; } 127 | 128 | QMap &imageSizes() { return scaledImageRects; } 129 | void setImageSizes(QMap rects) { imageRects = rects; scaledImageRects = rects; } 130 | 131 | QMap &windowSizes() { return scaledWindowRects; } 132 | void setWindowSizes(QMap rects) { windowRects = rects; scaledWindowRects = rects; } 133 | 134 | QVector &objectIDs() { return objectIds; } 135 | 136 | QMap forcedFlags; 137 | 138 | virtual SubPicture* copy(); 139 | 140 | QVector erasePatch; 141 | 142 | protected: 143 | int _imageWidth = 0; 144 | int _imageHeight = 0; 145 | int xOfs = 0; 146 | int yOfs = 0; 147 | 148 | QMap scaledImageRects; 149 | QMap imageRects; 150 | QMap scaledWindowRects; 151 | QMap windowRects; 152 | 153 | int _screenWidth = 0; 154 | int _screenHeight = 0; 155 | qint64 start = -1; 156 | qint64 end = 0; 157 | int compositionNumber = 0; 158 | int numberCompObjects = 0; 159 | int numWindows = 0; 160 | 161 | bool forced = false; 162 | bool decoded = false; 163 | bool excluded = false; 164 | QVector objectIds; 165 | }; 166 | 167 | #endif // SUBPICTURE_H 168 | -------------------------------------------------------------------------------- /src/Subtitles/subpicturebd.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * BDSup2Sub++ (C) 2012 Adam T. 3 | * Based on code from BDSup2Sub by Copyright 2009 Volker Oth (0xdeadbeef) 4 | * and Copyright 2012 Miklos Juhasz (mjuhasz) 5 | * 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #include "subpicturebd.h" 21 | 22 | SubPictureBD::SubPictureBD() 23 | { 24 | } 25 | 26 | SubPictureBD::SubPictureBD(const SubPictureBD *other) : 27 | SubPicture(other), 28 | type(other->type), 29 | paletteUpdate(other->paletteUpdate), 30 | compState(other->compState), 31 | paletteID(other->paletteID) 32 | { 33 | for (ImageObject imageObject : other->imageObjectList) 34 | { 35 | imageObjectList[imageObject.objectID()] = imageObject; 36 | } 37 | QList keys = other->palettes.keys(); 38 | int i = 0; 39 | for (QVector paletteInfos : other->palettes) 40 | { 41 | for (PaletteInfo paletteInfo : paletteInfos) 42 | { 43 | palettes[keys[i]].push_back(PaletteInfo(paletteInfo)); 44 | } 45 | ++i; 46 | } 47 | } 48 | 49 | SubPictureBD::SubPictureBD(const SubPictureBD &other) : 50 | SubPicture(other), 51 | type(other.type), 52 | paletteUpdate(other.paletteUpdate), 53 | compState(other.compState), 54 | paletteID(other.paletteID) 55 | { 56 | for (ImageObject imageObject : other.imageObjectList) 57 | { 58 | imageObjectList[imageObject.objectID()] = imageObject; 59 | } 60 | QList keys = other.palettes.keys(); 61 | int i = 0; 62 | for (QVector paletteInfos : other.palettes) 63 | { 64 | for (PaletteInfo paletteInfo : paletteInfos) 65 | { 66 | palettes[keys[i]].push_back(PaletteInfo(paletteInfo)); 67 | } 68 | ++i; 69 | } 70 | } 71 | 72 | SubPicture* SubPictureBD::copy() 73 | { 74 | return new SubPictureBD(this); 75 | } 76 | 77 | void SubPictureBD::setData(const PCS &pcs, QMap> ods, QMap> pds, const WDS &wds) 78 | { 79 | start = pcs.pts; 80 | _screenWidth = pcs.videoWidth; 81 | _screenHeight = pcs.videoHeight; 82 | type = pcs.frameRate; 83 | compositionNumber = pcs.compositionNumber; 84 | compState = pcs.compositionState; 85 | paletteUpdate = pcs.paletteUpdate; 86 | paletteID = pcs.paletteId; 87 | numberCompObjects = pcs.numberOfCompositionObjects; 88 | forcedFlags.clear(); 89 | 90 | QMap imageRects; 91 | 92 | objectIds = pcs.objectIds; 93 | 94 | for (int objectId : objectIds) 95 | { 96 | ImageObject object; 97 | if (ods[objectId][0].width == 0 || ods[objectId][0].height == 0) 98 | { 99 | continue; 100 | } 101 | object.setObjectID(objectId); 102 | object.setWindowID(pcs.windowIds[objectId]); 103 | object.setForcedFlags(pcs.forcedFlags[objectId]); 104 | forcedFlags[objectId] = pcs.forcedFlags[objectId]; 105 | object.setX(pcs.xPositions[objectId]); 106 | object.setY(pcs.yPositions[objectId]); 107 | object.setWidth(ods[objectId][0].width); 108 | object.setHeight(ods[objectId][0].height); 109 | object.setObjectVersion(ods[objectId][0].objectVersion); 110 | for (ODS odsData : ods[objectId]) 111 | { 112 | object.setBufferSize(object.bufferSize() + odsData.fragment.imagePacketSize()); 113 | object.fragmentList().push_back(odsData.fragment); 114 | } 115 | imageObjectList[objectId] = object; 116 | imageRects[objectId] = QRect(pcs.xPositions[objectId], pcs.yPositions[objectId], 117 | ods[objectId][0].width, ods[objectId][0].height); 118 | } 119 | palettes = pds; 120 | 121 | numWindows = wds.numberOfWindows; 122 | setWindowSizes(wds.windows); 123 | setImageSizes(imageRects); 124 | } 125 | -------------------------------------------------------------------------------- /src/Subtitles/subpicturebd.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BDSup2Sub++ (C) 2012 Adam T. 3 | * Based on code from BDSup2Sub by Copyright 2009 Volker Oth (0xdeadbeef) 4 | * and Copyright 2012 Miklos Juhasz (mjuhasz) 5 | * 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #ifndef SUBPICTUREBD_H 21 | #define SUBPICTUREBD_H 22 | 23 | #include "subpicture.h" 24 | #include "imageobject.h" 25 | #include "paletteinfo.h" 26 | #include "../types.h" 27 | 28 | #include 29 | #include 30 | 31 | class ImageObject; 32 | class PaletteInfo; 33 | 34 | struct PCS 35 | { 36 | long pts = -1; 37 | int videoWidth; 38 | int videoHeight; 39 | int frameRate; 40 | int compositionNumber; 41 | CompositionState compositionState; 42 | bool paletteUpdate = false; 43 | int paletteId; 44 | int numberOfCompositionObjects; 45 | QVector objectIds; 46 | QMap windowIds; // map of object id to window id 47 | QMap forcedFlags; // map of object id to forced flag 48 | QMap xPositions; // map of object id to x position 49 | QMap yPositions; // map of object id to y position 50 | }; 51 | 52 | struct WDS 53 | { 54 | int numberOfWindows; 55 | QVector windowIds; 56 | QMap windows; 57 | }; 58 | 59 | struct PDS 60 | { 61 | int paletteId = -1; 62 | int paletteVersion = -1; 63 | int paletteSize = -1; 64 | PaletteInfo paletteInfo; 65 | }; 66 | 67 | struct ODS 68 | { 69 | int objectId; 70 | int objectVersion; 71 | int objectSequence; 72 | int rleLength; 73 | int width; 74 | int height; 75 | ImageObjectFragment fragment; 76 | }; 77 | 78 | class SubPictureBD : public SubPicture 79 | { 80 | public: 81 | SubPictureBD(); 82 | SubPictureBD(const SubPictureBD* other); 83 | SubPictureBD(const SubPictureBD& other); 84 | ~SubPictureBD() override { } 85 | 86 | SubPicture* copy() override; 87 | 88 | int imageWidth() override 89 | { 90 | int width; 91 | if (numberCompObjects == 1) 92 | { 93 | width = scaledImageRects[objectIds[0]].width(); 94 | } 95 | else 96 | { 97 | int left = scaledImageRects[objectIds[0]].x() < scaledImageRects[objectIds[1]].x() ? 98 | scaledImageRects[objectIds[0]].x() : scaledImageRects[objectIds[1]].x(); 99 | int right = scaledImageRects[objectIds[0]].right() > scaledImageRects[objectIds[1]].right() ? 100 | scaledImageRects[objectIds[0]].right() : scaledImageRects[objectIds[1]].right(); 101 | width = (right - left) + 1; 102 | } 103 | return width; 104 | } 105 | 106 | int imageHeight() override 107 | { 108 | if (numberCompObjects == 1) 109 | { 110 | return scaledImageRects[objectIds[0]].height(); 111 | } 112 | else if (scaledImageRects[objectIds[0]].y() < scaledImageRects[objectIds[1]].y()) 113 | { 114 | return ((scaledImageRects[objectIds[1]].y() + scaledImageRects[objectIds[1]].height()) - scaledImageRects[objectIds[0]].y()); 115 | } 116 | else 117 | { 118 | return ((scaledImageRects[objectIds[0]].y() + scaledImageRects[objectIds[0]].height()) - scaledImageRects[objectIds[1]].y()); 119 | } 120 | } 121 | 122 | int x() override 123 | { 124 | if (numberCompObjects == 1) 125 | { 126 | return scaledImageRects[objectIds[0]].x(); 127 | } 128 | return scaledImageRects[objectIds[0]].x() < scaledImageRects[objectIds[1]].x() ? 129 | scaledImageRects[objectIds[0]].x() : scaledImageRects[objectIds[1]].x(); 130 | } 131 | 132 | int y() override 133 | { 134 | if (numberCompObjects == 1) 135 | { 136 | return scaledImageRects[objectIds[0]].y(); 137 | } 138 | return scaledImageRects[objectIds[0]].y() < scaledImageRects[objectIds[1]].y() ? 139 | scaledImageRects[objectIds[0]].y() : scaledImageRects[objectIds[1]].y(); 140 | } 141 | 142 | CompositionState compositionState() { return compState; } 143 | void setCompositionState(CompositionState compositionState) { compState = compositionState; } 144 | 145 | int paletteId() { return paletteID; } 146 | void setPaletteId(int paletteId) { paletteID = paletteId; } 147 | 148 | bool paletteUpdated() { return paletteUpdate; } 149 | void setPaletteUpdated(bool paletteUpdated) { paletteUpdate = paletteUpdated; } 150 | 151 | int numberOfWindows() { return numWindows; } 152 | void setNumberOfWindows(int numberOfWindows) { numWindows = numberOfWindows; } 153 | 154 | int subPictureType() { return type; } 155 | void setSubPictureType(int subPictureType) { type = subPictureType; } 156 | 157 | bool isForced() override 158 | { 159 | bool isForced = false; 160 | 161 | for (auto& imageObject : imageObjectList) 162 | { 163 | if (!imageObject.fragmentList().empty()) 164 | { 165 | isForced |= imageObject.isForced(); 166 | } 167 | } 168 | return isForced; 169 | } 170 | 171 | void setForced(bool isForced) override 172 | { 173 | for (auto key : imageObjectList.keys()) 174 | { 175 | auto& imageObject = imageObjectList[key]; 176 | if (!imageObject.fragmentList().empty()) 177 | { 178 | imageObject.setForcedFlags(isForced ? 0x40 : 0); 179 | forcedFlags[key] = imageObject.forcedFlags(); 180 | } 181 | } 182 | } 183 | 184 | void setData(const PCS &pcs, QMap> ods, QMap> pds, const WDS &wds); 185 | 186 | QMap imageObjectList; 187 | 188 | QMap> palettes; 189 | 190 | private: 191 | int type = 0; 192 | bool paletteUpdate = false; 193 | CompositionState compState; 194 | int paletteID = -1; 195 | }; 196 | 197 | #endif // SUBSPICTUREBD_H 198 | -------------------------------------------------------------------------------- /src/Subtitles/subpicturedvd.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * BDSup2Sub++ (C) 2012 Adam T. 3 | * Based on code from BDSup2Sub by Copyright 2009 Volker Oth (0xdeadbeef) 4 | * and Copyright 2012 Miklos Juhasz (mjuhasz) 5 | * 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #include "subpicturedvd.h" 21 | 22 | SubPictureDVD::SubPictureDVD() 23 | { 24 | 25 | } 26 | 27 | SubPictureDVD::SubPictureDVD(const SubPictureDVD &other) : 28 | SubPicture(other), 29 | pictureOffset(other.pictureOffset), 30 | size(other.size), 31 | evenOfs(other.evenOfs), 32 | oddOfs(other.oddOfs), 33 | origWidth(other.origWidth), 34 | origHeight(other.origHeight), 35 | origX(other.origX), 36 | origY(other.origY), 37 | rleFragments(other.rleFragments), 38 | originalAlpha(other.originalAlpha), 39 | originalPal(other.originalPal), 40 | alpha(other.alpha), 41 | pal(other.pal) 42 | { 43 | 44 | } 45 | 46 | SubPictureDVD::SubPictureDVD(const SubPictureDVD *other) : 47 | SubPicture(other), 48 | pictureOffset(other->pictureOffset), 49 | size(other->size), 50 | evenOfs(other->evenOfs), 51 | oddOfs(other->oddOfs), 52 | origWidth(other->origWidth), 53 | origHeight(other->origHeight), 54 | origX(other->origX), 55 | origY(other->origY), 56 | rleFragments(other->rleFragments), 57 | originalAlpha(other->originalAlpha), 58 | originalPal(other->originalPal), 59 | alpha(other->alpha), 60 | pal(other->pal) 61 | { 62 | 63 | } 64 | 65 | void SubPictureDVD::setOriginal() 66 | { 67 | origWidth = imageWidth(); 68 | origHeight = imageHeight(); 69 | origX = x(); 70 | origY = y(); 71 | 72 | originalAlpha = alpha; 73 | originalPal = pal; 74 | } 75 | 76 | void SubPictureDVD::copyInfo(SubPicture &subPicture) 77 | { 78 | setScreenWidth(subPicture.screenWidth()); 79 | setScreenHeight(subPicture.screenHeight()); 80 | setStartTime(subPicture.startTime()); 81 | setEndTime(subPicture.endTime()); 82 | setForced(subPicture.isForced()); 83 | setCompNum(subPicture.compNum()); 84 | QMap imageRects; 85 | QRect rect = QRect(subPicture.x(), subPicture.y(), subPicture.imageWidth(), subPicture.imageHeight()); 86 | numWindows = 1; 87 | numberCompObjects = 1; 88 | objectIds = QVector { 0 }; 89 | imageRects[0] = rect; 90 | setWindowSizes(imageRects); 91 | setImageSizes(imageRects); 92 | } 93 | -------------------------------------------------------------------------------- /src/Subtitles/subpicturedvd.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BDSup2Sub++ (C) 2012 Adam T. 3 | * Based on code from BDSup2Sub by Copyright 2009 Volker Oth (0xdeadbeef) 4 | * and Copyright 2012 Miklos Juhasz (mjuhasz) 5 | * 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #ifndef SUBPICTUREDVD_H 21 | #define SUBPICTUREDVD_H 22 | 23 | #include "subpicture.h" 24 | #include "imageobjectfragment.h" 25 | 26 | #include 27 | 28 | class SubPictureDVD : public SubPicture 29 | { 30 | public: 31 | SubPictureDVD(); 32 | SubPictureDVD(const SubPictureDVD &other); 33 | SubPictureDVD(const SubPictureDVD *other); 34 | ~SubPictureDVD() { } 35 | 36 | QVector originalAlpha = QVector(4); 37 | QVector originalPal = QVector(4); 38 | QVector alpha = QVector(4); 39 | QVector pal = QVector(4); 40 | 41 | QVector rleFragments; 42 | 43 | void setOriginal(); 44 | void copyInfo(SubPicture &subPicture); 45 | 46 | int offset() { return pictureOffset; } 47 | void setOffset(int offset) { pictureOffset = offset; } 48 | int rleSize() { return size; } 49 | void setRleSize(int rleSize) { size = rleSize; } 50 | int evenOffset() { return evenOfs; } 51 | void setEvenOffset(int evenOffset) { evenOfs = evenOffset; } 52 | int oddOffset() { return oddOfs; } 53 | void setOddOffset(int oddOffset) { oddOfs = oddOffset; } 54 | int originalWidth() { return origWidth; } 55 | void setOriginalWidth(int originalWidth) { origWidth = originalWidth; } 56 | int originalHeight() { return origHeight; } 57 | void setOriginalHeight(int originalHeight) { origHeight = originalHeight; } 58 | int originalX() { return origX; } 59 | void setOriginalX(int originalX) { origX = originalX; } 60 | int originalY() { return origY; } 61 | void setOriginalY(int originalY) { origY = originalY; } 62 | 63 | private: 64 | qint64 pictureOffset = 0; 65 | int size = 0; 66 | int evenOfs = 0; 67 | int oddOfs = 0; 68 | int origWidth = 0; 69 | int origHeight = 0; 70 | int origX = 0; 71 | int origY = 0; 72 | }; 73 | 74 | #endif // SUBPICTUREDVD_H 75 | -------------------------------------------------------------------------------- /src/Subtitles/subpicturehd.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * BDSup2Sub++ (C) 2012 Adam T. 3 | * Based on code from BDSup2Sub by Copyright 2009 Volker Oth (0xdeadbeef) 4 | * and Copyright 2012 Miklos Juhasz (mjuhasz) 5 | * 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #include "subpicturehd.h" 21 | 22 | SubPictureHD::SubPictureHD() 23 | { 24 | } 25 | 26 | SubPictureHD::SubPictureHD(const SubPictureHD &other) : 27 | SubPicture(other), 28 | paletteOfs(other.paletteOfs), 29 | alphaOfs(other.alphaOfs), 30 | imageBufSize(other.imageBufSize), 31 | imageBufferOfsEven(other.imageBufferOfsEven), 32 | imageBufferOfsOdd(other.imageBufferOfsOdd) 33 | { 34 | } 35 | 36 | SubPictureHD::SubPictureHD(const SubPictureHD *other) : 37 | SubPicture(other), 38 | paletteOfs(other->paletteOfs), 39 | alphaOfs(other->alphaOfs), 40 | imageBufSize(other->imageBufSize), 41 | imageBufferOfsEven(other->imageBufferOfsEven), 42 | imageBufferOfsOdd(other->imageBufferOfsOdd) 43 | { 44 | } 45 | -------------------------------------------------------------------------------- /src/Subtitles/subpicturehd.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BDSup2Sub++ (C) 2012 Adam T. 3 | * Based on code from BDSup2Sub by Copyright 2009 Volker Oth (0xdeadbeef) 4 | * and Copyright 2012 Miklos Juhasz (mjuhasz) 5 | * 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #ifndef SUBPICTUREHD_H 21 | #define SUBPICTUREHD_H 22 | 23 | #include "subpicture.h" 24 | 25 | class SubPictureHD : public SubPicture 26 | { 27 | public: 28 | SubPictureHD(); 29 | SubPictureHD(const SubPictureHD& other); 30 | SubPictureHD(const SubPictureHD* other); 31 | ~SubPictureHD() { } 32 | 33 | int paletteOffset() { return paletteOfs; } 34 | void setPaletteOffset(int paletteOffset) { paletteOfs = paletteOffset; } 35 | int alphaOffset() { return alphaOfs; } 36 | void setAlphaOffset(int alphaOffset) { alphaOfs = alphaOffset; } 37 | int imageBufferSize() { return imageBufSize; } 38 | void setImageBufferSize(int imageBufferSize) { imageBufSize = imageBufferSize; } 39 | int imageBufferOffsetEven() { return imageBufferOfsEven; } 40 | void setImageBufferOffsetEven(int imageBufferOffsetEven) { imageBufferOfsEven = imageBufferOffsetEven; } 41 | int imageBufferOffsetOdd() { return imageBufferOfsOdd; } 42 | void setImageBufferOffsetOdd(int imageBufferOffsetOdd) { imageBufferOfsOdd = imageBufferOffsetOdd; } 43 | 44 | private: 45 | int paletteOfs = 0; 46 | int alphaOfs = 0; 47 | int imageBufSize = 0; 48 | int imageBufferOfsEven = 0; 49 | int imageBufferOfsOdd = 0; 50 | }; 51 | 52 | #endif // SUBPICTUREHD_H 53 | -------------------------------------------------------------------------------- /src/Subtitles/subpicturexml.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * BDSup2Sub++ (C) 2012 Adam T. 3 | * Based on code from BDSup2Sub by Copyright 2009 Volker Oth (0xdeadbeef) 4 | * and Copyright 2012 Miklos Juhasz (mjuhasz) 5 | * 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #include "subpicturexml.h" 21 | 22 | SubPictureXML::SubPictureXML() 23 | { 24 | } 25 | 26 | SubPictureXML::SubPictureXML(const SubPictureXML &other) : 27 | SubPicture(other), 28 | origX(other.origX), 29 | origY(other.origY), 30 | filenames(other.filenames) 31 | { 32 | } 33 | 34 | SubPictureXML::SubPictureXML(const SubPictureXML *other) : 35 | SubPicture(other), 36 | origX(other->origX), 37 | origY(other->origY), 38 | filenames(other->filenames) 39 | { 40 | } 41 | 42 | SubPicture *SubPictureXML::copy() 43 | { 44 | return new SubPictureXML(this); 45 | } 46 | -------------------------------------------------------------------------------- /src/Subtitles/subpicturexml.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BDSup2Sub++ (C) 2012 Adam T. 3 | * Based on code from BDSup2Sub by Copyright 2009 Volker Oth (0xdeadbeef) 4 | * and Copyright 2012 Miklos Juhasz (mjuhasz) 5 | * 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #ifndef SUBPICTUREXML_H 21 | #define SUBPICTUREXML_H 22 | 23 | #include "subpicture.h" 24 | 25 | #include 26 | 27 | class SubPictureXML : public SubPicture 28 | { 29 | public: 30 | SubPictureXML(); 31 | SubPictureXML(const SubPictureXML& other); 32 | SubPictureXML(const SubPictureXML* other); 33 | ~SubPictureXML() { } 34 | 35 | SubPicture* copy(); 36 | 37 | void setOriginal() 38 | { 39 | origX = x(); 40 | origY = y(); 41 | } 42 | 43 | int originalX() { return origX; } 44 | void setOriginalX(int originalX) { origX = originalX; } 45 | int originalY() { return origY; } 46 | void setOriginalY(int originalY) { origY = originalY; } 47 | QVector fileNames() { return filenames; } 48 | void setFileName(QString fileName) { filenames.push_back(fileName); } 49 | 50 | private: 51 | int origX = 0; 52 | int origY = 0; 53 | 54 | QVector filenames; 55 | 56 | friend class SupXML; 57 | }; 58 | 59 | #endif // SUBPICTUREXML_H 60 | -------------------------------------------------------------------------------- /src/Subtitles/substream.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BDSup2Sub++ (C) 2012 Adam T. 3 | * Based on code from BDSup2Sub by Copyright 2009 Volker Oth (0xdeadbeef) 4 | * and Copyright 2012 Miklos Juhasz (mjuhasz) 5 | * 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #ifndef SUBSTREAM_H 21 | #define SUBSTREAM_H 22 | 23 | #include 24 | 25 | class Bitmap; 26 | class FileBuffer; 27 | class Palette; 28 | class QImage; 29 | class SubPicture; 30 | class SubPictureDVD; 31 | class SubtitleProcessor; 32 | 33 | class Substream 34 | { 35 | public: 36 | virtual ~Substream() { } 37 | 38 | virtual void decode(int index) = 0; 39 | 40 | virtual int primaryColorIndex() = 0; 41 | virtual int numFrames() = 0; 42 | virtual int numForcedFrames() = 0; 43 | 44 | virtual qint64 endTime(int index) = 0; 45 | virtual qint64 startTime(int index) = 0; 46 | virtual qint64 startOffset(int index) = 0; 47 | 48 | virtual bool isForced(int index) = 0; 49 | 50 | virtual Bitmap &bitmap() = 0; 51 | 52 | virtual Palette &palette() = 0; 53 | 54 | virtual SubPicture *subPicture(int index) = 0; 55 | 56 | virtual QImage image() = 0; 57 | virtual QImage image(Bitmap &bitmap) = 0; 58 | 59 | void incrementForcedFrames() { ++_numForcedFrames; } 60 | void decrementForcedFrames() { --_numForcedFrames; } 61 | 62 | protected: 63 | int _numForcedFrames = 0; 64 | }; 65 | 66 | #endif // SUBSTREAM_H 67 | -------------------------------------------------------------------------------- /src/Subtitles/substreamdvd.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BDSup2Sub++ (C) 2012 Adam T. 3 | * Based on code from BDSup2Sub by Copyright 2009 Volker Oth (0xdeadbeef) 4 | * and Copyright 2012 Miklos Juhasz (mjuhasz) 5 | * 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #ifndef SUBSTREAMDVD_H 21 | #define SUBSTREAMDVD_H 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | #include 28 | #include 29 | 30 | class SubPictureDVD; 31 | class FileBuffer; 32 | class SubtitleProcessor; 33 | 34 | class SubstreamDVD 35 | { 36 | 37 | public: 38 | SubstreamDVD(); 39 | virtual ~SubstreamDVD(); 40 | 41 | virtual void setSrcPalette(Palette &palette) = 0; 42 | void decode(SubPictureDVD &pic, SubtitleProcessor* subtitleProcessor); 43 | 44 | virtual int languageIdx() = 0; 45 | 46 | virtual Palette &getSrcPalette() = 0; 47 | static Palette decodePalette(SubPictureDVD &pic, Palette &palette, int alphaCrop); 48 | 49 | QVector encodeLines(Bitmap &bitmap, bool even); 50 | virtual QVector &getFrameAlpha(int index) = 0; 51 | virtual QVector &getFramePal(int index) = 0; 52 | virtual QVector getOriginalFrameAlpha(int index) = 0; 53 | virtual QVector getOriginalFramePal(int index) = 0; 54 | 55 | protected: 56 | Bitmap _bitmap; 57 | 58 | Palette srcPalette; 59 | Palette _palette; 60 | 61 | SubtitleProcessor* subtitleProcessor = 0; 62 | 63 | QScopedPointer fileBuffer; 64 | 65 | QVector lastAlpha = { 0, 0xf, 0xf, 0xf }; 66 | QVector subPictures; 67 | 68 | int screenWidth = 720; 69 | int screenHeight = 576; 70 | int ofsXglob = 0; 71 | int ofsYglob = 0; 72 | int delayGlob = 0; 73 | int _languageIdx = 0; 74 | int _primaryColorIndex = 0; 75 | 76 | private: 77 | void decodeLine(QVector src, int srcOfs, int srcLen, QImage &trg, int trgOfs, int width, int maxPixels); 78 | 79 | Bitmap decodeImage(SubPictureDVD &pic, int transIdx); 80 | }; 81 | 82 | #endif // SUBSTREAMDVD_H 83 | -------------------------------------------------------------------------------- /src/Subtitles/supdvd.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BDSup2Sub++ (C) 2012 Adam T. 3 | * Based on code from BDSup2Sub by Copyright 2009 Volker Oth (0xdeadbeef) 4 | * and Copyright 2012 Miklos Juhasz (mjuhasz) 5 | * 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #ifndef SUPDVD_H 21 | #define SUPDVD_H 22 | 23 | #include "substream.h" 24 | #include "substreamdvd.h" 25 | 26 | #include 27 | #include 28 | #include 29 | 30 | class Palette; 31 | class SubtitleProcessor; 32 | 33 | class SupDVD : public QObject, public Substream, public SubstreamDVD 34 | { 35 | Q_OBJECT 36 | 37 | public: 38 | SupDVD(QString supFileName, QString ifoFileName, SubtitleProcessor* subtitleProcessor); 39 | ~SupDVD(); 40 | 41 | void decode(int index); 42 | void readIfo(); 43 | void writeIfo(QString filename, SubPicture &subPicture, Palette &palette); 44 | void readAllSupFrames(); 45 | void setSrcPalette(Palette &palette); 46 | 47 | int languageIdx() { return _languageIdx; } 48 | int primaryColorIndex() { return _primaryColorIndex; } 49 | int numFrames(); 50 | int numForcedFrames() { return _numForcedFrames; } 51 | 52 | qint64 endTime(int index); 53 | qint64 startTime(int index); 54 | qint64 startOffset(int index); 55 | 56 | bool isForced(int index); 57 | 58 | Bitmap &bitmap() { return _bitmap; } 59 | 60 | Palette &palette() { return _palette; } 61 | Palette &getSrcPalette() { return srcPalette; } 62 | 63 | QImage image(); 64 | QImage image(Bitmap &bitmap); 65 | 66 | QVector createSupFrame(SubPictureDVD &subPicture, Bitmap &bitmap); 67 | QVector &getFrameAlpha(int index); 68 | QVector &getFramePal(int index); 69 | QVector getOriginalFrameAlpha(int index); 70 | QVector getOriginalFramePal(int index); 71 | 72 | SubPicture *subPicture(int index); 73 | 74 | signals: 75 | void maxProgressChanged(qint64 maxProgress); 76 | void currentProgressChanged(qint64 currentProgress); 77 | 78 | private: 79 | QString supFileName; 80 | QString ifoFileName; 81 | 82 | QVector subPictures; 83 | 84 | const QVector IFOheader = { 0x44, 0x56, 0x44, 0x56, 0x49, 0x44, 0x45, 0x4F, 0x2D, 0x56, 0x54, 0x53 }; 85 | 86 | QVector controlHeader = { 87 | 0x00, // dummy byte (for shifting when forced) 88 | 0x00, 0x00, // 0: offset to end sequence 89 | 0x01, // 2: CMD 1: start displaying 90 | 0x03, 0x32, 0x10, // 3: CMD 3: Palette Info 91 | 0x04, 0xff, 0xff, // 6: CMD 4: Alpha Info 92 | 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // 9: CMD 5: sub position 93 | 0x06, 0x00, 0x00, 0x00, 0x00, // 16: CMD 6: rle offsets 94 | 0xff, // 21: End of control header 95 | 0x00, 0x00, // 22: display duration in 90kHz/1024 96 | 0x00, 0x00, // 24: offset to end sequence (again) 97 | 0x02, 0xff, // 26: CMD 2: stop displaying 98 | }; 99 | 100 | qint64 readSupFrame(qint64 ofs); 101 | }; 102 | 103 | #endif // SUPDVD_H 104 | -------------------------------------------------------------------------------- /src/Subtitles/suphd.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BDSup2Sub++ (C) 2012 Adam T. 3 | * Based on code from BDSup2Sub by Copyright 2009 Volker Oth (0xdeadbeef) 4 | * and Copyright 2012 Miklos Juhasz (mjuhasz) 5 | * 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #ifndef SUPHD_H 21 | #define SUPHD_H 22 | 23 | #include "substream.h" 24 | #include "bitmap.h" 25 | #include "palette.h" 26 | 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | class SubtitleProcessor; 33 | class SubPictureHD; 34 | class QImage; 35 | class BitStream; 36 | 37 | class SupHD : public QObject, public Substream 38 | { 39 | Q_OBJECT 40 | 41 | public: 42 | SupHD(QString fileName, SubtitleProcessor* subtitleProcessor); 43 | ~SupHD(); 44 | 45 | void decode(int index); 46 | void readAllSupFrames(); 47 | 48 | int primaryColorIndex() { return _primaryColorIndex; } 49 | int numFrames(); 50 | int numForcedFrames() { return 0; } 51 | 52 | qint64 endTime(int index); 53 | qint64 startTime(int index); 54 | qint64 startOffset(int index); 55 | bool isForced(int /*index*/) { return false; } 56 | 57 | Bitmap &bitmap() { return _bitmap; } 58 | 59 | Palette &palette() { return _palette; } 60 | 61 | QImage image(); 62 | QImage image(Bitmap &bitmap); 63 | 64 | SubPicture *subPicture(int index); 65 | 66 | signals: 67 | void maxProgressChanged(qint64 maxProgress); 68 | void currentProgressChanged(qint64 currentProgress); 69 | 70 | private: 71 | int _primaryColorIndex = 0; 72 | 73 | Bitmap _bitmap; 74 | 75 | Palette _palette; 76 | 77 | QScopedPointer fileBuffer; 78 | 79 | QString supFileName; 80 | 81 | QVector subPictures; 82 | 83 | SubtitleProcessor* subtitleProcessor = 0; 84 | 85 | void decode(SubPictureHD &subPicture); 86 | void decodeLine(QImage &trg, int trgOfs, int width, int maxPixels, BitStream* src); 87 | 88 | Bitmap decodeImage(SubPictureHD &subPicture, int transparentIndex); 89 | 90 | Palette decodePalette(SubPictureHD &subPicture); 91 | }; 92 | 93 | #endif // SUPHD_H 94 | -------------------------------------------------------------------------------- /src/Subtitles/supxml.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BDSup2Sub++ (C) 2012 Adam T. 3 | * Based on code from BDSup2Sub by Copyright 2009 Volker Oth (0xdeadbeef) 4 | * and Copyright 2012 Miklos Juhasz (mjuhasz) 5 | * 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #ifndef SUPXML_H 21 | #define SUPXML_H 22 | 23 | #include "substream.h" 24 | #include "bitmap.h" 25 | #include "palette.h" 26 | 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | 35 | class SubtitleProcessor; 36 | class SubPictureXML; 37 | class QImage; 38 | class BitStream; 39 | class XmlHandler; 40 | 41 | enum class Resolution : int; 42 | 43 | class SupXML : public QObject, public Substream 44 | { 45 | Q_OBJECT 46 | 47 | class XmlHandler : public QXmlDefaultHandler 48 | { 49 | public: 50 | XmlHandler(SupXML* parent) { this->parent = parent; } 51 | 52 | bool characters(const QString &ch); 53 | bool endElement(const QString &namespaceURI, const QString &localName, const QString &qName); 54 | bool startElement(const QString &namespaceURI, const QString &localName, const QString &qName, const QXmlAttributes &atts); 55 | 56 | private: 57 | 58 | bool valid = false; 59 | 60 | QStringList xmlStates = { "bdn", "description", "name", "language", "format", "events", "event", "graphic" }; 61 | 62 | QString txt; 63 | 64 | QVector getResolutions(Resolution resolution); 65 | 66 | Resolution getResolution (QString string); 67 | 68 | SubPictureXML *subPicture = nullptr; 69 | 70 | SupXML* parent; 71 | 72 | enum class XmlState { BDN, DESCRIPT, NAME, LANGUAGE, FORMAT, EVENTS, EVENT, GRAPHIC, UNKNOWN }; 73 | 74 | XmlState state; 75 | XmlState findState(QString string); 76 | }; 77 | 78 | public: 79 | SupXML(QString fileName, SubtitleProcessor* subtitleProcessor); 80 | ~SupXML(); 81 | 82 | void decode(int index); 83 | void readAllImages(); 84 | void writeXml(QString filename, QVector pics); 85 | 86 | int primaryColorIndex() { return _primaryColorIndex; } 87 | int numFrames(); 88 | int numForcedFrames() { return _numForcedFrames; } 89 | 90 | qint64 endTime(int index); 91 | qint64 startTime(int index); 92 | qint64 startOffset(int /*index*/) { return 0; } 93 | 94 | double getFps() { return fps; } 95 | 96 | bool isForced(int index); 97 | 98 | Bitmap &bitmap() { return _bitmap; } 99 | 100 | Palette &palette() { return _palette; } 101 | 102 | QImage image(); 103 | QImage image(Bitmap &bitmap); 104 | 105 | QString getLanguage() { return language; } 106 | QString getPNGname(QString filename, int idx); 107 | 108 | SubPicture *subPicture(int index); 109 | 110 | signals: 111 | void maxProgressChanged(qint64 maxProgress); 112 | void currentProgressChanged(qint64 currentProgress); 113 | 114 | private: 115 | int _primaryColorIndex = 0; 116 | int numToImport = 0; 117 | double fps; 118 | double fpsXml; 119 | 120 | Bitmap _bitmap; 121 | 122 | Palette _palette; 123 | 124 | QScopedPointer xmlFile; 125 | 126 | QString title = ""; 127 | QString pathName; 128 | QString language = "deu"; 129 | QString xmlFileName; 130 | 131 | QVector subPictures; 132 | 133 | Resolution resolution; 134 | 135 | SubtitleProcessor* subtitleProcessor = 0; 136 | 137 | double XmlFps(double fps); 138 | }; 139 | 140 | #endif // SUPXML_H 141 | -------------------------------------------------------------------------------- /src/Tools/bitstream.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * BDSup2Sub++ (C) 2012 Adam T. 3 | * Based on code from BDSup2Sub by Copyright 2009 Volker Oth (0xdeadbeef) 4 | * and Copyright 2012 Miklos Juhasz (mjuhasz) 5 | * 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #include "bitstream.h" 21 | 22 | BitStream::BitStream(QVector &buffer) : 23 | byteOfs(0), 24 | b(buffer[0] & 0xff), 25 | bits(8), 26 | buf(buffer) 27 | { 28 | } 29 | 30 | int BitStream::readBits(int n) 31 | { 32 | int retval = 0; 33 | while (n > 0) 34 | { 35 | // bit by bit 36 | retval <<= 1; 37 | if ((b & 0x80) == 0x80) 38 | { 39 | retval |= 1; // get next bit 40 | } 41 | b <<= 1; 42 | n--; 43 | if (--bits == 0) 44 | { 45 | if (byteOfs < (buf.size() - 1)) 46 | { 47 | b = buf[++byteOfs] & 0xff; 48 | bits = 8; 49 | } 50 | else 51 | { 52 | bits = 0; 53 | } 54 | } 55 | } 56 | return retval; 57 | } 58 | 59 | void BitStream::syncToByte() 60 | { 61 | if (bits !=8) 62 | { 63 | if (byteOfs < (buf.size() - 1)) 64 | { 65 | b = buf[++byteOfs] & 0xff; 66 | bits = 8; 67 | } 68 | else 69 | { 70 | bits = 0; 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /src/Tools/bitstream.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BDSup2Sub++ (C) 2012 Adam T. 3 | * Based on code from BDSup2Sub by Copyright 2009 Volker Oth (0xdeadbeef) 4 | * and Copyright 2012 Miklos Juhasz (mjuhasz) 5 | * 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #ifndef BITSTREAM_H 21 | #define BITSTREAM_H 22 | 23 | #include 24 | 25 | class BitStream 26 | { 27 | public: 28 | BitStream(QVector &buffer); 29 | 30 | void syncToByte(); 31 | 32 | int bitsLeft() { return (8 * (buf.size() - byteOfs)) - (8 - bits); } 33 | int readBits(int n); 34 | 35 | private: 36 | int byteOfs; 37 | int b; 38 | int bits; 39 | 40 | QVector buf; 41 | }; 42 | 43 | #endif // BITSTREAM_H 44 | -------------------------------------------------------------------------------- /src/Tools/filebuffer.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * BDSup2Sub++ (C) 2012 Adam T. 3 | * Based on code from BDSup2Sub by Copyright 2009 Volker Oth (0xdeadbeef) 4 | * and Copyright 2012 Miklos Juhasz (mjuhasz) 5 | * 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #include "filebuffer.h" 21 | 22 | #include 23 | 24 | FileBuffer::FileBuffer(QString inFileName) : 25 | fileName(inFileName) 26 | { 27 | file.reset(new QFile(fileName)); 28 | length = file->size(); 29 | if (!file->open(QIODevice::ReadOnly)) 30 | { 31 | throw QString("File: '%1' can not be opened for reading.").arg(fileName); 32 | } 33 | 34 | buf.resize(length); 35 | file->read(buf.data(), length); 36 | if (buf.isEmpty() && file->error() != QFile::NoError) 37 | { 38 | throw QString("IO error at offset +%1 of file: '%2'") 39 | .arg(QString::number(0)).arg(fileName); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/Tools/filebuffer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BDSup2Sub++ (C) 2012 Adam T. 3 | * Based on code from BDSup2Sub by Copyright 2009 Volker Oth (0xdeadbeef) 4 | * and Copyright 2012 Miklos Juhasz (mjuhasz) 5 | * 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #ifndef FILEBUFFER_H 21 | #define FILEBUFFER_H 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | class FileBuffer 30 | { 31 | public: 32 | FileBuffer(QString inFileName); 33 | ~FileBuffer() 34 | { 35 | if (!file.isNull()) 36 | { 37 | file.reset(); 38 | } 39 | } 40 | 41 | int getDWord(uint ofs) 42 | { 43 | return (buf[ofs + 3] & 0xff) | ((buf[ofs + 2] & 0xff) << 8) | 44 | ((buf[ofs + 1] & 0xff) <<16) | ((buf[ofs] & 0xff) << 24); 45 | } 46 | int getByte(uint ofs) { return (buf[ofs] & 0xff); } 47 | int getWord(uint ofs) { return (buf[ofs + 1] & 0xff) | ((buf[ofs] & 0xff) << 8); } 48 | void getBytes(uint ofs, uchar *b, int length) 49 | { 50 | memcpy(b, (buf.data() + ofs), length); 51 | } 52 | int getDWordLE(uint ofs) 53 | { 54 | return (buf[ofs] & 0xff) | ((buf[ofs + 1] & 0xff) << 8) 55 | | ((buf[ofs + 2] & 0xff) << 16) | ((buf[ofs + 3] & 0xff) << 24); 56 | } 57 | 58 | qint64 getSize() { return length; } 59 | 60 | private: 61 | qint64 offset = 0; 62 | qint64 offsetEnd = 0; 63 | qint64 length = 0; 64 | 65 | QByteArray buf; 66 | 67 | QScopedPointer file; 68 | 69 | QString fileName; 70 | 71 | void readBuffer(qint64 ofs); 72 | }; 73 | 74 | #endif // FILEBUFFER_H 75 | -------------------------------------------------------------------------------- /src/Tools/hr_time.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #ifndef hr_timer 4 | #include "hr_time.h" 5 | #define hr_timer 6 | #endif 7 | 8 | double CStopWatch::LIToSecs( LARGE_INTEGER & L) { 9 | return ((double)L.QuadPart /(double)frequency.QuadPart); 10 | } 11 | 12 | CStopWatch::CStopWatch(){ 13 | timer.start.QuadPart=0; 14 | timer.stop.QuadPart=0; 15 | QueryPerformanceFrequency( &frequency ); 16 | } 17 | 18 | void CStopWatch::startTimer( ) { 19 | QueryPerformanceCounter(&timer.start); 20 | } 21 | 22 | void CStopWatch::stopTimer( ) { 23 | QueryPerformanceCounter(&timer.stop); 24 | } 25 | 26 | 27 | double CStopWatch::getElapsedTime() { 28 | LARGE_INTEGER time; 29 | time.QuadPart = timer.stop.QuadPart - timer.start.QuadPart; 30 | return LIToSecs( time) ; 31 | } 32 | -------------------------------------------------------------------------------- /src/Tools/hr_time.h: -------------------------------------------------------------------------------- 1 | #ifndef HR_TIME_H 2 | #define HR_TIME_H 3 | 4 | #include 5 | 6 | typedef struct { 7 | LARGE_INTEGER start; 8 | LARGE_INTEGER stop; 9 | } stopWatch; 10 | 11 | class CStopWatch { 12 | 13 | private: 14 | stopWatch timer; 15 | LARGE_INTEGER frequency; 16 | double LIToSecs( LARGE_INTEGER & L); 17 | public: 18 | CStopWatch(); 19 | void startTimer( ); 20 | void stopTimer( ); 21 | double getElapsedTime(); 22 | }; 23 | 24 | #endif // HR_TIME_H 25 | -------------------------------------------------------------------------------- /src/Tools/numberutil.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * BDSup2Sub++ (C) 2012 Adam T. 3 | * Based on code from BDSup2Sub by Copyright 2009 Volker Oth (0xdeadbeef) 4 | * and Copyright 2012 Miklos Juhasz (mjuhasz) 5 | * 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #include "numberutil.h" 21 | 22 | void NumberUtil::setString(QVector &buf, int index, QString string) 23 | { 24 | for (int i = 0; i < string.size(); ++i) 25 | { 26 | buf.replace(index + i, (uchar)string.at(i).toLatin1()); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/Tools/numberutil.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BDSup2Sub++ (C) 2012 Adam T. 3 | * Based on code from BDSup2Sub by Copyright 2009 Volker Oth (0xdeadbeef) 4 | * and Copyright 2012 Miklos Juhasz (mjuhasz) 5 | * 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #ifndef NUMBERUTIL_H 21 | #define NUMBERUTIL_H 22 | 23 | #include 24 | #include 25 | 26 | class NumberUtil 27 | { 28 | public: 29 | static void setByte(QVector& buf, int index, int value) 30 | { 31 | buf.replace(index, (uchar)value); 32 | } 33 | static void setWord(QVector& buf, int index, int value) 34 | { 35 | buf.replace(index, (uchar)(value >> 8)); 36 | buf.replace(index + 1, (uchar)value); 37 | } 38 | static void setDWord(QVector& buf, int index, int value) 39 | { 40 | buf.replace(index, (uchar)(value >> 24)); 41 | buf.replace(index + 1, (uchar)(value >> 16)); 42 | buf.replace(index + 2, (uchar)(value >> 8)); 43 | buf.replace(index + 3, (uchar)value); 44 | } 45 | static void setString(QVector &buf, int index, QString string); 46 | }; 47 | 48 | #endif // NUMBERUTIL_H 49 | -------------------------------------------------------------------------------- /src/Tools/quantizefilter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BDSup2Sub++ (C) 2012 Adam T. 3 | * Based on code from BDSup2Sub by Copyright 2009 Volker Oth (0xdeadbeef) 4 | * and Copyright 2012 Miklos Juhasz (mjuhasz) 5 | * 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #ifndef QUANTIZEFILTER_H 21 | #define QUANTIZEFILTER_H 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | /** 28 | * Floyd-Steinberg dithering matrix. 29 | */ 30 | static QVector matrix = { 31 | 0, 0, 0, 32 | 0, 0, 7, 33 | 3, 5, 1, 34 | }; 35 | 36 | class QuantizeFilter 37 | { 38 | class OctTreeQuantizer 39 | { 40 | struct OctTreeNode 41 | { 42 | int children = 0; 43 | int level = 0; 44 | OctTreeNode* parent = 0; 45 | QVector leaf = QVector(16); 46 | bool isLeaf = false; 47 | int count = 0; 48 | int totalAlpha = 0; 49 | int totalRed = 0; 50 | int totalGreen = 0; 51 | int totalBlue = 0; 52 | int index = 0; 53 | }; 54 | 55 | public: 56 | ~OctTreeQuantizer() 57 | { 58 | for (int i = 0; i < colorList.size(); ++i) 59 | { 60 | for (int j = 0; j < colorList[i].size(); ++j) 61 | { 62 | delete colorList[i][j]; 63 | colorList[i][j] = 0; 64 | } 65 | } 66 | } 67 | void addPixels(QImage &image); 68 | void buildColorTable(QVector inPixels, QVector &table); 69 | void setup(int numColors); 70 | 71 | int indexForColor(QRgb argb); 72 | 73 | QVector buildColorTable(); 74 | 75 | private: 76 | static constexpr int MAX_LEVEL = 5; 77 | 78 | int colors = 0; 79 | int maximumColors = 256; 80 | int nodes = 0; 81 | int reduceColors = 512; 82 | 83 | OctTreeNode* root = new OctTreeNode; 84 | 85 | QVector> colorList = QVector>(MAX_LEVEL + 1); 86 | 87 | void insertColor(QRgb rgb); 88 | void reduceTree(int numColors); 89 | int buildColorTable(OctTreeNode* node, QVector& table, int index); 90 | }quantizer; 91 | 92 | public: 93 | void setNumColors(int numColors); 94 | void setDither(bool dither) { this->dither = dither; } 95 | void setSerpentine(bool serpentine) { this->serpentine = serpentine; } 96 | 97 | int clamp(int c) 98 | { 99 | if (c < 0) 100 | { 101 | return 0; 102 | } 103 | if (c > 255) 104 | { 105 | return 255; 106 | } 107 | return c; 108 | } 109 | 110 | int numColors() { return _numColors; } 111 | 112 | bool getDither() { return dither; } 113 | bool getSerpentine() { return serpentine; } 114 | 115 | QVector quantize(QImage inImage, QImage *outImage, int width, int height, 116 | int numColors, bool dither, bool serpentine); 117 | 118 | private: 119 | static constexpr int sum = 3 + 5 + 7 + 1; 120 | int _numColors = 255; 121 | 122 | bool dither = false; 123 | bool serpentine = true; 124 | }; 125 | 126 | #endif // QUANTIZEFILTER_H 127 | -------------------------------------------------------------------------------- /src/Tools/timeutil.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * BDSup2Sub++ (C) 2012 Adam T. 3 | * Based on code from BDSup2Sub by Copyright 2009 Volker Oth (0xdeadbeef) 4 | * and Copyright 2012 Miklos Juhasz (mjuhasz) 5 | * 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #include "timeutil.h" 21 | 22 | #include 23 | #include 24 | 25 | TimeUtil::TimeUtil() 26 | { 27 | } 28 | 29 | qint64 TimeUtil::timeStrXmlToPTS(QString s, double fps) 30 | { 31 | if (timePattern.exactMatch(s) && timePattern.indexIn(s) != -1) 32 | { 33 | QStringList m = timePattern.capturedTexts(); 34 | qint64 hour = m[1].toInt(); 35 | qint64 min = m[2].toInt(); 36 | qint64 sec = m[3].toInt(); 37 | qint64 frames = m[4].toInt(); 38 | 39 | qint64 temp = hour * 60; 40 | temp += min; 41 | temp *= 60; 42 | temp += sec; 43 | temp *= 1000; 44 | return (temp +(int)(((frames / fps) * 1000.0) + 0.5)) * 90; 45 | } 46 | else 47 | { 48 | return -1; 49 | } 50 | } 51 | 52 | qint64 TimeUtil::timeStrToPTS(QString s, bool *ok) 53 | { 54 | *ok = false; 55 | bool timestampIsNegative = s[0] == '-'; 56 | QString temp = timestampIsNegative ? s.mid(1) : s; 57 | if (timePattern.exactMatch(temp) && timePattern.indexIn(temp) != -1) 58 | { 59 | QStringList m = timePattern.capturedTexts(); 60 | qint64 hour = m[1].toInt(); 61 | qint64 min = m[2].toInt(); 62 | qint64 sec = m[3].toInt(); 63 | qint64 ms = m[4].toInt(); 64 | 65 | qint64 temp = hour * 60; 66 | temp += min; 67 | temp *= 60; 68 | temp += sec; 69 | temp *= 1000; 70 | *ok = true; 71 | qint64 ret = (temp + ms) * 90; 72 | return timestampIsNegative ? -ret : ret; 73 | } 74 | else 75 | { 76 | return -1; 77 | } 78 | } 79 | 80 | QString TimeUtil::ptsToTimeStrXml(qint64 pts, double fps) 81 | { 82 | QVector time = msToTime((pts + 45) / 90); 83 | return QString("%1:%2:%3:%4").arg(QString::number(time[0]), 2, QChar('0')) 84 | .arg(QString::number(time[1]), 2, QChar('0')) 85 | .arg(QString::number(time[2]), 2, QChar('0')) 86 | .arg(QString::number((int)(((fps * time[3]) / 1000.0) + 0.5)), 2, QChar('0')); 87 | } 88 | 89 | QString TimeUtil::ptsToTimeStr(qint64 pts) 90 | { 91 | bool ptsIsNegative = pts < 0; 92 | pts = ptsIsNegative ? -pts : pts; 93 | QVector time = msToTime((pts + 45) / 90); 94 | return QString("%1%2:%3:%4.%5").arg(ptsIsNegative ? "-" : "") 95 | .arg(QString::number(time[0]), 2, QChar('0')) 96 | .arg(QString::number(time[1]), 2, QChar('0')) 97 | .arg(QString::number(time[2]), 2, QChar('0')) 98 | .arg(QString::number(time[3]), 3, QChar('0')); 99 | } 100 | 101 | QString TimeUtil::ptsToTimeStrIdx(qint64 pts) 102 | { 103 | bool ptsIsNegative = pts < 0; 104 | pts = ptsIsNegative ? -pts : pts; 105 | QVector time = msToTime((pts + 45) / 90); 106 | return QString("%1%2:%3:%4:%5").arg(ptsIsNegative ? "-" : "") 107 | .arg(QString::number(time[0]), 2, QChar('0')) 108 | .arg(QString::number(time[1]), 2, QChar('0')) 109 | .arg(QString::number(time[2]), 2, QChar('0')) 110 | .arg(QString::number(time[3]), 3, QChar('0')); 111 | } 112 | 113 | QVector TimeUtil::msToTime(qint64 ms) 114 | { 115 | QVector time(4); 116 | // time[0] = hours 117 | time.replace(0, (int)(ms / (60 * 60 * 1000))); 118 | ms -= (time[0] * 60 * 60 * 1000); 119 | // time[1] = minutes 120 | time.replace(1, (int)(ms / (60 * 1000))); 121 | ms -= (time[1] * 60 * 1000); 122 | // time[2] = seconds 123 | time.replace(2, (int)(ms / 1000)); 124 | ms -= (time[2] * 1000); 125 | time.replace(3, (int)ms); 126 | return time; 127 | } 128 | -------------------------------------------------------------------------------- /src/Tools/timeutil.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BDSup2Sub++ (C) 2012 Adam T. 3 | * Based on code from BDSup2Sub by Copyright 2009 Volker Oth (0xdeadbeef) 4 | * and Copyright 2012 Miklos Juhasz (mjuhasz) 5 | * 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #ifndef TIMEUTIL_H 21 | #define TIMEUTIL_H 22 | 23 | #include 24 | #include 25 | 26 | template class QVector; 27 | 28 | static QRegExp timePattern = QRegExp("(\\d+):(\\d+):(\\d+)[:\\.](\\d+)"); 29 | 30 | class TimeUtil 31 | { 32 | public: 33 | TimeUtil(); 34 | 35 | static qint64 timeStrToPTS(QString s, bool *ok = 0); 36 | static qint64 timeStrXmlToPTS(QString s, double fps); 37 | 38 | static QRegExp getTimePattern() { return timePattern; } 39 | 40 | static QString ptsToTimeStrXml(qint64 pts, double fps); 41 | static QString ptsToTimeStr(qint64 pts); 42 | static QString ptsToTimeStrIdx(qint64 pts); 43 | 44 | static QVector msToTime(qint64 ms); 45 | }; 46 | 47 | #endif // TIMEUTIL_H 48 | -------------------------------------------------------------------------------- /src/bdsup2sub++.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2011-12-26T16:10:17 4 | # 5 | #------------------------------------------------- 6 | 7 | #check Qt version 8 | QT_VERSION = $$[QT_VERSION] 9 | QT_VERSION = $$split(QT_VERSION, ".") 10 | QT_VER_MAJ = $$member(QT_VERSION, 0) 11 | 12 | QT += core xml 13 | lessThan(QT_VER_MAJ, 4) { 14 | QT += gui 15 | } 16 | greaterThan(QT_VER_MAJ, 4) { 17 | QT -= gui 18 | QT += widgets 19 | } 20 | CONFIG += qt console 21 | DEFINES += BUILD_QXT_CORE 22 | QMAKE_CXXFLAGS += -std=c++14 23 | TARGET = bdsup2sub++ 24 | TEMPLATE = app 25 | 26 | SOURCES += main.cpp\ 27 | bdsup2sub.cpp \ 28 | zoomableimagearea.cpp \ 29 | editpane.cpp \ 30 | Filters/trianglefilter.cpp \ 31 | Filters/mitchellfilter.cpp \ 32 | Filters/lanczos3filter.cpp \ 33 | Filters/hermitefilter.cpp \ 34 | Filters/bsplinefilter.cpp \ 35 | Filters/bicubicfilter.cpp \ 36 | Filters/bellfilter.cpp \ 37 | Filters/filterop.cpp \ 38 | Subtitles/subdvd.cpp \ 39 | Subtitles/palette.cpp \ 40 | Subtitles/bitmap.cpp \ 41 | Subtitles/subtitleprocessor.cpp \ 42 | Subtitles/subpicture.cpp \ 43 | Subtitles/erasepatch.cpp \ 44 | Subtitles/subpicturedvd.cpp \ 45 | Subtitles/imageobjectfragment.cpp \ 46 | progressdialog.cpp \ 47 | Subtitles/supdvd.cpp \ 48 | Tools/filebuffer.cpp \ 49 | conversiondialog.cpp \ 50 | Filters/filters.cpp \ 51 | Subtitles/palettebitmap.cpp \ 52 | Tools/timeutil.cpp \ 53 | Subtitles/suphd.cpp \ 54 | Subtitles/supbd.cpp \ 55 | Subtitles/subpicturebd.cpp \ 56 | Subtitles/paletteinfo.cpp \ 57 | Subtitles/substreamdvd.cpp \ 58 | Subtitles/subpicturehd.cpp \ 59 | Tools/bitstream.cpp \ 60 | Subtitles/supxml.cpp \ 61 | Subtitles/subpicturexml.cpp \ 62 | Tools/quantizefilter.cpp \ 63 | exportdialog.cpp \ 64 | Tools/numberutil.cpp \ 65 | editdialog.cpp \ 66 | helpdialog.cpp \ 67 | colordialog.cpp \ 68 | framepalettedialog.cpp \ 69 | movedialog.cpp \ 70 | Subtitles/imageobject.cpp \ 71 | qxtglobal.cpp \ 72 | qxtcommandoptions.cpp 73 | 74 | HEADERS += bdsup2sub.h \ 75 | zoomableimagearea.h \ 76 | editpane.h \ 77 | types.h \ 78 | Filters/trianglefilter.h \ 79 | Filters/mitchellfilter.h \ 80 | Filters/lanczos3filter.h \ 81 | Filters/hermitefilter.h \ 82 | Filters/filter.h \ 83 | Filters/bsplinefilter.h \ 84 | Filters/bicubicfilter.h \ 85 | Filters/bellfilter.h \ 86 | Filters/filterop.h \ 87 | Subtitles/substream.h \ 88 | Subtitles/substreamdvd.h \ 89 | Subtitles/subdvd.h \ 90 | Subtitles/palette.h \ 91 | Subtitles/bitmap.h \ 92 | Subtitles/subtitleprocessor.h \ 93 | Subtitles/subpicture.h \ 94 | Subtitles/erasepatch.h \ 95 | Subtitles/subpicturedvd.h \ 96 | Subtitles/imageobjectfragment.h \ 97 | progressdialog.h \ 98 | Subtitles/supdvd.h \ 99 | Tools/filebuffer.h \ 100 | conversiondialog.h \ 101 | Filters/filters.h \ 102 | Subtitles/palettebitmap.h \ 103 | Tools/timeutil.h \ 104 | Subtitles/suphd.h \ 105 | Subtitles/supbd.h \ 106 | Subtitles/subpicturebd.h \ 107 | Subtitles/imageobject.h \ 108 | Subtitles/paletteinfo.h \ 109 | Subtitles/subpicturehd.h \ 110 | Tools/bitstream.h \ 111 | Subtitles/supxml.h \ 112 | Subtitles/subpicturexml.h \ 113 | Tools/quantizefilter.h \ 114 | exportdialog.h \ 115 | Tools/numberutil.h \ 116 | editdialog.h \ 117 | helpdialog.h \ 118 | colordialog.h \ 119 | framepalettedialog.h \ 120 | movedialog.h \ 121 | qxtglobal.h \ 122 | qxtcommandoptions.h 123 | 124 | FORMS += bdsup2sub.ui \ 125 | progressdialog.ui \ 126 | conversiondialog.ui \ 127 | exportdialog.ui \ 128 | editdialog.ui \ 129 | helpdialog.ui \ 130 | colordialog.ui \ 131 | framepalettedialog.ui \ 132 | movedialog.ui 133 | 134 | RESOURCES += \ 135 | bdsup2sub.qrc 136 | 137 | RC_FILE = bdsup2sub.rc 138 | -------------------------------------------------------------------------------- /src/bdsup2sub.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BDSup2Sub++ (C) 2012 Adam T. 3 | * Based on code from BDSup2Sub by Copyright 2009 Volker Oth (0xdeadbeef) 4 | * and Copyright 2012 Miklos Juhasz (mjuhasz) 5 | * 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #ifndef BDSUP2SUB_H 21 | #define BDSUP2SUB_H 22 | 23 | #include "Subtitles/palette.h" 24 | 25 | #if QT_VERSION >= 0x050000 26 | #include 27 | #else 28 | #include 29 | #endif 30 | #include 31 | #include 32 | 33 | class SubtitleProcessor; 34 | class ProgressDialog; 35 | class QSettings; 36 | class QxtCommandOptions; 37 | class QTextStream; 38 | 39 | namespace Ui { 40 | class BDSup2Sub; 41 | } 42 | 43 | class BDSup2Sub : public QMainWindow 44 | { 45 | Q_OBJECT 46 | 47 | public: 48 | explicit BDSup2Sub(QWidget *parent = 0); 49 | ~BDSup2Sub(); 50 | bool execCLI(int argc, char** argv); 51 | 52 | public slots: 53 | void changeWindowTitle(QString newTitle); 54 | void onLoadingSubtitleFileFinished(const QString& errorString); 55 | void onWritingSubtitleFileFinished(const QString& errorString); 56 | void onMoveAllFinished(const QString& errorString); 57 | void convertSup(); 58 | 59 | protected: 60 | void dragEnterEvent(QDragEnterEvent *event); 61 | void dropEvent(QDropEvent *event); 62 | void showEvent(QShowEvent *event); 63 | void resizeEvent (QResizeEvent * event); 64 | void closeEvent(QCloseEvent *event); 65 | void keyPressEvent(QKeyEvent *event); 66 | 67 | private: 68 | Ui::BDSup2Sub *ui; 69 | ProgressDialog *progressDialog = 0; 70 | QString loadPath = ""; 71 | QString saveFileName = ""; 72 | QString savePath = ""; 73 | QString colorPath = ""; 74 | SubtitleProcessor *subtitleProcessor = 0; 75 | int subIndex = 0; 76 | QIntValidator *alphaThresholdValidator = new QIntValidator(0, 255, this); 77 | QIntValidator *medLowThresholdValidator = new QIntValidator(0, 255, this); 78 | QIntValidator *hiMedThresholdValidator = new QIntValidator(0, 255, this); 79 | QIntValidator *subtitleNumberValidator; 80 | QPalette* errorBackground; 81 | QPalette* okBackground; 82 | 83 | QxtCommandOptions* options; 84 | 85 | QSettings* settings = 0; 86 | bool fromCLI = false; 87 | 88 | QString filter = tr("All Files (*.*);;Subtitle Files (*.idx *.ifo *.sub *.sup *.xml)"); 89 | QString ifoFilter = tr("IFO File (*.ifo)"); 90 | QString selectedFilter = tr("Subtitle Files (*.idx *.ifo *.sub *.sup *.xml)"); 91 | 92 | int lumThr1 = -1; 93 | int lumThr2 = -1; 94 | int alphaThreshold = -1; 95 | int langIdx = -1; 96 | Palette importedPalette; 97 | 98 | bool setLumaThreshold = false; 99 | bool setAlphaThreshold = false; 100 | bool setLangIdx = false; 101 | bool setImportedPalette = false; 102 | 103 | void fillComboBoxes(); 104 | void enableCoreComponents(bool enable); 105 | void enableVobSubComponents(bool enable); 106 | void enableVobSubMenuCombo(); 107 | void closeSubtitle(); 108 | void updateRecentMenu(); 109 | void refreshSrcFrame(int index); 110 | void refreshTrgFrame(int index); 111 | void connectSubtitleProcessor(); 112 | void loadSubtitleFile(); 113 | QString getWarningMessage(); 114 | void warningDialog(); 115 | void errorDialog(const QString &errorMessage); 116 | void printWarnings(QTextStream &stream); 117 | void Redirect_console(); 118 | void addCLIOptions(); 119 | void showUsage(QTextStream& outStream); 120 | 121 | private slots: 122 | void init(); 123 | void loadSettings(); 124 | void showAboutQt(); 125 | void openFile(); 126 | void saveFile(); 127 | void closeFile(); 128 | void onOperationCancelled(); 129 | void onAddLanguage(const QString &language); 130 | void print(const QString &message); 131 | void onRecentItemClicked(); 132 | void onEditPaneClicked(QMouseEvent *event); 133 | void loadEditPane(); 134 | void loadHelpDialog(); 135 | void swapCrCb_toggled(bool checked); 136 | void fixInvisibleFrames_toggled(bool checked); 137 | void verbatimOutput_toggled(bool checked); 138 | void editDefaultDVDPalette_triggered(); 139 | void editImportedDVDPalette_triggered(); 140 | void editDVDFramePalette_triggered(); 141 | void moveAllCaptions_triggered(); 142 | void resetCropOffset_triggered(); 143 | void on_subtitleLanguageComboBox_currentIndexChanged(int index); 144 | void on_subtitleNumberComboBox_currentIndexChanged(int index); 145 | void openConversionSettings(); 146 | void on_paletteComboBox_currentIndexChanged(int index); 147 | void on_filterComboBox_currentIndexChanged(int index); 148 | void on_hiMedThresholdComboBox_currentIndexChanged(int index); 149 | void on_medLowThresholdComboBox_currentIndexChanged(int index); 150 | void on_alphaThresholdComboBox_currentIndexChanged(int index); 151 | void on_outputFormatComboBox_currentIndexChanged(int index); 152 | }; 153 | 154 | #endif // BDSUP2SUB_H 155 | -------------------------------------------------------------------------------- /src/bdsup2sub.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amichaeltm/BDSup2SubPlusPlus/5f8c159d2fed0ae1726718121f49d30e0821f398/src/bdsup2sub.icns -------------------------------------------------------------------------------- /src/bdsup2sub.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amichaeltm/BDSup2SubPlusPlus/5f8c159d2fed0ae1726718121f49d30e0821f398/src/bdsup2sub.ico -------------------------------------------------------------------------------- /src/bdsup2sub.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | bdsup2sub.ico 4 | help.htm 5 | help.ini 6 | 7 | 8 | -------------------------------------------------------------------------------- /src/bdsup2sub.rc: -------------------------------------------------------------------------------- 1 | // Microsoft Visual C++ generated resource script. 2 | // 3 | #include 4 | #include "resource.h" 5 | ///////////////////////////////////////////////////////////////////////////// 6 | // English (United States) resources 7 | 8 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) 9 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US 10 | #pragma code_page(65001) 11 | 12 | ///////////////////////////////////////////////////////////////////////////// 13 | // 14 | // Icon 15 | // 16 | 17 | // Icon with lowest ID value placed first to ensure application icon 18 | // remains consistent on all systems. 19 | IDI_ICON1 ICON "bdsup2sub.ico" 20 | 21 | 22 | #ifdef APSTUDIO_INVOKED 23 | ///////////////////////////////////////////////////////////////////////////// 24 | // 25 | // TEXTINCLUDE 26 | // 27 | 28 | 1 TEXTINCLUDE 29 | BEGIN 30 | "resource.h\0" 31 | END 32 | 33 | 2 TEXTINCLUDE 34 | BEGIN 35 | "\0" 36 | END 37 | 38 | 3 TEXTINCLUDE 39 | BEGIN 40 | "\r\n" 41 | "\0" 42 | END 43 | 44 | #endif // APSTUDIO_INVOKED 45 | 46 | 47 | ///////////////////////////////////////////////////////////////////////////// 48 | // 49 | // Version 50 | // 51 | 52 | VS_VERSION_INFO VERSIONINFO 53 | FILEVERSION 1,0,3,0 54 | PRODUCTVERSION 1,0,3,0 55 | FILEFLAGSMASK 0x3fL 56 | #ifdef _DEBUG 57 | FILEFLAGS 0x1L 58 | #else 59 | FILEFLAGS 0x0L 60 | #endif 61 | FILEOS 0x40004L 62 | FILETYPE 0x1L 63 | FILESUBTYPE 0x0L 64 | BEGIN 65 | BLOCK "StringFileInfo" 66 | BEGIN 67 | BLOCK "040904b0" 68 | BEGIN 69 | VALUE "FileDescription", "BDSup2Sub++" 70 | VALUE "FileVersion", "1.0.3.0" 71 | VALUE "InternalName", "bdsup2sub++.exe" 72 | VALUE "LegalCopyright", "Copyright (C) 2009 Volker Oth Copyright (C) 2012 Miklos Juhasz Copyright (C) 2012 & 2018 Adam T." 73 | VALUE "OriginalFilename", "bdsup2sub++.exe" 74 | VALUE "ProductName", "BDSup2Sub++" 75 | VALUE "ProductVersion", "1.0.3.0" 76 | END 77 | END 78 | BLOCK "VarFileInfo" 79 | BEGIN 80 | VALUE "Translation", 0x409, 1200 81 | END 82 | END 83 | 84 | #endif // English (United States) resources 85 | ///////////////////////////////////////////////////////////////////////////// 86 | 87 | 88 | 89 | #ifndef APSTUDIO_INVOKED 90 | ///////////////////////////////////////////////////////////////////////////// 91 | // 92 | // Generated from the TEXTINCLUDE 3 resource. 93 | // 94 | 95 | 96 | ///////////////////////////////////////////////////////////////////////////// 97 | #endif // not APSTUDIO_INVOKED 98 | 99 | -------------------------------------------------------------------------------- /src/colordialog.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BDSup2Sub++ (C) 2012 Adam T. 3 | * Based on code from BDSup2Sub by Copyright 2009 Volker Oth (0xdeadbeef) 4 | * and Copyright 2012 Miklos Juhasz (mjuhasz) 5 | * 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #ifndef COLORDIALOG_H 21 | #define COLORDIALOG_H 22 | 23 | #include 24 | #if QT_VERSION >= 0x050000 25 | #include 26 | #else 27 | #include 28 | #endif 29 | 30 | class QModelIndex; 31 | class SubtitleProcessor; 32 | 33 | namespace Ui { 34 | class ColorDialog; 35 | } 36 | 37 | class ColorDialog : public QDialog 38 | { 39 | Q_OBJECT 40 | 41 | public: 42 | explicit ColorDialog(QWidget *parent = 0, SubtitleProcessor* subtitleProcessor = 0); 43 | ~ColorDialog(); 44 | 45 | void setParameters(QStringList names, QVector currentColor, QVector defaultColor); 46 | void setPath(QString value) { colorPath = value; } 47 | QString getPath() { return colorPath; } 48 | QVector getColors() { return selectedColors; } 49 | 50 | private slots: 51 | void on_colorList_doubleClicked(const QModelIndex &index); 52 | void on_changeColorButton_clicked(); 53 | void on_restoreDefaultColorsButton_clicked(); 54 | void on_savePaletteButton_clicked(); 55 | void on_loadPaletteButton_clicked(); 56 | void on_cancelButton_clicked(); 57 | void on_okButton_clicked(); 58 | 59 | private: 60 | Ui::ColorDialog *ui; 61 | SubtitleProcessor* subtitleProcessor = 0; 62 | QVector colorIcons; 63 | QVector selectedColors; 64 | QVector defaultColors; 65 | QStringList colorNames; 66 | QString colorPath; 67 | 68 | QString filter = tr("All Files (*.*);;(*.ini)"); 69 | QString selectedFilter = tr("(*.ini)"); 70 | 71 | void changeColor(const QModelIndex &index); 72 | }; 73 | 74 | #endif // COLORDIALOG_H 75 | -------------------------------------------------------------------------------- /src/colordialog.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | ColorDialog 4 | 5 | 6 | 7 | 0 8 | 0 9 | 365 10 | 200 11 | 12 | 13 | 14 | 15 | 365 16 | 200 17 | 18 | 19 | 20 | 21 | Tahoma 22 | 23 | 24 | 25 | Choose Colors 26 | 27 | 28 | true 29 | 30 | 31 | 32 | QLayout::SetFixedSize 33 | 34 | 35 | 36 | 37 | Choose Color 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 150 48 | 0 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 170 60 | 0 61 | 62 | 63 | 64 | Edit the selected color 65 | 66 | 67 | &Change Color 68 | 69 | 70 | false 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 170 79 | 0 80 | 81 | 82 | 83 | Revert to default colors 84 | 85 | 86 | &Restore default Colors 87 | 88 | 89 | false 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 170 98 | 0 99 | 100 | 101 | 102 | Save the current palette settings in an INI file 103 | 104 | 105 | &Save Palette 106 | 107 | 108 | false 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 170 117 | 0 118 | 119 | 120 | 121 | Load palette settings from an INI file 122 | 123 | 124 | &Load Palette 125 | 126 | 127 | false 128 | 129 | 130 | 131 | 132 | 133 | 134 | 0 135 | 136 | 137 | 138 | 139 | 140 | 70 141 | 0 142 | 143 | 144 | 145 | Lose changes and return 146 | 147 | 148 | &Cancel 149 | 150 | 151 | false 152 | 153 | 154 | 155 | 156 | 157 | 158 | Qt::Horizontal 159 | 160 | 161 | QSizePolicy::Fixed 162 | 163 | 164 | 165 | 30 166 | 20 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 70 176 | 0 177 | 178 | 179 | 180 | Apply changes and return 181 | 182 | 183 | &Ok 184 | 185 | 186 | false 187 | 188 | 189 | true 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | okButton 203 | colorList 204 | changeColorButton 205 | restoreDefaultColorsButton 206 | savePaletteButton 207 | loadPaletteButton 208 | cancelButton 209 | 210 | 211 | 212 | 213 | -------------------------------------------------------------------------------- /src/conversiondialog.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BDSup2Sub++ (C) 2012 Adam T. 3 | * Based on code from BDSup2Sub by Copyright 2009 Volker Oth (0xdeadbeef) 4 | * and Copyright 2012 Miklos Juhasz (mjuhasz) 5 | * 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #ifndef CONVERSIONDIALOG_H 21 | #define CONVERSIONDIALOG_H 22 | 23 | #include 24 | #if QT_VERSION >= 0x050000 25 | #include 26 | #else 27 | #include 28 | #endif 29 | 30 | class QPalette; 31 | class SubtitleProcessor; 32 | class QDoubleValidator; 33 | class QRegExpValidator; 34 | class QSettings; 35 | 36 | enum class Resolution : int; 37 | enum class SetState : int; 38 | 39 | namespace Ui { 40 | class ConversionDialog; 41 | } 42 | 43 | class ConversionDialog : public QDialog 44 | { 45 | Q_OBJECT 46 | 47 | public: 48 | explicit ConversionDialog(QWidget *parent = 0, SubtitleProcessor *subtitleProcessor = 0, QSettings* settings = 0); 49 | ~ConversionDialog(); 50 | 51 | void enableOptionMove(bool enable); 52 | 53 | protected: 54 | void keyPressEvent(QKeyEvent *event); 55 | 56 | private slots: 57 | void on_okButton_clicked(); 58 | void on_cancelButton_clicked(); 59 | void on_storeButton_clicked(); 60 | void on_restoreButton_clicked(); 61 | void on_resetButton_clicked(); 62 | 63 | void on_convertResolutionCheckBox_toggled(bool checked); 64 | void on_applyMoveAllSettingsCheckBox_toggled(bool checked); 65 | void on_changeFrameRateCheckBox_toggled(bool checked); 66 | void on_scaleCheckBox_toggled(bool checked); 67 | void on_fixTooShortFramesCheckBox_toggled(bool checked); 68 | 69 | void on_resolutionComboBox_currentIndexChanged(int index); 70 | void on_forceFlagsComboBox_currentIndexChanged(int index); 71 | void on_sourceFramerateComboBox_currentIndexChanged(const QString &arg1); 72 | void on_targetFramerateComboBox_currentIndexChanged(const QString &arg1); 73 | 74 | void on_scaleXLineEdit_textChanged(const QString &arg1); 75 | void on_scaleYLineEdit_textChanged(const QString &arg1); 76 | void on_delayLineEdit_textChanged(const QString &arg1); 77 | void on_minTimeLineEdit_textChanged(const QString &arg1); 78 | void on_sourceFramerateComboBox_editTextChanged(const QString &arg1); 79 | void on_targetFramerateComboBox_editTextChanged(const QString &arg1); 80 | 81 | void on_scaleXLineEdit_editingFinished(); 82 | void on_scaleYLineEdit_editingFinished(); 83 | void on_delayLineEdit_editingFinished(); 84 | void on_minTimeLineEdit_editingFinished(); 85 | 86 | private: 87 | Ui::ConversionDialog *ui; 88 | SubtitleProcessor *subtitleProcessor; 89 | 90 | QRegExpValidator* fpsSrcValidator; 91 | QRegExpValidator* fpsTrgValidator; 92 | QDoubleValidator* scaleXValidator; 93 | QDoubleValidator* scaleYValidator; 94 | QDoubleValidator* delayPTSValidator; 95 | QDoubleValidator* minTimePTSValidator; 96 | 97 | QSettings* settings; 98 | 99 | QPalette* errorBackground; 100 | QPalette* warnBackground; 101 | QPalette* okBackground; 102 | 103 | Resolution resolution; 104 | int delayPTS; 105 | int minTimePTS = 520; 106 | bool changeFPS; 107 | bool changeResolution; 108 | bool fixShortFrames; 109 | double fpsSrc; 110 | double fpsTrg; 111 | bool isReady = false; 112 | bool changeScale; 113 | double scaleX = 1; 114 | double scaleY = 1; 115 | bool fpsSrcCertain; 116 | SetState forcedState; 117 | bool moveCaptions; 118 | 119 | void fillDialog(); 120 | void on_sourceFramerateComboBox_editingFinished(); 121 | void on_targetFramerateComboBox_editingFinished(); 122 | }; 123 | 124 | #endif // CONVERSIONDIALOG_H 125 | -------------------------------------------------------------------------------- /src/editdialog.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BDSup2Sub++ (C) 2012 Adam T. 3 | * Based on code from BDSup2Sub by Copyright 2009 Volker Oth (0xdeadbeef) 4 | * and Copyright 2012 Miklos Juhasz (mjuhasz) 5 | * 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #ifndef EDITDIALOG_H 21 | #define EDITDIALOG_H 22 | 23 | #include 24 | #if QT_VERSION >= 0x050000 25 | #include 26 | #else 27 | #include 28 | #endif 29 | 30 | class SubtitleProcessor; 31 | class SubPicture; 32 | class QImage; 33 | class QDoubleValidator; 34 | class QIntValidator; 35 | class QRegExpValidator; 36 | class QPalette; 37 | 38 | namespace Ui { 39 | class EditDialog; 40 | } 41 | 42 | class EditDialog : public QDialog 43 | { 44 | Q_OBJECT 45 | 46 | public: 47 | explicit EditDialog(QWidget *parent = 0, SubtitleProcessor* subtitleProcessor = 0); 48 | ~EditDialog(); 49 | 50 | void setIndex(int value); 51 | int getIndex() { return index; } 52 | 53 | protected: 54 | void keyPressEvent(QKeyEvent *event); 55 | 56 | private slots: 57 | void on_minButton_clicked(); 58 | void on_maxButton_clicked(); 59 | void on_centerButton_clicked(); 60 | void on_topButton_clicked(); 61 | void on_bottomButton_clicked(); 62 | void on_addErasePatchButton_clicked(); 63 | void on_undoErasePatchButton_clicked(); 64 | void on_undoAllErasePatchesButton_clicked(); 65 | void on_cancelButton_clicked(); 66 | void on_saveButton_clicked(); 67 | void on_okButton_clicked(); 68 | 69 | void on_excludeCheckBox_toggled(bool checked); 70 | void on_forcedCaptionCheckBox_toggled(bool checked); 71 | 72 | void on_verticalSlider_valueChanged(int value); 73 | void on_horizontalSlider_valueChanged(int value); 74 | 75 | void on_startTimeLineEdit_textChanged(const QString &arg1); 76 | void on_endTimeLineEdit_textChanged(const QString &arg1); 77 | void on_durationLineEdit_textChanged(const QString &arg1); 78 | void on_xOffsetLineEdit_textChanged(const QString &arg1); 79 | void on_yOffsetLineEdit_textChanged(const QString &arg1); 80 | 81 | void on_startTimeLineEdit_editingFinished(); 82 | void on_endTimeLineEdit_editingFinished(); 83 | void on_durationLineEdit_editingFinished(); 84 | void on_xOffsetLineEdit_editingFinished(); 85 | void on_yOffsetLineEdit_editingFinished(); 86 | 87 | void onSelectionPerformed(bool validSelection); 88 | 89 | void on_storePreviousButton_clicked(); 90 | void on_storeNextButton_clicked(); 91 | void on_previousButton_clicked(); 92 | void on_nextButton_clicked(); 93 | 94 | private: 95 | Ui::EditDialog *ui; 96 | QImage image; 97 | SubtitleProcessor* subtitleProcessor = 0; 98 | SubPicture* subPicture; 99 | SubPicture* subPictureNext = 0; 100 | SubPicture* subPicturePrevious = 0; 101 | QDoubleValidator* durationValidator; 102 | QIntValidator* xOffsetValidator; 103 | QIntValidator* yOffsetValidator; 104 | QRegExpValidator* startTimeValidator; 105 | QRegExpValidator* endTimeValidator; 106 | QPalette* errorBackground; 107 | QPalette* warnBackground; 108 | QPalette* okBackground; 109 | int frameTime = 0; 110 | int index = 0; 111 | int minimumWidth = 768; 112 | int minimumHeight = 432; 113 | bool enableSliders = false; 114 | bool edited = false; 115 | bool isReady = false; 116 | 117 | void setEdited(bool edited); 118 | void store(); 119 | }; 120 | 121 | #endif // EDITDIALOG_H 122 | -------------------------------------------------------------------------------- /src/editpane.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BDSup2Sub++ (C) 2012 Adam T. 3 | * Based on code from BDSup2Sub by Copyright 2009 Volker Oth (0xdeadbeef) 4 | * and Copyright 2012 Miklos Juhasz (mjuhasz) 5 | * 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #ifndef EDITPANE_H 21 | #define EDITPANE_H 22 | 23 | #include 24 | #if QT_VERSION >= 0x050000 25 | #include 26 | #else 27 | #include 28 | #endif 29 | 30 | class EditPane : public QLabel 31 | { 32 | Q_OBJECT 33 | public: 34 | explicit EditPane(QWidget *parent = 0, bool isLabel = true); 35 | 36 | void setDimension(int width, int height) { this->width = width; this->height = height; } 37 | void setOffsets(int x, int y); 38 | void setCropOfsY(int ofs) { cropOfsY = ofs; } 39 | void setImage(const QImage &image, int width, int height); 40 | void setExcluded(bool excluded) { this->excluded = excluded; } 41 | void setAllowSelection(bool value) { allowSelection = value; } 42 | void setIsLabel(bool value) { isLabel = value; } 43 | QVector getSelection(); 44 | void removeSelection() { if (allowSelection && validSelection) { validSelection = false; } } 45 | void setScreenRatio(double ratio) { screenRatioIn = ratio; cineBarFactor = (1.0 - (screenRatio / screenRatioIn)) / 2.0; } 46 | 47 | signals: 48 | void onMouseClicked(QMouseEvent *event); 49 | void selectionPerformed(bool validSelection); 50 | 51 | protected: 52 | void mousePressEvent(QMouseEvent *event); 53 | void mouseReleaseEvent(QMouseEvent *event); 54 | void mouseMoveEvent(QMouseEvent *event); 55 | void paintEvent(QPaintEvent *event); 56 | 57 | private: 58 | QImage img; 59 | QColor color1 = Qt::blue; 60 | QColor color2 = Qt::black; 61 | int width = 1920; 62 | int height = 1080; 63 | int ofsX = 0; 64 | int ofsY = 0; 65 | int imgWidth = 0; 66 | int imgHeight = 0; 67 | double screenRatioIn = 21.0 / 9; 68 | double cineBarFactor = 5.0 / 42; 69 | static constexpr double screenRatio = 16.0 / 9; 70 | int cropOfsY = 0; 71 | int inset = 2; 72 | bool validSelection = false; 73 | bool isLabel = true; 74 | int selectStartX = -1; 75 | int selectEndX = 0; 76 | int selectStartY = 0; 77 | int selectEndY = 0; 78 | bool allowSelection = false; 79 | bool leftButtonPressed = false; 80 | bool excluded = false; 81 | double xScaleCaption = 0; 82 | double yScaleCaption = 0; 83 | int yCrop = 0; 84 | 85 | void Initialize(bool isLayoutPane); 86 | 87 | }; 88 | 89 | #endif // EDITPANE_H 90 | -------------------------------------------------------------------------------- /src/exportdialog.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * BDSup2Sub++ (C) 2012 Adam T. 3 | * Based on code from BDSup2Sub by Copyright 2009 Volker Oth (0xdeadbeef) 4 | * and Copyright 2012 Miklos Juhasz (mjuhasz) 5 | * 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #include "exportdialog.h" 21 | #include "ui_exportdialog.h" 22 | #include "Subtitles/subtitleprocessor.h" 23 | #include 24 | 25 | #if QT_VERSION >= 0x050000 26 | #include 27 | #else 28 | #include 29 | #endif 30 | 31 | #include "types.h" 32 | 33 | ExportDialog::ExportDialog(QWidget *parent, QString filePath, SubtitleProcessor* subtitleProcessor) : 34 | QDialog(parent), 35 | ui(new Ui::ExportDialog), 36 | saveFileName(filePath) 37 | { 38 | this->subtitleProcessor = subtitleProcessor; 39 | ui->setupUi(this); 40 | setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint); 41 | ui->fileNameLineEdit->setText(QDir::toNativeSeparators(saveFileName)); 42 | languageIdx = subtitleProcessor->getLanguageIdx(); 43 | exportForced = subtitleProcessor->getNumForcedFrames() > 0 && subtitleProcessor->getExportForced(); 44 | writePGCPal = subtitleProcessor->getWritePGCEditPal(); 45 | 46 | ui->languageComboBox->blockSignals(true); 47 | for (auto language : subtitleProcessor->getLanguages()) 48 | { 49 | int n = subtitleProcessor->getOutputMode() == OutputMode::XML ? 2 : 1; 50 | ui->languageComboBox->addItem(QString(language[0] + " (" + language[n] + ")")); 51 | } 52 | ui->languageComboBox->setCurrentIndex(languageIdx); 53 | ui->languageComboBox->blockSignals(false); 54 | 55 | if (subtitleProcessor->getOutputMode() == OutputMode::BDSUP) 56 | { 57 | ui->languageComboBox->setEnabled(false); 58 | } 59 | 60 | if (subtitleProcessor->getOutputMode() == OutputMode::VOBSUB || subtitleProcessor->getOutputMode() == OutputMode::SUPIFO) 61 | { 62 | ui->exportPGCEditFormatCheckBox->setEnabled(true); 63 | ui->exportPGCEditFormatCheckBox->setChecked(writePGCPal); 64 | } 65 | else 66 | { 67 | ui->exportPGCEditFormatCheckBox->setEnabled(false); 68 | } 69 | 70 | ui->exportForcedOnlyCheckBox->setEnabled(subtitleProcessor->getNumForcedFrames() > 0); 71 | ui->exportForcedOnlyCheckBox->setChecked(exportForced); 72 | 73 | if (subtitleProcessor->getOutputMode() == OutputMode::VOBSUB) 74 | { 75 | this->setWindowTitle("Export SUB/IDX (VobSub)"); 76 | } 77 | else if (subtitleProcessor->getOutputMode() == OutputMode::SUPIFO) 78 | { 79 | this->setWindowTitle("Export SUP/IFO (SUP DVD)"); 80 | } 81 | else if (subtitleProcessor->getOutputMode() == OutputMode::BDSUP) 82 | { 83 | this->setWindowTitle("Export BD SUP"); 84 | } 85 | else 86 | { 87 | this->setWindowTitle("Export XML (SONY BDN)"); 88 | } 89 | } 90 | 91 | ExportDialog::~ExportDialog() 92 | { 93 | delete ui; 94 | } 95 | 96 | void ExportDialog::on_cancelButton_clicked() 97 | { 98 | reject(); 99 | } 100 | 101 | void ExportDialog::on_saveButton_clicked() 102 | { 103 | accept(); 104 | subtitleProcessor->setExportForced(exportForced); 105 | subtitleProcessor->setLanguageIdx(languageIdx); 106 | if (subtitleProcessor->getOutputMode() == OutputMode::VOBSUB || subtitleProcessor->getOutputMode() == OutputMode::SUPIFO) 107 | { 108 | subtitleProcessor->setWritePGCEditPal(writePGCPal); 109 | } 110 | } 111 | 112 | void ExportDialog::on_browseButton_clicked() 113 | { 114 | QString extension = QFileInfo(ui->fileNameLineEdit->text()).suffix(); 115 | filter += QString(extension + ")"); 116 | selectedFilter += QString(extension + ")"); 117 | QString fileName = QFileDialog::getSaveFileName(this, tr("Save"), 118 | ui->fileNameLineEdit->text(), 119 | filter, 120 | &selectedFilter); 121 | 122 | if (fileName.isNull() || fileName.isEmpty()) return; 123 | 124 | ui->fileNameLineEdit->setText(QDir::toNativeSeparators(fileName)); 125 | saveFileName = fileName; 126 | } 127 | 128 | void ExportDialog::on_fileNameLineEdit_textChanged(const QString &inFileName) 129 | { 130 | saveFileName = inFileName; 131 | } 132 | 133 | void ExportDialog::on_exportPGCEditFormatCheckBox_toggled(bool checked) 134 | { 135 | writePGCPal = checked; 136 | } 137 | 138 | void ExportDialog::on_exportForcedOnlyCheckBox_toggled(bool checked) 139 | { 140 | exportForced = checked; 141 | } 142 | 143 | void ExportDialog::on_languageComboBox_currentIndexChanged(int index) 144 | { 145 | languageIdx = index; 146 | } 147 | -------------------------------------------------------------------------------- /src/exportdialog.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BDSup2Sub++ (C) 2012 Adam T. 3 | * Based on code from BDSup2Sub by Copyright 2009 Volker Oth (0xdeadbeef) 4 | * and Copyright 2012 Miklos Juhasz (mjuhasz) 5 | * 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #ifndef EXPORTDIALOG_H 21 | #define EXPORTDIALOG_H 22 | 23 | #include 24 | #if QT_VERSION >= 0x050000 25 | #include 26 | #else 27 | #include 28 | #endif 29 | 30 | class SubtitleProcessor; 31 | 32 | namespace Ui { 33 | class ExportDialog; 34 | } 35 | 36 | class ExportDialog : public QDialog 37 | { 38 | Q_OBJECT 39 | 40 | public: 41 | explicit ExportDialog(QWidget *parent = 0, QString filePath = "", SubtitleProcessor* subtitleProcessor = 0); 42 | ~ExportDialog(); 43 | QString getFileName() { return saveFileName; } 44 | 45 | private slots: 46 | void on_cancelButton_clicked(); 47 | void on_saveButton_clicked(); 48 | void on_browseButton_clicked(); 49 | void on_fileNameLineEdit_textChanged(const QString &inFileName); 50 | void on_exportPGCEditFormatCheckBox_toggled(bool checked); 51 | void on_exportForcedOnlyCheckBox_toggled(bool checked); 52 | 53 | void on_languageComboBox_currentIndexChanged(int index); 54 | 55 | private: 56 | Ui::ExportDialog *ui; 57 | QString filter = tr("All Files (*.*);;(*."); 58 | QString selectedFilter = tr("(*."); 59 | QString saveFileName; 60 | SubtitleProcessor* subtitleProcessor; 61 | int languageIdx; 62 | bool exportForced; 63 | bool writePGCPal; 64 | }; 65 | 66 | #endif // EXPORTDIALOG_H 67 | -------------------------------------------------------------------------------- /src/exportdialog.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | ExportDialog 4 | 5 | 6 | 7 | 0 8 | 0 9 | 350 10 | 150 11 | 12 | 13 | 14 | 15 | 350 16 | 150 17 | 18 | 19 | 20 | Dialog 21 | 22 | 23 | true 24 | 25 | 26 | 27 | 6 28 | 29 | 30 | QLayout::SetFixedSize 31 | 32 | 33 | 9 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 60 44 | 0 45 | 46 | 47 | 48 | Filename 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 180 57 | 0 58 | 59 | 60 | 61 | Set file name for export 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | Open file dialog to select file name for export 71 | 72 | 73 | &Browse 74 | 75 | 76 | false 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 60 91 | 0 92 | 93 | 94 | 95 | Language 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 110 104 | 0 105 | 106 | 107 | 108 | Set language identifier 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | Qt::Horizontal 118 | 119 | 120 | 121 | 128 122 | 20 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | false 133 | 134 | 135 | Export only subpictures marked as 'forced' 136 | 137 | 138 | Export only &forced 139 | 140 | 141 | 142 | 143 | 144 | 145 | Export palette in PGCEdit text format (RGB, 0..255) 146 | 147 | 148 | Export &palette in PGCEdit text format 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | Cancel export and return 158 | 159 | 160 | &Cancel 161 | 162 | 163 | false 164 | 165 | 166 | 167 | 168 | 169 | 170 | Qt::Horizontal 171 | 172 | 173 | 174 | 158 175 | 20 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | Start creation of export stream 184 | 185 | 186 | &Save 187 | 188 | 189 | false 190 | 191 | 192 | true 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | saveButton 202 | fileNameLineEdit 203 | browseButton 204 | languageComboBox 205 | exportForcedOnlyCheckBox 206 | exportPGCEditFormatCheckBox 207 | cancelButton 208 | 209 | 210 | 211 | 212 | -------------------------------------------------------------------------------- /src/framepalettedialog.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BDSup2Sub++ (C) 2012 Adam T. 3 | * Based on code from BDSup2Sub by Copyright 2009 Volker Oth (0xdeadbeef) 4 | * and Copyright 2012 Miklos Juhasz (mjuhasz) 5 | * 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #ifndef FRAMEPALETTEDIALOG_H 21 | #define FRAMEPALETTEDIALOG_H 22 | 23 | #include 24 | #if QT_VERSION >= 0x050000 25 | #include 26 | #else 27 | #include 28 | #endif 29 | 30 | class SubtitleProcessor; 31 | 32 | namespace Ui { 33 | class FramePaletteDialog; 34 | } 35 | 36 | class FramePaletteDialog : public QDialog 37 | { 38 | Q_OBJECT 39 | 40 | public: 41 | explicit FramePaletteDialog(QWidget *parent = 0, SubtitleProcessor* subtitleProcessor = 0); 42 | ~FramePaletteDialog(); 43 | 44 | void setIndex(int idx); 45 | 46 | private slots: 47 | 48 | void on_color1ComboBox_currentIndexChanged(int index); 49 | void on_color2ComboBox_currentIndexChanged(int index); 50 | void on_color3ComboBox_currentIndexChanged(int index); 51 | void on_color4ComboBox_currentIndexChanged(int index); 52 | void on_alpha1ComboBox_currentIndexChanged(int index); 53 | void on_alpha2ComboBox_currentIndexChanged(int index); 54 | void on_alpha3ComboBox_currentIndexChanged(int index); 55 | void on_alpha4ComboBox_currentIndexChanged(int index); 56 | 57 | void on_resetAllButton_clicked(); 58 | void on_setAllButton_clicked(); 59 | void on_cancelButton_clicked(); 60 | void on_resetButton_clicked(); 61 | void on_okButton_clicked(); 62 | 63 | private: 64 | Ui::FramePaletteDialog *ui; 65 | SubtitleProcessor* subtitleProcessor = 0; 66 | QStringList colorNames = { "00", "01", "02", "03", "04", "05", "06" ,"07", 67 | "08", "09", "10", "11", "12", "13", "14", "15" 68 | }; 69 | QVector colorIcons; 70 | int index; 71 | QVector alpha; 72 | QVector pal; 73 | }; 74 | 75 | #endif // FRAMEPALETTEDIALOG_H 76 | -------------------------------------------------------------------------------- /src/help.ini: -------------------------------------------------------------------------------- 1 | chapter_0=Intro,Introduction 2 | chapter_1=Using_the_GUI,Using the GUI 3 | chapter_2=Color_Palettes,Color Palettes 4 | chapter_3=Concepts_and_Features,Other Concepts and Features 5 | chapter_4=Export_Dialog,Export Dialog 6 | chapter_5=Conversion_Dialog,Conversion Dialog 7 | chapter_6=Edit_Dialog,Edit Dialog 8 | chapter_7=Move_Crop_Dialog,Moving and Cropping 9 | chapter_8=Formats,Notes on Formats 10 | chapter_9=Command_Line_Interface,Command Line Interface 11 | chapter_10=Application_Hints,Application Hints 12 | chapter_11=Source_Code,Source Code 13 | chapter_12=Disclaimer,Disclaimer 14 | chapter_13=Change_History,Change History 15 | -------------------------------------------------------------------------------- /src/helpdialog.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * BDSup2Sub++ (C) 2012 Adam T. 3 | * Based on code from BDSup2Sub by Copyright 2009 Volker Oth (0xdeadbeef) 4 | * and Copyright 2012 Miklos Juhasz (mjuhasz) 5 | * 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #include "helpdialog.h" 21 | #include "ui_helpdialog.h" 22 | #include "types.h" 23 | 24 | #include 25 | 26 | HelpDialog::HelpDialog(QWidget *parent) : 27 | QDialog(parent), 28 | ui(new Ui::HelpDialog) 29 | { 30 | ui->setupUi(this); 31 | setWindowTitle(progNameVer + " Help"); 32 | setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowMinimizeButtonHint | 33 | Qt::WindowMaximizeButtonHint | Qt::WindowCloseButtonHint); 34 | 35 | QFile file(":/new/resources/help.htm"); 36 | if(!file.open(QIODevice::ReadOnly | QIODevice::Text)) 37 | { 38 | return; 39 | } 40 | ui->textBrowser->setHtml(file.readAll()); 41 | file.close(); 42 | } 43 | 44 | HelpDialog::~HelpDialog() 45 | { 46 | delete ui; 47 | } 48 | -------------------------------------------------------------------------------- /src/helpdialog.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BDSup2Sub++ (C) 2012 Adam T. 3 | * Based on code from BDSup2Sub by Copyright 2009 Volker Oth (0xdeadbeef) 4 | * and Copyright 2012 Miklos Juhasz (mjuhasz) 5 | * 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #ifndef HELPDIALOG_H 21 | #define HELPDIALOG_H 22 | 23 | #include 24 | #if QT_VERSION >= 0x050000 25 | #include 26 | #else 27 | #include 28 | #endif 29 | 30 | namespace Ui { 31 | class HelpDialog; 32 | } 33 | 34 | class HelpDialog : public QDialog 35 | { 36 | Q_OBJECT 37 | 38 | public: 39 | explicit HelpDialog(QWidget *parent = 0); 40 | ~HelpDialog(); 41 | 42 | private: 43 | Ui::HelpDialog *ui; 44 | }; 45 | 46 | #endif // HELPDIALOG_H 47 | -------------------------------------------------------------------------------- /src/helpdialog.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | HelpDialog 4 | 5 | 6 | 7 | 0 8 | 0 9 | 785 10 | 565 11 | 12 | 13 | 14 | 15 | 785 16 | 565 17 | 18 | 19 | 20 | 21 | Times New Roman 22 | 10 23 | 24 | 25 | 26 | Dialog 27 | 28 | 29 | 30 | :/new/resources/bdsup2sub.ico:/new/resources/bdsup2sub.ico 31 | 32 | 33 | 34 | 0 35 | 36 | 37 | 0 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /src/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * BDSup2Sub++ (C) 2012 Adam T. 3 | * Based on code from BDSup2Sub by Copyright 2009 Volker Oth (0xdeadbeef) 4 | * and Copyright 2012 Miklos Juhasz (mjuhasz) 5 | * 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #include 21 | 22 | #if QT_VERSION >= 0x050000 23 | #include 24 | #else 25 | #include 26 | #endif 27 | 28 | #include "bdsup2sub.h" 29 | #ifdef Q_OS_WIN 30 | #include 31 | #endif 32 | 33 | int main(int argc, char *argv[]) 34 | { 35 | QApplication a(argc, argv); 36 | BDSup2Sub w; 37 | 38 | bool isGUI = argc == 1; 39 | 40 | if (isGUI || !w.execCLI(argc, argv)) 41 | { 42 | #ifdef Q_OS_WIN 43 | FreeConsole(); 44 | #endif 45 | w.show(); 46 | } 47 | return a.exec(); 48 | } 49 | -------------------------------------------------------------------------------- /src/movedialog.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BDSup2Sub++ (C) 2012 Adam T. 3 | * Based on code from BDSup2Sub by Copyright 2009 Volker Oth (0xdeadbeef) 4 | * and Copyright 2012 Miklos Juhasz (mjuhasz) 5 | * 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #ifndef MOVEDIALOG_H 21 | #define MOVEDIALOG_H 22 | 23 | #include 24 | #if QT_VERSION >= 0x050000 25 | #include 26 | #else 27 | #include 28 | #endif 29 | 30 | class SubtitleProcessor; 31 | class SubPicture; 32 | class QImage; 33 | class QButtonGroup; 34 | class QIntValidator; 35 | class QDoubleValidator; 36 | 37 | enum class MoveModeX : int; 38 | enum class MoveModeY: int; 39 | 40 | namespace Ui { 41 | class MoveDialog; 42 | } 43 | 44 | class MoveDialog : public QDialog 45 | { 46 | Q_OBJECT 47 | 48 | public: 49 | explicit MoveDialog(QWidget *parent = 0, SubtitleProcessor* subtitleProcessor = 0); 50 | ~MoveDialog(); 51 | void setIndex(int idx); 52 | int getIndex() { return index; } 53 | double getTrgRatio() { return screenRatioTrg; } 54 | 55 | protected: 56 | void keyPressEvent(QKeyEvent *event); 57 | 58 | private slots: 59 | void on_previousButton_clicked(); 60 | void on_nextButton_clicked(); 61 | void on_cropBarsButton_clicked(); 62 | void on_cancelButton_clicked(); 63 | void on_moveAllButton_clicked(); 64 | void on_aspectRatio1Button_clicked(); 65 | void on_aspectRatio2Button_clicked(); 66 | void on_aspectRatio3Button_clicked(); 67 | 68 | void on_keepXPositionRadioButton_clicked(); 69 | void on_moveFromXPositionRadioButton_clicked(); 70 | void on_moveLeftRadioButton_clicked(); 71 | void on_moveRightRadioButton_clicked(); 72 | void on_moveToCenterRadioButton_clicked(); 73 | 74 | void on_keepYPositionRadioButton_clicked(); 75 | void on_moveFromYPositionRadioButton_clicked(); 76 | void on_moveInsideBoundsRadioButton_clicked(); 77 | void on_moveOutsideBoundsRadioButton_clicked(); 78 | 79 | void on_xOffsetLineEdit_textChanged(const QString &arg1); 80 | void on_yOffsetLineEdit_textChanged(const QString &arg1); 81 | void on_aspectRatioLineEdit_textChanged(const QString &arg1); 82 | void on_cropOffsetYLineEdit_textChanged(const QString &arg1); 83 | 84 | void on_xOffsetLineEdit_editingFinished(); 85 | void on_yOffsetLineEdit_editingFinished(); 86 | void on_aspectRatioLineEdit_editingFinished(); 87 | void on_cropOffsetYLineEdit_editingFinished(); 88 | 89 | private: 90 | Ui::MoveDialog *ui; 91 | SubtitleProcessor* subtitleProcessor; 92 | SubPicture* subPicture; 93 | QButtonGroup* xButtonGroup; 94 | QButtonGroup* yButtonGroup; 95 | QImage image; 96 | 97 | QIntValidator* offsetXValidator; 98 | QIntValidator* offsetYValidator; 99 | QIntValidator* cropOffsetYValidator; 100 | QDoubleValidator* aspectRatioValidator; 101 | 102 | MoveModeX moveModeX; 103 | MoveModeY moveModeY; 104 | 105 | int index; 106 | int originalX; 107 | int originalY; 108 | int offsetX; 109 | int offsetY; 110 | int cropOfsY; 111 | 112 | double screenRatioTrg = 21.0 / 9; 113 | double screenRatio = 16.0 / 9; 114 | double cineBarFactor = 5.0 / 42; 115 | 116 | QPalette* errorBackground; 117 | QPalette* okBackground; 118 | 119 | void setRatio(double ratio); 120 | void move(); 121 | }; 122 | 123 | #endif // MOVEDIALOG_H 124 | -------------------------------------------------------------------------------- /src/progressdialog.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * BDSup2Sub++ (C) 2012 Adam T. 3 | * Based on code from BDSup2Sub by Copyright 2009 Volker Oth (0xdeadbeef) 4 | * and Copyright 2012 Miklos Juhasz (mjuhasz) 5 | * 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #include "progressdialog.h" 21 | #include "ui_progressdialog.h" 22 | 23 | ProgressDialog::ProgressDialog(QWidget *parent) : 24 | QDialog(parent), 25 | ui(new Ui::ProgressDialog) 26 | { 27 | ui->setupUi(this); 28 | setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint); 29 | } 30 | 31 | ProgressDialog::~ProgressDialog() 32 | { 33 | delete ui; 34 | } 35 | 36 | void ProgressDialog::setText(QString text) 37 | { 38 | ui->label->setText(text); 39 | } 40 | 41 | void ProgressDialog::setCurrentValue(int value) 42 | { 43 | ui->progressBar->setValue(value); 44 | } 45 | 46 | void ProgressDialog::on_cancelButton_pressed() 47 | { 48 | emit operationCancelled(); 49 | this->close(); 50 | } 51 | -------------------------------------------------------------------------------- /src/progressdialog.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BDSup2Sub++ (C) 2012 Adam T. 3 | * Based on code from BDSup2Sub by Copyright 2009 Volker Oth (0xdeadbeef) 4 | * and Copyright 2012 Miklos Juhasz (mjuhasz) 5 | * 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #ifndef PROGRESSDIALOG_H 21 | #define PROGRESSDIALOG_H 22 | 23 | #include 24 | #if QT_VERSION >= 0x050000 25 | #include 26 | #else 27 | #include 28 | #endif 29 | #include 30 | 31 | namespace Ui { 32 | class ProgressDialog; 33 | } 34 | 35 | class ProgressDialog : public QDialog 36 | { 37 | Q_OBJECT 38 | 39 | public: 40 | explicit ProgressDialog(QWidget *parent = 0); 41 | ~ProgressDialog(); 42 | 43 | signals: 44 | void operationCancelled(); 45 | 46 | public slots: 47 | void setText(QString newText); 48 | void setCurrentValue(int value); 49 | 50 | private slots: 51 | void on_cancelButton_pressed(); 52 | 53 | private: 54 | Ui::ProgressDialog *ui; 55 | }; 56 | 57 | #endif // PROGRESSDIALOG_H 58 | -------------------------------------------------------------------------------- /src/progressdialog.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | ProgressDialog 4 | 5 | 6 | 7 | 0 8 | 0 9 | 225 10 | 140 11 | 12 | 13 | 14 | 15 | 225 16 | 140 17 | 18 | 19 | 20 | Loading 21 | 22 | 23 | true 24 | 25 | 26 | 27 | QLayout::SetFixedSize 28 | 29 | 30 | 31 | 32 | 0 33 | 34 | 35 | Qt::AlignCenter 36 | 37 | 38 | 39 | 40 | 41 | 42 | Qt::Vertical 43 | 44 | 45 | 46 | 86 47 | 11 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | Qt::Horizontal 56 | 57 | 58 | 59 | 54 60 | 20 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | Cancel 69 | 70 | 71 | true 72 | 73 | 74 | 75 | 76 | 77 | 78 | Qt::Horizontal 79 | 80 | 81 | 82 | 45 83 | 20 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | Qt::Vertical 92 | 93 | 94 | 95 | 20 96 | 10 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | Tahoma 106 | 107 | 108 | 109 | Exporting SUB/IDX 110 | 111 | 112 | Qt::AlignCenter 113 | 114 | 115 | 116 | 117 | 118 | 119 | Qt::Vertical 120 | 121 | 122 | 123 | 86 124 | 13 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | -------------------------------------------------------------------------------- /src/qxtcommandoptions.h: -------------------------------------------------------------------------------- 1 | 2 | /**************************************************************************** 3 | ** Copyright (c) 2006 - 2011, the LibQxt project. 4 | ** See the Qxt AUTHORS file for a list of authors and copyright holders. 5 | ** All rights reserved. 6 | ** 7 | ** Redistribution and use in source and binary forms, with or without 8 | ** modification, are permitted provided that the following conditions are met: 9 | ** * Redistributions of source code must retain the above copyright 10 | ** notice, this list of conditions and the following disclaimer. 11 | ** * Redistributions in binary form must reproduce the above copyright 12 | ** notice, this list of conditions and the following disclaimer in the 13 | ** documentation and/or other materials provided with the distribution. 14 | ** * Neither the name of the LibQxt project nor the 15 | ** names of its contributors may be used to endorse or promote products 16 | ** derived from this software without specific prior written permission. 17 | ** 18 | ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 19 | ** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | ** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | ** DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY 22 | ** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | ** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | ** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 25 | ** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | ** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | ** 29 | ** 30 | *****************************************************************************/ 31 | 32 | #ifndef QXTCOMMANDOPTIONS_H 33 | #define QXTCOMMANDOPTIONS_H 34 | #include 35 | #include 36 | #include 37 | #include // for Q_DECLARE_TR_FUNCTIONS 38 | #include 39 | #include 40 | class QxtCommandOptionsPrivate; 41 | QT_FORWARD_DECLARE_CLASS(QTextStream) 42 | QT_FORWARD_DECLARE_CLASS(QIODevice) 43 | 44 | 45 | class QXT_CORE_EXPORT QxtCommandOptions 46 | { 47 | Q_DECLARE_TR_FUNCTIONS(QxtCommandOptions) 48 | 49 | public: 50 | /*! 51 | * \enum QxtCommandOptions::FlagStyle 52 | * This enum type defines which type of option prefix is used. 53 | * Slash is the default on Windows. 54 | * DoubleDash is the default on all other platforms. 55 | */ 56 | enum FlagStyle 57 | { 58 | DoubleDash, /*!< Two dashes (GNU-style) */ 59 | SingleDash, /*!< One dash (UNIX-style) */ 60 | Slash /*!< Forward slash (Windows-style) */ 61 | }; 62 | /*! 63 | * \enum QxtCommandOptions::ParamStyle 64 | * This enum type defines what syntax is used for options that 65 | * require parameters. Equals is the default on Windows. 66 | * SpaceAndEquals is the default on all other platforms. 67 | */ 68 | enum ParamStyle 69 | { 70 | Space = 1, /*!< Space ("-option value") */ 71 | Equals = 2, /*!< Equals sign ("/option=value") */ 72 | SpaceAndEquals = 3 /*!< Accept either */ 73 | }; 74 | /*! 75 | * \enum QxtCommandOptions::ParamType 76 | * \flags QxtCommandOptions::ParamTypes 77 | * This enum type is used to specify flags that control the 78 | * interpretation of an option. 79 | * 80 | * The ParamTypes type is a typedef for QFlags. It stores 81 | * an OR combination of ParamType values. 82 | */ 83 | enum ParamType 84 | { 85 | NoValue = 0, /*!< The option does not accept a value. */ 86 | ValueOptional = 1, /*!< The option may accept a value. */ 87 | ValueRequired = 2, /*!< The option requires a value. */ 88 | Optional = ValueOptional, /*!< The option may accept a value. Deprecated in favor of ValueOptional. */ 89 | Required = ValueRequired, /*!< The option requires a value. Deprecated in favor of ValueRequired. */ 90 | AllowMultiple = 4, /*!< The option may be passed multiple times. */ 91 | Undocumented = 8 /*!< The option is not output in the help text. */ 92 | }; 93 | Q_DECLARE_FLAGS(ParamTypes, ParamType) 94 | 95 | QxtCommandOptions(); 96 | 97 | void setFlagStyle(FlagStyle style); 98 | FlagStyle flagStyle() const; 99 | void setParamStyle(ParamStyle style); 100 | ParamStyle paramStyle() const; 101 | void setScreenWidth(quint16 width); 102 | quint16 screenWidth() const; 103 | 104 | void addSection(const QString& name); 105 | void add(const QString& name, const QString& desc = QString(), ParamTypes paramType = NoValue, int group = -1); 106 | void alias(const QString& from, const QString& to); 107 | 108 | QStringList positional() const; 109 | QStringList unrecognized() const; 110 | int count(const QString& name) const; 111 | QVariant value(const QString& name) const; 112 | QMultiHash parameters() const; 113 | 114 | void parse(int argc, char** argv); 115 | void parse(QStringList params); 116 | 117 | void showUsage(bool showQtOptions = false, QIODevice* device = 0) const; 118 | void showUsage(bool showQtOptions, QTextStream& stream) const; 119 | QString getUsage(bool showQtOptions = false) const; 120 | 121 | bool showUnrecognizedWarning(QIODevice* device = 0) const; 122 | bool showUnrecognizedWarning(QTextStream& stream) const; 123 | QString getUnrecognizedWarning() const; 124 | 125 | private: 126 | QXT_DECLARE_PRIVATE(QxtCommandOptions) 127 | }; 128 | Q_DECLARE_OPERATORS_FOR_FLAGS(QxtCommandOptions::ParamTypes) 129 | 130 | #endif // QXTCOMMANDOPTIONS_H 131 | -------------------------------------------------------------------------------- /src/zoomableimagearea.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * BDSup2Sub++ (C) 2012 Adam T. 3 | * Based on code from BDSup2Sub by Copyright 2009 Volker Oth (0xdeadbeef) 4 | * and Copyright 2012 Miklos Juhasz (mjuhasz) 5 | * 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #include "zoomableimagearea.h" 21 | #include 22 | #include 23 | #include 24 | 25 | #if QT_VERSION >= 0x050000 26 | #include 27 | #else 28 | #include 29 | #endif 30 | 31 | ZoomableImageArea::ZoomableImageArea(QWidget *parent) : 32 | QLabel(parent) 33 | { 34 | } 35 | 36 | void ZoomableImageArea::setImage(const QImage &inImage) 37 | { 38 | image = inImage; 39 | if (zoomScale == 0) 40 | { 41 | setZoomScale(1); 42 | } 43 | else 44 | { 45 | setZoomScale(zoomScale); 46 | } 47 | } 48 | 49 | void ZoomableImageArea::updateImage() 50 | { 51 | setZoomScale(zoomScale); 52 | } 53 | 54 | void ZoomableImageArea::setZoomScale(int scale) 55 | { 56 | if (scale != zoomScale) 57 | { 58 | zoomScale = scale; 59 | } 60 | if (!image.isNull() && image.width() != 0) 61 | { 62 | QRect target = image.rect(); 63 | target.setWidth(image.width() * zoomScale); 64 | target.setHeight(image.height() * zoomScale); 65 | 66 | QRect visibleArea = this->parentWidget()->visibleRegion().boundingRect(); 67 | 68 | int drawHeight = target.height() > visibleArea.height() ? target.height() : visibleArea.height(); 69 | int drawWidth = target.width() > visibleArea.width() ? target.width() : visibleArea.width(); 70 | 71 | 72 | drawPixmap.reset(new QPixmap(drawWidth, drawHeight)); 73 | drawPixmap->fill(); 74 | 75 | painter->begin(drawPixmap.data()); 76 | QLinearGradient gradient(0, 0, drawPixmap->width(), drawPixmap->height()); 77 | gradient.setColorAt(0, Qt::blue); 78 | gradient.setColorAt(1, Qt::black); 79 | painter->fillRect(0, 0, drawPixmap->width(), drawPixmap->height(), gradient); 80 | painter->drawImage(target, image, image.rect()); 81 | painter->end(); 82 | this->setPixmap(*drawPixmap); 83 | } 84 | } 85 | 86 | void ZoomableImageArea::paintEvent(QPaintEvent * /*event*/) 87 | { 88 | if (image.isNull() || image.width() == 0) 89 | { 90 | painter->begin(this); 91 | QLinearGradient gradient(0, 0, this->width(), this->height()); 92 | gradient.setColorAt(0, Qt::blue); 93 | gradient.setColorAt(1, Qt::black); 94 | painter->fillRect(0, 0, this->width(), this->height(), gradient); 95 | painter->end(); 96 | originalSize = this->size(); 97 | } 98 | else 99 | { 100 | painter->begin(this); 101 | painter->drawPixmap(0, 0, *drawPixmap); 102 | painter->end(); 103 | } 104 | } 105 | 106 | void ZoomableImageArea::mousePressEvent(QMouseEvent *event) 107 | { 108 | int scale = zoomScale; 109 | if (event->button() == Qt::LeftButton) 110 | { 111 | if (scale < 8) 112 | { 113 | ++scale; 114 | } 115 | } 116 | else 117 | { 118 | if (scale > 1) 119 | { 120 | --scale; 121 | } 122 | } 123 | if (scale != zoomScale) 124 | { 125 | setZoomScale(scale); 126 | } 127 | } 128 | -------------------------------------------------------------------------------- /src/zoomableimagearea.h: -------------------------------------------------------------------------------- 1 | /* 2 | * BDSup2Sub++ (C) 2012 Adam T. 3 | * Based on code from BDSup2Sub by Copyright 2009 Volker Oth (0xdeadbeef) 4 | * and Copyright 2012 Miklos Juhasz (mjuhasz) 5 | * 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | */ 19 | 20 | #ifndef ZOOMABLEIMAGEAREA_H 21 | #define ZOOMABLEIMAGEAREA_H 22 | 23 | #include 24 | #if QT_VERSION >= 0x050000 25 | #include 26 | #else 27 | #include 28 | #endif 29 | 30 | class ZoomableImageArea : public QLabel 31 | { 32 | Q_OBJECT 33 | public: 34 | explicit ZoomableImageArea(QWidget *parent = 0); 35 | void setImage(const QImage &inImage); 36 | void updateImage(); 37 | 38 | protected: 39 | void mousePressEvent(QMouseEvent *event); 40 | void paintEvent(QPaintEvent *event); 41 | 42 | signals: 43 | 44 | public slots: 45 | 46 | private: 47 | int zoomScale = 0; 48 | double scaleFactor = 0.0; 49 | bool settingPixmap = false; 50 | QImage image; 51 | QScopedPointer drawPixmap; 52 | QPainter* painter = new QPainter(); 53 | QSize originalSize; 54 | 55 | void setZoomScale(int scale); 56 | }; 57 | 58 | #endif // ZOOMABLEIMAGEAREA_H 59 | -------------------------------------------------------------------------------- /tools/linuxdeployqt.AppImage: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/amichaeltm/BDSup2SubPlusPlus/5f8c159d2fed0ae1726718121f49d30e0821f398/tools/linuxdeployqt.AppImage --------------------------------------------------------------------------------