├── VERSION ├── debian ├── patches │ └── series ├── dvbcut.manpages ├── source │ └── format ├── dirs ├── gbp.conf ├── dvbcut.docs ├── watch ├── upstream │ └── metadata ├── dvbcut.install ├── rules ├── control └── copyright ├── dvbcut.ico ├── icons ├── play.png ├── play.svgz ├── stop.png ├── stop.svgz ├── bookmark.png ├── chapter.png ├── chapter.svgz ├── bookmark.svgz └── icons.qrc ├── contrib ├── arch │ ├── dvbcut.install │ ├── readme.txt │ └── PKGBUILD ├── AR_to_43 └── AR_to_169 ├── import ├── stdlib.cpp ├── stdlib.h └── sys │ └── mman.h ├── .gitignore ├── CREDITS ├── dvbcut.xml ├── dvbcut.desktop.in ├── mkinstalldirs ├── INSTALL ├── src ├── playaudio.h ├── busyindicator.h ├── port.h ├── mplayererrorbase.h ├── exportdialog.h ├── mplayererrorbase.cpp ├── pts.h ├── differenceimageprovider.h ├── exception.h ├── psfile.h ├── exception.cpp ├── progresswindowbase.ui ├── exportdialog.cpp ├── progressstatusbar.h ├── logoutput.h ├── defines.h ├── streamhandle.h ├── eventlistitem.h ├── avframe.h ├── progresswindow.h ├── muxer.h ├── mplayererrorbase.ui ├── dvbcut_en.html ├── imageprovider.h ├── logoutput.cpp ├── dvbcut_cs.html ├── dvbcut_de.html ├── lavfmuxer.h ├── types.h ├── settings.h ├── stream.h ├── pts.cpp ├── progressstatusbar.cpp ├── imageprovider.cpp ├── dvbcut.pro ├── eventlistitem.cpp ├── differenceimageprovider.cpp ├── progresswindow.cpp ├── Makefile.in ├── avframe.cpp ├── tsfile.h ├── exportdialogbase.ui ├── index.h ├── buffer.h ├── lavfmuxer.cpp ├── mpgfile.h ├── dvbcut.h ├── psfile.cpp ├── mpegmuxer.h ├── streamdata.h ├── playaudio.cpp └── streamdata.cpp ├── dvbcut.1 ├── README ├── DISTFILES ├── README.icons ├── configure.ac └── Makefile.in /VERSION: -------------------------------------------------------------------------------- 1 | 0.7.4 2 | -------------------------------------------------------------------------------- /debian/patches/series: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /debian/dvbcut.manpages: -------------------------------------------------------------------------------- 1 | dvbcut.1 2 | -------------------------------------------------------------------------------- /debian/source/format: -------------------------------------------------------------------------------- 1 | 3.0 (quilt) 2 | -------------------------------------------------------------------------------- /debian/dirs: -------------------------------------------------------------------------------- 1 | usr/bin 2 | usr/share/man/man1 3 | -------------------------------------------------------------------------------- /debian/gbp.conf: -------------------------------------------------------------------------------- 1 | [DEFAULT] 2 | pristine-tar = True 3 | -------------------------------------------------------------------------------- /debian/dvbcut.docs: -------------------------------------------------------------------------------- 1 | README 2 | README.icons 3 | CREDITS 4 | -------------------------------------------------------------------------------- /dvbcut.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bernhardu/dvbcut-deb/HEAD/dvbcut.ico -------------------------------------------------------------------------------- /icons/play.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bernhardu/dvbcut-deb/HEAD/icons/play.png -------------------------------------------------------------------------------- /icons/play.svgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bernhardu/dvbcut-deb/HEAD/icons/play.svgz -------------------------------------------------------------------------------- /icons/stop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bernhardu/dvbcut-deb/HEAD/icons/stop.png -------------------------------------------------------------------------------- /icons/stop.svgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bernhardu/dvbcut-deb/HEAD/icons/stop.svgz -------------------------------------------------------------------------------- /icons/bookmark.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bernhardu/dvbcut-deb/HEAD/icons/bookmark.png -------------------------------------------------------------------------------- /icons/chapter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bernhardu/dvbcut-deb/HEAD/icons/chapter.png -------------------------------------------------------------------------------- /icons/chapter.svgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bernhardu/dvbcut-deb/HEAD/icons/chapter.svgz -------------------------------------------------------------------------------- /icons/bookmark.svgz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bernhardu/dvbcut-deb/HEAD/icons/bookmark.svgz -------------------------------------------------------------------------------- /debian/watch: -------------------------------------------------------------------------------- 1 | version=3 2 | 3 | opts=filenamemangle=s/.+\/v(\d\S*)\.tar\.gz/dvbcut-$1\.tar\.gz/ \ 4 | https://github.com/bernhardu/dvbcut-deb/tags .*/v(\d\S*)\.tar\.gz 5 | -------------------------------------------------------------------------------- /contrib/arch/dvbcut.install: -------------------------------------------------------------------------------- 1 | post_install() { 2 | update-desktop-database -q 3 | } 4 | 5 | post_upgrade() { 6 | post_install $1 7 | } 8 | 9 | post_remove() { 10 | post_install $1 11 | } 12 | -------------------------------------------------------------------------------- /icons/icons.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | bookmark.png 4 | chapter.png 5 | play.png 6 | stop.png 7 | 8 | 9 | -------------------------------------------------------------------------------- /debian/upstream/metadata: -------------------------------------------------------------------------------- 1 | Bug-Database: https://github.com/bernhardu/dvbcut-deb/issues 2 | Bug-Submit: https://github.com/bernhardu/dvbcut-deb/issues/new 3 | Repository: https://github.com/bernhardu/dvbcut-deb.git 4 | Repository-Browse: https://github.com/bernhardu/dvbcut-deb 5 | -------------------------------------------------------------------------------- /debian/dvbcut.install: -------------------------------------------------------------------------------- 1 | dvbcut.desktop usr/share/applications 2 | dvbcut.svg usr/share/dvbcut/icons 3 | dvbcut.xml usr/share/mime/packages 4 | src/dvbcut usr/bin 5 | src/dvbcut.qm usr/share/dvbcut 6 | src/dvbcut_cs.html usr/share/dvbcut 7 | src/dvbcut_cs.qm usr/share/dvbcut 8 | src/dvbcut_de.html usr/share/dvbcut 9 | src/dvbcut_de.qm usr/share/dvbcut 10 | src/dvbcut_en.html usr/share/dvbcut 11 | -------------------------------------------------------------------------------- /debian/rules: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | 3 | export QT_SELECT := qt5 4 | 5 | export DEB_BUILD_MAINT_OPTIONS = hardening=+all 6 | DPKG_EXPORT_BUILDFLAGS = 1 7 | include /usr/share/dpkg/buildflags.mk 8 | 9 | include /usr/share/dpkg/pkg-info.mk 10 | DVBCUT_VERSION := $(DEB_VERSION) 11 | export CPPFLAGS += -DDVBCUT_VERSION=\"$(DVBCUT_VERSION)\" 12 | 13 | %: 14 | dh $@ 15 | 16 | override_dh_auto_install: 17 | -------------------------------------------------------------------------------- /import/stdlib.cpp: -------------------------------------------------------------------------------- 1 | #include "stdlib.h" 2 | 3 | int vasprintf (char**s, const char* fmt, va_list va){ 4 | *s=(char *)malloc(1024); 5 | return vsprintf(*s,fmt,va); 6 | } 7 | 8 | char *realpath (const char *path, char *resolved) 9 | { 10 | strcpy(resolved,path); return resolved; 11 | } 12 | 13 | int asprintf (char **text, const char *fmt, ...) 14 | { 15 | va_list ap; 16 | va_start(ap,fmt); 17 | return vasprintf(text,fmt,ap); 18 | } 19 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .pc/ 2 | autom4te.cache/ 3 | bin/dvbcut 4 | config.guess.dh-orig 5 | config.log 6 | config.status 7 | config.sub.dh-orig 8 | configure 9 | debian/.debhelper/ 10 | debian/autoreconf.* 11 | debian/debhelper-build-stamp 12 | debian/dvbcut.debhelper.log 13 | debian/dvbcut.substvars 14 | debian/dvbcut/ 15 | debian/files 16 | dvbcut.desktop 17 | Makefile 18 | src/*.o 19 | src/*.qm 20 | src/dvbcut 21 | src/moc_*.cpp 22 | src/qrc_icons.cpp 23 | src/ui_*.h 24 | -------------------------------------------------------------------------------- /import/stdlib.h: -------------------------------------------------------------------------------- 1 | #ifndef MYSTDLIB 2 | #define MYSTDLIB 3 | #include_next 4 | #include 5 | #include 6 | #include 7 | 8 | char *realpath (const char *path, char *resolved); 9 | int vasprintf (char**s, const char* fmt, va_list va); 10 | int asprintf (char **text, const char *fmt, ...); 11 | 12 | typedef unsigned char u_int8_t; 13 | typedef unsigned long u_int32_t; 14 | 15 | #define bzero(p,s) memset(p,0,s) 16 | 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /CREDITS: -------------------------------------------------------------------------------- 1 | DVBCUT CREDITS -- last edited 2016-06-22 2 | 3 | Authors and Contributors (in alphabetical order): 4 | 5 | Alessio Treglia 6 | Andreas Cadhalpun 7 | Anton Khirnov 8 | Bernhard Übelacker 9 | Christian Marillat 10 | David Timms 11 | Fabrice Coutadeur 12 | Martin Doucha 13 | Michael "Tired" Riepe 14 | Raik Bieniek 15 | Reinhard Tartler 16 | Roland Lagarden 17 | Sean Gallagher 18 | Sebastian Ramacher 19 | Sven Over 20 | Tim Riemenschneider 21 | Wolfram Gloger 22 | 23 | And possibly others not mentioned in git log. 24 | Thanks to all for supplying patches and good ideas. 25 | -------------------------------------------------------------------------------- /dvbcut.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | DVBcut project file 5 | DVBcut-Projektdatei 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /dvbcut.desktop.in: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Type=Application 3 | Version=1.0 4 | Name=DVBcut 5 | GenericName=DVB Cutting Program for MPEG Transport Stream files 6 | GenericName[de]=DVB-Schnittprogramm für MPEG Tranport Stream Dateien 7 | NoDisplay=false 8 | Comment=Trim and cut video MPEG2 transport streams into multiple export formats 9 | Comment[de]=Kürze und schneide MPEG Tranport Ströme in verschiedene Exportformate 10 | Icon=@prefix@/share/dvbcut/icons/dvbcut.svg 11 | TryExec=@prefix@/bin/dvbcut 12 | Exec=@prefix@/bin/dvbcut %F 13 | Terminal=false 14 | MimeType=application/x-dvbcut;video/mp2t;video/mpeg; 15 | Categories=AudioVideo;AudioVideoEditing;Qt; 16 | StartupWMClass=Dvbcut 17 | -------------------------------------------------------------------------------- /mkinstalldirs: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Make directory hierarchy. 3 | # Written by Noah Friedman 4 | # Public domain. 5 | 6 | defaultIFS=' 7 | ' 8 | IFS="${IFS-${defaultIFS}}" 9 | 10 | errstatus=0 11 | 12 | for file in ${1+"$@"} ; do 13 | oIFS="${IFS}" 14 | # Some sh's can't handle IFS=/ for some reason. 15 | IFS='%' 16 | set - `echo ${file} | sed -e 's@/@%@g' -e 's@^%@/@'` 17 | IFS="${oIFS}" 18 | 19 | pathcomp='' 20 | 21 | for d in ${1+"$@"} ; do 22 | pathcomp="${pathcomp}${d}" 23 | 24 | if test ! -d "${pathcomp}"; then 25 | echo "mkdir $pathcomp" 1>&2 26 | mkdir "${pathcomp}" || errstatus=$? 27 | fi 28 | 29 | pathcomp="${pathcomp}/" 30 | done 31 | done 32 | 33 | exit $errstatus 34 | 35 | # eof 36 | -------------------------------------------------------------------------------- /contrib/AR_to_43: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Copyright (c) 2009 Dominik Kopp 4 | # This program is free software; see COPYING for details. 5 | 6 | 7 | # call programm with movies as arguments 8 | # it will create the sub folder good43 and put the converted movie there. 9 | 10 | for X in "$@" 11 | do 12 | 13 | file=`basename "$X"` 14 | path=`dirname "$X"` 15 | 16 | mkdir "$path/good43" 17 | 18 | sed -r 's/(\x00\x00\x01\xB3...)\x33/\1\x23/g' "$X" > "$path/good43/$file" 19 | # example of a MPEG2 movie: 20 | # 00 00 01 B3 2D 02 40 33 21 | # for more information about the structure 22 | # see http://dvd.sourceforge.net/dvdinfo/mpeghdrs.html 23 | # 24 | # how the sed command works: 25 | # 's/search/replace/g' g = global and not only one 26 | # \x00 = hex code 00 27 | # . = one character 28 | # () = group pattern and \1 for reference 29 | 30 | done -------------------------------------------------------------------------------- /contrib/AR_to_169: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Copyright (c) 2009 Dominik Kopp 4 | # This program is free software; see COPYING for details. 5 | 6 | 7 | # call programm with movies as arguments 8 | # it will create the sub folder good169 and put the converted movie there. 9 | 10 | for X in "$@" 11 | do 12 | 13 | file=`basename "$X"` 14 | path=`dirname "$X"` 15 | 16 | mkdir "$path/good169" 17 | 18 | sed -r 's/(\x00\x00\x01\xB3...)\x23/\1\x33/g' "$X" > "$path/good169/$file" 19 | # example of a MPEG2 movie: 20 | # 00 00 01 B3 2D 02 40 23 21 | # for more information about the structure 22 | # see http://dvd.sourceforge.net/dvdinfo/mpeghdrs.html 23 | # 24 | # how the sed command works: 25 | # 's/search/replace/g' g = global and not only one 26 | # \x00 = hex code 00 27 | # . = one character 28 | # () = group pattern and \1 for reference 29 | 30 | done -------------------------------------------------------------------------------- /INSTALL: -------------------------------------------------------------------------------- 1 | DVBCUT INSTALL -- last edited 2016-06-22 2 | 3 | In order to compile dvbcut, you need to have the following libraries 4 | installed: 5 | 6 | * Qt, version 5 (when building just the dvbcut.pro Qt 4 should work too.) 7 | * libao (for sound output) 8 | * libmad and liba52 for MP2 and AC3 decoding, respectively. 9 | * ffmpeg (libavformat, libavcodec, libavutil, libswscale) 10 | 11 | On a Debian system, the following packages should do the job: 12 | apt-get install \ 13 | qt5-qmake qtbase5-dev qtbase5-dev-tools qttools5-dev-tools \ 14 | autotools-dev pkg-config \ 15 | libao-dev libmad0-dev liba52-0.7.4-dev \ 16 | libavcodec-dev libavformat-dev libavutil-dev libswscale-dev 17 | 18 | If you have MPlayer installed on your machine (and it is accessible as 19 | "mplayer"), you can play the videos inside DVBCUT. 20 | 21 | How to compile DVBCUT: 22 | 23 | * Unpack the dvbcut source archive and enter the dvbcut directory. 24 | * Type 'autoconf && ./configure && make'. 25 | If everything works well, you can run DVBCUT with 'src/dvbcut'. 26 | To install it, run 'make install' (as root). 27 | -------------------------------------------------------------------------------- /src/playaudio.h: -------------------------------------------------------------------------------- 1 | /* dvbcut 2 | Copyright (c) 2005 Sven Over 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | */ 18 | 19 | /* $Id$ */ 20 | 21 | #ifndef _DVBCUT_PLAYAUDIO_H 22 | #define _DVBCUT_PLAYAUDIO_H 23 | 24 | #include 25 | void playaudio_ac3(const void *data, uint32_t len); 26 | void playaudio_mp2(const void *data, uint32_t len); 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /src/busyindicator.h: -------------------------------------------------------------------------------- 1 | /* dvbcut 2 | Copyright (c) 2005 Sven Over 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | */ 18 | 19 | /* $Id$ */ 20 | 21 | #ifndef _DVBCUT_BUSYINDICATOR_H 22 | #define _DVBCUT_BUSYINDICATOR_H 23 | 24 | class busyindicator 25 | { 26 | public: 27 | virtual ~busyindicator() 28 | {} 29 | virtual void setbusy(bool=true) 30 | {} 31 | }; 32 | 33 | #endif 34 | 35 | -------------------------------------------------------------------------------- /src/port.h: -------------------------------------------------------------------------------- 1 | /* port.h - portability definitions 2 | Copyright (c) 2007 Michael Riepe 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | */ 18 | 19 | /* $Id$ */ 20 | 21 | #ifndef _DVBCUT_PORT_H 22 | #define _DVBCUT_PORT_H 23 | 24 | #include 25 | #ifndef __WIN32__ 26 | #include 27 | #endif 28 | #include 29 | 30 | typedef int64_t dvbcut_off_t; 31 | 32 | #endif /* _DVBCUT_PORT_H */ 33 | -------------------------------------------------------------------------------- /src/mplayererrorbase.h: -------------------------------------------------------------------------------- 1 | /* dvbcut 2 | Copyright (c) 2005 Sven Over 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | */ 18 | 19 | #ifndef _DVBCUT_MPLAYERERRORBASE_H 20 | #define _DVBCUT_MPLAYERERRORBASE_H 21 | 22 | #include "ui_mplayererrorbase.h" 23 | 24 | class mplayererrorbase: public QDialog 25 | { 26 | Q_OBJECT 27 | public: 28 | mplayererrorbase(QWidget *parent = 0); 29 | ~mplayererrorbase(); 30 | void setText(QString text); 31 | 32 | private: 33 | Ui::mplayererrorbase* ui; 34 | 35 | }; 36 | 37 | #endif //_DVBCUT_MPLAYERERRORBASE_H 38 | -------------------------------------------------------------------------------- /debian/control: -------------------------------------------------------------------------------- 1 | Source: dvbcut 2 | Section: graphics 3 | Priority: optional 4 | Maintainer: Bernhard Übelacker 5 | Build-Depends: 6 | debhelper-compat (= 12), 7 | liba52-0.7.4-dev, 8 | libao-dev, 9 | libavcodec-dev (>> 6:11~), 10 | libavformat-dev (>> 6:11~), 11 | libavutil-dev (>> 6:11~), 12 | libmad0-dev, 13 | libswscale-dev (>> 6:11~), 14 | pkg-config, 15 | qt5-qmake, 16 | qtbase5-dev, 17 | qtbase5-dev-tools, 18 | qttools5-dev-tools 19 | Vcs-Git: https://github.com/bernhardu/dvbcut-deb.git 20 | Vcs-Browser: https://github.com/bernhardu/dvbcut-deb 21 | Homepage: https://github.com/bernhardu/dvbcut-deb 22 | Standards-Version: 4.1.4 23 | 24 | Package: dvbcut 25 | Architecture: any 26 | Depends: 27 | ${misc:Depends}, 28 | ${shlibs:Depends} 29 | Recommends: 30 | mplayer 31 | Description: Qt application for cutting parts out of DVB streams 32 | DVBcut is a Qt application that allows you to select certain parts of an 33 | MPEG transport stream (as received via Digital Video Broadcasting, DVB) and 34 | save these parts into a single MPEG output file. It follows a `keyhole 35 | surgery'' approach where the input video and audio data is mostly kept 36 | unchanged, and only very few frames at the beginning and/or end of the 37 | selected range are re-encoded in order to obtain a valid MPEG file. 38 | -------------------------------------------------------------------------------- /src/exportdialog.h: -------------------------------------------------------------------------------- 1 | /* dvbcut 2 | Copyright (c) 2005 Sven Over 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | */ 18 | 19 | /* $Id$ */ 20 | 21 | #ifndef _DVBCUT_EXPORTDIALOG_H 22 | #define _DVBCUT_EXPORTDIALOG_H 23 | 24 | #include 25 | #include "ui_exportdialogbase.h" 26 | 27 | class exportdialog: public QDialog 28 | { 29 | Q_OBJECT 30 | public: 31 | exportdialog(const QString &filename, QWidget *parent = 0); 32 | ~exportdialog(); 33 | Ui::exportdialogbase* ui; 34 | 35 | private: 36 | 37 | public slots: 38 | virtual void fileselector(); 39 | }; 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /contrib/arch/readme.txt: -------------------------------------------------------------------------------- 1 | 2 | # minimal arch qemu VM 2021-02-19 3 | 4 | 5 | ### Install graphical environment 6 | # pacman -Syy # similar: apt update 7 | # pacman -Syu # similar: apt update && apt dist-upgrade 8 | # pacman -S xorg-server xorg-xinit xf86-video-vesa xfce4 lightdm lightdm-gtk-greeter 9 | # systemctl enable lightdm 10 | 11 | 12 | ### Install dependencies 13 | # pacman -S git fakeroot base-devel qt5 libao libmad a52dec wget desktop-file-utils gdb 14 | 15 | 16 | mkdir dvbcut 17 | cd dvbcut 18 | wget https://raw.githubusercontent.com/bernhardu/dvbcut-deb/master/contrib/arch/PKGBUILD 19 | wget https://raw.githubusercontent.com/bernhardu/dvbcut-deb/master/contrib/arch/dvbcut.install 20 | # Taken and updated from https://aur.archlinux.org/dvbcut.git 21 | 22 | makepkg 23 | 24 | 25 | ### Install package: 26 | # pacman -U /home/user/path/to/dvbcut-0.7.4-1-x86_64.pkg.tar.zst 27 | 28 | 29 | ### Debug 30 | # uncomment "options=(debug !strip)" in PKGBUILD and rebuild (with a clean directory), reinstall 31 | 32 | # Run from the build directory, as somehow the binary in the package still gets stripped. 33 | $ gdb -q --args ./src/dvbcut-deb-0.7.4/src/dvbcut 34 | (gdb) run 35 | 36 | # When gdb stopps because of the crash 37 | (gdb) bt full 38 | 39 | 40 | # Maybe some hints in debugging: https://wiki.archlinux.org/index.php/Debug_-_Getting_Traces 41 | -------------------------------------------------------------------------------- /src/mplayererrorbase.cpp: -------------------------------------------------------------------------------- 1 | /* dvbcut 2 | Copyright (c) 2005 Sven Over 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | */ 18 | 19 | #include 20 | #include 21 | #include "mplayererrorbase.h" 22 | 23 | mplayererrorbase::mplayererrorbase(QWidget *parent) 24 | :QDialog(parent) 25 | { 26 | ui = new Ui::mplayererrorbase(); 27 | ui->setupUi(this); 28 | this->setVisible(true); 29 | } 30 | 31 | mplayererrorbase::~mplayererrorbase() 32 | { 33 | delete ui; 34 | } 35 | 36 | void mplayererrorbase::setText(QString text) 37 | { 38 | ui->textbrowser->setText(text); 39 | } 40 | -------------------------------------------------------------------------------- /src/pts.h: -------------------------------------------------------------------------------- 1 | /* dvbcut 2 | Copyright (c) 2005 Sven Over 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | */ 18 | 19 | /* $Id$ */ 20 | 21 | #ifndef _DVBCUT_PTS_H_ 22 | #define _DVBCUT_PTS_H_ 23 | 24 | #include 25 | #include 26 | 27 | 28 | typedef int64_t pts_t; 29 | 30 | #define mplayer_ptsreference(x,y) (ptsreference(x,y)) 31 | #define PTSMASK (0x0ffffffffll) 32 | #define PTSMSB (1ll<<31) 33 | #define PTS_T_MAX (0x7fffffffffffffffll) 34 | static inline pts_t ptsreference(pts_t t, pts_t reference) 35 | { 36 | t&=PTSMASK; 37 | return t| ((reference+((t<((reference&PTSMASK)^PTSMSB))?(1ll<<32):0)-((reference&PTSMSB)?0:(1ll<<32)))&~PTSMASK); 38 | } 39 | 40 | std::string ptsstring(pts_t pts); 41 | pts_t string2pts(std::string); 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /src/differenceimageprovider.h: -------------------------------------------------------------------------------- 1 | /* dvbcut 2 | Copyright (c) 2005 Sven Over 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | */ 18 | 19 | /* $Id$ */ 20 | 21 | #ifndef _DVBCUT_DIFFERENCEIMAGEPROVIDER_H 22 | #define _DVBCUT_DIFFERENCEIMAGEPROVIDER_H 23 | 24 | #include "imageprovider.h" 25 | #include 26 | 27 | /** 28 | @author Sven Over 29 | */ 30 | class differenceimageprovider : public imageprovider 31 | { 32 | protected: 33 | int basepic; 34 | QImage baseimg; 35 | virtual void decodepicture(int picture, bool decodeallgop=false); 36 | 37 | public: 38 | differenceimageprovider(mpgfile &mpg, int basepicture, busyindicator *bi=0, 39 | bool unscaled=false, double factor=1.0, int cachesize=50); 40 | 41 | ~differenceimageprovider(); 42 | 43 | }; 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /src/exception.h: -------------------------------------------------------------------------------- 1 | /* dvbcut 2 | Copyright (c) 2007 Sven Over 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | */ 18 | 19 | /* $Id$ */ 20 | 21 | #ifndef _DVBCUT_EXCEPTION_H 22 | #define _DVBCUT_EXCEPTION_H 23 | 24 | #include 25 | #include 26 | 27 | class dvbcut_exception : public std::exception 28 | { 29 | protected: 30 | std::string _M_msg; 31 | std::string _M_extype; 32 | public: 33 | explicit dvbcut_exception(const std::string &__arg); 34 | explicit dvbcut_exception(const char* __arg); 35 | virtual ~dvbcut_exception() throw(); 36 | 37 | virtual const char *what() const throw(); 38 | 39 | const std::string &msg() const throw() { return _M_msg; } 40 | const std::string &type() const throw() { return _M_extype; } 41 | 42 | void show() const; 43 | }; 44 | 45 | #endif // ifndef _DVBCUT_EXCEPTION_H 46 | -------------------------------------------------------------------------------- /dvbcut.1: -------------------------------------------------------------------------------- 1 | .\" Hey, EMACS: -*- nroff -*- 2 | .TH DVBCUT 1 "November 27, 2005" 3 | .SH NAME 4 | dvbcut \- Qt application for cutting parts out of DVB streams 5 | .SH SYNOPSIS 6 | .B dvbcut 7 | [ 8 | .B \-idx 9 | .I indexfile 10 | ] 11 | [ 12 | .I mpegfile 13 | ] 14 | .br 15 | .B dvbcut 16 | .I projectfile 17 | .br 18 | .B dvbcut 19 | .B \-generateidx 20 | .B \-idx 21 | .I indexfile 22 | .I mpegfile 23 | .SH DESCRIPTION 24 | DVBCUT is a Qt application that allows you to select certain parts of an MPEG transport stream 25 | (as received via Digital Video Broadcasting, DVB) and save these parts into a single MPEG output file. It follows a 26 | ``keyhole surgery'' approach where the input video and audio data is mostly kept unchanged, and only very few frames at the beginning and/or end of the selected range are re-encoded in order to obtain a valid MPEG file. 27 | .br 28 | DVBCUT needs to create index information on an MPEG file first. Therefore, when loading an MPEG transport stream file, it also asks you for a filename of an index file. If you choose an existing file, it is loaded and used as index if suitable. (That means, that dvbcut performs some sanity checks on the index itself and also checks if the index describes the chosen MPEG file.) If you select a file which does not yet exist, dvbcut creates the necessary index in place. 29 | .SH OPTIONS 30 | .TP 31 | .BI "\-idx" " indexfile" 32 | Use 33 | .I indexfile 34 | as index. 35 | .TP 36 | .B \-generateidx 37 | Do not show the graphical user interface, only generate an index. 38 | .SH AUTHOR 39 | dvbcut was written by Sven Over . 40 | -------------------------------------------------------------------------------- /src/psfile.h: -------------------------------------------------------------------------------- 1 | /* dvbcut 2 | Copyright (c) 2005 Sven Over 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | */ 18 | 19 | /* $Id$ */ 20 | 21 | #ifndef _DVBCUT_PSFILE_H 22 | #define _DVBCUT_PSFILE_H 23 | 24 | #include "mpgfile.h" 25 | 26 | /** 27 | @author Sven Over 28 | */ 29 | class psfile : public mpgfile 30 | { 31 | protected: 32 | int streamnumber[0x300]; // PS stream ids are 0..0xff plus possibly 2x256 private streams 33 | 34 | public: 35 | psfile(inbuffer &b, int initial_offset); 36 | 37 | ~psfile(); 38 | int streamreader(struct streamhandle &s); 39 | static int probe(inbuffer &buf); 40 | virtual int mplayeraudioid(int astr) 41 | { 42 | int sid=s[audiostream(astr)].id; 43 | if (sid>=0xc0 && sid<0xe0) 44 | return sid-0xc0; 45 | if (sid>=0x180 && sid<0x1a0) 46 | return sid-0x100; 47 | return 0; 48 | } 49 | }; 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /src/exception.cpp: -------------------------------------------------------------------------------- 1 | /* dvbcut 2 | Copyright (c) 2007 Sven Over 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | */ 18 | 19 | /* $Id$ */ 20 | 21 | #include "exception.h" 22 | #include 23 | #include 24 | 25 | dvbcut_exception::dvbcut_exception(const std::string &__arg) : _M_msg(__arg), _M_extype() 26 | { 27 | } 28 | 29 | dvbcut_exception::dvbcut_exception(const char* __arg) : _M_msg(__arg), _M_extype() 30 | { 31 | } 32 | 33 | dvbcut_exception::~dvbcut_exception() throw() 34 | { 35 | } 36 | 37 | const char *dvbcut_exception::what() const throw() 38 | { 39 | return _M_msg.c_str(); 40 | } 41 | 42 | void dvbcut_exception::show() const 43 | { 44 | std::string extype(type()); 45 | 46 | if (extype.empty()) 47 | extype="DVBCUT error"; 48 | 49 | QMessageBox::critical(NULL,QString::fromStdString(extype),what(),QMessageBox::Abort,QMessageBox::NoButton); 50 | } 51 | -------------------------------------------------------------------------------- /src/progresswindowbase.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | progresswindowbase 4 | 5 | 6 | 7 | 0 8 | 0 9 | 600 10 | 480 11 | 12 | 13 | 14 | dvbcut 15 | 16 | 17 | 18 | 19 | 20 | QTextEdit::NoWrap 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 1000 30 | 31 | 32 | 33 | 34 | 35 | 36 | &Cancel 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | cancelbutton 49 | clicked() 50 | progresswindowbase 51 | clickedcancel() 52 | 53 | 54 | 20 55 | 20 56 | 57 | 58 | 20 59 | 20 60 | 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /src/exportdialog.cpp: -------------------------------------------------------------------------------- 1 | /* dvbcut 2 | Copyright (c) 2005 Sven Over 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | */ 18 | 19 | /* $Id$ */ 20 | 21 | #include 22 | #include 23 | #include "exportdialog.h" 24 | 25 | exportdialog::exportdialog(const QString &filename, QWidget *parent) 26 | :QDialog(parent) 27 | { 28 | ui = new Ui::exportdialogbase(); 29 | ui->setupUi(this); 30 | setModal(true); 31 | ui->filenameline->setText(filename); 32 | } 33 | 34 | exportdialog::~exportdialog() 35 | { 36 | delete ui; 37 | } 38 | 39 | void exportdialog::fileselector() 40 | { 41 | QString newfilename(QFileDialog::getSaveFileName( 42 | this, 43 | tr("Export video..."), 44 | ui->filenameline->text(), 45 | tr("MPEG program streams (*.mpg)" 46 | ";;All files (*)") )); 47 | 48 | if (!newfilename.isEmpty()) 49 | ui->filenameline->setText(newfilename); 50 | } 51 | -------------------------------------------------------------------------------- /src/progressstatusbar.h: -------------------------------------------------------------------------------- 1 | /* dvbcut 2 | Copyright (c) 2005 Sven Over 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | */ 18 | 19 | /* $Id$ */ 20 | 21 | #ifndef _DVBCUT_PROGRESSSTATUSBAR_H 22 | #define _DVBCUT_PROGRESSSTATUSBAR_H 23 | 24 | #include 25 | #include "logoutput.h" 26 | 27 | class QStatusBar; 28 | class QProgressBar; 29 | class QPushButton; 30 | class QLabel; 31 | 32 | /** 33 | @author Sven Over 34 | */ 35 | class progressstatusbar : public QObject, public logoutput 36 | { 37 | Q_OBJECT 38 | 39 | protected: 40 | bool cancelwasclicked; 41 | QStatusBar *statusbar; 42 | QProgressBar *progressbar; 43 | QPushButton *cancelbutton; 44 | QLabel *label; 45 | 46 | public: 47 | progressstatusbar(QStatusBar *bar); 48 | ~progressstatusbar(); 49 | 50 | virtual bool cancelled() 51 | { 52 | return cancelwasclicked; 53 | } 54 | virtual void finish(); 55 | virtual void print(const QString &str); 56 | 57 | public slots: 58 | virtual void setprogress(int permille); 59 | virtual void clickedcancel(); 60 | }; 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /contrib/arch/PKGBUILD: -------------------------------------------------------------------------------- 1 | # Contributor: sp42b 2 | # Contributor: AndyRTR 3 | # Contributor: Bernhard Übelacker 4 | 5 | pkgname=dvbcut 6 | pkgver=0.7.4 7 | pkgrel=1 8 | pkgdesc='Qt5 application for cutting parts out of DVB streams' 9 | arch=('i686' 'x86_64') 10 | url='https://github.com/bernhardu/dvbcut-deb' 11 | license=('GPL') 12 | depends=('desktop-file-utils' 'qt5-base' 'libao' 'libmad' 'a52dec') 13 | optdepends=('mplayer: for video playback inside of DVBCUT') 14 | install="$pkgname.install" 15 | source=("https://github.com/bernhardu/dvbcut-deb/archive/v0.7.4.tar.gz") 16 | # update when available. sha256sums=('c0397919e89bd3a77f488b8c25d3bad9a11f14cd30d16097c3bf666bc3f56d7b') 17 | #options=(debug !strip) 18 | 19 | build() { 20 | cd "$srcdir/dvbcut-deb-$pkgver" 21 | 22 | autoconf 23 | ./configure --prefix=/usr 24 | make -j1 25 | } 26 | 27 | package() { 28 | cd "$srcdir/dvbcut-deb-$pkgver" 29 | 30 | install -Dm755 bin/dvbcut "$pkgdir/usr/bin/dvbcut" 31 | install -Dm644 dvbcut.1 "$pkgdir/usr/share/man/man1/dvbcut.1" 32 | install -Dm644 dvbcut.desktop "$pkgdir/usr/share/applications/dvbcut.desktop" 33 | install -Dm644 dvbcut.svg "$pkgdir/usr/share/dvbcut/icons/dvbcut.svg" 34 | install -Dm644 dvbcut.xml "$pkgdir/usr/share/mime/packages/dvbcut.xml" 35 | install -Dm644 src/dvbcut_en.html "$pkgdir/usr/share/dvbcut/dvbcut_en.html" 36 | install -Dm644 src/dvbcut.qm "$pkgdir/usr/share/dvbcut/dvbcut.qm" 37 | install -Dm644 src/dvbcut_cs.html "$pkgdir/usr/share/dvbcut/dvbcut_cs.html" 38 | install -Dm644 src/dvbcut_cs.qm "$pkgdir/usr/share/dvbcut/dvbcut_cs.qm" 39 | install -Dm644 src/dvbcut_de.html "$pkgdir/usr/share/dvbcut/dvbcut_de.html" 40 | install -Dm644 src/dvbcut_de.qm "$pkgdir/usr/share/dvbcut/dvbcut_de.qm" 41 | } 42 | 43 | # vim:set ts=2 sw=2 et: 44 | -------------------------------------------------------------------------------- /src/logoutput.h: -------------------------------------------------------------------------------- 1 | /* dvbcut 2 | Copyright (c) 2005 Sven Over 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | */ 18 | 19 | /* $Id$ */ 20 | 21 | #ifndef _DVBCUT_LOGOUTPUT_H 22 | #define _DVBCUT_LOGOUTPUT_H 23 | 24 | class QString; 25 | 26 | /** 27 | @author Sven Over 28 | */ 29 | class logoutput 30 | { 31 | protected: 32 | int currentprogress; 33 | void printmsg(const QString &str, const QString head, const QString tail); 34 | 35 | public: 36 | logoutput() : currentprogress(0) 37 | {} 38 | virtual ~logoutput() 39 | {} 40 | 41 | int getprogress() 42 | { 43 | return currentprogress; 44 | } 45 | virtual void setprogress(int permille); 46 | 47 | virtual void print(const QString &str); 48 | virtual void printheading(const QString &str); 49 | virtual void printinfo(const QString &str); 50 | virtual void printerror(const QString &str); 51 | virtual void printwarning(const QString &str); 52 | 53 | virtual bool cancelled() 54 | { 55 | return false; 56 | } 57 | virtual void finish() 58 | { 59 | return; 60 | } 61 | }; 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /src/defines.h: -------------------------------------------------------------------------------- 1 | /* dvbcut 2 | Copyright (c) 2005 Sven Over 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | */ 18 | 19 | /* $Id$ */ 20 | 21 | #ifndef _DVBCUT_DEFINES_H 22 | #define _DVBCUT_DEFINES_H 23 | 24 | #define MUXER_FLAG_KEY (1<<0) 25 | 26 | #define MAXAUDIOSTREAMS (0x20) 27 | #define MAXVIDEOSTREAMS (1) 28 | #define MAXAVSTREAMS (MAXVIDEOSTREAMS+MAXAUDIOSTREAMS) 29 | #define VIDEOSTREAM (MAXAUDIOSTREAMS) 30 | 31 | static inline int audiostream(int s=0) 32 | { 33 | return s; 34 | } 35 | static inline int videostream(int s=0) 36 | { 37 | #if MAXVIDEOSTREAMS == 1 38 | return MAXAUDIOSTREAMS+s; 39 | #else 40 | 41 | return MAXAUDIOSTREAMS+(s%MAXVIDEOSTREAMS); 42 | #endif 43 | } 44 | 45 | #if __BYTE_ORDER == __LITTLE_ENDIAN 46 | #define mbo32(x) \ 47 | ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) | \ 48 | (((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24)) 49 | #define htom32(x) mbo32(x) 50 | #define mbo16(x) ((((x) >> 8) & 0xff) | (((x) & 0xff) << 8)) 51 | #define htom16(x) mbo16(x) 52 | #else 53 | #define mbo32(x) (x) 54 | #define htom32(x) (x) 55 | #define mbo16(x) (x) 56 | #define htom16(x) (x) 57 | #endif 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /src/streamhandle.h: -------------------------------------------------------------------------------- 1 | /* dvbcut 2 | Copyright (c) 2005 Sven Over 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | */ 18 | 19 | /* $Id$ */ 20 | 21 | #ifndef _DVBCUT_STREAMHANDLE_H 22 | #define _DVBCUT_STREAMHANDLE_H 23 | 24 | #include "port.h" 25 | #include "mpgfile.h" 26 | #include "streamdata.h" 27 | 28 | struct streamhandle 29 | { 30 | dvbcut_off_t fileposition; 31 | streamdata *stream[MAXAVSTREAMS]; 32 | 33 | streamhandle(dvbcut_off_t filepos=0) : fileposition(filepos), stream() 34 | {} 35 | ~streamhandle() 36 | { 37 | for(unsigned int i=0;i 21 | License: GPL-2+ 22 | 23 | Files: debian/* 24 | Copyright: 25 | 2012 Reinhard Tartler 26 | 2012 Alessio Treglia 27 | 2009-2012 Fabrice Coutadeur 28 | 2005-2007 Sven Over 29 | License: GPL-2+ 30 | 31 | License: GPL-2+ 32 | This program is free software; you can redistribute it and/or modify 33 | it under the terms of the GNU General Public License as published by 34 | the Free Software Foundation; either version 2 of the License, or 35 | (at your option) any later version. 36 | . 37 | This program is distributed in the hope that it will be useful, 38 | but WITHOUT ANY WARRANTY; without even the implied warranty of 39 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 40 | GNU General Public License for more details. 41 | Comment: 42 | On Debian systems, the complete text of the GNU General Public 43 | License version 2 can be found in `/usr/share/common-licenses/GPL-2'. 44 | . 45 | You should have received a copy of the GNU General Public License 46 | along with this program. If not, see 47 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | DVBCUT README -- last edited 2022-06-26 2 | 3 | I am pleased to announce version 0.7.4 of dvbcut. 4 | 5 | See the file "COPYING" for license issues. See the file "INSTALL" file for 6 | installation instructions. 7 | 8 | dvbcut is a Qt application which enables you to select certain parts of an 9 | MPEG transport stream (as received on Digital Video Broadcasting, DVB) and 10 | save these parts into a single MPEG output file. It follows a "keyhole 11 | surgery" approach. Thus, the input video and audio data is mostly kept 12 | unchanged, only very few frames at the beginning and/or end of the selected 13 | range are recoded in order to obtain a valid MPEG file. 14 | 15 | dvbcut needs to create index information on an MPEG file first. Therefore, 16 | when loading an MPEG transport stream file, it also asks you for a filename 17 | of an index file. If you choose an existing file, it is loaded and used as 18 | index if suitable. (That means, that dvbcut performs some sanity checks on 19 | the index itself and also checks if the index describes the chosen MPEG 20 | file.) If you select a file which does not yet exist, dvbcut creates the 21 | necessary index in place. 22 | 23 | After opening the MPEG file, you can navigate through the video by means of 24 | a linear and a log scale slider. While the first represents the whole video, 25 | the latter enables you to precisely select frames close to the current frame. 26 | At any place in the video, you can add START, STOP, CHAPTER and BOOKMARK 27 | markers. Markers are shown in the list on the left. With the START and STOP 28 | markers you determine what parts of the video you want to write to a new 29 | file. dvbcut starts at the first START marker and proceeds until it 30 | encounters a STOP marker. If there are more START markers after that STOP, 31 | it will continue at the next START marker, and so on. Every START marker, 32 | which follows a START with no STOP inbetween, is meaningless. So is a STOP 33 | marker before the first START or after another STOP (with no START 34 | inbetween). 35 | -------------------------------------------------------------------------------- /src/eventlistitem.h: -------------------------------------------------------------------------------- 1 | /* dvbcut 2 | Copyright (c) 2005 Sven Over 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | */ 18 | 19 | /* $Id$ */ 20 | 21 | #ifndef _DVBCUT_EVENTLISTIEM_H_ 22 | #define _DVBCUT_EVENTLISTIEM_H_ 23 | 24 | #include 25 | #include "pts.h" 26 | 27 | class QLabel; 28 | class QPixmap; 29 | 30 | class EventListItem : public QListWidgetItem 31 | { 32 | public: 33 | enum eventtype { none, start, stop, chapter, bookmark }; 34 | 35 | public: 36 | EventListItem( QListWidget *listbox, const QPixmap &pixmap, eventtype type, int picture, int picturetype, pts_t _pts ); 37 | ~EventListItem(); 38 | 39 | int getpicture() const 40 | { 41 | return pic; 42 | } 43 | pts_t getpts() const 44 | { 45 | return pts; 46 | } 47 | enum eventtype geteventtype() const 48 | { 49 | return evtype; 50 | } 51 | void seteventtype(enum eventtype type) 52 | { 53 | evtype=type; 54 | label_text->setText(getstring()); 55 | return; 56 | } 57 | 58 | virtual bool operator<(const QListWidgetItem &other) const; 59 | 60 | private: 61 | enum eventtype evtype; 62 | int pic; 63 | int pictype; 64 | pts_t pts; 65 | 66 | QString getstring() const; 67 | QLabel *label_text; 68 | 69 | }; 70 | 71 | #endif // ifndef _EVENTLISTIEM_H_ 72 | -------------------------------------------------------------------------------- /src/avframe.h: -------------------------------------------------------------------------------- 1 | /* dvbcut 2 | Copyright (c) 2005 Sven Over 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | */ 18 | 19 | /* $Id$ */ 20 | 21 | #ifndef _DVBCUT_AVFRAME_H 22 | #define _DVBCUT_AVFRAME_H 23 | 24 | extern "C" { 25 | #include 26 | #include 27 | #ifdef HAVE_LIB_SWSCALE 28 | #include 29 | #endif 30 | } 31 | 32 | class QImage; 33 | 34 | /** 35 | @author Sven Over 36 | */ 37 | class avframe 38 | { 39 | protected: 40 | AVFrame *f; 41 | uint8_t *tobefreed; 42 | int w,h,dw; 43 | enum AVPixelFormat pix_fmt; 44 | #ifdef HAVE_LIB_SWSCALE 45 | struct SwsContext *img_convert_ctx; 46 | #endif 47 | 48 | public: 49 | avframe(); 50 | avframe(AVFrame *src, AVCodecContext *ctx); 51 | ~avframe(); 52 | 53 | operator AVFrame*() 54 | { 55 | return f; 56 | } 57 | AVFrame *operator->() 58 | { 59 | return f; 60 | } 61 | int getwidth() const 62 | { 63 | return w; 64 | } 65 | int getheight() const 66 | { 67 | return h; 68 | } 69 | int getdisplaywidth() const 70 | { 71 | return dw; 72 | } 73 | enum AVPixelFormat getpixfmt() const 74 | { 75 | return pix_fmt; 76 | } 77 | QImage getqimage(bool scaled=true, double viewscalefactor=1.0); 78 | }; 79 | 80 | #endif 81 | -------------------------------------------------------------------------------- /src/progresswindow.h: -------------------------------------------------------------------------------- 1 | /* dvbcut 2 | Copyright (c) 2005 Sven Over 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | */ 18 | 19 | /* $Id$ */ 20 | 21 | #ifndef _DVBCUT_PROGRESSWINDOW_H 22 | #define _DVBCUT_PROGRESSWINDOW_H 23 | 24 | #include 25 | #include 26 | #include "ui_progresswindowbase.h" 27 | #include "logoutput.h" 28 | 29 | class progresswindow: public QDialog, public logoutput 30 | { 31 | Q_OBJECT 32 | protected: 33 | bool cancelwasclicked; 34 | bool waitingforclose; 35 | QTextCharFormat fc_normal; 36 | QTextCharFormat fc_head; 37 | QTextCharFormat fc_info; 38 | QTextCharFormat fc_warn; 39 | QTextCharFormat fc_error; 40 | void printmsg(const QString&str, const QTextCharFormat &format); 41 | 42 | void closeEvent(QCloseEvent *e); 43 | Ui::progresswindowbase* ui; 44 | public: 45 | progresswindow(QWidget *parent = 0); 46 | ~progresswindow(); 47 | virtual bool cancelled() 48 | { 49 | return cancelwasclicked; 50 | } 51 | virtual void finish(); 52 | virtual void print(const QString &str); 53 | virtual void printheading(const QString &str); 54 | virtual void printinfo(const QString &str); 55 | virtual void printerror(const QString &str); 56 | virtual void printwarning(const QString &str); 57 | 58 | public slots: 59 | virtual void setprogress(int permille); 60 | virtual void clickedcancel(); 61 | }; 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /src/muxer.h: -------------------------------------------------------------------------------- 1 | /* dvbcut 2 | Copyright (c) 2005 Sven Over 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | */ 18 | 19 | /* $Id$ */ 20 | 21 | #ifndef _DVBCUT_MUXER_H 22 | #define _DVBCUT_MUXER_H 23 | 24 | #include 25 | #include "pts.h" 26 | #include "defines.h" 27 | 28 | /** 29 | @author Sven Over 30 | */ 31 | class muxer 32 | { 33 | protected: 34 | pts_t pts[MAXAVSTREAMS]; 35 | pts_t dts[MAXAVSTREAMS]; 36 | bool strpres[MAXAVSTREAMS]; 37 | bool empty; 38 | 39 | public: 40 | muxer() : pts(), dts(), strpres(), empty(true) 41 | {} 42 | virtual ~muxer() 43 | {} 44 | 45 | pts_t getpts(int str) const 46 | { 47 | return pts[str]; 48 | } 49 | void setpts(int str, pts_t p) 50 | { 51 | pts[str]=p; 52 | } 53 | pts_t getdts(int str) const 54 | { 55 | return dts[str]; 56 | } 57 | void setdts(int str, pts_t d) 58 | { 59 | dts[str]=d; 60 | } 61 | bool streampresent(int str) const 62 | { 63 | return strpres[str]; 64 | } 65 | void unsetempty() 66 | { 67 | empty=false; 68 | } 69 | bool isempty() 70 | { 71 | return empty; 72 | } 73 | 74 | virtual bool putpacket(int str, const void *data, int len, pts_t pts, pts_t dts, uint32_t flags=0)=0; 75 | virtual bool ready() 76 | { 77 | return false; 78 | } 79 | virtual void finish() 80 | { 81 | return; 82 | } 83 | }; 84 | 85 | #endif 86 | -------------------------------------------------------------------------------- /src/mplayererrorbase.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | mplayererrorbase 4 | 5 | 6 | 7 | 0 8 | 0 9 | 600 10 | 480 11 | 12 | 13 | 14 | dvbcut: MPlayer error 15 | 16 | 17 | 18 | 19 | 20 | MPlayer finished unsuccessfully. 21 | 22 | 23 | false 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | Qt::Horizontal 37 | 38 | 39 | QSizePolicy::Expanding 40 | 41 | 42 | 43 | 191 44 | 20 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | Okay 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | okaybutton 65 | clicked() 66 | mplayererrorbase 67 | accept() 68 | 69 | 70 | 20 71 | 20 72 | 73 | 74 | 20 75 | 20 76 | 77 | 78 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /src/dvbcut_en.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | DVBcut Help 5 | 6 | 7 |

Keyboard Shortcuts

8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 |
ShortcutDescription
Alt+FOpen file menu
Alt+EOpen edit menu
Alt+VOpen view menu
Alt+HOpen help menu
OOpen a new file
SSave the current project
GSave a snapshot
Ctrl+GSave chapter snapshots
EExport Video
Ctrl+QQuit the program
ASet start marker
NSet stop marker
CSet chapter marker
BSet bookmark
Ctrl+CAuto chapters
MSuggest bookmarks
IImport bookmarks
Ctrl+NNormal view
Ctrl+UUnscaled view
Ctrl+DShow difference to current picture
Ctrl++Zoom in
Ctrl+—Zoom out
Ctrl+1View full size
Ctrl+2View half size
Ctrl+4View quarter size
Ctrl+3View custom size
PPlay video
QStop playing video
Shift+>Play last 2 seconds audio
<Play next 2 seconds audio
F1Show this file
Ctrl+MouseWheelmove 1 frame
Shift+MouseWheelmove ~1 second
MouseWheelmove ~1 minute
Alt+MouseWheelmove ~15 minutes
46 | 47 | 48 | -------------------------------------------------------------------------------- /src/imageprovider.h: -------------------------------------------------------------------------------- 1 | /* dvbcut 2 | Copyright (c) 2005 Sven Over 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | */ 18 | 19 | /* $Id$ */ 20 | 21 | #ifndef _DVBCUT_IMAGEPROVIDER_H 22 | #define _DVBCUT_IMAGEPROVIDER_H 23 | 24 | #include 25 | #include 26 | class mpgfile; 27 | class busyindicator; 28 | 29 | #define IMAGEPROVIDER_STANDARD 1 30 | #define IMAGEPROVIDER_UNSCALED 2 31 | #define IMAGEPROVIDER_DIFFERENCE 3 32 | #define IMAGEPROVIDER_DIFFERENCE_UNSCALED 4 33 | 34 | /** 35 | @author Sven Over 36 | */ 37 | class imageprovider 38 | { 39 | protected: 40 | int RTTI; 41 | mpgfile &m; 42 | int maxcachedframes; 43 | double viewscalefactor; 44 | typedef std::pair framecacheitem; 45 | std::list framecache; 46 | busyindicator *busyind; 47 | 48 | void shrinkcache(int free=0); 49 | virtual void decodepicture(int picture, bool decodeallgop=false); 50 | 51 | public: 52 | imageprovider(mpgfile &mpg, busyindicator *bi=0, bool unscaled=false, double factor=1.0, int cachesize=50); 53 | virtual ~imageprovider(); 54 | int rtti() const 55 | { 56 | return RTTI; 57 | } 58 | QImage getimage(int picture, bool decodeallgop=false); 59 | void clearcache() 60 | { 61 | framecache.clear(); 62 | } 63 | void setviewscalefactor(double factor) 64 | { 65 | if (factor<=0.0) factor=1.0; 66 | if (factor==viewscalefactor) return; 67 | clearcache(); 68 | viewscalefactor=factor; 69 | } 70 | 71 | }; 72 | 73 | #endif 74 | -------------------------------------------------------------------------------- /src/logoutput.cpp: -------------------------------------------------------------------------------- 1 | /* dvbcut 2 | Copyright (c) 2005 Sven Over 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | */ 18 | 19 | /* $Id$ */ 20 | 21 | #ifndef _GNU_SOURCE 22 | #define _GNU_SOURCE 23 | #endif 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include "logoutput.h" 30 | 31 | void 32 | logoutput::setprogress(int permille) { 33 | if (currentprogress==permille) 34 | return; 35 | currentprogress=permille; 36 | fprintf(stderr,"[%3d.%d]\r",currentprogress/10,currentprogress%10); 37 | } 38 | 39 | void logoutput::printmsg(const QString &str, const QString head, const QString tail) 40 | { 41 | if (!head.isEmpty()) 42 | fprintf(stderr, "%s", head.toLatin1().data()); 43 | fprintf(stderr, "%s", str.toLatin1().data()); 44 | if (!tail.isEmpty()) 45 | fprintf(stderr, "%s", tail.toLatin1().data()); 46 | fprintf(stderr, "\n"); 47 | } 48 | 49 | /*virtual*/ 50 | void logoutput::print(const QString &str) 51 | { 52 | printmsg(str, "", ""); 53 | } 54 | 55 | /*virtual*/ 56 | void logoutput::printheading(const QString &str) 57 | { 58 | printmsg(str, "=== ", " ==="); 59 | } 60 | 61 | /*virtual*/ 62 | void logoutput::printinfo(const QString &str) 63 | { 64 | printmsg(str, "INFO: ", 0); 65 | } 66 | 67 | /*virtual*/ 68 | void logoutput::printerror(const QString &str) 69 | { 70 | printmsg(str, "ERROR: ", 0); 71 | } 72 | 73 | /*virtual*/ 74 | void logoutput::printwarning(const QString &str) 75 | { 76 | printmsg(str, "WARNING: ", 0); 77 | } 78 | -------------------------------------------------------------------------------- /src/dvbcut_cs.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Nápověda Dvbcut 5 | 6 | 7 |

Klávesové zkratky

8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 |
ZkratkaPopis
Alt+SOtevře menu Soubor
Alt+AOtevře menu Úpravy
Alt+ZOtevře menu Zobrazení
Alt+NOtevře menu Nápověda
OOtevře soubor
SUloží aktuální projekt
GUloží snímek
Ctrl+GUloží snímky kapitol
EExportuje video
Ctrl+QUkončí program
AVloží značku start
NVloží značku stop
CVloží značku kapitoly
BVloží záložku
Ctrl+CAutomaticky vygeneruje kapitoly
MDoporučí záložky
IImportuje záložky
Ctrl+NNormální zobrazení
Ctrl+UNeškálované zobrazení
Ctrl+DZobrazí rozdíl proti aktuálnímu snímku
Ctrl++Zvětší zobrazení
Ctrl+–Zmenší zobrazení
Ctrl+1Zobrazení v plné velikosti
Ctrl+2Zobrazení v poloviční velikosti
Ctrl+4Zobrazení ve čtvrtinové velikosti
Ctrl+3Zobrazení v uživatelské velikosti
PPřehraje video
QZastaví přehrávání videa
>Přehraje předchozí 2 sekundy zvuku
<Přehraje následující 2 sekundy zvuku
F1Zobrazí toto okno
Ctrl+MouseWheelmove 1 frame
Shift+MouseWheelmove ~1 second
MouseWheelmove ~1 minute
Alt+MouseWheelmove ~15 minutes
46 | 47 | 48 | -------------------------------------------------------------------------------- /DISTFILES: -------------------------------------------------------------------------------- 1 | COPYING 2 | CREDITS 3 | ChangeLog 4 | DISTFILES 5 | INSTALL 6 | Makefile.in 7 | README 8 | README.icons 9 | VERSION 10 | config.guess 11 | config.sub 12 | configure.ac 13 | contrib/AR_to_169 14 | contrib/AR_to_43 15 | debian/changelog 16 | debian/compat 17 | debian/control 18 | debian/copyright 19 | debian/dirs 20 | debian/dvbcut.docs 21 | debian/dvbcut.install 22 | debian/dvbcut.manpages 23 | debian/gbp.conf 24 | debian/patches/series 25 | debian/rules 26 | debian/source/format 27 | debian/watch 28 | dvbcut.1 29 | dvbcut.desktop.in 30 | dvbcut.ico 31 | dvbcut.svg 32 | dvbcut.xml 33 | icons/bookmark.png 34 | icons/bookmark.svgz 35 | icons/chapter.png 36 | icons/chapter.svgz 37 | icons/icons.qrc 38 | icons/play.png 39 | icons/play.svgz 40 | icons/stop.png 41 | icons/stop.svgz 42 | import/stdlib.cpp 43 | import/stdlib.h 44 | import/sys/mman.h 45 | install-sh 46 | mkinstalldirs 47 | src/Makefile.in 48 | src/avframe.cpp 49 | src/avframe.h 50 | src/buffer.cpp 51 | src/buffer.h 52 | src/busyindicator.h 53 | src/defines.h 54 | src/differenceimageprovider.cpp 55 | src/differenceimageprovider.h 56 | src/dvbcut.cpp 57 | src/dvbcut.h 58 | src/dvbcut.pro 59 | src/dvbcut.ts 60 | src/dvbcut_cs.html 61 | src/dvbcut_cs.ts 62 | src/dvbcut_de.html 63 | src/dvbcut_de.ts 64 | src/dvbcut_en.html 65 | src/dvbcutbase.ui 66 | src/eventlistitem.cpp 67 | src/eventlistitem.h 68 | src/exception.cpp 69 | src/exception.h 70 | src/exportdialog.cpp 71 | src/exportdialog.h 72 | src/exportdialogbase.ui 73 | src/imageprovider.cpp 74 | src/imageprovider.h 75 | src/index.cpp 76 | src/index.h 77 | src/lavfmuxer.cpp 78 | src/lavfmuxer.h 79 | src/logoutput.cpp 80 | src/logoutput.h 81 | src/main.cpp 82 | src/mpegmuxer.cpp 83 | src/mpegmuxer.h 84 | src/mpgfile.cpp 85 | src/mpgfile.h 86 | src/mplayererrorbase.cpp 87 | src/mplayererrorbase.h 88 | src/mplayererrorbase.ui 89 | src/muxer.h 90 | src/playaudio.cpp 91 | src/playaudio.h 92 | src/port.h 93 | src/progressstatusbar.cpp 94 | src/progressstatusbar.h 95 | src/progresswindow.cpp 96 | src/progresswindow.h 97 | src/progresswindowbase.ui 98 | src/psfile.cpp 99 | src/psfile.h 100 | src/pts.cpp 101 | src/pts.h 102 | src/settings.cpp 103 | src/settings.h 104 | src/stream.h 105 | src/streamdata.cpp 106 | src/streamdata.h 107 | src/streamhandle.h 108 | src/tsfile.cpp 109 | src/tsfile.h 110 | src/types.h 111 | -------------------------------------------------------------------------------- /src/dvbcut_de.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | DVBcut Hilfe 5 | 6 | 7 |

Tastenkürzel

8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 |
TastenBeschreibung
Alt+DÖffne Menü Datei
Alt+BÖffne Menü Bearbeiten
Alt+AÖffne Menü Ansicht
Alt+HÖffne Menü Hilfe
OÖffne neue Datei
SSpeichere aktuelles Projekt
GSpeichere Video-Schnappschuss
Strg+GSpeichere Kapitel-Schnappschuss
EVideo exportieren
Strg+QBeenden
AStart-Markierung setzen
NStopp-Markierung setzen
CKapitel-Markierung setzen
BLesezeichen setzen
Strg+CKapitel vorschlagen lassen
MLesezeichen vorschlagen lassen
ILesezeichen importieren
Strg+NNormalansicht
Strg+Uunskalierte Ansicht
Strg+DZeige Abweichungen zum aktuellen Bild
Strg++Ansicht vergrößern
Strg+–Ansicht verkleinern
Strg+1Ansicht 1:1 Original
Strg+2Ansicht 1:2 Hälfte
Strg+4Ansicht 1:4 Viertel
Strg+3Ansicht benutzerdefiniert
PWiedergabe starten
QWiedergabe stoppen
>Wiedergabe vorheriger 2 Sekunden Audio
<Wiedergabe nächster 2 Sekunden Audio
F1Zeige diese Hilfe
Ctrl+MouseWheelGehe 1 Bild
Shift+MouseWheelGehe ca. 1 Sekunde
MouseWheelGehe ca. 1 Mintue
Alt+MouseWheelGehe ca. 15 Minuten
46 | 47 | 48 | -------------------------------------------------------------------------------- /src/lavfmuxer.h: -------------------------------------------------------------------------------- 1 | /* dvbcut 2 | Copyright (c) 2005 Sven Over 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | */ 18 | 19 | /* $Id$ */ 20 | 21 | #ifndef _DVBCUT_LAVFMUXER_H 22 | #define _DVBCUT_LAVFMUXER_H 23 | 24 | extern "C" { 25 | #include 26 | } 27 | 28 | #include "mpgfile.h" 29 | #include "muxer.h" 30 | 31 | /** 32 | @author Sven Over 33 | */ 34 | class lavfmuxer : public muxer 35 | { 36 | protected: 37 | struct stream 38 | { 39 | AVStream *avstr; 40 | int stream_index; 41 | 42 | stream() : avstr(0), stream_index(0) 43 | {} 44 | ~stream() 45 | { 46 | if (avstr) 47 | av_free(avstr); 48 | } 49 | }; 50 | 51 | const AVOutputFormat *fmt; 52 | AVFormatContext *avfc; 53 | 54 | stream st[MAXAVSTREAMS]; 55 | 56 | bool fileopened; 57 | 58 | public: 59 | lavfmuxer(const char *format, uint32_t audiostreammask, mpgfile &mpg, const char *filename); 60 | 61 | ~lavfmuxer(); 62 | 63 | bool putpacket(int str, const void *data, int len, pts_t pts, pts_t dts, uint32_t flags=0) 64 | { 65 | if (len<=0) 66 | return 0; 67 | 68 | AVPacket* avp = av_packet_alloc(); 69 | avp->data = (uint8_t*)data; 70 | avp->size = len; 71 | avp->pts = pts; 72 | avp->dts = dts; 73 | avp->stream_index = st[str].stream_index; 74 | if (flags & MUXER_FLAG_KEY) 75 | avp->flags |= AV_PKT_FLAG_KEY; 76 | 77 | int rv = av_interleaved_write_frame(avfc, avp); 78 | 79 | av_packet_free(&avp); 80 | return rv>=0; 81 | } 82 | 83 | virtual bool ready() 84 | { 85 | return bool(avfc); 86 | } 87 | virtual void finish() 88 | { 89 | return; 90 | } 91 | }; 92 | 93 | #endif 94 | -------------------------------------------------------------------------------- /src/types.h: -------------------------------------------------------------------------------- 1 | /* dvbcut 2 | Copyright (c) 2005 Sven Over 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | */ 18 | 19 | /* $Id$ */ 20 | 21 | #ifndef _DVBCUT_TYPES_H 22 | #define _DVBCUT_TYPES_H 23 | 24 | #include 25 | #include 26 | 27 | #include "port.h" 28 | 29 | class filepos_t 30 | { 31 | private: 32 | uint64_t p; 33 | public: 34 | filepos_t(dvbcut_off_t pos, uint32_t offset):p((pos<<24)|(offset&0xffffff)) 35 | {} 36 | filepos_t(uint64_t pos) : p(pos) 37 | {} 38 | ~filepos_t() 39 | {} 40 | 41 | dvbcut_off_t packetposition() const 42 | { 43 | return (p>>24); 44 | } 45 | uint32_t packetoffset() const 46 | { 47 | return uint32_t(p)&0xffffff; 48 | } 49 | dvbcut_off_t fileposition() const 50 | { 51 | return packetposition()+packetoffset(); 52 | } 53 | operator uint64_t() const 54 | { 55 | return fileposition(); 56 | } 57 | 58 | filepos_t &operator+=(uint32_t a) 59 | { 60 | p+=a; 61 | return *this; 62 | } 63 | filepos_t operator+(uint32_t a) const 64 | { 65 | return filepos_t(p+a); 66 | } 67 | bool operator<(filepos_t a) const 68 | { 69 | return p(filepos_t a) const 76 | { 77 | return p>a.p; 78 | } 79 | bool operator>=(filepos_t a) const 80 | { 81 | return p>=a.p; 82 | } 83 | bool operator==(filepos_t a) const 84 | { 85 | return p==a.p; 86 | } 87 | bool operator!=(filepos_t a) const 88 | { 89 | return p!=a.p; 90 | } 91 | }; 92 | 93 | namespace streamtype 94 | { 95 | enum type { unknown, mpeg2video, mpegaudio, ac3audio }; 96 | }; 97 | 98 | #endif 99 | -------------------------------------------------------------------------------- /src/settings.h: -------------------------------------------------------------------------------- 1 | /* dvbcut settings 2 | Copyright (c) 2006 Michael Riepe 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | */ 18 | 19 | /* $Id$ */ 20 | 21 | #ifndef _DVBCUT_SETTINGS_H 22 | #define _DVBCUT_SETTINGS_H 23 | 24 | #include 25 | #include 26 | 27 | #include 28 | 29 | enum { 30 | WHEEL_INCR_NORMAL, 31 | WHEEL_INCR_SHIFT, 32 | WHEEL_INCR_CTRL, 33 | WHEEL_INCR_ALT, 34 | WHEEL_INCR_num 35 | }; 36 | 37 | class dvbcut_settings : QSettings { 38 | public: 39 | dvbcut_settings(); 40 | ~dvbcut_settings(); 41 | 42 | void load_settings(); 43 | void save_settings(); 44 | 45 | bool loaded; 46 | 47 | QString lastdir; 48 | bool lastdir_update; 49 | std::vector,std::string> > recentfiles; 50 | unsigned int recentfiles_max; 51 | double viewscalefactor; 52 | double viewscalefactor_custom; 53 | int wheel_increments[WHEEL_INCR_num]; 54 | int wheel_threshold; 55 | int wheel_delta; 56 | int jog_maximum; 57 | int jog_threshold; 58 | double jog_offset; 59 | int jog_interval; 60 | int lin_interval; 61 | int export_format; 62 | bool start_bof; 63 | bool stop_eof; 64 | QString snapshot_type; 65 | QString snapshot_prefix; 66 | QString snapshot_delimiter; 67 | QString snapshot_extension; 68 | int snapshot_quality; 69 | int snapshot_first; 70 | int snapshot_width; 71 | int snapshot_range; 72 | int snapshot_samples; 73 | std::vector pipe_command; 74 | std::vector pipe_post; 75 | std::vector pipe_label; 76 | std::vector pipe_format; 77 | int chapter_interval; 78 | int chapter_tolerance; 79 | double chapter_threshold; 80 | int chapter_minimum; 81 | int search_dups_range; 82 | }; 83 | 84 | // access function 85 | extern dvbcut_settings& settings(); 86 | 87 | #endif // _DVBCUT_SETTINGS_H 88 | -------------------------------------------------------------------------------- /src/stream.h: -------------------------------------------------------------------------------- 1 | /* dvbcut 2 | Copyright (c) 2005 Sven Over 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | */ 18 | 19 | /* $Id$ */ 20 | 21 | #ifndef DVBCUT_STREAM_H 22 | #define DVBCUT_STREAM_H 23 | 24 | #include 25 | 26 | extern "C" { 27 | #include 28 | #include 29 | #include 30 | } 31 | 32 | class stream 33 | { 34 | protected: 35 | int id; //avfid; 36 | streamtype::type type; 37 | std::string infostring; 38 | const AVCodec *dec; 39 | const AVCodec *enc; 40 | AVCodecContext *avcc; 41 | stream() : id(-1),type(streamtype::unknown),dec(0),enc(0),avcc(0) 42 | {} 43 | ~stream() 44 | { 45 | if (avcc) 46 | av_free(avcc); 47 | } 48 | void freeavcc() 49 | { 50 | if (avcc) 51 | av_free(avcc); 52 | avcc=0; 53 | } 54 | void allocavcc() 55 | { 56 | if (avcc) 57 | av_free(avcc); 58 | avcc=avcodec_alloc_context3(NULL); 59 | } 60 | void setvideoencodingparameters(int tb_num, int tb_den, bool interlaced=false) 61 | { 62 | avcc->bit_rate=9500000; 63 | avcc->rc_min_rate=9500000; 64 | avcc->rc_max_rate=9500000; 65 | avcc->rc_buffer_size=224*1024*8; 66 | avcc->rc_initial_buffer_occupancy = avcc->rc_buffer_size*3/4; 67 | avcc->qmax=2; 68 | avcc->mb_lmax= FF_QP2LAMBDA * 2; 69 | #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 0, 0) 70 | av_opt_set_double(avcc, "rc_buffer_aggressivity", 1.0, AV_OPT_SEARCH_CHILDREN); 71 | av_opt_set_int(avcc, "lmax", FF_QP2LAMBDA * 2, AV_OPT_SEARCH_CHILDREN); 72 | #else 73 | avcc->rc_buffer_aggressivity=1.0; 74 | avcc->lmax= FF_QP2LAMBDA * 2; 75 | #endif 76 | if (interlaced) 77 | avcc->flags |= AV_CODEC_FLAG_INTERLACED_DCT | AV_CODEC_FLAG_INTERLACED_ME; 78 | avcc->time_base.num = tb_num; 79 | avcc->time_base.den = tb_den; 80 | //fprintf(stderr, "video %stb=%d/%d\n", (interlaced ? "interlaced " : ""), avcc->time_base.num, avcc->time_base.den); 81 | } 82 | 83 | friend class mpgfile; 84 | friend class tsfile; 85 | friend class psfile; 86 | public: 87 | const std::string &getinfo() const 88 | { 89 | return infostring; 90 | } 91 | }; 92 | 93 | #endif 94 | -------------------------------------------------------------------------------- /README.icons: -------------------------------------------------------------------------------- 1 | Some of the icons (actually all icons used, apart from the start/stop/ 2 | chapter/bookmark icons, for which you find the source in the folder icons) 3 | used in the DVBCUT GUI are taken from the Crystal SVG icon theme from KDE. 4 | These icons are licensed under the LGPL. 5 | 6 | The following text accompanies the icons in the kdelibs source package: 7 | ===== QUOTATION ================================================================ 8 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 9 | This copyright and license notice covers all CrystalSVG images. 10 | Note the license notice contains an add-on. 11 | ******************************************************************************** 12 | KDE Crystal theme icons. 13 | Copyright (C) 2002 and following years KDE Artists 14 | This library is free software; you can redistribute it and/or 15 | modify it under the terms of the GNU Lesser General Public 16 | License as published by the Free Software Foundation, 17 | version 2.1 of the License. 18 | This library is distributed in the hope that it will be useful, 19 | but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 21 | Lesser General Public License for more details. 22 | You should have received a copy of the GNU Lesser General Public 23 | License along with this library; if not, write to the Free Software 24 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 25 | **** NOTE THIS ADD-ON **** 26 | The GNU Lesser General Public License or LGPL is written for software libraries 27 | in the first place. We expressly want the LGPL to be valid for this artwork 28 | library too. 29 | KDE Crystal theme icons is a special kind of software library, it is an 30 | artwork library, it's elements can be used in a Graphical User Interface, or 31 | GUI. 32 | Source code, for this library means: 33 | - for vectors svg; 34 | - for pixels, if applicable, the multi-layered formats xcf or psd, or 35 | otherwise png. 36 | The LGPL in some sections obliges you to make the files carry 37 | notices. With images this is in some cases impossible or hardly useful. 38 | With this library a notice is placed at a prominent place in the directory 39 | containing the elements. You may follow this practice. 40 | The exception in section 6 of the GNU Lesser General Public License covers 41 | the use of elements of this art library in a GUI. 42 | kde-artists [at] kde.org 43 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 44 | ===== QUOTATION END HERE ======================================================= 45 | 46 | My understanding of this license as it is applied to the icons here, is that 47 | I am allowed to include the icons in my GUI. I hereby give all credits for the 48 | icons to their authors, and refer to the KDE project (www.kde.org) for the 49 | full Crystal SVG theme and the sources. 50 | 51 | If my understanding of the license is wrong or incomplete, please inform me 52 | in a friendly manner. 53 | Sven Over 54 | -------------------------------------------------------------------------------- /src/pts.cpp: -------------------------------------------------------------------------------- 1 | /* dvbcut 2 | Copyright (c) 2005 Sven Over 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | */ 18 | 19 | /* $Id$ */ 20 | 21 | #include "pts.h" 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | // convert a pts (1/90000 sec) to a readable timestamp string 29 | std::string ptsstring(pts_t pts) 30 | { 31 | char *str=0; 32 | const char *minus=""; 33 | if (pts<0) { 34 | minus="-"; 35 | pts*=-1; 36 | } 37 | 38 | if (asprintf(&str,"%s%02d:%02d:%02d.%03d/%02d", 39 | minus, 40 | int(pts/90000)/3600, 41 | (int(pts/90000)/60)%60, 42 | int(pts/90000)%60, 43 | int(pts/90)%1000, 44 | int(pts%90) )<0 || !str) 45 | return std::string(); 46 | 47 | std::string s(str); 48 | free(str); 49 | return s; 50 | } 51 | 52 | // parse timestamp string (hh:mm:ss.frac/nn) and convert to pts (1/90000 of a second) 53 | pts_t string2pts(std::string str) 54 | { 55 | int hour=0,min=0,sec=0,ms=0,sub=0,sign=1; 56 | double dsec; 57 | std::list tokens; 58 | 59 | size_t from=0, pos; 60 | while((pos=str.find(':',from))!=std::string::npos) { 61 | tokens.push_back(str.substr(from,pos-from)); 62 | from=pos+1; 63 | } 64 | tokens.push_back(str.substr(from)); 65 | 66 | if(!tokens.empty()) { 67 | std::string t=tokens.back(); 68 | pos=t.find('/'); 69 | dsec=atof(t.substr(0,pos).c_str()); 70 | if(dsec<0) { 71 | dsec*=-1; 72 | sign=-1; 73 | } 74 | sec=int(dsec); 75 | ms=int(1000*(dsec-sec)+0.5); 76 | 77 | if(pos!=std::string::npos) 78 | sub=atoi(t.substr(pos+1).c_str())%90; 79 | tokens.pop_back(); 80 | 81 | if(!tokens.empty()) { 82 | min=atoi(tokens.back().c_str()); 83 | if(min<0) { 84 | min*=-1; 85 | sign=-1; 86 | } 87 | tokens.pop_back(); 88 | 89 | if(!tokens.empty()) { 90 | hour=atoi(tokens.back().c_str()); 91 | if(hour<0) { 92 | hour*=-1; 93 | sign=-1; 94 | } 95 | } 96 | } 97 | } 98 | 99 | return sign*((((hour*60 + min)*60 + sec)*1000 + ms)*90 + sub); 100 | } 101 | -------------------------------------------------------------------------------- /src/progressstatusbar.cpp: -------------------------------------------------------------------------------- 1 | /* dvbcut 2 | Copyright (c) 2005 Sven Over 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | */ 18 | 19 | /* $Id$ */ 20 | 21 | #ifndef _GNU_SOURCE 22 | #define _GNU_SOURCE 23 | #endif 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include "progressstatusbar.h" 35 | 36 | progressstatusbar::progressstatusbar(QStatusBar *bar) 37 | : logoutput(), cancelwasclicked(false), statusbar(bar) 38 | { 39 | label=new QLabel(statusbar); 40 | label->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum)); 41 | statusbar->addWidget(label,true); 42 | 43 | cancelbutton=new QPushButton(statusbar); 44 | cancelbutton->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum)); 45 | cancelbutton->setText(tr("cancel")); 46 | cancelbutton->setMaximumWidth(80); 47 | statusbar->addWidget(cancelbutton,true); 48 | 49 | progressbar=new QProgressBar(statusbar); 50 | progressbar->setMaximum(1000); 51 | progressbar->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum)); 52 | progressbar->setMinimumWidth(160); 53 | progressbar->setMaximumWidth(160); 54 | statusbar->addWidget(progressbar,true); 55 | 56 | connect(cancelbutton,SIGNAL(clicked()),SLOT(clickedcancel())); 57 | progressbar->show(); 58 | cancelbutton->show(); 59 | label->show(); 60 | qApp->processEvents(); 61 | } 62 | 63 | 64 | progressstatusbar::~progressstatusbar() 65 | { 66 | delete progressbar; 67 | delete cancelbutton; 68 | delete label; 69 | statusbar->clearMessage(); 70 | } 71 | 72 | 73 | void progressstatusbar::setprogress(int permille) 74 | { 75 | if (permille==currentprogress) 76 | return; 77 | currentprogress=permille; 78 | progressbar->setValue(permille); 79 | qApp->processEvents(); 80 | } 81 | 82 | void progressstatusbar::finish() 83 | { 84 | cancelbutton->setEnabled(false); 85 | } 86 | 87 | void progressstatusbar::clickedcancel() 88 | { 89 | cancelwasclicked=true; 90 | cancelbutton->setEnabled(false); 91 | qApp->processEvents(); 92 | } 93 | 94 | void progressstatusbar::print(const QString &str) { 95 | label->setText(str); 96 | qApp->processEvents(); 97 | } 98 | -------------------------------------------------------------------------------- /src/imageprovider.cpp: -------------------------------------------------------------------------------- 1 | /* dvbcut 2 | Copyright (c) 2005 Sven Over 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | */ 18 | 19 | /* $Id$ */ 20 | 21 | #include "imageprovider.h" 22 | #include "mpgfile.h" 23 | #include "avframe.h" 24 | #include "busyindicator.h" 25 | 26 | imageprovider::imageprovider(mpgfile &mpg, busyindicator *bi, bool unscaled, double factor, int cachesize) : 27 | RTTI(IMAGEPROVIDER_STANDARD), m(mpg), maxcachedframes(cachesize), viewscalefactor(factor), 28 | busyind(bi) 29 | { 30 | if (unscaled) 31 | RTTI=IMAGEPROVIDER_UNSCALED; 32 | } 33 | 34 | 35 | imageprovider::~imageprovider() 36 | { 37 | if (busyind) 38 | delete busyind; 39 | } 40 | 41 | 42 | void imageprovider::shrinkcache(int free) 43 | { 44 | int keep=maxcachedframes; 45 | if (free>0) 46 | keep-=free; 47 | 48 | std::list::iterator it=framecache.begin(); 49 | for(int i=0;i= m.getpictures()) 59 | return QImage(); 60 | 61 | for (std::list::iterator it = framecache.begin(); it != framecache.end(); ++it) 62 | if (it->first == picture) { 63 | framecache.push_front(*it); 64 | framecache.erase(it); 65 | return framecache.front().second; 66 | } 67 | 68 | if (busyind) 69 | busyind->setbusy(true); 70 | shrinkcache(1); 71 | 72 | decodepicture(picture,decodeallgop); 73 | if (busyind) 74 | busyind->setbusy(false); 75 | 76 | for (std::list::iterator it = framecache.begin(); it != framecache.end(); ++it) 77 | if (it->first == picture) { 78 | framecache.push_front(*it); 79 | framecache.erase(it); 80 | return framecache.front().second; 81 | } 82 | 83 | return QImage(); 84 | } 85 | 86 | void imageprovider::decodepicture(int picture, bool decodeallgop) 87 | { 88 | std::list framelist; 89 | int startpic=m.lastiframe(picture); 90 | m.decodegop(startpic,decodeallgop?-1:(picture+1),framelist); 91 | 92 | for (std::list::iterator it=framelist.begin();it!=framelist.end();++it) { 93 | framecache.push_front(framecacheitem(startpic++,(*it)->getqimage(RTTI!=IMAGEPROVIDER_UNSCALED,viewscalefactor))); 94 | delete *it; 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /src/dvbcut.pro: -------------------------------------------------------------------------------- 1 | 2 | QT += core gui xml 3 | 4 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 5 | 6 | TARGET = dvbcut 7 | TEMPLATE = app 8 | 9 | SOURCES += \ 10 | avframe.cpp \ 11 | buffer.cpp \ 12 | differenceimageprovider.cpp \ 13 | dvbcut.cpp \ 14 | eventlistitem.cpp \ 15 | exception.cpp \ 16 | exportdialog.cpp \ 17 | imageprovider.cpp \ 18 | index.cpp \ 19 | lavfmuxer.cpp \ 20 | logoutput.cpp \ 21 | main.cpp \ 22 | mpegmuxer.cpp \ 23 | mpgfile.cpp \ 24 | mplayererrorbase.cpp \ 25 | playaudio.cpp \ 26 | progressstatusbar.cpp \ 27 | progresswindow.cpp \ 28 | psfile.cpp \ 29 | pts.cpp \ 30 | settings.cpp \ 31 | streamdata.cpp \ 32 | tsfile.cpp 33 | 34 | HEADERS += \ 35 | avframe.h \ 36 | buffer.h \ 37 | busyindicator.h \ 38 | defines.h \ 39 | differenceimageprovider.h \ 40 | dvbcut.h \ 41 | eventlistitem.h \ 42 | exception.h \ 43 | exportdialog.h \ 44 | imageprovider.h \ 45 | index.h \ 46 | lavfmuxer.h \ 47 | logoutput.h \ 48 | mpegmuxer.h \ 49 | mpgfile.h \ 50 | mplayererrorbase.h \ 51 | muxer.h \ 52 | playaudio.h \ 53 | port.h \ 54 | progressstatusbar.h \ 55 | progresswindow.h \ 56 | psfile.h \ 57 | pts.h \ 58 | settings.h \ 59 | streamdata.h \ 60 | stream.h \ 61 | streamhandle.h \ 62 | tsfile.h \ 63 | types.h 64 | 65 | FORMS += \ 66 | dvbcutbase.ui \ 67 | exportdialogbase.ui \ 68 | mplayererrorbase.ui \ 69 | progresswindowbase.ui 70 | 71 | RESOURCES += \ 72 | ../icons/icons.qrc 73 | 74 | TRANSLATIONS += \ 75 | dvbcut.ts \ 76 | dvbcut_cs.ts \ 77 | dvbcut_de.ts 78 | 79 | 80 | qtPrepareTool(LRELEASE, lrelease) 81 | 82 | l10n.commands = $$LRELEASE ${QMAKE_FILE_IN} -qm ${QMAKE_FILE_OUT} 83 | l10n.input = TRANSLATIONS 84 | l10n.output = ${QMAKE_FILE_BASE}.qm 85 | l10n.CONFIG += no_link target_predeps 86 | l10n.variable_out = l10ninst.files 87 | QMAKE_EXTRA_COMPILERS += l10n 88 | 89 | 90 | CONFIG += link_pkgconfig 91 | 92 | 93 | system(pkg-config --exists libavformat) { 94 | PKGCONFIG += libavformat 95 | } else { error(Please install development package libavformat-dev) } 96 | 97 | system(pkg-config --exists libavcodec) { 98 | PKGCONFIG += libavcodec 99 | } else { error(Please install development package libavcodec-dev) } 100 | 101 | system(pkg-config --exists libavutil) { 102 | PKGCONFIG += libavutil 103 | } else { error(Please install development package libavutil-dev) } 104 | 105 | system(pkg-config --exists libswscale) { 106 | QMAKE_CXXFLAGS += -DHAVE_LIB_SWSCALE 107 | PKGCONFIG += libswscale 108 | } else { error(Please install development package libswscale-dev) } 109 | 110 | system(pkg-config --exists ao) { 111 | QMAKE_CXXFLAGS += -DHAVE_LIB_AO 112 | PKGCONFIG += ao 113 | } else { error(Please install development package libao-dev) } 114 | 115 | system(pkg-config --exists mad) { 116 | QMAKE_CXXFLAGS += -DHAVE_LIB_MAD 117 | PKGCONFIG += mad 118 | } else { error(Please install development package libmad0-dev) } 119 | 120 | QMAKE_CXXFLAGS += -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS -D_FILE_OFFSET_BITS=64 121 | -------------------------------------------------------------------------------- /configure.ac: -------------------------------------------------------------------------------- 1 | # configure.ac - Configure template for dvbcut. 2 | # Process this file with autoconf to produce a configure script. 3 | # Copyright (C) 2007 - 2009 Michael Riepe 4 | 5 | #@(#) $Id$ 6 | 7 | AC_INIT 8 | AC_CONFIG_SRCDIR([src/dvbcut.cpp]) 9 | 10 | AC_PREREQ([2.71]) 11 | 12 | AC_CANONICAL_BUILD 13 | 14 | CONFIGURE_ARGS="$ac_configure_args" 15 | AC_SUBST(CONFIGURE_ARGS) 16 | 17 | dnl Checks for programs. 18 | AC_PROG_MAKE_SET 19 | AC_PROG_CC 20 | AC_PROG_CXX 21 | AC_PROG_INSTALL 22 | AC_CHECK_TOOL(STRIP, strip, :) 23 | AC_CHECK_TOOL(PKG_CONFIG, pkg-config, :) 24 | 25 | AC_EXEEXT 26 | AC_OBJEXT 27 | 28 | dnl check for library dir 29 | mr_libdirname=lib 30 | set -- `LC_ALL=C $CC -print-search-dirs | sed -n -e 's,^libraries: ,,p' | sed -e 's,^=,,' | sed -e 's,:, ,'g` 31 | for ac_dir; do 32 | case `cd $ac_dir 2>/dev/null && pwd` in 33 | */lib32 | */lib32/) mr_libdirname=lib32; break;; 34 | */lib64 | */lib64/) mr_libdirname=lib64; break;; 35 | esac 36 | done 37 | 38 | dnl Checks for libraries. 39 | 40 | FFMPEG_LIBS='-lavformat -lavcodec -lavutil' 41 | AC_SUBST(FFMPEG_LIBS) 42 | 43 | AC_CHECK_LIB(swscale, main, 44 | [AC_DEFINE(HAVE_LIB_SWSCALE, 1, [Define this if you have libswscale.]) 45 | FFMPEG_LIBS="$FFMPEG_LIBS -lswscale"]) 46 | 47 | AC_CHECK_LIB(mad, mad_decoder_init, 48 | [AC_DEFINE(HAVE_LIB_MAD, 1, [Define this if you have libmad.]) 49 | LIBS="$LIBS -lmad"], 50 | [AC_MSG_WARN([Did not find mad library])]) 51 | AC_CHECK_LIB(a52, a52_init, 52 | [AC_DEFINE(HAVE_LIB_A52, 1, [Define this if you have liba52.]) 53 | LIBS="$LIBS -la52 -lm"], 54 | [AC_MSG_ERROR([Did not find required a52 library])], 55 | [-lm]) 56 | 57 | AC_CHECK_LIB(ao, ao_initialize, 58 | [AC_DEFINE(HAVE_LIB_AO, 1, [Define this if you have libao.]) 59 | LIBS="$LIBS -lao"], 60 | [AC_MSG_WARN([Did not find libao - dvbcut will not play audio])]) 61 | 62 | STDLIB= 63 | AC_SUBST(STDLIB) 64 | 65 | dnl AC_CHECK_LIB(m, sqrt, [LIBS="$LIBS -lm"]) 66 | 67 | dnl Checks for header files. 68 | AC_CHECK_HEADERS(ao/ao.h mad.h stdint.h a52dec/a52.h) 69 | 70 | dnl Checks for typedefs, structures, and compiler characteristics. 71 | AC_C_CONST 72 | AC_TYPE_OFF_T 73 | AC_TYPE_SIZE_T 74 | 75 | dnl Checks for library functions. 76 | AC_FUNC_MMAP 77 | 78 | dnl external stuff 79 | PKG_CHECK_MODULES([QT5], [Qt5Core >= 5.3 Qt5Gui >= 5.3 Qt5Xml >= 5.3 Qt5Widgets >= 5.3]) 80 | AC_SUBST([QT5_CFLAGS]) 81 | AC_SUBST([QT5_LIBS]) 82 | 83 | #error "You must build your code with position independent code if Qt was built with -reduce-relocations. " \ 84 | # "Compile your code with -fPIC (-fPIE is not enough)." 85 | # 86 | # https://bugreports.qt.io/browse/QTBUG-50156 87 | # With Qt5 pkg-config reports no '-fPIC', but header file complains that it is needed. 88 | # 89 | CPPFLAGS="$CPPFLAGS -fPIC $QT5_CFLAGS" 90 | LIBS="$LIBS $QT5_LIBS" 91 | 92 | AC_CHECK_PROGS(MOC, [moc-qt5 moc]) 93 | AC_CHECK_PROGS(UIC, [uic-qt5 uic]) 94 | AC_CHECK_PROGS(RCC, [rcc-qt5 rcc]) 95 | AC_CHECK_PROGS(LRELEASE, [lrelease-qt5 lrelease]) 96 | if test -z "$MOC" || test -z "$UIC" || test -z "$RCC" || test -z "$LRELEASE"; then 97 | AC_MSG_ERROR([Qt utility programs moc, uic, rcc and lrelease are required.]) 98 | fi 99 | 100 | AC_DEFINE(__STDC_LIMIT_MACROS, 1, [Required for C++]) 101 | AC_DEFINE(__STDC_CONSTANT_MACROS, 1, [Required for C++]) 102 | AC_DEFINE(_FILE_OFFSET_BITS, 64, [We are always using large files]) 103 | dnl AC_DEFINE(_LARGEFILE_SOURCE) 104 | 105 | AC_CONFIG_FILES([Makefile src/Makefile dvbcut.desktop]) 106 | AC_OUTPUT 107 | 108 | # vi: set ts=8 sw=2 : 109 | -------------------------------------------------------------------------------- /import/sys/mman.h: -------------------------------------------------------------------------------- 1 | /* sys/mman.h 2 | 3 | Copyright 1996, 1997, 1998, 2000, 2001 Red Hat, Inc. 4 | 5 | This file is part of Cygwin. 6 | 7 | This software is a copyrighted work licensed under the terms of the 8 | Cygwin license. Please consult the file "CYGWIN_LICENSE" for 9 | details. */ 10 | 11 | #ifndef _SYS_MMAN_H_ 12 | #define _SYS_MMAN_H_ 13 | #include "windows.h" 14 | #include "io.h" 15 | 16 | #include 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif /* __cplusplus */ 20 | 21 | #include 22 | #include 23 | 24 | #define PROT_NONE 0 25 | #define PROT_READ 1 26 | #define PROT_WRITE 2 27 | #define PROT_EXEC 4 28 | 29 | #define MAP_FILE 0 30 | #define MAP_SHARED 1 31 | #define MAP_PRIVATE 2 32 | #define MAP_TYPE 0xF 33 | #define MAP_FIXED 0x10 34 | #define MAP_ANONYMOUS 0x20 35 | #define MAP_ANON MAP_ANONYMOUS 36 | /* Non-standard flag */ 37 | #define MAP_NORESERVE 0x4000 /* Don't reserve swap space for this mapping. 38 | Page protection must be set explicitely 39 | to access page. Only supported for anonymous 40 | private mappings. */ 41 | #define MAP_AUTOGROW 0x8000 /* Grow underlying object to mapping size. 42 | File must be opened for writing. */ 43 | 44 | #define MAP_FAILED ((void *)0) 45 | 46 | /* 47 | * Flags for msync. 48 | */ 49 | #define MS_ASYNC 1 50 | #define MS_SYNC 2 51 | #define MS_INVALIDATE 4 52 | #include 53 | #include 54 | 55 | #define L 10 56 | 57 | struct ah { void *addr; HANDLE h; }; 58 | static struct ah ahs[L]; 59 | void breakit() {} 60 | static void *mmap (void *__addr, size_t __len, int __prot, int __flags, int __fd, off64_t __off) 61 | { 62 | HANDLE FILE=(HANDLE)_get_osfhandle(__fd); 63 | HANDLE fm=CreateFileMapping(FILE,NULL,(__prot==PROT_READ ? PAGE_READONLY : PAGE_READWRITE),0,0,NULL); 64 | if(fm==0) 65 | { 66 | DWORD error=GetLastError(); 67 | return MAP_FAILED; 68 | } 69 | void *d=MapViewOfFile( fm,(__prot==PROT_READ ? FILE_MAP_READ : FILE_MAP_ALL_ACCESS),__off>>32,__off&0xFFFFFFFF,__len); 70 | 71 | for(int i=0;i 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | */ 18 | 19 | /* $Id$ */ 20 | 21 | #include 22 | #include 23 | #include 24 | #include "eventlistitem.h" 25 | #include "settings.h" 26 | 27 | EventListItem::EventListItem( QListWidget *listbox, const QPixmap &pixmap, 28 | eventtype type, int picture, int picturetype, pts_t _pts ) : 29 | QListWidgetItem("", listbox), evtype(type), pic(picture), pictype(picturetype), pts(_pts) 30 | { 31 | QWidget *w = new QWidget(); 32 | 33 | QLabel *label_pic = new QLabel(w); 34 | label_pic->setPixmap(pixmap.scaledToHeight(80, Qt::SmoothTransformation)); 35 | 36 | label_text = new QLabel(getstring(), w); 37 | 38 | QHBoxLayout *hbox = new QHBoxLayout(); 39 | hbox->addWidget(label_pic); 40 | hbox->addWidget(label_text); 41 | w->setLayout(hbox); 42 | 43 | listbox->setItemWidget(this, w); 44 | 45 | setSizeHint(label_pic->size()); 46 | } 47 | 48 | EventListItem::~EventListItem() 49 | {} 50 | 51 | QString EventListItem::getstring() const 52 | { 53 | QString label; 54 | if (evtype==start) 55 | label = QString("%1") 56 | //: Text shown on start markers in the main window marker list 57 | .arg(QCoreApplication::translate("eventlist", "START")); 58 | else if (evtype==stop) 59 | label = QString("%1") 60 | //: Text shown on stop markers in the main window marker list 61 | .arg(QCoreApplication::translate("eventlist", "STOP")); 62 | else if (evtype==chapter) 63 | label = QString("%1") 64 | //: Text shown on chapter markers in the main window marker list 65 | .arg(QCoreApplication::translate("eventlist", "CHAPTER")); 66 | else if (evtype==bookmark) 67 | label = QString("%1") 68 | //: Text shown on bookmark markers in the main window marker list 69 | .arg(QCoreApplication::translate("eventlist", "BOOKMARK")); 70 | 71 | return label + QString().asprintf("
%02d:%02d:%02d.%03d
%d (%c)", 72 | int(pts/(3600*90000)), 73 | int(pts/(60*90000))%60, 74 | int(pts/90000)%60, 75 | int(pts/90)%1000, 76 | pic, 77 | ((const char *)".IPB....")[pictype&7]); 78 | } 79 | 80 | /*virtual*/ bool EventListItem::operator<(const QListWidgetItem &other) const 81 | { 82 | const EventListItem *item = dynamic_cast(&other); 83 | if (!item) 84 | return false; 85 | 86 | if (pic != item->pic) 87 | return pic < item->pic; 88 | else 89 | return evtype < item->evtype; 90 | } 91 | -------------------------------------------------------------------------------- /Makefile.in: -------------------------------------------------------------------------------- 1 | # Makefile.in - top-level Makefile template for Linux/Unix 2 | # Copyright (c) 2008 - 2011 Michael Riepe 3 | # 4 | # This program is free software; you can redistribute it and/or modify 5 | # it under the terms of the GNU General Public License as published by 6 | # the Free Software Foundation; either version 2 of the License, or 7 | # (at your option) any later version. 8 | # 9 | # This program is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # GNU General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU General Public License 15 | # along with this program; if not, write to the Free Software 16 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | 18 | #@(#) $Id$ 19 | 20 | srcdir = @srcdir@ 21 | top_srcdir = @top_srcdir@ 22 | 23 | prefix = @prefix@ 24 | exec_prefix = @exec_prefix@ 25 | bindir = @bindir@ 26 | datadir = @datadir@ 27 | datarootdir = @datarootdir@ 28 | mandir = @mandir@ 29 | man1dir = $(mandir)/man1 30 | pkgdatadir = $(datarootdir)/dvbcut 31 | 32 | installdirs = $(DESTDIR)$(man1dir) \ 33 | $(DESTDIR)$(datadir)/icons/hicolor/scalable/apps \ 34 | $(DESTDIR)$(datadir)/applications \ 35 | $(DESTDIR)$(datadir)/mime/packages 36 | 37 | INSTALL = @INSTALL@ 38 | INSTALL_DATA = @INSTALL_DATA@ 39 | INSTALL_PROGRAM = @INSTALL_PROGRAM@ 40 | 41 | all check dep distfiles install mostlyclean clean distclean maintainer-clean:: 42 | $(MAKE) -C src $@ 43 | $(MAKE) $@-local 44 | 45 | all-local: 46 | check-local: 47 | dep-local: 48 | install-local: $(installdirs) dvbcut.1 dvbcut.desktop dvbcut.xml 49 | $(INSTALL_DATA) dvbcut.1 $(DESTDIR)$(man1dir)/dvbcut.1 50 | $(INSTALL_DATA) dvbcut.desktop $(DESTDIR)$(datadir)/applications 51 | $(INSTALL_DATA) dvbcut.svg $(DESTDIR)$(datadir)/icons/hicolor/scalable/apps 52 | $(INSTALL_DATA) dvbcut.xml $(DESTDIR)$(datadir)/mime/packages 53 | 54 | $(installdirs): 55 | $(SHELL) $(top_srcdir)/mkinstalldirs $@ 56 | 57 | mostlyclean-local: 58 | clean-local: mostlyclean-local 59 | rm -f config.log 60 | distclean-local: clean-local 61 | rm -f Makefile config.cache config.status 62 | maintainer-clean-local: distclean-local 63 | rm -f configure 64 | 65 | distfiles-local: configure 66 | configure: configure.ac 67 | autoconf 68 | 69 | VERSION := $(shell cat VERSION) 70 | DISTFILES := $(shell cat DISTFILES) 71 | 72 | distdir = dvbcut-$(VERSION) 73 | dist: distfiles ./stamp-dist 74 | ./stamp-dist: $(DISTFILES) 75 | rm -rf $(distdir) 76 | mkdir $(distdir) 77 | files="$(DISTFILES)"; for file in $$files; do \ 78 | d=`dirname $$file`; \ 79 | test -d $(distdir)/$$d || mkdir -p $(distdir)/$$d || exit 1; \ 80 | ln $$file $(distdir)/$$file || exit 1; \ 81 | done 82 | cd $(distdir) && \ 83 | find . -type f ! -name MANIFEST -exec wc -c {} \; | \ 84 | sort -k 2 >MANIFEST 85 | -@rm -f $(distdir).tar.gz.bak dvbcut.tar.gz 86 | -@mv -f $(distdir).tar.gz $(distdir).tar.gz.bak 87 | tar cvohfz $(distdir).tar.gz --numeric-owner --owner=0 --group=0 $(distdir) 88 | ln -s $(distdir).tar.gz dvbcut.tar.gz 89 | rm -f stamp-dist && echo timestamp > stamp-dist 90 | 91 | CONFIGURE_ARGS = @CONFIGURE_ARGS@ 92 | 93 | check-dist: 94 | cd $(distdir) && CONFIG_SITE=/no/config.site ./configure $(CONFIGURE_ARGS) 95 | $(MAKE) -C $(distdir) 96 | $(MAKE) -C $(distdir) check 97 | $(MAKE) -C $(distdir) dist 98 | diff $(distdir)/MANIFEST $(distdir)/$(distdir)/MANIFEST 99 | 100 | bindist: all 101 | dir=$(distdir)-`arch`; \ 102 | rm -rf $$dir; \ 103 | make install DESTDIR=`pwd`/$$dir && \ 104 | cd $$dir && \ 105 | tar cvofz ../$$dir.tar.gz --numeric-owner --owner=0 --group=0 * 106 | 107 | -------------------------------------------------------------------------------- /src/differenceimageprovider.cpp: -------------------------------------------------------------------------------- 1 | /* dvbcut 2 | Copyright (c) 2005 Sven Over 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | */ 18 | 19 | /* $Id$ */ 20 | 21 | #include 22 | 23 | #include "differenceimageprovider.h" 24 | #include "avframe.h" 25 | #include "mpgfile.h" 26 | #include "busyindicator.h" 27 | 28 | differenceimageprovider::differenceimageprovider(mpgfile &mpg, int basepicture, busyindicator *bi, 29 | bool unscaled, double factor, int cachesize) 30 | : imageprovider(mpg,bi,unscaled,factor,cachesize), basepic(basepicture) 31 | { 32 | RTTI=unscaled?IMAGEPROVIDER_DIFFERENCE_UNSCALED:IMAGEPROVIDER_DIFFERENCE; 33 | baseimg=imageprovider(mpg,bi?new busyindicator(*bi):0,true).getimage(basepic); 34 | } 35 | 36 | 37 | differenceimageprovider::~differenceimageprovider() 38 | {} 39 | 40 | 41 | static inline int square(int x) 42 | { 43 | return x*x; 44 | } 45 | static inline QRgb mixcolors(QRgb a, QRgb b, int num, int den) 46 | { 47 | return qRgb( 48 | (qRed(b)*num+qRed(a)*(den-num))/den, 49 | (qGreen(b)*num+qGreen(a)*(den-num))/den, 50 | (qBlue(b)*num+qBlue(a)*(den-num))/den 51 | ); 52 | } 53 | 54 | void differenceimageprovider::decodepicture(int picture, bool decodeallgop) 55 | { 56 | std::list framelist; 57 | int startpic=m.lastiframe(picture); 58 | m.decodegop(startpic,decodeallgop?-1:(picture+1),framelist); 59 | 60 | for (std::list::iterator it=framelist.begin();it!=framelist.end();++it) { 61 | QImage im=(*it)->getqimage(false); 62 | int displaywidth=(*it)->getdisplaywidth(); 63 | delete *it; 64 | 65 | if (im.size()!=baseimg.size()) 66 | im=im.scaled(baseimg.size()); 67 | 68 | if (im.format() == QImage::Format_RGB888 && 69 | baseimg.format() == QImage::Format_RGB888) 70 | { 71 | int bytes_per_pixel = baseimg.depth()/8; 72 | int bytes_per_line = baseimg.bytesPerLine(); 73 | 74 | uchar* im_bits = im.bits(); 75 | const uchar* baseimg_bits = baseimg.constBits(); 76 | 77 | for (int y = 0; y < baseimg.height(); y++) { 78 | for (int x = 0; x < baseimg.width(); x++) { 79 | QRgb *imd = (QRgb*)(im_bits + x*bytes_per_pixel + y*bytes_per_line); 80 | const QRgb *bimd = (const QRgb*)(baseimg_bits + x*bytes_per_pixel + y*bytes_per_line); 81 | 82 | int dist = square(qRed(*imd)-qRed(*bimd)) + 83 | square(qGreen(*imd)-qGreen(*bimd)) + 84 | square(qBlue(*imd)-qBlue(*bimd)); 85 | if (dist>1000) 86 | dist=1000; 87 | 88 | QRgb new_pixel = mixcolors(*imd, ((x/16+y/16)&1) ? qRgb(64,64,64) : qRgb(192,192,192), 1000-dist, 1000); 89 | memcpy(imd, &new_pixel, 3); 90 | } 91 | } 92 | } else { 93 | fprintf(stderr, "%s: wrong format.\n", __FUNCTION__); 94 | } 95 | 96 | 97 | if ((RTTI!=IMAGEPROVIDER_DIFFERENCE_UNSCALED && displaywidth!=im.width())||(viewscalefactor!=1.0)) 98 | im=im.scaled(int(((RTTI!=IMAGEPROVIDER_DIFFERENCE_UNSCALED)?displaywidth:im.width())/viewscalefactor+0.5), 99 | int(im.height()/viewscalefactor+0.5)); 100 | framecache.push_front(framecacheitem(startpic++,im)); 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /src/progresswindow.cpp: -------------------------------------------------------------------------------- 1 | /* dvbcut 2 | Copyright (c) 2005 Sven Over 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | */ 18 | 19 | /* $Id$ */ 20 | 21 | #ifndef _GNU_SOURCE 22 | #define _GNU_SOURCE 23 | #endif 24 | 25 | #include 26 | #include 27 | #include 28 | 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include "progresswindow.h" 35 | 36 | progresswindow::progresswindow(QWidget *parent) 37 | :QDialog(parent), logoutput(), 38 | cancelwasclicked(false), waitingforclose(false) 39 | { 40 | ui = new Ui::progresswindowbase(); 41 | ui->setupUi(this); 42 | setModal(true); 43 | 44 | fc_head.setFontWeight(QFont::Bold); 45 | fc_head.setFontUnderline(true); 46 | 47 | fc_warn.setForeground(Qt::red); 48 | 49 | fc_error.setFontWeight(QFont::Bold); 50 | fc_error.setForeground(Qt::red); 51 | fc_error.setFontUnderline(true); 52 | 53 | QPalette palette; 54 | palette.setColor(ui->cancelbutton->backgroundRole(), QColor( 255,0,0 )); 55 | ui->cancelbutton->setPalette(palette); 56 | 57 | show(); 58 | qApp->processEvents(); 59 | } 60 | 61 | progresswindow::~progresswindow() 62 | { 63 | delete ui; 64 | } 65 | 66 | void progresswindow::closeEvent(QCloseEvent *e) 67 | { 68 | if (waitingforclose) 69 | e->accept(); 70 | else 71 | e->ignore(); 72 | } 73 | 74 | void progresswindow::finish() 75 | { 76 | ui->cancelbutton->setEnabled(false); 77 | waitingforclose=true; 78 | ui->cancelbutton->setText( tr( "Close" ) ); 79 | 80 | QPalette palette; 81 | palette.setColor(ui->cancelbutton->backgroundRole(), QColor( 0,255,0 )); 82 | ui->cancelbutton->setPalette(palette); 83 | 84 | ui->cancelbutton->setEnabled(true); 85 | exec(); 86 | } 87 | 88 | void progresswindow::setprogress(int permille) 89 | { 90 | if (permille==currentprogress) 91 | return; 92 | currentprogress=permille; 93 | ui->progressbar->setValue(permille); 94 | qApp->processEvents(); 95 | } 96 | 97 | void progresswindow::printmsg(const QString &str, const QTextCharFormat &format) 98 | { 99 | ui->logbrowser->setCurrentCharFormat(format); 100 | ui->logbrowser->append(str); 101 | qApp->processEvents(); 102 | } 103 | 104 | void progresswindow::print(const QString &str) 105 | { 106 | printmsg(str, fc_normal); 107 | } 108 | 109 | void progresswindow::printheading(const QString &str) 110 | { 111 | printmsg(str, fc_head); 112 | } 113 | 114 | void progresswindow::printinfo(const QString &str) 115 | { 116 | printmsg(str, fc_info); 117 | } 118 | 119 | void progresswindow::printerror(const QString &str) 120 | { 121 | printmsg(str, fc_error); 122 | } 123 | 124 | void progresswindow::printwarning(const QString &str) 125 | { 126 | printmsg(str, fc_warn); 127 | } 128 | 129 | void progresswindow::clickedcancel() 130 | { 131 | if ((cancelwasclicked==false) && (waitingforclose==false)) { 132 | // button function is cancel 133 | cancelwasclicked=true; 134 | ui->cancelbutton->setEnabled(false); 135 | qApp->processEvents(); 136 | ui->cancelbutton->setText( tr( "Close" ) ); 137 | 138 | QPalette palette; 139 | palette.setColor(ui->cancelbutton->backgroundRole(), QColor( 0,255,0 )); 140 | ui->cancelbutton->setPalette(palette); 141 | 142 | ui->cancelbutton->setEnabled(true); 143 | } else { 144 | // button function is close 145 | close(); 146 | } 147 | } 148 | -------------------------------------------------------------------------------- /src/Makefile.in: -------------------------------------------------------------------------------- 1 | # Makefile - Makefile template for Linux/Unix 2 | # Copyright (c) 2007 - 2011 Michael Riepe 3 | # 4 | # This program is free software; you can redistribute it and/or modify 5 | # it under the terms of the GNU General Public License as published by 6 | # the Free Software Foundation; either version 2 of the License, or 7 | # (at your option) any later version. 8 | # 9 | # This program is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # GNU General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU General Public License 15 | # along with this program; if not, write to the Free Software 16 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | 18 | # @(#) $Id$ 19 | 20 | srcdir = @srcdir@ 21 | top_srcdir = @top_srcdir@ 22 | topdir = .. 23 | subdir = src 24 | 25 | prefix = @prefix@ 26 | exec_prefix = @exec_prefix@ 27 | bindir = @bindir@ 28 | datadir = @datadir@ 29 | datarootdir = @datarootdir@ 30 | mandir = @mandir@ 31 | man1dir = $(mandir)/man1 32 | helpdir = $(datadir)/dvbcut 33 | 34 | installdirs = $(DESTDIR)$(bindir) $(DESTDIR)$(helpdir) 35 | 36 | CXX = @CXX@ 37 | CXXFLAGS = @CXXFLAGS@ -Wall -Wcast-align $(DEFS) $(CPPFLAGS) 38 | CPPFLAGS = @CPPFLAGS@ -I. 39 | DEFS = @DEFS@ 40 | LDFLAGS = @LDFLAGS@ 41 | FFMPEG_LIBS = @FFMPEG_LIBS@ 42 | LIBS = $(FFMPEG_LIBS) @LIBS@ 43 | 44 | INSTALL = @INSTALL@ 45 | INSTALL_DATA = @INSTALL_DATA@ 46 | INSTALL_PROGRAM = @INSTALL_PROGRAM@ 47 | STRIP = @STRIP@ 48 | 49 | EXEEXT = @EXEEXT@ 50 | OBJEXT = @OBJEXT@ 51 | STDLIB = @STDLIB@ 52 | 53 | QTDIR = @QTDIR@ 54 | 55 | PATH := $(QTDIR)/bin:$(PATH) 56 | 57 | ui_%.h: %.ui 58 | @UIC@ -o $@ $< 59 | 60 | uic_%.cpp: %.h 61 | @UIC@ -o $@ $< 62 | 63 | moc_%.cpp: %.h 64 | @MOC@ -o $@ $< 65 | 66 | %.qm: %.ts 67 | @LRELEASE@ $< -qm $@ 68 | 69 | MOC = \ 70 | moc_dvbcut.cpp \ 71 | moc_exportdialog.cpp \ 72 | moc_mplayererrorbase.cpp \ 73 | moc_progressstatusbar.cpp \ 74 | moc_progresswindow.cpp \ 75 | 76 | UIC = \ 77 | ui_dvbcutbase.h \ 78 | ui_exportdialogbase.h \ 79 | ui_mplayererrorbase.h \ 80 | ui_progresswindowbase.h 81 | 82 | QM = \ 83 | dvbcut.qm \ 84 | dvbcut_cs.qm \ 85 | dvbcut_de.qm 86 | 87 | QRC = \ 88 | qrc_icons.cpp 89 | 90 | SRCS = \ 91 | avframe.cpp differenceimageprovider.cpp buffer.cpp \ 92 | dvbcut.cpp eventlistitem.cpp exception.cpp exportdialog.cpp \ 93 | imageprovider.cpp index.cpp lavfmuxer.cpp logoutput.cpp \ 94 | main.cpp mpegmuxer.cpp mpgfile.cpp mplayererrorbase.cpp playaudio.cpp \ 95 | progressstatusbar.cpp progresswindow.cpp psfile.cpp \ 96 | pts.cpp streamdata.cpp tsfile.cpp settings.cpp $(MOC) $(QRC) \ 97 | $(STDLIB) 98 | 99 | OBJS = $(SRCS:.cpp=.$(OBJEXT)) 100 | 101 | all: $(topdir)/bin $(topdir)/bin/dvbcut$(EXEEXT) $(QM) 102 | 103 | check: 104 | 105 | install: all installdirs 106 | $(INSTALL_PROGRAM) dvbcut$(EXEEXT) $(DESTDIR)$(bindir) 107 | $(INSTALL_DATA) dvbcut_cs.html $(DESTDIR)$(helpdir) 108 | $(INSTALL_DATA) dvbcut_en.html $(DESTDIR)$(helpdir) 109 | $(INSTALL_DATA) dvbcut_de.html $(DESTDIR)$(helpdir) 110 | 111 | installdirs: $(installdirs) 112 | 113 | $(installdirs): 114 | $(SHELL) $(top_srcdir)/mkinstalldirs $@ 115 | 116 | $(topdir)/bin: 117 | mkdir $@ 118 | 119 | qrc_icons.cpp: 120 | @RCC@ -name icons -o $@ ../icons/icons.qrc 121 | 122 | $(topdir)/bin/dvbcut$(EXEEXT): dvbcut$(EXEEXT) 123 | $(INSTALL_PROGRAM) dvbcut$(EXEEXT) $(topdir)/bin/dvbcut$(EXEEXT) 124 | $(STRIP) $(topdir)/bin/dvbcut$(EXEEXT) 125 | 126 | dvbcut$(EXEEXT): $(SRCS) $(UIC) $(OBJS) 127 | $(CXX) -o $@ $(LDFLAGS) $(OBJS) $(LIBS) 128 | 129 | clean: 130 | -rm -f *.$(OBJEXT) 131 | 132 | distclean: clean 133 | -rm -f $(MOC) $(UIC) $(QM) $(QRC) $(topdir)/bin/dvbcut$(EXEEXT) dvbcut$(EXEEXT) 134 | -rmdir $(topdir)/bin 135 | -rm -f .depend stamp-depend 136 | 137 | maintainer-clean: distclean 138 | 139 | dep: stamp-depend 140 | stamp-depend: $(SRCS) 141 | -@rm -f .depend $@ 142 | -$(CXX) -MM $(DEFS) $(CPPFLAGS) $(SRCS) > .depend 143 | echo timestamp > $@ 144 | 145 | -include .depend 146 | 147 | # static dependencies: 148 | 149 | moc_dvbcut.cpp: dvbcut.h 150 | moc_exportdialog.cpp: exportdialog.h 151 | moc_progressstatusbar.cpp: progressstatusbar.h 152 | moc_progresswindow.cpp: progresswindow.h 153 | uic_dvbcutbase.cpp: dvbcutbase.h 154 | uic_exportdialogbase.cpp: exportdialogbase.h 155 | uic_mplayererrorbase.cpp: mplayererrorbase.h 156 | uic_progresswindowbase.cpp: progresswindowbase.h 157 | dvbcutbase.h: dvbcutbase.ui 158 | exportdialogbase.h: exportdialogbase.ui 159 | mplayererrorbase.h: mplayererrorbase.ui 160 | progresswindowbase.h: progresswindowbase.ui 161 | 162 | distfiles: \ 163 | dvbcutbase.h \ 164 | exportdialogbase.h \ 165 | moc_dvbcut.cpp \ 166 | moc_dvbcutbase.cpp \ 167 | moc_exportdialog.cpp \ 168 | moc_mplayererrorbase.cpp \ 169 | moc_progressstatusbar.cpp \ 170 | moc_progresswindow.cpp \ 171 | moc_progresswindowbase.cpp \ 172 | mplayererrorbase.h \ 173 | progresswindowbase.h \ 174 | uic_dvbcutbase.cpp \ 175 | uic_exportdialogbase.cpp \ 176 | uic_mplayererrorbase.cpp \ 177 | uic_progresswindowbase.cpp \ 178 | qrc_icons.cpp 179 | -------------------------------------------------------------------------------- /src/avframe.cpp: -------------------------------------------------------------------------------- 1 | /* dvbcut 2 | Copyright (c) 2005 Sven Over 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | */ 18 | 19 | /* $Id$ */ 20 | 21 | #include 22 | #include 23 | #include 24 | extern "C" { 25 | #include 26 | } 27 | #include "avframe.h" 28 | 29 | #ifdef HAVE_LIB_SWSCALE 30 | avframe::avframe() : tobefreed(0),w(0),h(0),dw(0),pix_fmt(),img_convert_ctx(0) 31 | #else 32 | avframe::avframe() : tobefreed(0),w(0),h(0),dw(0),pix_fmt() 33 | #endif 34 | { 35 | f=av_frame_alloc(); 36 | } 37 | 38 | avframe::avframe(AVFrame *src, AVCodecContext *ctx) : f(0),tobefreed(0) 39 | { 40 | f=av_frame_alloc(); 41 | 42 | #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 0, 0) 43 | tobefreed = (uint8_t *)malloc(av_image_get_buffer_size(ctx->pix_fmt, ctx->width, ctx->height, 1)); 44 | 45 | av_image_fill_arrays(f->data, f->linesize, 46 | tobefreed, 47 | ctx->pix_fmt, ctx->width, ctx->height, 1); 48 | 49 | av_image_copy(f->data, f->linesize, (const uint8_t**)src->data, src->linesize, 50 | ctx->pix_fmt, ctx->width, ctx->height); 51 | #else 52 | tobefreed = (uint8_t *)malloc(avpicture_get_size(ctx->pix_fmt, ctx->width, ctx->height)); 53 | 54 | avpicture_fill((AVPicture *)f, 55 | (u_int8_t*)tobefreed, 56 | ctx->pix_fmt,ctx->width,ctx->height); 57 | 58 | av_picture_copy((AVPicture *)f, (const AVPicture *) src, 59 | ctx->pix_fmt, ctx->width, ctx->height); 60 | #endif 61 | 62 | f->pict_type = src->pict_type; 63 | f->quality = src->quality; 64 | f->coded_picture_number = src->coded_picture_number; 65 | f->display_picture_number = src->display_picture_number; 66 | f->pts = src->pts; 67 | f->interlaced_frame = src->interlaced_frame; 68 | f->top_field_first = src->top_field_first; 69 | f->repeat_pict = src->repeat_pict; 70 | f->quality = src->quality; 71 | f->format = src->format; 72 | f->width = src->width; 73 | f->height = src->height; 74 | 75 | w=ctx->width; 76 | h=ctx->height; 77 | pix_fmt=ctx->pix_fmt; 78 | dw=w*ctx->sample_aspect_ratio.num/ctx->sample_aspect_ratio.den; 79 | #ifdef HAVE_LIB_SWSCALE 80 | img_convert_ctx=sws_getContext(w, h, pix_fmt, 81 | w, h, AV_PIX_FMT_RGB24, SWS_BICUBIC, 82 | NULL, NULL, NULL); 83 | #endif 84 | } 85 | 86 | avframe::~avframe() 87 | { 88 | if (tobefreed) 89 | free(tobefreed); 90 | if (f) 91 | av_frame_free(&f); 92 | #ifdef HAVE_LIB_SWSCALE 93 | if (img_convert_ctx) 94 | sws_freeContext(img_convert_ctx); 95 | #endif 96 | } 97 | 98 | QImage avframe::getqimage(bool scaled, double viewscalefactor) 99 | { 100 | #ifdef HAVE_LIB_SWSCALE 101 | if (w<=0 || h<=0 || img_convert_ctx==NULL) 102 | #else 103 | if (w<=0 || h<=0) 104 | #endif 105 | return QImage(); 106 | 107 | #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 0, 0) 108 | uint8_t *rgbbuffer = (uint8_t*)malloc(av_image_get_buffer_size(AV_PIX_FMT_RGB24, w, h, 1)); 109 | #else 110 | uint8_t *rgbbuffer=(uint8_t*)malloc(avpicture_get_size(AV_PIX_FMT_RGB24, w, h)); 111 | #endif 112 | 113 | AVFrame *avframergb=av_frame_alloc(); 114 | 115 | #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 0, 0) 116 | av_image_fill_arrays(avframergb->data, avframergb->linesize, 117 | rgbbuffer, 118 | AV_PIX_FMT_RGB24, w, h, 1); 119 | #else 120 | avpicture_fill((AVPicture*)avframergb, 121 | rgbbuffer, 122 | AV_PIX_FMT_RGB24,w,h); 123 | #endif 124 | 125 | #ifdef HAVE_LIB_SWSCALE 126 | sws_scale(img_convert_ctx, f->data, f->linesize, 0, h, 127 | avframergb->data, avframergb->linesize); 128 | #else 129 | img_convert((AVPicture *)avframergb, AV_PIX_FMT_RGB24, (AVPicture*)f, pix_fmt, w, h); 130 | #endif 131 | 132 | QImage im(rgbbuffer, w, h, 3*w, QImage::Format_RGB888, ::free, rgbbuffer); 133 | 134 | if ((scaled && w!=dw)||(viewscalefactor!=1.0)) { 135 | #ifdef SMOOTHSCALE 136 | im = im.scaled(int((scaled?dw:w)/viewscalefactor+0.5), int(h/viewscalefactor+0.5), Qt::IgnoreAspectRatio, Qt::SmoothTransformation); 137 | #else 138 | im = im.scaled(int((scaled?dw:w)/viewscalefactor+0.5), int(h/viewscalefactor+0.5)); 139 | #endif 140 | } 141 | 142 | av_frame_free(&avframergb); 143 | return (im); 144 | } 145 | -------------------------------------------------------------------------------- /src/tsfile.h: -------------------------------------------------------------------------------- 1 | /* dvbcut 2 | Copyright (c) 2005 Sven Over 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | */ 18 | 19 | /* $Id$ */ 20 | 21 | #ifndef _DVBCUT_TSFILE_H 22 | #define _DVBCUT_TSFILE_H 23 | 24 | #include 25 | #include "mpgfile.h" 26 | #define MAXPACKETSIZE (208) 27 | #define TSPACKETSIZE (188) 28 | #define TSSYNCBYTE (0x47) 29 | 30 | // stuff to identify proprietary (topfield) headers and find bookmarks 31 | // ==> magic ('TFrc') &version number, position of bookmarks, length of header, max number of bookmarks 32 | #define TF5XXXPVR_MAGIC (0x54467263) 33 | #define TF5XXXPVR_LEN (20*TSPACKETSIZE) 34 | #define TF5XXXPVR_MAX (64) 35 | #define TF5000PVR_VERSION (0x5000) 36 | #define TF5000PVR_POS (1400) 37 | #define TF5010PVR_VERSION (0x5010) 38 | #define TF5010PVR_POS (1404) 39 | #define TF4000PVR_LEN (3*TSPACKETSIZE) 40 | #define TF4000PVR_POS (216) 41 | #define TF7700HDPVR_LEN (2636) 42 | #define TF7700HDPVR_MAX (48) 43 | #define TF7700HDPVR_POS (1040) 44 | 45 | /** 46 | @author Sven Over 47 | */ 48 | 49 | class tsfile : public mpgfile 50 | { 51 | protected: 52 | struct tspacket { 53 | uint8_t data[MAXPACKETSIZE]; 54 | 55 | int pid() const { 56 | return ((data[1]&0x1f)<<8) | data[2]; 57 | } 58 | bool transport_error_indicator() const { 59 | return data[1] & 0x80; 60 | } 61 | bool payload_unit_start_indicator() const { 62 | return data[1] & 0x40; 63 | } 64 | bool transport_priority() const { 65 | return data[1] & 0x20; 66 | } 67 | int transport_scrambling_control() const { 68 | return (data[3]>>6)&0x03; 69 | } 70 | bool contains_adaptation_field() const { 71 | return data[3]&0x20; 72 | } 73 | bool contains_payload() const { 74 | return data[3]&0x10; 75 | } 76 | int continuity_counter() const { 77 | return data[3]&0x0f; 78 | } 79 | const void *adaptation_field() const { 80 | return contains_adaptation_field()?&data[4]:0; 81 | } 82 | int adaptation_field_length() const { 83 | return contains_adaptation_field()?(1+data[4]):0; 84 | } 85 | const void *payload() const { 86 | return contains_payload()?(void*) &data[4+adaptation_field_length()]:0; 87 | } 88 | int payload_length() const { 89 | return contains_payload()?(184-adaptation_field_length()):0; 90 | } 91 | int sid() const { 92 | if (!(payload_unit_start_indicator()&&contains_payload())) 93 | return -1; 94 | int afl=adaptation_field_length(); 95 | if (afl>180) 96 | return -1; // no space for four bytes of payload 97 | const uint8_t *d=data+4+afl; 98 | if (d[0]==0 && d[1]==0 && d[2]==1) 99 | return d[3]; 100 | return -1; 101 | } 102 | }; 103 | 104 | unsigned int packetsize; // usually 188, but sometimes more 105 | 106 | int streamnumber[8192]; // TS pids are 0..8191 107 | 108 | bool check_si_tables(); 109 | size_t get_si_table(uint8_t*, size_t, size_t&, int, int); 110 | 111 | int isTOPFIELD(const uint8_t*, int, std::string); 112 | int isTF7700HDPVR(std::string); 113 | enum bookmarktype { none, byte, time, pic }; 114 | bookmarktype bmtype; // indicates type of read bookmarks 115 | std::vector pic_bookmarks; // to store the bookmarks as frame numbers (returned by getbookmarks) 116 | std::vector byte_bookmarks; // to store the bookmarks as byte positions 117 | std::vector time_bookmarks; // to store the bookmarks as time stamps 118 | 119 | public: 120 | tsfile(inbuffer &b, int initial_offset, int stride); 121 | 122 | ~tsfile(); 123 | int streamreader(struct streamhandle &s); 124 | static int probe(inbuffer &buf, int stride); 125 | virtual int mplayeraudioid(int astr) { 126 | return s[audiostream(astr)].id; 127 | } 128 | virtual bool istransportstream() { 129 | return true; 130 | } 131 | virtual std::vector getbookmarks() { 132 | if(bmtype==byte) { 133 | // convert byte positions to frame numbers if not already done/stored 134 | int picnr; 135 | for (std::vector::iterator b = byte_bookmarks.begin(); b != byte_bookmarks.end(); ++b) 136 | if((picnr = getpictureatposition(*b)) >= 0) 137 | pic_bookmarks.push_back(picnr); 138 | bmtype = pic; 139 | } else if(bmtype==time) { 140 | // convert pts positions to frame numbers if not already done/stored 141 | int picnr; 142 | for (std::vector::iterator b = time_bookmarks.begin(); b != time_bookmarks.end(); ++b) 143 | if((picnr = getpictureattime(*b)) >= 0) 144 | pic_bookmarks.push_back(picnr); 145 | bmtype = pic; 146 | } 147 | return pic_bookmarks; 148 | } 149 | 150 | }; 151 | 152 | #endif 153 | -------------------------------------------------------------------------------- /src/exportdialogbase.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | exportdialogbase 4 | 5 | 6 | 7 | 0 8 | 0 9 | 664 10 | 343 11 | 12 | 13 | 14 | dvbcut: export video 15 | 16 | 17 | true 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | ... 26 | 27 | 28 | 29 | 30 | 31 | 32 | Export as: 33 | 34 | 35 | false 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | Output format: 46 | 47 | 48 | false 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | Audio channels 61 | 62 | 63 | 64 | 65 | 66 | QAbstractItemView::MultiSelection 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | QFrame::HLine 77 | 78 | 79 | QFrame::Sunken 80 | 81 | 82 | 83 | 84 | 85 | 86 | 6 87 | 88 | 89 | 0 90 | 91 | 92 | 93 | 94 | Qt::Horizontal 95 | 96 | 97 | QSizePolicy::Expanding 98 | 99 | 100 | 101 | 20 102 | 20 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | &OK 111 | 112 | 113 | 114 | 115 | 116 | true 117 | 118 | 119 | true 120 | 121 | 122 | 123 | 124 | 125 | 126 | &Cancel 127 | 128 | 129 | 130 | 131 | 132 | true 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | buttonOk 145 | clicked() 146 | exportdialogbase 147 | accept() 148 | 149 | 150 | 20 151 | 20 152 | 153 | 154 | 20 155 | 20 156 | 157 | 158 | 159 | 160 | buttonCancel 161 | clicked() 162 | exportdialogbase 163 | reject() 164 | 165 | 166 | 20 167 | 20 168 | 169 | 170 | 20 171 | 20 172 | 173 | 174 | 175 | 176 | filenamebrowsebutton 177 | clicked() 178 | exportdialogbase 179 | fileselector() 180 | 181 | 182 | 20 183 | 20 184 | 185 | 186 | 20 187 | 20 188 | 189 | 190 | 191 | 192 | 193 | -------------------------------------------------------------------------------- /src/index.h: -------------------------------------------------------------------------------- 1 | /* dvbcut 2 | Copyright (c) 2005 Sven Over 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | */ 18 | 19 | /* $Id$ */ 20 | 21 | #ifndef _DVBCUT_INDEX_H 22 | #define _DVBCUT_INDEX_H 23 | 24 | #include 25 | #include 26 | #include 27 | #include "types.h" 28 | #include "pts.h" 29 | #include "defines.h" 30 | 31 | #define IDX_PICTYPE_I 1 32 | #define IDX_PICTYPE_P 2 33 | #define IDX_PICTYPE_B 3 34 | #define IDX_PICTYPE ((char*)".IPB") 35 | 36 | class mpgfile; 37 | class logoutput; 38 | 39 | /** 40 | @author Sven Over 41 | */ 42 | class index 43 | { 44 | public: 45 | struct picture 46 | { 47 | filepos_t position; 48 | uint64_t pts; // additional information in the 24 most significant bits: 49 | // RRRQTTSSSSSSSSSSAAAAFFFF 50 | // R: resolution number (according to lookup table with WIDTHxHEIGHT at end of index) 51 | // Q: sequence header flag 52 | // T: picture type 53 | // S: picture sequence number 54 | // A: aspect ratio (mpeg code) 55 | // F: frame rate (mpeg code) 56 | 57 | picture(filepos_t pos, pts_t _pts, int framerate, int aspectratio, 58 | int sequencenumber, int picturetype, bool seqheader=false, int resolution=0) : 59 | position( pos ), 60 | pts((_pts&0xffffffffffll) | ((uint64_t)( (framerate&0xf)|((aspectratio&0xf)<<4)| 61 | ((sequencenumber&0x3ff)<<8)|((picturetype&0x3)<<18)| 62 | (seqheader?0x100000:0)|((resolution&0x7)<<21) )<<40)) 63 | { } 64 | picture() : position(0), pts(0) 65 | {} 66 | 67 | filepos_t getpos() const 68 | { 69 | return position; 70 | } 71 | pts_t getpts() const 72 | { 73 | pts_t l=pts&0xffffffffffll; 74 | return (l ^ 0x8000000000ll) - 0x8000000000ll; 75 | } 76 | int getframerate() const 77 | { 78 | return int(pts>>40)&0xf; 79 | } 80 | int getaspectratio() const 81 | { 82 | return int(pts>>44)&0xf; 83 | } 84 | int getsequencenumber() const 85 | { 86 | return int(pts>>48)&0x3ff; 87 | } 88 | void setsequencenumber(int s) 89 | { 90 | pts=(pts&0xfc00ffffffffffffull)|(uint64_t(s&0x3ff)<<48); 91 | } 92 | int getpicturetype() const 93 | { 94 | return int(pts>>58)&0x3; 95 | } 96 | bool getseqheader() const 97 | { 98 | return pts&0x1000000000000000ll; 99 | } 100 | int getresolution() const 101 | { 102 | return int(pts>>61)&0x7; 103 | } 104 | bool isbframe() const 105 | { 106 | return getpicturetype()==IDX_PICTYPE_B; 107 | } 108 | bool ispframe() const 109 | { 110 | return getpicturetype()==IDX_PICTYPE_P; 111 | } 112 | bool isiframe() const 113 | { 114 | return getpicturetype()==IDX_PICTYPE_I; 115 | } 116 | 117 | bool operator<(picture &a) const 118 | { 119 | return getsequencenumber() WIDTH, HEIGHT; 137 | std::set > resolutions; 138 | 139 | public: 140 | index(mpgfile &m) : mpg(m),p(0),pictures(0) 141 | {} 142 | 143 | ~index(); 144 | 145 | int generate(const char *savefilename=0, std::string *errorstring=0, logoutput *log=0); 146 | int save(int fd, std::string *errorstring = 0, bool closeme = false); 147 | int save(const char *filename, std::string *errorstring=0); 148 | int load(const char *filename, std::string *errorstring=0); 149 | 150 | int getwidth(int res) const 151 | { 152 | return res>0 && res<=int(WIDTH.size()) ? WIDTH[res-1] : -1; 153 | } 154 | int getheight(int res) const 155 | { 156 | return res>0 && res<=int(HEIGHT.size()) ? HEIGHT[res-1] : -1; 157 | } 158 | 159 | int indexnr(int pic) const 160 | { 161 | pic+=skipfirst; 162 | int seq=pic; 163 | while (seq > 0 && !p[seq].getseqheader()) 164 | --seq; 165 | pic-=seq; 166 | while(seq < pictures && p[seq].getsequencenumber()!=pic) 167 | ++seq; 168 | return seq; 169 | } 170 | int picturenr(int ind) const // the reverse function 171 | { 172 | int pic=p[ind].getsequencenumber(); 173 | while (ind > 0 && !p[ind].getseqheader()) 174 | --ind; 175 | pic+=ind-skipfirst; 176 | return pic; 177 | } 178 | const picture &operator[](unsigned int i) const 179 | { 180 | return p[i]; 181 | } 182 | int getpictures() const 183 | { 184 | return pictures; 185 | } 186 | int getrealpictures() const 187 | { 188 | return realpictures; 189 | } 190 | }; 191 | 192 | #endif 193 | -------------------------------------------------------------------------------- /src/buffer.h: -------------------------------------------------------------------------------- 1 | /* dvbcut 2 | Copyright (c) 2005 Sven Over 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | */ 18 | 19 | /* $Id$ */ 20 | 21 | #ifndef _DVBCUT_BUFFER_H_ 22 | #define _DVBCUT_BUFFER_H_ 23 | 24 | #include "port.h" 25 | 26 | class buffer 27 | { 28 | protected: 29 | void *d; 30 | unsigned int size, readpos, writepos; 31 | unsigned long long wrtot; 32 | 33 | void relax(); 34 | 35 | public: 36 | buffer(unsigned int _size); 37 | ~buffer(); 38 | 39 | void writeposition(int v) 40 | { 41 | if (v<-(signed)writepos) 42 | writepos=0; 43 | else { 44 | writepos+=v; 45 | if (writepos>size) 46 | writepos=size; 47 | } 48 | } 49 | unsigned int inbytes() const 50 | { 51 | return writepos-readpos; 52 | } 53 | unsigned int freebytes() const 54 | { 55 | return size-writepos+readpos; 56 | } 57 | bool empty() const 58 | { 59 | return writepos==readpos; 60 | } 61 | bool full() const 62 | { 63 | return (readpos==0)&&(writepos==size); 64 | } 65 | unsigned long long written() const 66 | { 67 | return wrtot; 68 | } 69 | void *data() const 70 | { 71 | return (void*)((unsigned char*)d+readpos); 72 | } 73 | void *writeptr() const 74 | { 75 | return (void*)((unsigned char*)d+writepos); 76 | } 77 | int discard(unsigned int len) 78 | { 79 | if (len>inbytes()) 80 | len=inbytes(); 81 | readpos+=len; 82 | return len; 83 | } 84 | int discardback(unsigned int len) 85 | { 86 | if (len>inbytes()) 87 | len=inbytes(); 88 | writepos-=len; 89 | return len; 90 | } 91 | void resize(unsigned int newsize); 92 | void clear() 93 | { 94 | readpos=writepos=0; 95 | wrtot=0; 96 | } 97 | unsigned int getsize() const 98 | { 99 | return size; 100 | } 101 | unsigned int putdata(const void *data, unsigned int len, bool autoresize=false); 102 | unsigned int getdata(void *data, unsigned int len); 103 | int readdata(int fd); 104 | int writedata(int fd); 105 | 106 | int writedata(int fd, unsigned int minspace) 107 | { 108 | int wrn=0; 109 | if (minspace>size) { 110 | while (readpos0) { 133 | int w=writedata(fd); 134 | if (w<0) 135 | return w; 136 | wrn+=w; 137 | } 138 | return wrn; 139 | } 140 | }; 141 | 142 | class inbuffer { 143 | protected: 144 | void *d; 145 | unsigned int size, mmapsize, readpos, writepos; 146 | 147 | struct infile { 148 | dvbcut_off_t off; 149 | dvbcut_off_t end; 150 | bool closeme; 151 | int fd; 152 | std::string name; 153 | }; 154 | std::vector files; 155 | bool eof; 156 | dvbcut_off_t pos; 157 | dvbcut_off_t filesize; 158 | bool mmapped; 159 | static long pagesize; 160 | bool sequential; 161 | bool pipe_mode; 162 | 163 | void close(); 164 | int pipedata(unsigned int amount, long long position); 165 | 166 | public: 167 | inbuffer(unsigned int _size, unsigned int mmapsize = 0); 168 | ~inbuffer(); 169 | bool open(int fd, std::string *errmsg = 0, bool closeme = false, std::string filename=""); 170 | bool open(std::string filename, std::string *errmsg = 0); 171 | void reset(); 172 | 173 | const void *data() const { return (void*)((char*)d + readpos); } 174 | unsigned int getsize() const { return size; } 175 | unsigned int inbytes() const { return writepos - readpos; } 176 | bool iseof() const { return eof; } 177 | 178 | int providedata(unsigned int amount, long long position); 179 | int providedata(unsigned int amount) { 180 | if (amount <= inbytes()) 181 | return inbytes(); 182 | return providedata(amount, pos + readpos); 183 | } 184 | void discarddata(unsigned int amount) { 185 | readpos += amount; 186 | if (readpos >= writepos) { 187 | pos += writepos; 188 | readpos = 0; 189 | writepos = 0; 190 | } 191 | } 192 | dvbcut_off_t getfilesize() const { return filesize; } 193 | dvbcut_off_t getfilepos() const { return pos + readpos; } 194 | int getfilenum(dvbcut_off_t offset, dvbcut_off_t &fileoff); 195 | std::string getfilename(int filenum); 196 | void setsequential(bool flag) { sequential = flag; } 197 | }; 198 | 199 | class outbuffer : protected buffer 200 | { 201 | protected: 202 | int fd; 203 | bool close; 204 | public: 205 | outbuffer(unsigned int _size, int _fd=-1, bool tobeclosed=true) : 206 | buffer(_size), fd(_fd), close(tobeclosed) 207 | {} 208 | ~outbuffer(); 209 | int open(const char *filename); 210 | int putdata(const void *data, unsigned int len, bool autoresize=false); 211 | 212 | using buffer::written; 213 | using buffer::getsize; 214 | using buffer::resize; 215 | }; 216 | 217 | #endif 218 | -------------------------------------------------------------------------------- /src/lavfmuxer.cpp: -------------------------------------------------------------------------------- 1 | /* dvbcut 2 | Copyright (c) 2005 Sven Over 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | */ 18 | 19 | /* $Id$ */ 20 | 21 | extern "C" { 22 | #include 23 | #include 24 | #include 25 | } 26 | #include 27 | #include 28 | #include 29 | #include "avframe.h" 30 | #include "streamhandle.h" 31 | #include "lavfmuxer.h" 32 | 33 | #include 34 | 35 | lavfmuxer::lavfmuxer(const char *format, uint32_t audiostreammask, mpgfile &mpg, const char *filename) 36 | : muxer(), avfc(0), fileopened(false) 37 | { 38 | auto fmt_ = av_guess_format(format, NULL, NULL); 39 | if (!fmt_) { 40 | return; 41 | } 42 | fmt = fmt_; 43 | 44 | if (avformat_alloc_output_context2(&avfc, fmt_, NULL, av_strdup(filename ? filename : "")) < 0) 45 | return; 46 | 47 | av_opt_set_int(avfc, "preload", (int)(.5 * AV_TIME_BASE), AV_OPT_SEARCH_CHILDREN); 48 | av_opt_set_int(avfc, "muxrate", 10080000, AV_OPT_SEARCH_CHILDREN); 49 | avfc->max_delay= (int)(.7*AV_TIME_BASE); 50 | 51 | int id=0; 52 | 53 | st[VIDEOSTREAM].stream_index=id; 54 | 55 | strpres[VIDEOSTREAM]=true; 56 | mpg.setvideoencodingparameters(); 57 | AVCodecContext* codec = mpg.getavcc(VIDEOSTREAM); 58 | codec->rc_buffer_size = 224*1024*8; 59 | AVStream *s = st[VIDEOSTREAM].avstr = avformat_new_stream(avfc, codec->codec); 60 | s->id = id++; 61 | s->sample_aspect_ratio = codec->sample_aspect_ratio; 62 | s->time_base = codec->time_base; 63 | 64 | int avlogflags = av_log_get_flags(); 65 | 66 | int ret = 0; 67 | #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 14, 0) 68 | // Use Parameters instead of Codec, necessary to get correct results, prevent crash and correct display of the output of av_dump 69 | ret = avcodec_parameters_from_context(s->codecpar, codec); 70 | if (ret < 0) { 71 | av_log(NULL, AV_LOG_ERROR, "Failed to copy encoder parameters to output stream #%u\n", s->id); 72 | return; 73 | } 74 | #endif 75 | 76 | for (int i=0;icodec_type = AVMEDIA_TYPE_AUDIO; 82 | codec->codec_id = (mpg.getstreamtype(astr)==streamtype::ac3audio) ? AV_CODEC_ID_AC3 : AV_CODEC_ID_MP2; 83 | codec->rc_buffer_size = 224*1024*8; 84 | s = st[astr].avstr = avformat_new_stream(avfc, codec->codec); 85 | s->id = id++; 86 | strpres[astr]=true; 87 | 88 | // Must read some packets to get codec parameters 89 | streamhandle sh(mpg.getinitialoffset()); 90 | streamdata *sd=sh.newstream(astr,mpg.getstreamtype(astr),mpg.istransportstream()); 91 | 92 | int srerror = 0; 93 | while (sh.fileposition < mpg.getinitialoffset()+(8<<20)) { 94 | if (mpg.streamreader(sh)<=0) 95 | break; 96 | 97 | if (sd->getitemlistsize() > 1) { 98 | if (!avcodec_open2(codec, 99 | avcodec_find_decoder(codec->codec_id), NULL)) { 100 | AVFrame *frame = av_frame_alloc(); 101 | AVPacket* pkt = av_packet_alloc(); 102 | 103 | pkt->data = (uint8_t*)sd->getdata(); 104 | pkt->size = sd->inbytes(); 105 | 106 | avcodec_send_packet(codec, pkt); 107 | avcodec_receive_frame(codec, frame); 108 | 109 | av_packet_free(&pkt); 110 | av_frame_free(&frame); 111 | avcodec_close(codec); 112 | } 113 | if (codec->sample_rate == 0) { 114 | ++srerror; 115 | if (srerror == 1) { 116 | fprintf(stderr,"Error, could not determine sample rate\n"); 117 | av_log_set_flags(AV_LOG_SKIP_REPEATED); 118 | } 119 | sd->pop(); 120 | } 121 | else { 122 | fprintf(stdout,"Sample rate found after %d errors\n", srerror); 123 | break; 124 | } 125 | } 126 | } 127 | s->time_base = codec->time_base; 128 | #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(57, 14, 0) 129 | // Use Parameters instead of Codec, necessary to get correct results, prevent crash and correct display of the output of av_dump 130 | ret = avcodec_parameters_from_context(s->codecpar, codec); 131 | if (ret < 0) { 132 | av_log(NULL, AV_LOG_ERROR, "Failed to copy encoder parameters to output stream #%u\n", s->id); 133 | return; 134 | } 135 | #endif 136 | } 137 | 138 | av_log_set_flags(avlogflags); 139 | 140 | if (!(fmt->flags & AVFMT_NOFILE)&&(avio_open(&avfc->pb, filename, AVIO_FLAG_WRITE) < 0)) { 141 | av_free(avfc); 142 | avfc=0; 143 | return; 144 | } 145 | 146 | av_opt_set_int(avfc, "preload", (int)(.5 * AV_TIME_BASE), AV_OPT_SEARCH_CHILDREN); 147 | av_opt_set_int(avfc, "muxrate", 10080000, AV_OPT_SEARCH_CHILDREN); 148 | avfc->max_delay= (int)(.7*AV_TIME_BASE); 149 | 150 | av_dump_format(avfc, 0, filename, 1); 151 | ret = avformat_write_header(avfc, NULL); 152 | if (ret < 0) { 153 | fprintf(stderr, "avformat_write_header failed ret[%d]\n", ret); 154 | return; 155 | } 156 | 157 | fileopened = true; 158 | } 159 | 160 | 161 | lavfmuxer::~lavfmuxer() 162 | { 163 | if (avfc) { 164 | if (fileopened) { 165 | av_write_trailer(avfc); 166 | if (!(fmt->flags & AVFMT_NOFILE)) 167 | avio_close(avfc->pb); 168 | } 169 | 170 | av_free(avfc); 171 | } 172 | } 173 | 174 | -------------------------------------------------------------------------------- /src/mpgfile.h: -------------------------------------------------------------------------------- 1 | /* dvbcut 2 | Copyright (c) 2005 Sven Over 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | */ 18 | 19 | /* $Id$ */ 20 | 21 | #ifndef _DVBCUT_MPGFILE_H 22 | #define _DVBCUT_MPGFILE_H 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | #include "port.h" 29 | #include "buffer.h" 30 | #include "types.h" 31 | #include "index.h" 32 | #include "pts.h" 33 | #include "defines.h" 34 | #include "stream.h" 35 | 36 | /** 37 | @author Sven Over 38 | */ 39 | class avframe; 40 | class muxer; 41 | class logoutput; 42 | 43 | class mpgfile 44 | { 45 | public: 46 | 47 | protected: 48 | inbuffer &buf; 49 | stream s[MAXAVSTREAMS]; 50 | int videostreams, audiostreams; 51 | int initialoffset; 52 | class index idx; 53 | int pictures; 54 | int time_base_num, time_base_den; 55 | 56 | mpgfile(inbuffer &b, int initial_offset); 57 | 58 | 59 | public: 60 | virtual ~mpgfile(); 61 | 62 | static mpgfile *open(inbuffer &b, std::string *errormessage = 0); 63 | virtual int streamreader(struct streamhandle &s)=0; 64 | virtual int mplayeraudioid(int audiostream)=0; 65 | virtual bool istransportstream() 66 | { 67 | return false; 68 | } 69 | virtual std::vector getbookmarks() 70 | { 71 | std::vector pic_bookmarks; 72 | return pic_bookmarks; 73 | } 74 | 75 | int getinitialoffset() const 76 | { 77 | return initialoffset; 78 | } 79 | int getpictures() const 80 | { 81 | return pictures; 82 | } 83 | int getaudiostreams() const 84 | { 85 | return audiostreams; 86 | } 87 | streamtype::type getstreamtype(int str) const 88 | { 89 | return s[str].type; 90 | } 91 | const std::string &getstreaminfo(int str) const 92 | { 93 | return s[str].getinfo(); 94 | } 95 | const index::picture &operator[](unsigned int i) const 96 | { 97 | return idx[idx.indexnr(i)]; 98 | } 99 | int lastseqheader(int i) const 100 | { 101 | while (i>0 && !idx[idx.indexnr(i)].getseqheader()) 102 | --i; 103 | return i; 104 | } 105 | int lastiframe(int i) const 106 | { 107 | while (i>0 && !idx[idx.indexnr(i)].isiframe()) 108 | --i; 109 | return i; 110 | } 111 | int nextseqheader(int i) const 112 | { 113 | while (i+1= 0 && i < pictures) 126 | { 127 | int aspect = idx[idx.indexnr(i)].getaspectratio(); 128 | while (++i < pictures) 129 | { 130 | if (aspect != idx[idx.indexnr(i)].getaspectratio()) 131 | return i; 132 | } 133 | } 134 | return -1; 135 | } 136 | int getpictureatposition(dvbcut_off_t position) const 137 | { 138 | // binary search for the picture at nearest file position (in bytes) 139 | int firstpic=0, lastpic=pictures-1; 140 | int first=idx.indexnr(firstpic), mid, last=idx.indexnr(lastpic); 141 | dvbcut_off_t firstpos=idx[first].getpos(); 142 | dvbcut_off_t lastpos=idx[last].getpos(); 143 | dvbcut_off_t midpos; 144 | 145 | if(positionlastpos) return -1; 146 | 147 | while( last-first > 1 ) 148 | { 149 | mid = (first + last)/2; 150 | midpos = idx[mid].getpos(); 151 | 152 | if(position > midpos) { 153 | first = mid; 154 | firstpos = midpos; 155 | } else if(position < midpos) { 156 | last = mid; 157 | lastpos = midpos; 158 | } else { // equality 159 | first = mid; 160 | firstpos = midpos; 161 | last = mid; 162 | lastpos = midpos; 163 | } 164 | } 165 | 166 | // index of picture at nearest file position 167 | int ind = (position-firstpos)<(lastpos-position) ? first : last; 168 | 169 | // get the corresponding picture number 170 | return idx.picturenr(ind); 171 | } 172 | int getpictureattime(pts_t time) const 173 | { 174 | int first=idx.indexnr(0), second=idx.indexnr(1); 175 | pts_t firstpts=idx[first].getpts(), secondpts=idx[second].getpts(); 176 | 177 | int timeperframe=secondpts-firstpts; 178 | timeperframe = timeperframe>0 && timeperframe<5000 ? timeperframe : 3003; 179 | 180 | return time/timeperframe; 181 | } 182 | AVCodecContext *getavcc(int str) 183 | { 184 | return s[str].avcc; 185 | } 186 | void setvideoencodingparameters() 187 | { 188 | s[videostream()].setvideoencodingparameters(time_base_num, time_base_den); 189 | } 190 | 191 | int generateindex(const char *savefilename=0, std::string *errorstring=0, logoutput *log=0) 192 | { 193 | int rv=idx.generate(savefilename,errorstring,log); 194 | pictures=(rv>0)?rv:0; 195 | return rv; 196 | } 197 | int loadindex(const char *filename, std::string *errorstring=0) 198 | { 199 | int rv=idx.load(filename,errorstring); 200 | pictures=(rv>0)?rv:0; 201 | return rv; 202 | } 203 | int saveindex(const char *filename, std::string *errorstring=0) 204 | { 205 | return idx.save(filename,errorstring); 206 | } 207 | int getwidth(int res) 208 | { 209 | return idx.getwidth(res); 210 | } 211 | int getheight(int res) 212 | { 213 | return idx.getheight(res); 214 | } 215 | 216 | void decodegop(int start, int stop, std::list &framelist); 217 | void initaudiocodeccontext(int aud); 218 | void initcodeccontexts(int vid); 219 | void playaudio(int aud, int picture, int ms); 220 | void savempg(muxer &mux, int start, int stop, int progresspics=0, 221 | int progresstotal=0, logoutput *log=0); 222 | void recodevideo(muxer &mux, int start, int stop, pts_t offset, 223 | int progresspics=0, int progresstotal=0, logoutput *log=0); 224 | void fixtimecode(uint8_t *buf, int len, pts_t pts); 225 | ssize_t readfile(std::string filename, uint8_t **buffer); 226 | 227 | dvbcut_off_t getfilesize() 228 | { 229 | return buf.getfilesize(); 230 | } 231 | dvbcut_off_t getfilepos() const 232 | { 233 | return buf.getfilepos(); 234 | } 235 | 236 | static pts_t char2pts(const unsigned char *h) 237 | { 238 | return pts_t((uint32_t(h[4] & 0xfe) >> 1) | 239 | (uint32_t(h[3]) << 7) | 240 | (uint32_t(h[2] & 0xfe) << 14) | 241 | (uint32_t(h[1]) << 22)) | pts_t((uint32_t) (h[0] & 0x0e) << 29); 242 | } 243 | static pts_t char2pts(const unsigned char *h, pts_t reference) 244 | { 245 | return ptsreference(char2pts(h),reference); 246 | } 247 | static const int frameratescr[16]; 248 | }; 249 | 250 | #endif 251 | -------------------------------------------------------------------------------- /src/dvbcut.h: -------------------------------------------------------------------------------- 1 | /* dvbcut 2 | Copyright (c) 2005 Sven Over 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | */ 18 | 19 | /* $Id$ */ 20 | 21 | #ifndef _DVBCUT_DVBCUT_H 22 | #define _DVBCUT_DVBCUT_H 23 | 24 | #if !defined(DVBCUT_VERSION) 25 | #define DVBCUT_VERSION "git" 26 | #endif 27 | 28 | #ifndef VERSION_STRING 29 | #define VERSION_STRING "dvbcut-" DVBCUT_VERSION 30 | #endif 31 | 32 | #include 33 | #include 34 | #include 35 | #include "mpgfile.h" 36 | #include "ui_dvbcutbase.h" 37 | #include "pts.h" 38 | #include "eventlistitem.h" 39 | 40 | class QProcess; 41 | class imageprovider; 42 | 43 | class dvbcut: public QMainWindow 44 | { 45 | Q_OBJECT 46 | 47 | public: 48 | static bool cache_friendly; 49 | 50 | struct quick_picture_lookup_s 51 | { 52 | int startpicture; 53 | pts_t startpts; 54 | int stoppicture; 55 | pts_t stoppts; 56 | int outpicture; 57 | pts_t outpts; 58 | 59 | quick_picture_lookup_s(int _startpicture, pts_t _startpts, int _stoppicture, pts_t _stoppts, int _outpicture, pts_t _outpts) : 60 | startpicture(_startpicture), startpts(_startpts), stoppicture(_stoppicture), stoppts(_stoppts), outpicture(_outpicture), outpts(_outpts) 61 | { 62 | } 63 | 64 | struct cmp_picture 65 | { 66 | bool operator()(int lhs, const quick_picture_lookup_s &rhs) const 67 | { 68 | return lhs quick_picture_lookup_t; 80 | 81 | protected: 82 | quick_picture_lookup_t quick_picture_lookup; 83 | std::list chapterlist; 84 | 85 | QMenu *audiotrackpopup,*recentfilespopup,*editconvertpopup; 86 | QAction* audiotrackmenu; 87 | inbuffer buf; 88 | mpgfile *mpg; 89 | int pictures; 90 | int curpic; 91 | double alpha; 92 | pts_t firstpts; 93 | int timeperframe; 94 | bool showimage; 95 | bool fine; 96 | bool jogsliding; 97 | int jogmiddlepic; 98 | std::string prjfilen,idxfilen,expfilen; 99 | QString picfilen; 100 | std::list mpgfilen; 101 | QProcess *mplayer_process; 102 | bool mplayer_success; 103 | QString mplayer_out; 104 | pts_t mplayer_curpts; 105 | imageprovider *imgp; 106 | int busy; 107 | double viewscalefactor; 108 | int currentaudiotrack; 109 | bool nogui; 110 | int exportformat; 111 | bool start_bof; 112 | bool stop_eof; 113 | Ui::dvbcutbase* ui; 114 | 115 | protected: 116 | // QPixmap getpixmap(int picture, bool allgop=false); 117 | void exportvideo(const char *fmt); 118 | void addtorecentfiles(const std::list &filenames, const std::string &idxfilename=std::string()); 119 | void setviewscalefactor(double factor); 120 | 121 | // special event handling (mouse wheel) 122 | bool eventFilter(QObject *watched, QEvent *e); 123 | 124 | void update_time_display(); 125 | void update_quick_picture_lookup_table(); 126 | 127 | // QMessagebox interface 128 | int question(const QString & caption, const QString & text); 129 | int critical(const QString & caption, const QString & text); 130 | int critical(const QString & caption, const std::string & text); 131 | 132 | // filename handling 133 | void make_canonical(std::string &filename); 134 | void make_canonical(std::list &filenames); 135 | 136 | // generic event item adder 137 | void addEventListItem(int pic, EventListItem::eventtype type); 138 | 139 | // save given (or current) picture (or select the best from a given number of samples inside a range) 140 | void snapshotSave(std::vector piclist, int range=0, int samples=1); 141 | int chooseBestPicture(int startpic, int range, int smaples); 142 | 143 | void gotoFrame(int frameno); 144 | int getPreviousStopEvent(int picture); 145 | 146 | protected slots: 147 | virtual void helpAboutAction_activated(); 148 | virtual void helpContentAction_activated(); 149 | 150 | public: 151 | ~dvbcut(); 152 | dvbcut(); 153 | void open(std::list filenames=std::list(), 154 | std::string idxfilename=std::string(), std::string expfilename=std::string()); 155 | void setbusy(bool b=true); 156 | void batchmode(bool b=true) { nogui = b; } 157 | void exportoptions(int format=0, bool bof=true, bool eof=true) { exportformat = format; start_bof=bof; stop_eof=eof; } 158 | // static dvbcut *New(std::string filename=std::string(), std::string idxfilename=std::string()); 159 | void addStartStopItems(std::vector, int option=0); 160 | int getTimePerFrame() { return timeperframe>0 && timeperframe<5000 ? timeperframe : 3003; }; 161 | void setSliderPercentage(float percentage); 162 | void updateMoodbar(); 163 | 164 | enum editconvertpop_actions { 165 | act_start_stop = 0, 166 | act_stop_start, 167 | act_4_3, 168 | act_16_9 169 | }; 170 | 171 | public slots: 172 | virtual void fileNew(); 173 | virtual void fileOpen(); 174 | virtual void fileSaveAs(); 175 | virtual void fileSave(); 176 | virtual void snapshotSave(); 177 | virtual void chapterSnapshotsSave(); 178 | virtual void fileExport(); 179 | virtual void fileClose(); 180 | virtual void editBookmark(); 181 | virtual void editChapter(); 182 | virtual void editStop(); 183 | virtual void editStart(); 184 | virtual void editAutoChapters(); 185 | virtual void editSuggest(); 186 | virtual void editImport(); 187 | virtual void editConvert(QAction* a); 188 | virtual void editConvert(editconvertpop_actions options); 189 | virtual void abouttoshoweditconvert(); 190 | virtual void viewDifference(); 191 | virtual void searchDuplicate(); 192 | virtual void viewUnscaled(); 193 | virtual void viewNormal(); 194 | virtual void zoomIn(); 195 | virtual void zoomOut(); 196 | virtual void viewFullSize(); 197 | virtual void viewHalfSize(); 198 | virtual void viewQuarterSize(); 199 | virtual void viewCustomSize(); 200 | virtual void viewMoodbar(); 201 | virtual void playAudio2(); 202 | virtual void playAudio1(); 203 | virtual void playStop(); 204 | virtual void playPlay(); 205 | virtual void jogsliderreleased(); 206 | virtual void jogslidervalue(int); 207 | virtual void linslidervalue(int); 208 | virtual void doubleclickedeventlist(QListWidgetItem *lbi); 209 | virtual void eventlistcontextmenu(const QPoint &); 210 | virtual void mplayer_exited(); 211 | virtual void mplayer_readstdout(); 212 | virtual void clickedgo(); 213 | virtual void clickedgo2(); 214 | virtual void updateimagedisplay(); 215 | virtual void audiotrackchosen(QAction* a); 216 | virtual void loadrecentfile(QAction* a); 217 | virtual void abouttoshowrecentfiles(); 218 | virtual void wheelEvent(QWheelEvent* event); 219 | }; 220 | 221 | #endif 222 | -------------------------------------------------------------------------------- /src/psfile.cpp: -------------------------------------------------------------------------------- 1 | /* dvbcut 2 | Copyright (c) 2005 Sven Over 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | */ 18 | 19 | /* $Id$ */ 20 | 21 | #include 22 | 23 | #include "psfile.h" 24 | #include "streamhandle.h" 25 | #include "stream.h" 26 | 27 | static inline streamtype::type 28 | stream_type(int sid) { 29 | if (sid >= 0xc0 && sid <= 0xdf) 30 | return streamtype::mpegaudio; 31 | if (sid >= 0x180 && sid <= 0x187) 32 | return streamtype::ac3audio; 33 | /* not supported yet: 34 | if (sid >= 0x188 && sid <= 0x18f) 35 | return streamtype::dtsaudio; 36 | if (sid >= 0x120 && sid <= 0x13f) 37 | return streamtype::vobsub; 38 | */ 39 | return streamtype::unknown; 40 | } 41 | 42 | static inline bool 43 | is_audio_stream(streamtype::type t) { 44 | return t == streamtype::mpegaudio 45 | || t == streamtype::ac3audio 46 | /* not yet 47 | || t == streamtype::dtsaudio 48 | */ 49 | ; 50 | } 51 | 52 | psfile::psfile(inbuffer &b, int initial_offset) 53 | : mpgfile(b, initial_offset) 54 | { 55 | int vid=-1; 56 | for(unsigned int i=0;i<0x300;++i) 57 | streamnumber[i]=-1; 58 | 59 | int inbytes=buf.providedata(buf.getsize(),initialoffset); 60 | const uint8_t* data=(const uint8_t*) buf.data(); 61 | 62 | bool streamfound[0x300]={}; 63 | int count = 0; 64 | int sid; 65 | 66 | while (inbytes>=9) { 67 | if (data[2]&0xfe) { 68 | data+=3; 69 | inbytes-=3; 70 | continue; 71 | } 72 | 73 | if (data[0]!=0 || data[1]!=0 || data[2]!=1 || data[3]<0xb9) { 74 | // sync lost 75 | ++data; 76 | --inbytes; 77 | continue; 78 | } 79 | 80 | sid=data[3]; 81 | int len=6; 82 | 83 | if (sid==0xba) { // pack header 84 | if (inbytes<14) 85 | break; 86 | len=14+(data[13]&0x07); 87 | } 88 | else if (sid==0xb9) { // program end 89 | break; 90 | } 91 | else { 92 | len=((data[4]<<8)|data[5])+6; 93 | } 94 | 95 | if (sid>=0xe0 && sid<=0xef) { 96 | if (vid<0) { 97 | vid=sid; 98 | streamnumber[vid]=VIDEOSTREAM; 99 | } 100 | inbytes-=len; 101 | data+=len; 102 | continue; 103 | } 104 | 105 | if (sid==0xbd || sid==0xbf) { // private stream 106 | if (inbytes<(10+data[8])) 107 | break; 108 | int ssid=data[9+data[8]]; 109 | sid=((sid==0xbd)?0x100:0x200) | ssid; 110 | } 111 | 112 | if (!streamfound[sid]) { // first occurrence of this stream 113 | streamfound[sid] = true; 114 | streamtype::type t = stream_type(sid); 115 | if (is_audio_stream(t) && count < MAXAUDIOSTREAMS) { 116 | // note: streams will be renumbered later 117 | streamnumber[sid] = audiostream(0); 118 | ++count; 119 | } 120 | } 121 | inbytes-=len; 122 | data+=len; 123 | continue; 124 | } 125 | 126 | // renumber audio streams 127 | for (sid = 0; sid < 0x300; ++sid) { 128 | if (streamnumber[sid] == audiostream(0)) { 129 | fprintf(stderr, "Found audio stream %d (sid 0x%03x)\n", audiostreams, sid); 130 | streamnumber[sid] = audiostream(audiostreams); 131 | stream *S = &s[audiostream(audiostreams++)]; 132 | S->id = sid; 133 | S->type = stream_type(sid); 134 | } 135 | } 136 | assert(audiostreams == count); 137 | 138 | initcodeccontexts(vid); 139 | } 140 | 141 | 142 | psfile::~psfile() 143 | {} 144 | 145 | int psfile::streamreader(streamhandle &sh) 146 | { 147 | int bytes=0; 148 | const uint8_t *data=0; 149 | int skipped=0; 150 | int minbytes=14; 151 | 152 | for(;;) { 153 | if (bytes=0) { 203 | if (bytes= 0x180 && sid <= 0x18f) // ac3audio or dtsaudio 212 | payloadbegin += 4; 213 | else if (sid&0x300) 214 | ++payloadbegin; 215 | else if ((sid&0xf0)==0xe0) { 216 | if ( *(uint32_t*)(data+payloadbegin)==mbo32(0x00000001) ) 217 | ++payloadbegin; 218 | } 219 | 220 | streamdata *sd=sh.stream[sn]; 221 | if (len>payloadbegin && sd) { 222 | 223 | sd->appenditem(filepos_t(sh.fileposition,0), std::string((const char*)data+6,payloadbegin-6), 224 | data+payloadbegin, len-payloadbegin); 225 | int returnvalue = len-payloadbegin; 226 | 227 | sh.fileposition+=len; 228 | return returnvalue; 229 | } 230 | } 231 | 232 | skipped+=len; 233 | data+=len; 234 | bytes-=len; 235 | } 236 | 237 | } 238 | 239 | /// This function probes the data in the given inbuffer for an mpeg program stream. 240 | /// It returns the buffer offset at which the program stream starts, or -1 if 241 | /// no program stream was identified. 242 | int psfile::probe(inbuffer &buf) 243 | { 244 | int latestsync=buf.inbytes()-2048-16; 245 | if (latestsync>(8<<10)) 246 | latestsync=8<<10; 247 | 248 | int testupto=buf.inbytes()-16; 249 | if (testupto > (2 << 20)) // scan at most 2 MB 250 | testupto = 2 << 20; 251 | 252 | const uint8_t *data = (const uint8_t*) buf.data(); 253 | int ps; 254 | for (ps = 0; ps < latestsync; ++ps) { 255 | if (data[ps+2]&0xfe) { 256 | ps+=3; 257 | continue; 258 | } 259 | 260 | int pos=ps; 261 | while(pos < testupto) { 262 | const uint8_t *d=&data[pos]; 263 | 264 | if (d[0]!=0 || d[1]!=0 || d[2]!=1 || d[3]<0xba) 265 | break; 266 | if (d[3]==0xba) 267 | pos+=14+(d[13]&0x07); 268 | else 269 | pos+=((d[4]<<8)|d[5])+6; 270 | } 271 | if (pos >= testupto) { // this is a MPEG PS file 272 | return ps; 273 | } 274 | } 275 | 276 | return -1; 277 | } 278 | -------------------------------------------------------------------------------- /src/mpegmuxer.h: -------------------------------------------------------------------------------- 1 | /* dvbcut 2 | Copyright (c) 2005 Sven Over 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | */ 18 | 19 | /* $Id$ */ 20 | 21 | #ifndef _DVBCUT_MPEGMUXER_H 22 | #define _DVBCUT_MPEGMUXER_H 23 | 24 | #define MINPACKSIZE 64 25 | #define DTSMAXDELAY 90000 26 | 27 | #include 28 | #include "defines.h" 29 | #include "muxer.h" 30 | #include "mpgfile.h" 31 | 32 | typedef int64_t scr_t; 33 | #define pts2scr(x) (((scr_t)(x))*300) 34 | #define scr2pts(x) ((pts_t)((x)/300)) 35 | 36 | /** 37 | @author Sven Over 38 | */ 39 | class mpegmuxer : public muxer 40 | { 41 | public: 42 | class bufferremoval 43 | { 44 | scr_t _scr; 45 | int _bytes; 46 | public: 47 | bufferremoval(scr_t scr, int bytes) : _scr(scr),_bytes(bytes) 48 | {} 49 | int bytes() 50 | { 51 | return _bytes; 52 | } 53 | scr_t scr() 54 | { 55 | return _scr; 56 | } 57 | }; 58 | 59 | class au 60 | { 61 | protected: 62 | void *data; 63 | int size; 64 | pts_t pts,dts; 65 | int flags; 66 | int pos; 67 | public: 68 | au(const void *_data,int _size, pts_t _pts, pts_t _dts, int _flags); 69 | ~au(); 70 | const void *getdata() const 71 | { 72 | return data; 73 | } 74 | void *getdata() 75 | { 76 | return (void*)((char*)data+pos); 77 | } 78 | int getsize() 79 | { 80 | return size-pos; 81 | } 82 | bool incomplete() 83 | { 84 | return pos; 85 | } 86 | int getpos() 87 | { 88 | return pos; 89 | } 90 | void addpos(int p) 91 | { 92 | pos+=p; 93 | if (pos>size) 94 | pos=size; 95 | } 96 | pts_t getpts() 97 | { 98 | return pts; 99 | } 100 | pts_t getdts() 101 | { 102 | return dts; 103 | } 104 | int getflags() 105 | { 106 | return flags; 107 | } 108 | void addflags(int fl) 109 | { 110 | flags|=fl; 111 | } 112 | void unsetflags(int fl) 113 | { 114 | flags &= ~fl; 115 | } 116 | }; 117 | 118 | class pack 119 | { 120 | protected: 121 | void *data; 122 | int size; 123 | scr_t minscr,maxscr; 124 | pts_t dts; 125 | int payloadpos; 126 | int payloadlen; 127 | int aupayloadlen; 128 | friend class mpegmuxer; 129 | 130 | public: 131 | pack(int packsize, int payloadsize, int muxrate, pts_t _dts); 132 | ~pack(); 133 | 134 | const void *getdata() const 135 | { 136 | return data; 137 | } 138 | int getsize() const 139 | { 140 | return size; 141 | } 142 | void *getpayload() 143 | { 144 | return (void*)((char*)data+payloadpos); 145 | } 146 | int getpayloadlen() const 147 | { 148 | return payloadlen; 149 | } 150 | void addaupayload(int p) 151 | { 152 | aupayloadlen+=p; 153 | } 154 | int getaupayloadlen() const 155 | { 156 | return aupayloadlen; 157 | } 158 | void setscr(scr_t scr); 159 | void setlastdts(pts_t dts) 160 | { 161 | setminscr(pts2scr(dts-DTSMAXDELAY)); 162 | } 163 | void setminscr(scr_t scr) 164 | { 165 | if (scr>minscr) 166 | minscr=scr; 167 | } 168 | void setmaxscr(scr_t scr) 169 | { 170 | if (scr aulist; 207 | std::list packlist; 208 | std::list bufferremovals; 209 | streamtype::type type; 210 | int id; 211 | int bufsize; 212 | int filllevel; 213 | int packet; 214 | uint32_t startcode; 215 | uint16_t pstdbuffer; 216 | friend class mpegmuxer; 217 | 218 | public: 219 | stream(streamtype::type _type, int _id, int _bufsize, int _pstdbuffer, bool bufferscale=true) : 220 | type(_type), id(_id&0x3ff), bufsize(_bufsize), filllevel(0), packet(0) 221 | { 222 | if (bufferscale) 223 | pstdbuffer=htom16(0x6000|((_pstdbuffer/1024)&0x1fff)); 224 | else 225 | pstdbuffer=htom16(0x4000|((_pstdbuffer/128)&0x1fff)); 226 | 227 | if ( (id&~0xff)==0x100 ) 228 | startcode=mbo32(0x1bd); 229 | else if ( (id&~0xff)==0x200 ) 230 | startcode=mbo32(0x1bf); 231 | else 232 | startcode=htom32(0x100|id); 233 | } 234 | ~stream() 235 | { 236 | for(std::list::iterator it=aulist.begin();it!=aulist.end();++it) 237 | delete *it; 238 | for(std::list::iterator it=packlist.begin();it!=packlist.end();++it) 239 | delete *it; 240 | } 241 | int getbufsize() const 242 | { 243 | return bufsize; 244 | } 245 | int getbuffree() const 246 | { 247 | return bufsize-filllevel; 248 | } 249 | uint32_t getstartcode() const 250 | { 251 | return startcode; 252 | } 253 | uint16_t getpstdbuffer() const 254 | { 255 | return pstdbuffer; 256 | } 257 | int getid() const 258 | { 259 | return id; 260 | } 261 | void fill(int bytes) 262 | { 263 | filllevel+=bytes; 264 | } 265 | void unfill(int bytes) 266 | { 267 | filllevel-=bytes; 268 | if (filllevel<0) 269 | filllevel=0; 270 | } 271 | void zerofill() 272 | { 273 | filllevel=0; 274 | } 275 | int getfill() const 276 | { 277 | return filllevel; 278 | } 279 | bool operator<(const stream &s) const 280 | { 281 | if (packlist.empty()) 282 | return false; 283 | if (s.packlist.empty()) 284 | return true; 285 | return packlist.front()->getmaxscr()getmaxscr(); 286 | } 287 | bool operator<(const scr_t &s) const 288 | { 289 | if (packlist.empty()) 290 | return false; 291 | return packlist.front()->getmaxscr()=0; 319 | } 320 | virtual void finish() 321 | { 322 | flush(true); 323 | } 324 | }; 325 | 326 | #endif 327 | 328 | -------------------------------------------------------------------------------- /src/streamdata.h: -------------------------------------------------------------------------------- 1 | /* dvbcut 2 | Copyright (c) 2005 Sven Over 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | */ 18 | 19 | /* $Id$ */ 20 | 21 | #ifndef _DVBCUT_STREAMDATA_H 22 | #define _DVBCUT_STREAMDATA_H 23 | 24 | #include 25 | #include 26 | extern "C" { 27 | #include 28 | } 29 | 30 | #include "port.h" 31 | #include "tsfile.h" 32 | #include "psfile.h" 33 | #include "buffer.h" 34 | #include "types.h" 35 | #include "pts.h" 36 | 37 | /* obsolete, do not use --mr 38 | #define STREAM_ITEM_FLAG_DATA_ALIGNMENT_INDICATOR (1<<0) 39 | */ 40 | #define STREAM_ITEM_FLAG_HAS_PTS (1<<1) 41 | #define STREAM_ITEM_FLAG_FRAME (1<<2) 42 | 43 | /** 44 | @author Sven Over 45 | */ 46 | class streamdata 47 | { 48 | public: 49 | struct item 50 | { 51 | filepos_t fileposition; 52 | 53 | uint32_t bufferposition; 54 | uint32_t flags; 55 | pts_t pts; 56 | 57 | item(filepos_t fp, uint32_t fl, pts_t p, uint32_t bp) : fileposition(fp), bufferposition(bp), flags(fl), pts(p) 58 | { 59 | if (!(flags&STREAM_ITEM_FLAG_HAS_PTS)) 60 | pts=(pts_t)AV_NOPTS_VALUE; 61 | } 62 | ~item() 63 | {} 64 | 65 | void setpts(pts_t p) 66 | { 67 | if (p!=(pts_t)AV_NOPTS_VALUE) 68 | flags |= STREAM_ITEM_FLAG_HAS_PTS; 69 | else 70 | flags &=~ STREAM_ITEM_FLAG_HAS_PTS; 71 | pts=p; 72 | } 73 | bool headerhaspts() const 74 | { 75 | return flags & STREAM_ITEM_FLAG_HAS_PTS; 76 | } 77 | pts_t headerpts() const 78 | { 79 | return pts; 80 | } 81 | pts_t headerpts(pts_t reference) const 82 | { 83 | if (flags & STREAM_ITEM_FLAG_HAS_PTS) 84 | return ptsreference(pts,reference); 85 | return AV_NOPTS_VALUE; 86 | } 87 | void clearpts() 88 | { 89 | flags &=~ STREAM_ITEM_FLAG_HAS_PTS; 90 | pts=AV_NOPTS_VALUE; 91 | } 92 | bool is_frame() const 93 | { 94 | return flags & STREAM_ITEM_FLAG_FRAME; 95 | } 96 | } 97 | ; 98 | typedef std::list itemlisttype; 99 | 100 | protected: 101 | itemlisttype items; 102 | unsigned int itemlistsize; 103 | buffer data; 104 | uint32_t offset; 105 | std::string header; 106 | filepos_t curpos; 107 | const streamtype::type type; 108 | bool transportstream; 109 | dvbcut_off_t nextfilepos; 110 | 111 | public: 112 | streamdata(streamtype::type t, bool transport_stream, uint32_t buffersize=256<<10) : 113 | itemlistsize(0), data(buffersize), offset(0), curpos(0), type(t), transportstream(transport_stream) 114 | {} 115 | ~streamdata() 116 | {} 117 | 118 | const std::list &itemlist() const 119 | { 120 | return items; 121 | } 122 | bool empty() const 123 | { 124 | return items.empty(); 125 | } 126 | void pop() 127 | { 128 | items.pop_front(); 129 | --itemlistsize; 130 | if (items.empty()) { 131 | itemlistsize=0; // ...should be redundant 132 | offset=0; 133 | curpos+=data.inbytes(); 134 | data.clear(); 135 | } else { 136 | data.discard(items.front().bufferposition-offset); 137 | offset=items.front().bufferposition; 138 | curpos=items.front().fileposition; 139 | if (offset & (1ul<<31)) { 140 | for(std::list::iterator it=items.begin();it!=items.end();++it) 141 | it->bufferposition-=offset; 142 | offset=0; 143 | } 144 | } 145 | } 146 | void pop(unsigned int number) 147 | { 148 | if (number==0) 149 | return; 150 | if (number>=itemlistsize) { 151 | itemlistsize=0; 152 | offset=0; 153 | curpos+=data.inbytes(); 154 | data.clear(); 155 | return; 156 | } 157 | 158 | --number; 159 | for (unsigned int i=0;i=data.inbytes()) { 170 | curpos+=data.inbytes(); 171 | data.clear(); 172 | items.clear(); 173 | itemlistsize=0; 174 | offset=0; 175 | return; 176 | } 177 | data.discard(bytes); 178 | offset+=bytes; 179 | curpos+=bytes; 180 | if (items.empty()) 181 | return; 182 | std::list::iterator it=items.begin(); 183 | std::list::iterator nx=it; 184 | ++nx; 185 | while(nx!=items.end()) { 186 | if (nx->bufferposition>offset) 187 | break; 188 | ++nx; 189 | it=items.erase(it); 190 | --itemlistsize; 191 | } 192 | if (it->bufferpositionfileposition += offset-it->bufferposition; 194 | it->bufferposition=offset; 195 | } 196 | curpos=items.front().fileposition; 197 | if (offset & (1ul<<31)) { 198 | for(std::list::iterator it=items.begin();it!=items.end();++it) 199 | it->bufferposition-=offset; 200 | offset=0; 201 | } 202 | } 203 | void append(const void *d, int s) 204 | { 205 | data.putdata(d,s,true); 206 | } 207 | void appenditem(filepos_t fp, const std::string &header, const void *d, int s); 208 | void appenditem(filepos_t fp, int flags, pts_t pts, const void *d, int s) 209 | { 210 | if (items.empty()) 211 | curpos=fp; 212 | items.push_back(item(fp,flags,pts,offset+data.inbytes())); 213 | ++itemlistsize; 214 | data.putdata(d,s,true); 215 | } 216 | const void *getdata() const 217 | { 218 | return data.data(); 219 | } 220 | void *getdata() 221 | { 222 | return data.data(); 223 | } 224 | const void *getdata(uint32_t bufferpos) const 225 | { 226 | return (char*)data.data()+(bufferpos-offset); 227 | } 228 | void *getdata(uint32_t bufferpos) 229 | { 230 | return (char*)data.data()+(bufferpos-offset); 231 | } 232 | const buffer &getbuffer() const 233 | { 234 | return data; 235 | } 236 | uint32_t getoffset() const 237 | { 238 | return offset; 239 | } 240 | unsigned int inbytes() const 241 | { 242 | return data.inbytes(); 243 | } 244 | void discardheader() 245 | { 246 | if (!items.empty()) 247 | items.front().clearpts(); 248 | } 249 | const filepos_t &getcurpos() const 250 | { 251 | return curpos; 252 | } 253 | unsigned int getitemlistsize() const 254 | { 255 | return itemlistsize; 256 | } 257 | void audio_addpts(uint32_t startbufferpos=0, bool onepacket=false); 258 | uint32_t ptsbufferpos(pts_t pts); 259 | uint32_t closestptsbufferpos(pts_t pts); 260 | uint32_t fileposbufferpos(filepos_t pos) 261 | { 262 | for (itemlisttype::iterator it=items.begin();it!=items.end();++it) 263 | if (it->fileposition.packetposition() > pos.packetposition()) 264 | return it->bufferposition; 265 | else if (it->fileposition.packetposition() == pos.packetposition()) 266 | return it->bufferposition+(pos.packetoffset()-it->fileposition.packetoffset()); 267 | return offset+inbytes(); 268 | } 269 | const item &filepositem(filepos_t pos) 270 | { 271 | for (itemlisttype::iterator it=items.begin();it!=items.end();++it) 272 | if (it->fileposition.packetposition() >= pos.packetposition()) 273 | return *it; 274 | return items.back(); 275 | } 276 | const item &bufferpositem(uint32_t bpos) const 277 | { 278 | const item *i=&items.front(); 279 | for (itemlisttype::const_iterator it=++items.begin();it!=items.end();++it) 280 | if (it->bufferposition > bpos) 281 | break; 282 | else 283 | i=&(*it); 284 | return *i; 285 | } 286 | 287 | friend int tsfile::streamreader(streamhandle &s); 288 | friend int psfile::streamreader(streamhandle &s); 289 | }; 290 | 291 | #endif 292 | -------------------------------------------------------------------------------- /src/playaudio.cpp: -------------------------------------------------------------------------------- 1 | /* dvbcut 2 | Copyright (c) 2005-2007 Sven Over 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | */ 18 | 19 | /* $Id$ */ 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | #include "playaudio.h" 28 | #include "exception.h" 29 | 30 | #ifdef HAVE_LIB_AO 31 | #include 32 | 33 | /// Simple class for audio output through libao 34 | class audioout 35 | { 36 | protected: 37 | ao_device *m_device; 38 | int m_channels, m_samplerate; 39 | public: 40 | audioout() : m_device(NULL), m_channels(0), m_samplerate(0) {} 41 | ~audioout() 42 | { 43 | if (m_device) 44 | ao_close(m_device); 45 | } 46 | 47 | void play(int channels, int samplerate, int16_t *data, int bytes) 48 | { 49 | if ((not m_device) or channels!=m_channels or samplerate!=m_samplerate) 50 | { 51 | if (m_device) 52 | { 53 | ao_close(m_device); 54 | m_device=NULL; 55 | } 56 | 57 | ao_sample_format format; 58 | // zero-initialize 59 | memset(&format, 0, sizeof(format)); 60 | 61 | format.bits = 16; 62 | format.channels = channels; 63 | format.rate = samplerate; 64 | format.byte_format = AO_FMT_LITTLE; 65 | 66 | m_channels=channels; 67 | m_samplerate=samplerate; 68 | 69 | m_device = ao_open_live(ao_default_driver_id(), &format, NULL /* no options */ ); 70 | if (!m_device) 71 | throw dvbcut_exception("Error setting up audio output"); 72 | } 73 | 74 | ao_play(m_device, (char*) data, bytes); 75 | } 76 | }; 77 | 78 | 79 | #ifdef HAVE_LIB_A52 80 | extern "C" 81 | { 82 | #include 83 | #include 84 | } 85 | 86 | /// Simple class for AC3 decoding 87 | class a52dec 88 | { 89 | protected: 90 | a52_state_t *m_state; 91 | public: 92 | a52dec() : m_state(0) 93 | { 94 | m_state=a52_init(MM_ACCEL_DJBFFT); 95 | 96 | if (not m_state) 97 | throw dvbcut_exception("Error setting up AC3 decoder"); 98 | } 99 | ~a52dec() 100 | { 101 | a52_free(m_state); 102 | } 103 | const sample_t *samples() 104 | { 105 | return a52_samples(m_state); 106 | } 107 | int syncinfo(uint8_t *buffer, int &flags, int &sample_rate, int &bitrate) const 108 | { 109 | return a52_syncinfo(buffer,&flags,&sample_rate,&bitrate); 110 | } 111 | int frame(uint8_t *buffer, int &flags, sample_t &level, sample_t bias) 112 | { 113 | return a52_frame(m_state, buffer, &flags, &level, bias); 114 | } 115 | int block() 116 | { 117 | return a52_block(m_state); 118 | } 119 | }; 120 | 121 | void playaudio_ac3(const void *data, uint32_t len) 122 | { 123 | uint8_t *d=const_cast(reinterpret_cast(data)); 124 | 125 | a52dec dec; 126 | audioout aout; 127 | int flags=0, sample_rate=0, bit_rate=0; 128 | sample_t level; 129 | 130 | while (len>=7) 131 | { 132 | int bytes=dec.syncinfo(d,flags,sample_rate,bit_rate); 133 | 134 | if (bytes==0) 135 | { 136 | ++d; 137 | --len; 138 | continue; 139 | } 140 | 141 | if (bytes>signed(len)) 142 | break; 143 | 144 | flags=A52_STEREO | A52_ADJUST_LEVEL; 145 | level=1; 146 | if (dec.frame(d,flags,level,0)!=0) 147 | throw dvbcut_exception("Error while decoding AC3 data"); 148 | if ((flags&A52_CHANNEL_MASK)!=A52_STEREO) 149 | throw dvbcut_exception("Error while decoding AC3 data (non-stereo output)"); 150 | for (int i=0;i<6;++i) 151 | { 152 | if (dec.block()!=0) 153 | dvbcut_exception("Error while decoding AC3 data"); 154 | int16_t samples[256*2]; 155 | const sample_t *decoded=dec.samples(); 156 | for(int j=0;j<256;++j) 157 | { 158 | samples[j*2+0]=int16_t(decoded[j]*sample_t(32767)); 159 | samples[j*2+1]=int16_t(decoded[j+256]*sample_t(32767)); 160 | } 161 | aout.play(2,sample_rate,samples,256*2*2); //dec.samples(); 162 | } 163 | 164 | len-=bytes; 165 | d+=bytes; 166 | } 167 | 168 | // throw dvbcut_exception("AC3 playback not yet implemented"); 169 | } 170 | #else // HAVE_LIB_A52 171 | void playaudio_ac3(const void *, uint32_t) 172 | { 173 | throw dvbcut_exception("DVBCUT was built without AC3 support"); 174 | } 175 | #endif // ifdef HAVE_LIB_A52 176 | 177 | 178 | #ifdef HAVE_LIB_MAD 179 | #include 180 | 181 | /// Simple class for MP2 decoding and output throught the audioout class 182 | class mp2dec 183 | { 184 | protected: 185 | mad_decoder m_decoder; 186 | const void *m_data; 187 | uint32_t m_len; 188 | audioout &m_aout; 189 | std::string m_error; 190 | 191 | static enum mad_flow input(void *data,struct mad_stream *stream) 192 | { 193 | mp2dec *This=reinterpret_cast(data); 194 | 195 | if (This->m_len==0) 196 | return MAD_FLOW_STOP; 197 | 198 | mad_stream_buffer(stream, reinterpret_cast(This->m_data), This->m_len); 199 | This->m_len=0; 200 | 201 | return MAD_FLOW_CONTINUE; 202 | } 203 | 204 | static enum mad_flow output(void *data, 205 | struct mad_header const */*header*/, 206 | struct mad_pcm *pcm) 207 | { 208 | mp2dec *This=reinterpret_cast(data); 209 | 210 | unsigned int channels=pcm->channels; 211 | if (channels>2) 212 | channels=2; 213 | 214 | const unsigned int samples=pcm->length; 215 | 216 | mad_fixed_t *sample[channels]; 217 | for (unsigned int i=0;isamples[i]; 219 | 220 | int16_t buffer[samples*channels]; 221 | 222 | // Transform the data delivered by libmad into samples accepted by libao. 223 | for (unsigned int s=0;s> (MAD_F_FRACBITS + 1 - 16); 235 | } 236 | 237 | This->m_aout.play(channels,pcm->samplerate,buffer,samples*channels*2); 238 | 239 | return MAD_FLOW_CONTINUE; 240 | } 241 | 242 | static enum mad_flow error(void *data, 243 | struct mad_stream *stream, 244 | struct mad_frame */*frame*/) 245 | { 246 | mp2dec *This=reinterpret_cast(data); 247 | 248 | std::ostringstream out; 249 | 250 | out << "MP2 decoding error " << int(stream->error) << " (" << mad_stream_errorstr(stream) 251 | << ") at byte offset " << int(stream->this_frame - reinterpret_cast(This->m_data)); 252 | 253 | This->m_error=out.str(); 254 | return MAD_FLOW_CONTINUE; 255 | } 256 | 257 | public: 258 | mp2dec(const void *data, uint32_t len, audioout &aout) : m_data(data),m_len(len),m_aout(aout) 259 | { 260 | mad_decoder_init(&m_decoder,this,input,0,0,output,error,0); 261 | } 262 | ~mp2dec() 263 | { 264 | mad_decoder_finish(&m_decoder); 265 | } 266 | void run() 267 | { 268 | if (mad_decoder_run(&m_decoder,MAD_DECODER_MODE_SYNC)!=0) 269 | { 270 | if (m_error.empty()) 271 | throw dvbcut_exception("Error decoding/playing MP2 audio"); 272 | else 273 | throw dvbcut_exception("Error decoding/playing MP2 audio: "+m_error); 274 | } 275 | } 276 | }; 277 | 278 | void playaudio_mp2(const void *data, uint32_t len) 279 | { 280 | audioout aout; 281 | mp2dec(data,len,aout).run(); 282 | } 283 | #else // ifdef HAVE_LIB_MAD 284 | void playaudio_mp2(const void *data, uint32_t len) 285 | { 286 | throw dvbcut_exception("DVBCUT was built without MP2 support"); 287 | } 288 | #endif // ifdef HAVE_LIB_MAD 289 | 290 | // If DVBCUT is compiled without audio support, these dummy functions 291 | // will just throw an exception. However, they should never get called, as 292 | // the Play Audio actions should be disabled anyhow. 293 | #else // ifdef HAVE_LIB_AO 294 | void playaudio_ac3(const void *, uint32_t) 295 | { 296 | throw dvbcut_exception("DVBCUT was built without support for audio output"); 297 | } 298 | void playaudio_mp2(const void *, uint32_t) 299 | { 300 | throw dvbcut_exception("DVBCUT was built without support for audio output"); 301 | } 302 | #endif // ifdef HAVE_LIB_AO 303 | -------------------------------------------------------------------------------- /src/streamdata.cpp: -------------------------------------------------------------------------------- 1 | /* dvbcut 2 | Copyright (c) 2005 Sven Over 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 2 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, write to the Free Software 16 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 | */ 18 | 19 | /* $Id$ */ 20 | 21 | #include 22 | #include "streamdata.h" 23 | 24 | static const int mpegaudio_rates[]= 25 | { 26 | 44100,48000,32000,16000 27 | }; 28 | static const int mpegaudio_bitrate[][16]= 29 | { 30 | {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}, // undefined layer 31 | {0,32,40,48, 56, 64, 80, 96,112,128,160,192,224,256,320}, // layer 3 32 | {0,32,48,56, 64, 80, 96,112,128,160,192,224,256,320,384}, // layer 2 33 | {0,32,64,96,128,160,192,224,256,288,320,352,384,416,448} // layer 1 34 | }; 35 | 36 | static inline int is_mpa(const unsigned char *header) 37 | { 38 | return header[0] == 0xff /* sync word */ 39 | && (header[1] & 0xe6) > 0xe0 /* sync word & layer */ 40 | && (header[2] & 0xf0) != 0xf0 /* bitrate code */ 41 | && (header[2] & 0x0c) != 0x0c; /* sampling rate code */ 42 | } 43 | 44 | // return frame size in bytes, or 0 for no valid frame 45 | static int mpaframe(const void *data, int &pos, int len, int &duration) 46 | { 47 | const unsigned char *d=(const unsigned char *)data; 48 | 49 | for (; pos+2>1)&0x03; 54 | int samples=(layer==4-1)?384:1152; 55 | int samplingrate=mpegaudio_rates[(d[pos+2]>>2)&0x03]; 56 | int bitratecode=(d[pos+2]>>4)&0x0f; 57 | 58 | int skipbytes=(mpegaudio_bitrate[layer][bitratecode]*125)*samples/samplingrate; 59 | if (skipbytes>0 && pos+skipbytes+2>6)&3]/300; // Duration of AC3 audio frame in 90000Hz units 122 | return framelength; 123 | } 124 | } 125 | return 0; 126 | } 127 | 128 | void streamdata::audio_addpts(uint32_t startbufferpos, bool onepacket) 129 | { 130 | bool needsync=true; 131 | itemlisttype::iterator it=items.begin(); 132 | 133 | while(it!=items.end()) 134 | if (!it->headerhaspts()) 135 | it=items.erase(it); 136 | else 137 | ++it; 138 | 139 | it=items.begin(); 140 | while (it!=items.end() && it->bufferpositionheaderhaspts()); 152 | 153 | if (onepacket) { 154 | if (stopbufferpos) { 155 | if (it->bufferposition>=stopbufferpos) 156 | break; 157 | } else { 158 | itemlisttype::iterator n=it; 159 | for(++n;n!=items.end();++n) 160 | if (it->headerhaspts()) 161 | break; 162 | if (n!=items.end()) 163 | stopbufferpos=n->bufferposition; 164 | else 165 | onepacket=false; 166 | } 167 | } 168 | 169 | nx=it; 170 | ++nx; 171 | } 172 | 173 | pts=it->headerpts(); 174 | uint32_t bufferposition=it->bufferposition; 175 | 176 | // parse frames in this item 177 | int pos=0; 178 | int ptsplus=0; 179 | int (*auframe)(const void *data, int &pos, int len, int &duration) = 180 | (type==streamtype::ac3audio) ? ac3frame : mpaframe; 181 | uint8_t *data = (uint8_t*)getdata(bufferposition); 182 | int len = inbytes()-(bufferposition-getoffset()); 183 | int bytes; 184 | while ((bytes = auframe(data,pos,len,ptsplus)) != 0) { 185 | if (pos == 0) { 186 | //fprintf(stderr, "setting frame at item\n"); 187 | it->flags |= STREAM_ITEM_FLAG_FRAME; 188 | } else { 189 | bufferposition+=pos; 190 | data += pos; 191 | len -= pos; 192 | if (nx != items.end() && bufferposition >= nx->bufferposition) { 193 | //fprintf(stderr, "hit next %ld>=%ld pts=%lld interp=%lld\n", 194 | // bufferposition, nx->bufferposition,nx->headerpts(), 195 | // pts - (bufferposition - nx->bufferposition)*ptsplus/bytes); 196 | break; 197 | } 198 | it=items.insert(nx,item(it->fileposition+(bufferposition-it->bufferposition), 199 | STREAM_ITEM_FLAG_HAS_PTS|STREAM_ITEM_FLAG_FRAME, 200 | pts,bufferposition)); 201 | //fprintf(stderr, "sd: insert %p (pos %ld, nxflags %d) pts=%lld\n", 202 | // &(*it), bufferposition, nx->flags, pts); 203 | } 204 | pos = bytes; 205 | pts+=ptsplus; 206 | } 207 | it=nx; 208 | ++nx; 209 | } 210 | } 211 | 212 | /// Find the packet with the highest PTS less or equal than the given pts and returns its buffer position. 213 | uint32_t streamdata::ptsbufferpos(pts_t pts) 214 | { 215 | uint32_t bufferpos=getoffset(); 216 | streamdata::itemlisttype::const_iterator it=items.begin(); 217 | 218 | while(it!=items.end()) 219 | if (it->headerhaspts()) 220 | break; 221 | else 222 | ++it; 223 | 224 | if (it!=items.end()) 225 | for(;;) { 226 | bufferpos=it->bufferposition; 227 | pts_t itpts=it->headerpts(pts); 228 | if (itpts>=pts) 229 | break; 230 | streamdata::itemlisttype::const_iterator nx=it; 231 | ++nx; 232 | while (nx!=items.end() && !nx->headerhaspts()) 233 | ++nx; 234 | if (nx==items.end()) 235 | break; 236 | pts_t nxpts=nx->headerpts(pts); 237 | if (nxpts>pts) 238 | break; 239 | if (nxpts==pts) { 240 | bufferpos=nx->bufferposition; 241 | break; 242 | } 243 | 244 | it=nx; 245 | continue; 246 | } 247 | 248 | return bufferpos; 249 | } 250 | 251 | /// Find the packet with its PTS closest to the given pts and returns its buffer position. 252 | uint32_t streamdata::closestptsbufferpos(pts_t pts) 253 | { 254 | uint32_t bufferpos=getoffset(); 255 | streamdata::itemlisttype::const_iterator it=items.begin(); 256 | 257 | while(it!=items.end()) 258 | if (it->headerhaspts()) 259 | break; 260 | else 261 | ++it; 262 | 263 | for(;it!=items.end();) { 264 | pts_t itpts=it->headerpts(pts); 265 | if (itpts>=pts) 266 | break; 267 | streamdata::itemlisttype::const_iterator nx=it; 268 | ++nx; 269 | while (nx!=items.end() && !nx->headerhaspts()) 270 | ++nx; 271 | if (nx==items.end()) 272 | break; 273 | pts_t nxpts=nx->headerpts(pts); 274 | if (nxptsbufferposition; 276 | it=nx; 277 | continue; 278 | } 279 | if (nxpts==pts) { 280 | bufferpos=nx->bufferposition; 281 | break; 282 | } 283 | 284 | if (pts-itpts>=nxpts-pts) 285 | bufferpos=nx->bufferposition; 286 | 287 | break; 288 | } 289 | 290 | return bufferpos; 291 | } 292 | 293 | void streamdata::appenditem(filepos_t fp, const std::string &header, const void *d, int s) 294 | { 295 | int flags(0); 296 | pts_t pts(0); 297 | const uint8_t *data=(const uint8_t*)d; 298 | 299 | if (header.size()>=3) { 300 | if ((header[1]&0x80) && (header.size()>=8)) { 301 | flags |= STREAM_ITEM_FLAG_HAS_PTS; 302 | pts=mpgfile::char2pts((const unsigned char *)header.c_str()+3); 303 | } 304 | } 305 | 306 | if (s>0) { 307 | appenditem(fp, flags, pts, (const void*)data, s); 308 | } 309 | } 310 | 311 | --------------------------------------------------------------------------------