summaryrefslogtreecommitdiffstats
path: root/src/rip/videodvd
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-02-03 02:15:56 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-02-03 02:15:56 +0000
commit50b48aec6ddd451a6d1709c0942477b503457663 (patch)
treea9ece53ec06fd0a2819de7a2a6de997193566626 /src/rip/videodvd
downloadk3b-50b48aec6ddd451a6d1709c0942477b503457663.tar.gz
k3b-50b48aec6ddd451a6d1709c0942477b503457663.zip
Added abandoned KDE3 version of K3B
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/k3b@1084400 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'src/rip/videodvd')
-rw-r--r--src/rip/videodvd/Makefile.am16
-rw-r--r--src/rip/videodvd/base_k3bvideodvdrippingwidget.ui721
-rw-r--r--src/rip/videodvd/k3bvideodvdrippingdialog.cpp634
-rw-r--r--src/rip/videodvd/k3bvideodvdrippingdialog.h82
-rw-r--r--src/rip/videodvd/k3bvideodvdrippingjob.cpp385
-rw-r--r--src/rip/videodvd/k3bvideodvdrippingjob.h106
-rw-r--r--src/rip/videodvd/k3bvideodvdrippingpreview.cpp135
-rw-r--r--src/rip/videodvd/k3bvideodvdrippingpreview.h66
-rw-r--r--src/rip/videodvd/k3bvideodvdrippingtitlelistview.cpp410
-rw-r--r--src/rip/videodvd/k3bvideodvdrippingtitlelistview.h58
-rw-r--r--src/rip/videodvd/k3bvideodvdrippingview.cpp256
-rw-r--r--src/rip/videodvd/k3bvideodvdrippingview.h66
-rw-r--r--src/rip/videodvd/k3bvideodvdrippingwidget.cpp375
-rw-r--r--src/rip/videodvd/k3bvideodvdrippingwidget.h67
14 files changed, 3377 insertions, 0 deletions
diff --git a/src/rip/videodvd/Makefile.am b/src/rip/videodvd/Makefile.am
new file mode 100644
index 0000000..bac9b0a
--- /dev/null
+++ b/src/rip/videodvd/Makefile.am
@@ -0,0 +1,16 @@
+AM_CPPFLAGS = -I$(srcdir)/../../../libk3b/core \
+ -I$(srcdir)/../../../libk3bdevice \
+ -I$(srcdir)/../../../libk3b/tools \
+ -I$(srcdir)/../../../libk3b/videodvd/ \
+ -I$(srcdir)/../../../libk3b/jobs/ \
+ -I$(srcdir)/../.. \
+ $(all_includes)
+
+METASOURCES = AUTO
+
+noinst_LTLIBRARIES = libvideodvdrip.la
+
+libvideodvdrip_la_SOURCES = base_k3bvideodvdrippingwidget.ui k3bvideodvdrippingview.cpp \
+ k3bvideodvdrippingtitlelistview.cpp \
+ k3bvideodvdrippingjob.cpp k3bvideodvdrippingwidget.cpp \
+ k3bvideodvdrippingdialog.cpp k3bvideodvdrippingpreview.cpp
diff --git a/src/rip/videodvd/base_k3bvideodvdrippingwidget.ui b/src/rip/videodvd/base_k3bvideodvdrippingwidget.ui
new file mode 100644
index 0000000..72b03b4
--- /dev/null
+++ b/src/rip/videodvd/base_k3bvideodvdrippingwidget.ui
@@ -0,0 +1,721 @@
+<!DOCTYPE UI><UI version="3.2" stdsetdef="1">
+<class>base_K3bVideoDVDRippingWidget</class>
+<author>Seastian Trueg</author>
+<widget class="QWidget">
+ <property name="name">
+ <cstring>Form1</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>644</width>
+ <height>387</height>
+ </rect>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel4</cstring>
+ </property>
+ <property name="text">
+ <string>Please select the audio streams you want to include in every ripped title</string>
+ </property>
+ </widget>
+ <widget class="KListView">
+ <property name="name">
+ <cstring>m_titleView</cstring>
+ </property>
+ <property name="allColumnsShowFocus">
+ <bool>true</bool>
+ </property>
+ <property name="fullWidth">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <widget class="QTabWidget">
+ <property name="name">
+ <cstring>tabWidget2</cstring>
+ </property>
+ <widget class="QWidget">
+ <property name="name">
+ <cstring>tab</cstring>
+ </property>
+ <attribute name="title">
+ <string>Setti&amp;ngs</string>
+ </attribute>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QGroupBox" row="0" column="1">
+ <property name="name">
+ <cstring>groupBox6</cstring>
+ </property>
+ <property name="title">
+ <string>Video Quality</string>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout9</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel2_2</cstring>
+ </property>
+ <property name="text">
+ <string>Video Size:</string>
+ </property>
+ </widget>
+ <widget class="QComboBox">
+ <property name="name">
+ <cstring>m_comboVideoSize</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>1</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>m_buttonCustomPictureSize</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Custom...</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout9</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel2_3</cstring>
+ </property>
+ <property name="text">
+ <string>Video Bitrate:</string>
+ </property>
+ </widget>
+ <widget class="QSpinBox">
+ <property name="name">
+ <cstring>m_spinVideoBitrate</cstring>
+ </property>
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>1</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="suffix">
+ <string> kbps</string>
+ </property>
+ <property name="maxValue">
+ <number>10000</number>
+ </property>
+ <property name="value">
+ <number>1800</number>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ </vbox>
+ </widget>
+ <widget class="QGroupBox" row="1" column="0">
+ <property name="name">
+ <cstring>groupBox1_2</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>5</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>1</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="title">
+ <string>Target Folder</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel" row="1" column="0">
+ <property name="name">
+ <cstring>textLabel1_2</cstring>
+ </property>
+ <property name="text">
+ <string>Free space in directory:</string>
+ </property>
+ </widget>
+ <widget class="KURLRequester" row="0" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>m_editBaseDir</cstring>
+ </property>
+ </widget>
+ <widget class="QLabel" row="1" column="1">
+ <property name="name">
+ <cstring>m_labelFreeSpace</cstring>
+ </property>
+ <property name="text">
+ <string>-</string>
+ </property>
+ <property name="alignment">
+ <set>AlignVCenter|AlignRight</set>
+ </property>
+ </widget>
+ <widget class="QLabel" row="2" column="0">
+ <property name="name">
+ <cstring>textLabel1_2_2</cstring>
+ </property>
+ <property name="text">
+ <string>Space needed:</string>
+ </property>
+ </widget>
+ <widget class="QLabel" row="2" column="1">
+ <property name="name">
+ <cstring>m_labelNeededSpace</cstring>
+ </property>
+ <property name="text">
+ <string>-</string>
+ </property>
+ <property name="alignment">
+ <set>AlignVCenter|AlignRight</set>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="QGroupBox" row="1" column="1">
+ <property name="name">
+ <cstring>groupBox4</cstring>
+ </property>
+ <property name="title">
+ <string>Audio Quality</string>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QWidgetStack">
+ <property name="name">
+ <cstring>m_stackAudioQuality</cstring>
+ </property>
+ <widget class="QWidget">
+ <property name="name">
+ <cstring>m_stackPageAudioQualityMp3</cstring>
+ </property>
+ <attribute name="id">
+ <number>0</number>
+ </attribute>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>m_checkAudioVBR</cstring>
+ </property>
+ <property name="text">
+ <string>Variable &amp;Bitrate</string>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout4</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>m_labelAudioBitrate</cstring>
+ </property>
+ <property name="text">
+ <string>Audio Bitrate:</string>
+ </property>
+ </widget>
+ <widget class="QComboBox">
+ <property name="name">
+ <cstring>m_comboAudioBitrate</cstring>
+ </property>
+ <property name="duplicatesEnabled">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ </vbox>
+ </widget>
+ <widget class="QWidget">
+ <property name="name">
+ <cstring>m_stackPageAudioQualityAC3Pt</cstring>
+ </property>
+ <attribute name="id">
+ <number>1</number>
+ </attribute>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <widget class="KActiveLabel">
+ <property name="name">
+ <cstring>m_labelNoAudioSettings</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>7</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>&lt;p&gt;No Audio Quality settings available for &lt;em&gt;AC3 pass-through&lt;/em&gt;. The audio stream from the Video DVD is used without any changes.</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QWidget">
+ <property name="name">
+ <cstring>m_stackPageAudioQualityAC3</cstring>
+ </property>
+ <attribute name="id">
+ <number>2</number>
+ </attribute>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout8</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel1_3</cstring>
+ </property>
+ <property name="text">
+ <string>Audio Bitrate:</string>
+ </property>
+ </widget>
+ <widget class="QSpinBox">
+ <property name="name">
+ <cstring>m_spinAudioBitrate</cstring>
+ </property>
+ <property name="suffix">
+ <string> kbps</string>
+ </property>
+ <property name="maxValue">
+ <number>640</number>
+ </property>
+ <property name="minValue">
+ <number>32</number>
+ </property>
+ <property name="lineStep">
+ <number>2</number>
+ </property>
+ <property name="value">
+ <number>128</number>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer3</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>0</height>
+ </size>
+ </property>
+ </spacer>
+ </vbox>
+ </widget>
+ </widget>
+ </vbox>
+ </widget>
+ <widget class="QGroupBox" row="0" column="0">
+ <property name="name">
+ <cstring>groupBox1</cstring>
+ </property>
+ <property name="title">
+ <string>Filetype</string>
+ </property>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout10</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel1</cstring>
+ </property>
+ <property name="text">
+ <string>Video Codec:</string>
+ </property>
+ </widget>
+ <widget class="K3bIntMapComboBox">
+ <property name="name">
+ <cstring>m_comboVideoCodec</cstring>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>Select the Video codec used to encode the DVD titles</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout9</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel2</cstring>
+ </property>
+ <property name="text">
+ <string>Audio Codec:</string>
+ </property>
+ </widget>
+ <widget class="K3bIntMapComboBox">
+ <property name="name">
+ <cstring>m_comboAudioCodec</cstring>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>Select the Audio codec used to encode the DVD titles</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ </vbox>
+ </widget>
+ </grid>
+ </widget>
+ <widget class="QWidget">
+ <property name="name">
+ <cstring>TabPage</cstring>
+ </property>
+ <attribute name="title">
+ <string>File Namin&amp;g</string>
+ </attribute>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout14</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel1_4</cstring>
+ </property>
+ <property name="text">
+ <string>Ripped files pattern:</string>
+ </property>
+ </widget>
+ <widget class="QComboBox">
+ <property name="name">
+ <cstring>m_comboFilenamePattern</cstring>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>1</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>1</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="acceptDrops">
+ <bool>true</bool>
+ </property>
+ <property name="editable">
+ <bool>true</bool>
+ </property>
+ <property name="duplicatesEnabled">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="KURLLabel">
+ <property name="name">
+ <cstring>m_specialStringsLabel</cstring>
+ </property>
+ <property name="text">
+ <string>See special strings</string>
+ </property>
+ <property name="alignment">
+ <set>AlignVCenter|AlignRight</set>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget">
+ <property name="name">
+ <cstring>layout8</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>m_checkBlankReplace</cstring>
+ </property>
+ <property name="text">
+ <string>Replace all &amp;blanks with:</string>
+ </property>
+ </widget>
+ <widget class="KLineEdit">
+ <property name="name">
+ <cstring>m_editBlankReplace</cstring>
+ </property>
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>7</hsizetype>
+ <vsizetype>0</vsizetype>
+ <horstretch>1</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>_</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer5</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>5</width>
+ <height>1</height>
+ </size>
+ </property>
+ </spacer>
+ </vbox>
+ </widget>
+ <widget class="QWidget">
+ <property name="name">
+ <cstring>tab</cstring>
+ </property>
+ <attribute name="title">
+ <string>&amp;Advanced</string>
+ </attribute>
+ <vbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>m_checkTwoPassEncoding</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;2-pass encoding</string>
+ </property>
+ <property name="accel">
+ <string>Alt+2</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>Enable 2-pass encoding</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>&lt;p&gt;If this option is checked K3b encodes the video titles in two passes. The first pass is used to gather information about the video in order to improve the distribution of bits in the second pass. The resulting video will have a higher quality using a variable bitrate.
+&lt;p&gt;If this option is not checked K3b will create video files with a constant bitrate and a lower quality.
+&lt;p&gt;2-pass encoding results in a doubled encoding time.</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>m_checkAutoClipping</cstring>
+ </property>
+ <property name="text">
+ <string>Automatic &amp;Video Clipping</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>Automatically detect the black borders of the video</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>&lt;p&gt;Most Video DVDs are encoded in a letterboxed format. &lt;em&gt;Letterboxed&lt;/em&gt; refers to black bars used at the top and bottom (and sometimes at the sides) of the video to force it into one of the aspect ratios supported by the Video DVD standard.
+&lt;p&gt;If this option is checked K3b will automatically detect and remove these black bars from the resulting video.
+&lt;p&gt;Although this method is very reliable there may be problems if the source material is exceptionally short or dark.</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>m_checkAudioResampling</cstring>
+ </property>
+ <property name="text">
+ <string>Resample Audio to &amp;44.1 KHz</string>
+ </property>
+ <property name="accel">
+ <string>Alt+4</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>Change the sample rate of the audio stream to 44.1 KHz</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>&lt;p&gt;Video DVD audio streams normally are encoded with a sampling rate of 48000 Hz. Audio CDs on the other hand are encoded with a sampling rate of 44100 Hz.
+&lt;p&gt;If this option is checked K3b will change the sampling rate of the audio stream to 44100 Hz.</string>
+ </property>
+ </widget>
+ <widget class="QCheckBox">
+ <property name="name">
+ <cstring>m_checkLowPriority</cstring>
+ </property>
+ <property name="text">
+ <string>Low s&amp;cheduling priority for the video transcoding process</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>spacer1</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>1</height>
+ </size>
+ </property>
+ </spacer>
+ </vbox>
+ </widget>
+ </widget>
+ </vbox>
+</widget>
+<customwidgets>
+ <customwidget>
+ <class>K3bIntMapComboBox</class>
+ <header location="global">k3bintmapcombobox.h</header>
+ <sizehint>
+ <width>-1</width>
+ <height>-1</height>
+ </sizehint>
+ <container>0</container>
+ <sizepolicy>
+ <hordata>5</hordata>
+ <verdata>5</verdata>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ <pixmap>image0</pixmap>
+ </customwidget>
+</customwidgets>
+<images>
+ <image name="image0">
+ <data format="PNG" length="1125">89504e470d0a1a0a0000000d4948445200000016000000160806000000c4b46c3b0000042c49444154388db5954f6c14551cc73fefcd7476b65bdaae4bb78bb5502a14d404e4801c88182d1c4c2c693da847400f9c24c68b878684238660e2b1e01f12c19493012ef2478c814412d354a46017a8a564bb6da5bbedccee767776e63d0ffb073751d483bfe49799974c3eeffb7ebf37df9fd05a530b2184040cc0042420aaf9a4d0d554800f045a6b256ae0e1e1e1d6bebebe838ee31c48a7d39b5cd7fd075e251cc7617272f2ded8d8d819cff33e0316819259537aead4a9839d5dd6d1784f91f55b0a94830242088404d304292bef68a89f520802a598fecddaa04f1a876f5c250c7c0a64cdeac686e33807e23d45e6b297c8b877f1831542614550b6599835c83c2a81b6786a75134faf2f1169f12997350881d9021d0903e06de0745d3160a6d3e94dbd5b0a64dcbb94b5831d0e3375ab892b1772dcf9790528543f8dd0d367b36768153b5e31503a0f1aecb004580b44ffac58baae8b1714f0833c7638cc8dab303a320f4822ab4c7a37c69196203de3319d5ce1c4d13c733331dedc67a129a154fd128401ab0616d55a130ac3d42d93d1913940d13fd0c9ee0183685c60da01c5421bd72f7a8c8efccef9afd374267ad93d642365be0636a0d28ec7600941d9e6f23917f0e97f23ce5bef35d19ec863da0ed9059b2be70bec196c66dfa10ec0e49b338f7017258651bf95021035c595429bb0903248fe52a2b5b595dd7b4d945cc2340cdca536be389ee3f67886c5798f773fe8e0dac508c989659277a2180da4ca4ff07821058b8b251445d63d6b13ed1098a6417e39cac85197dbe31962ab9bd9f1f22a226d45366f6d0620fdb08c900d281af6110284b20085b414861d905d88f2e52739ee8cbb8022143259d3dd84691730aa2d52da441a8de0c6958068870022a41e9629ad3473fd3b8fdbe319dadb9b4924da994d2d716c7896fbe35152f78b48245d6b2da4507faf582be8eaf159b721cc837b05ae7debb1f79d08cb8b515edad942a22bc4b1c33eb3d34b1c797f06af90a72d16e2f96d9a74aa11dca8586b222d01af0fb60070f6c402d72f15d97f28c6f6d7027a5f5ce6c3233dc4e2ede496b278be4fff608cee8d3e1add806aeca51094cbb06397c1ecc328e746537c7e3ccdb5cb1136bf60635882d4d41c6ec6836ab37efa214f72208ed9f4d7cdd38ee310280542e38b1c43fb6de26b3672e1ec3cc99bcb246f66a938a3241ab3e91f7c861fbf77710b1e5e49915bae974203ba0e9e9c9cbc373d6d6d305a040a89c2a77f50b27d5782bbbf7acccf28349235dd16cf6dd374f7295e1de8a45c02d37499182b01cc0201a085d61a2144d8b2ac8fb6ed340e77240c4261890e04c250185262546d534a032154b59e0ad394e41c98182bf268ce6721ed9f064e0253356f6da2e24c1f030f783c15fe6da680af8021602bd051532ca9b8521488559f61aa86c29343578fbf0264a94c906c7d3409214c20043457a116ff6de6795578012889ff6b98fe016ea0ce1c6a2573410000000049454e44ae426082</data>
+ </image>
+</images>
+<connections>
+ <connection>
+ <sender>m_checkBlankReplace</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>m_editBlankReplace</receiver>
+ <slot>setEnabled(bool)</slot>
+ </connection>
+</connections>
+<layoutdefaults spacing="6" margin="11"/>
+<includehints>
+ <includehint>klistview.h</includehint>
+ <includehint>kurlrequester.h</includehint>
+ <includehint>klineedit.h</includehint>
+ <includehint>kpushbutton.h</includehint>
+ <includehint>kactivelabel.h</includehint>
+ <includehint>k3bintmapcombobox.h</includehint>
+ <includehint>k3bintmapcombobox.h</includehint>
+ <includehint>kurllabel.h</includehint>
+ <includehint>klineedit.h</includehint>
+</includehints>
+</UI>
diff --git a/src/rip/videodvd/k3bvideodvdrippingdialog.cpp b/src/rip/videodvd/k3bvideodvdrippingdialog.cpp
new file mode 100644
index 0000000..ddb5ff2
--- /dev/null
+++ b/src/rip/videodvd/k3bvideodvdrippingdialog.cpp
@@ -0,0 +1,634 @@
+/*
+ *
+ * $Id: sourceheader 511311 2006-02-19 14:51:05Z trueg $
+ * Copyright (C) 2006 Sebastian Trueg <trueg@k3b.org>
+ *
+ * This file is part of the K3b project.
+ * Copyright (C) 1998-2007 Sebastian Trueg <trueg@k3b.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ * See the file "COPYING" for the exact licensing terms.
+ */
+
+#include "k3bvideodvdrippingdialog.h"
+#include "k3bvideodvdrippingwidget.h"
+#include <k3bvideodvdtitletranscodingjob.h>
+#include <k3bjobprogressdialog.h>
+#include <k3bapplication.h>
+#include <k3bmedium.h>
+#include <k3bmediacache.h>
+#include <k3bglobals.h>
+#include <k3bfilesysteminfo.h>
+
+#include <klocale.h>
+#include <klistview.h>
+#include <klocale.h>
+#include <kglobal.h>
+#include <kurlrequester.h>
+#include <kcombobox.h>
+#include <klineedit.h>
+#include <kio/global.h>
+#include <kconfig.h>
+#include <kmessagebox.h>
+
+#include <qlayout.h>
+#include <qcheckbox.h>
+#include <qspinbox.h>
+#include <qstyle.h>
+#include <qfontmetrics.h>
+
+
+static QString videoCodecId( K3bVideoDVDTitleTranscodingJob::VideoCodec codec )
+{
+ switch( codec ) {
+ case K3bVideoDVDTitleTranscodingJob::VIDEO_CODEC_FFMPEG_MPEG4:
+ return "ffmpeg_mpeg4";
+ case K3bVideoDVDTitleTranscodingJob::VIDEO_CODEC_XVID:
+ return "xvid";
+ default:
+ return "none";
+ }
+}
+
+
+static QString audioCodecId( K3bVideoDVDTitleTranscodingJob::AudioCodec codec )
+{
+ switch( codec ) {
+ case K3bVideoDVDTitleTranscodingJob::AUDIO_CODEC_MP3:
+ return "mp3";
+ case K3bVideoDVDTitleTranscodingJob::AUDIO_CODEC_AC3_STEREO:
+ return "ac3_stereo";
+ case K3bVideoDVDTitleTranscodingJob::AUDIO_CODEC_AC3_PASSTHROUGH:
+ return "ac3_passthrough";
+ default:
+ return "none";
+ }
+}
+
+
+static K3bVideoDVDTitleTranscodingJob::VideoCodec videoCodecFromId( const QString& codec )
+{
+ if( codec == "xvid" )
+ return K3bVideoDVDTitleTranscodingJob::VIDEO_CODEC_XVID;
+ else // if( codec == "ffmpeg_mpeg4" )
+ return K3bVideoDVDTitleTranscodingJob::VIDEO_CODEC_FFMPEG_MPEG4;
+}
+
+
+static K3bVideoDVDTitleTranscodingJob::AudioCodec audioCodecFromId( const QString& codec )
+{
+ if( codec == "ac3_stereo" )
+ return K3bVideoDVDTitleTranscodingJob::AUDIO_CODEC_AC3_STEREO;
+ else if( codec == "ac3_passthrough" )
+ return K3bVideoDVDTitleTranscodingJob::AUDIO_CODEC_AC3_PASSTHROUGH;
+ else // if( codec == "mp3" )
+ return K3bVideoDVDTitleTranscodingJob::AUDIO_CODEC_MP3;
+}
+
+
+// resize according to aspect ratio
+static QSize resizeTitle( const K3bVideoDVD::VideoStream& title, const QSize& size )
+{
+ int w = size.width();
+ int h = size.height();
+ int rw = title.realPictureWidth();
+ int rh = title.realPictureHeight();
+
+ if( w == 0 && h == 0 ) {
+ w = rw;
+ h = rh;
+ }
+ else if( w == 0 ) {
+ w = h * rw / rh;
+ }
+ else if( h == 0 ) {
+ h = w * rh / rw;
+ }
+
+ return QSize(w,h);
+}
+
+
+
+class K3bVideoDVDRippingDialog::AudioStreamViewItem : public QCheckListItem
+{
+public:
+ AudioStreamViewItem( K3bVideoDVDRippingDialog* dlg,
+ QCheckListItem* parent, QListViewItem* after, const QString& text,
+ int audioStream )
+ : QCheckListItem( parent, after, text, RadioButton ),
+ m_audioStream( audioStream ),
+ m_dlg( dlg ) {
+ }
+
+private:
+ void stateChange( bool ) {
+ if( state() == On ) {
+ m_dlg->m_titleRipInfos[static_cast<QCheckListItem*>(parent())].audioStream = m_audioStream;
+ m_dlg->slotUpdateFilenames();
+ }
+ }
+
+ int m_audioStream;
+ K3bVideoDVDRippingDialog* m_dlg;
+};
+
+
+class K3bVideoDVDRippingDialog::Private
+{
+public:
+ K3bFileSystemInfo fsInfo;
+};
+
+
+K3bVideoDVDRippingDialog::K3bVideoDVDRippingDialog( const K3bVideoDVD::VideoDVD& dvd,
+ const QValueList<int>& titles,
+ QWidget* parent, const char* name )
+ : K3bInteractionDialog( parent, name,
+ i18n("Video DVD Ripping"),
+ QString::null,
+ START_BUTTON|CANCEL_BUTTON,
+ START_BUTTON,
+ "VideoDVD Ripping" ), // config group
+ m_dvd( dvd )
+{
+ d = new Private;
+
+ QWidget* frame = mainWidget();
+ QHBoxLayout* frameLayout = new QHBoxLayout( frame );
+ frameLayout->setMargin( 0 );
+ frameLayout->setAutoAdd( true );
+ m_w = new K3bVideoDVDRippingWidget( frame );
+
+ connect( m_w, SIGNAL(changed()),
+ this, SLOT(slotUpdateFilesizes()) );
+ connect( m_w, SIGNAL(changed()),
+ this, SLOT(slotUpdateFilenames()) );
+ connect( m_w, SIGNAL(changed()),
+ this, SLOT(slotUpdateVideoSizes()) );
+
+ setTitle( i18n("Video DVD Ripping"),
+ i18n("1 title from %1", "%n titles from %1", titles.count())
+ .arg( k3bappcore->mediaCache()->medium(m_dvd.device()).beautifiedVolumeId() ) );
+
+ // populate list map
+ populateTitleView( titles );
+}
+
+
+K3bVideoDVDRippingDialog::~K3bVideoDVDRippingDialog()
+{
+ delete d;
+}
+
+
+void K3bVideoDVDRippingDialog::populateTitleView( const QValueList<int>& titles )
+{
+ m_w->m_titleView->clear();
+ m_titleRipInfos.clear();
+
+ QCheckListItem* titleItem = 0;
+ for( QValueList<int>::const_iterator it = titles.begin(); it != titles.end(); ++it ) {
+ titleItem = new QCheckListItem( m_w->m_titleView,
+ titleItem,
+ i18n("Title %1 (%2)")
+ .arg(*it)
+ .arg(m_dvd[*it-1].playbackTime().toString()),
+ QCheckListItem::RadioButtonController );
+ titleItem->setText( 1, QString("%1x%2")
+ .arg(m_dvd[*it-1].videoStream().realPictureWidth())
+ .arg(m_dvd[*it-1].videoStream().realPictureHeight()) );
+ titleItem->setText( 3, QString("%1 Title %2.avi").arg(m_dvd.volumeIdentifier()).arg(*it) );
+
+ // now for the rip info
+ K3bVideoDVDRippingJob::TitleRipInfo ri( *it );
+
+ //
+ // Determine default language selection:
+ // first try the configured locale, if that fails, fall back to the first audio stream
+ //
+ ri.audioStream = 0;
+ for( unsigned int i = 0; i < m_dvd[*it-1].numAudioStreams(); ++i ) {
+ if( m_dvd[*it-1].audioStream(i).langCode() == KGlobal::locale()->language() &&
+ m_dvd[*it-1].audioStream(i).format() != K3bVideoDVD::AUDIO_FORMAT_DTS ) {
+ ri.audioStream = i;
+ break;
+ }
+ }
+
+ QListViewItem* asI = 0;
+ for( unsigned int i = 0; i < m_dvd[*it-1].numAudioStreams(); ++i ) {
+ QString text = i18n("%1 %2Ch (%3%4)")
+ .arg( K3bVideoDVD::audioFormatString( m_dvd[*it-1].audioStream(i).format() ) )
+ .arg( m_dvd[*it-1].audioStream(i).channels() )
+ .arg( m_dvd[*it-1].audioStream(i).langCode().isEmpty()
+ ? i18n("unknown language")
+ : KGlobal::locale()->twoAlphaToLanguageName( m_dvd[*it-1].audioStream(i).langCode() ) )
+ .arg( m_dvd[*it-1].audioStream(i).codeExtension() != K3bVideoDVD::AUDIO_CODE_EXT_UNSPECIFIED
+ ? QString(" ") + K3bVideoDVD::audioCodeExtensionString( m_dvd[*it-1].audioStream(i).codeExtension() )
+ : QString::null );
+
+ if( m_dvd[*it-1].audioStream(i).format() == K3bVideoDVD::AUDIO_FORMAT_DTS ) {
+ // width of the radio button from QCheckListItem::paintCell
+ int buttonSize = style().pixelMetric( QStyle::PM_CheckListButtonSize, m_w->m_titleView ) + 4;
+ int spaceWidth = fontMetrics().width( ' ' );
+ int numSpaces = buttonSize/spaceWidth;
+ asI = new QListViewItem( titleItem, asI, QString().fill( ' ', numSpaces ) + text + " (" + i18n("not supported") + ")" );
+ }
+ else {
+ asI = new AudioStreamViewItem( this, titleItem, asI, text, i );
+
+ if( ri.audioStream == (int)i )
+ ((AudioStreamViewItem*)asI)->setState( QCheckListItem::On );
+ }
+ }
+
+ titleItem->setOpen( true );
+
+ m_titleRipInfos[titleItem] = ri;
+ }
+}
+
+
+void K3bVideoDVDRippingDialog::slotUpdateFilenames()
+{
+ QString baseDir = K3b::prepareDir( m_w->m_editBaseDir->url() );
+ d->fsInfo.setPath( baseDir );
+
+ for( QMap<QCheckListItem*, K3bVideoDVDRippingJob::TitleRipInfo>::iterator it = m_titleRipInfos.begin();
+ it != m_titleRipInfos.end(); ++it ) {
+ QString f = d->fsInfo.fixupPath( createFilename( it.data(), m_w->m_comboFilenamePattern->currentText() ) );
+ if( m_w->m_checkBlankReplace->isChecked() )
+ f.replace( QRegExp( "\\s" ), m_w->m_editBlankReplace->text() );
+ it.data().filename = baseDir + f;
+ it.key()->setText( 3, f );
+ }
+}
+
+
+void K3bVideoDVDRippingDialog::slotUpdateFilesizes()
+{
+ double bitrate = (double)m_w->m_spinVideoBitrate->value();
+ KIO::filesize_t overallSize = 0ULL;
+
+ // update file sizes
+ for( QMap<QCheckListItem*, K3bVideoDVDRippingJob::TitleRipInfo>::iterator it = m_titleRipInfos.begin();
+ it != m_titleRipInfos.end(); ++it ) {
+
+ double sec = m_dvd[it.data().title-1].playbackTime().totalSeconds();
+
+ // estimate the filesize
+ KIO::filesize_t size = (KIO::filesize_t)( sec * bitrate * 1000.0 / 8.0 );
+
+ // add audio stream size
+ // FIXME: consider AC3 passthrough
+ size += (KIO::filesize_t)( sec * m_w->selectedAudioBitrate() / 8.0 * 1024.0 );
+
+ it.key()->setText( 2, KIO::convertSize( size ) );
+
+ overallSize += size;
+ }
+
+ m_w->setNeededSize( overallSize );
+}
+
+
+void K3bVideoDVDRippingDialog::slotUpdateVideoSizes()
+{
+ QSize size = m_w->selectedPictureSize();
+ for( QMap<QCheckListItem*, K3bVideoDVDRippingJob::TitleRipInfo>::iterator it = m_titleRipInfos.begin();
+ it != m_titleRipInfos.end(); ++it ) {
+ QSize s( resizeTitle( m_dvd[it.data().title-1].videoStream(), size ) );
+ it.key()->setText( 1, QString("%1x%2").arg(s.width()).arg(s.height()) );
+ }
+}
+
+
+void K3bVideoDVDRippingDialog::setBaseDir( const QString& path )
+{
+ m_w->m_editBaseDir->setURL( path );
+}
+
+
+QString K3bVideoDVDRippingDialog::createFilename( const K3bVideoDVDRippingJob::TitleRipInfo& info, const QString& pattern ) const
+{
+ QString f;
+
+ const K3bVideoDVD::Title& title = m_dvd[info.title-1];
+
+ for( unsigned int i = 0; i < pattern.length(); ++i ) {
+ //
+ // every pattern starts with a % sign
+ //
+ if( pattern[i] == '%' ) {
+ ++i; // skip the %
+ QChar c = pattern[i];
+
+ //
+ // first check if we have a long keyword instead of a one-char
+ //
+ if( pattern[i] == '{' ) {
+ int j = pattern.find( '}', i );
+ if( j < 0 ) // no closing bracket -> no valid pattern
+ c = '*';
+ else {
+ QString keyword = pattern.mid( i+1, j-i-1 );
+ if( keyword == "titlenumber" ||
+ keyword == "title_number" ||
+ keyword == "title" ) {
+ c = PATTERN_TITLE_NUMBER;
+ }
+ else if( keyword == "volumeid" ||
+ keyword == "volume_id" ||
+ keyword == "volid" ||
+ keyword == "vol_id" ) {
+ c = PATTERN_VOLUME_ID;
+ }
+ else if( keyword == "beautifiedvolumeid" ||
+ keyword == "beautified_volumeid" ||
+ keyword == "beautified_volume_id" ||
+ keyword == "beautifiedvolid" ||
+ keyword == "beautified_volid" ||
+ keyword == "beautified_vol_id" ||
+ keyword == "nicevolid" ||
+ keyword == "nice_volid" ||
+ keyword == "nice_vol_id" ) {
+ c = PATTERN_BEAUTIFIED_VOLUME_ID;
+ }
+ else if( keyword == "languagecode" ||
+ keyword == "language_code" ||
+ keyword == "langcode" ||
+ keyword == "lang_code" ) {
+ c = PATTERN_LANGUAGE_CODE;
+
+ }
+ else if( keyword == "lang" ||
+ keyword == "language" ||
+ keyword == "langname" ||
+ keyword == "languagename" ||
+ keyword == "lang_name" ||
+ keyword == "language_name" ) {
+ c = PATTERN_LANGUAGE_NAME;
+ }
+ else if( keyword == "audioformat" ||
+ keyword == "audio_format" ||
+ keyword == "audio" ) {
+ c = PATTERN_AUDIO_FORMAT;
+ }
+ else if( keyword == "channels" ||
+ keyword == "audiochannels" ||
+ keyword == "audio_channels" ||
+ keyword == "ch" ) {
+ c = PATTERN_AUDIO_CHANNELS;
+ }
+ else if( keyword == "videosize" ||
+ keyword == "video_size" ||
+ keyword == "vsize" ) {
+ c = PATTERN_VIDEO_SIZE;
+ }
+ else if( keyword == "originalvideosize" ||
+ keyword == "original_video_size" ||
+ keyword == "origvideosize" ||
+ keyword == "orig_video_size" ||
+ keyword == "origvsize" ) {
+ c = PATTERN_ORIG_VIDEO_SIZE;
+ }
+ else if( keyword == "aspect_ratio" ||
+ keyword == "aspectratio" ||
+ keyword == "ratio" ) {
+ c = PATTERN_ASPECT_RATIO;
+ }
+ else if( keyword == "current_date" ||
+ keyword == "currentdate" ||
+ keyword == "date" ) {
+ c = PATTERN_CURRENT_DATE;
+ }
+ else {
+ // unusable pattern
+ c = '*';
+ }
+
+ //
+ // skip the keyword and the closing bracket
+ //
+ if( c != '*' ) {
+ i += keyword.length() + 1;
+ }
+ }
+ }
+
+ switch( c ) {
+ case PATTERN_TITLE_NUMBER:
+ f.append( QString::number(info.title).rightJustify( 2, '0' ) );
+ break;
+ case PATTERN_VOLUME_ID:
+ f.append( m_dvd.volumeIdentifier() );
+ break;
+ case PATTERN_BEAUTIFIED_VOLUME_ID:
+ f.append( k3bappcore->mediaCache()->medium( m_dvd.device() ).beautifiedVolumeId() );
+ break;
+ case PATTERN_LANGUAGE_CODE:
+ if( title.numAudioStreams() > 0 )
+ f.append( title.audioStream( info.audioStream ).langCode() );
+ break;
+ case PATTERN_LANGUAGE_NAME:
+ if( title.numAudioStreams() > 0 )
+ f.append( KGlobal::locale()->twoAlphaToLanguageName( title.audioStream( info.audioStream ).langCode() ) );
+ break;
+ case PATTERN_AUDIO_FORMAT:
+ // FIXME: what about MPEG audio streams?
+ if( title.numAudioStreams() > 0 ) {
+ if( m_w->selectedAudioCodec() == K3bVideoDVDTitleTranscodingJob::AUDIO_CODEC_MP3 )
+ f.append( K3bVideoDVDTitleTranscodingJob::audioCodecString( m_w->selectedAudioCodec() ) );
+ else
+ f.append( K3bVideoDVD::audioFormatString( title.audioStream( info.audioStream ).format() ) );
+ }
+ break;
+ case PATTERN_AUDIO_CHANNELS:
+ if( title.numAudioStreams() > 0 )
+ f.append( i18n("%nCh", "%nCh",
+ m_w->selectedAudioCodec() == K3bVideoDVDTitleTranscodingJob::AUDIO_CODEC_AC3_PASSTHROUGH
+ ? title.audioStream( info.audioStream ).channels()
+ : 2 ) );
+ break;
+ case PATTERN_ORIG_VIDEO_SIZE:
+ f.append( QString("%1x%2")
+ .arg(title.videoStream().pictureWidth())
+ .arg(title.videoStream().pictureHeight()) );
+ break;
+ case PATTERN_VIDEO_SIZE: {
+ QSize s( resizeTitle( m_dvd[info.title-1].videoStream(), m_w->selectedPictureSize() ) );
+ f.append( QString("%1x%2").arg(s.width()).arg(s.height()) );
+ break;
+ }
+ case PATTERN_ASPECT_RATIO:
+ if( title.videoStream().displayAspectRatio() == K3bVideoDVD::VIDEO_ASPECT_RATIO_4_3 )
+ f.append( "4:3" );
+ else
+ f.append( "16:9" );
+ break;
+ case PATTERN_CURRENT_DATE:
+ f.append( KGlobal::locale()->formatDate( QDate::currentDate() ) );
+ break;
+ default:
+ f.append( pattern[i-1] );
+ f.append( pattern[i] );
+ }
+ }
+
+ //
+ // normal character -> just append to filename
+ //
+ else {
+ f.append( pattern[i] );
+ }
+ }
+
+ //
+ // and the extension (for now only avi)
+ //
+ f.append( ".avi" );
+
+ return f;
+}
+
+
+void K3bVideoDVDRippingDialog::loadK3bDefaults()
+{
+ m_w->m_spinVideoBitrate->setValue( 1800 );
+ m_w->m_checkTwoPassEncoding->setChecked( true );
+ m_w->m_checkAudioResampling->setChecked( false );
+ m_w->m_checkAutoClipping->setChecked( false );
+ m_w->m_checkLowPriority->setChecked( true );
+ m_w->m_checkAudioVBR->setChecked( true );
+ m_w->setSelectedAudioBitrate( 128 );
+ m_w->setSelectedVideoCodec( K3bVideoDVDTitleTranscodingJob::VIDEO_CODEC_FFMPEG_MPEG4 );
+ m_w->setSelectedAudioCodec( K3bVideoDVDTitleTranscodingJob::AUDIO_CODEC_MP3 );
+ m_w->m_checkBlankReplace->setChecked( false );
+ m_w->m_editBlankReplace->setText( "_" );
+ m_w->m_comboFilenamePattern->setEditText( m_w->m_comboFilenamePattern->text(0) );
+ m_w->m_editBaseDir->setURL( K3b::defaultTempPath() );
+}
+
+
+void K3bVideoDVDRippingDialog::loadUserDefaults( KConfigBase* c )
+{
+ m_w->m_spinVideoBitrate->setValue( c->readNumEntry( "video bitrate", 1200 ) );
+ m_w->m_checkTwoPassEncoding->setChecked( c->readBoolEntry( "two pass encoding", true ) );
+ m_w->m_checkAudioResampling->setChecked( c->readBoolEntry( "audio resampling", false ) );
+ m_w->m_checkAutoClipping->setChecked( c->readBoolEntry( "auto clipping", false ) );
+ m_w->m_checkLowPriority->setChecked( c->readBoolEntry( "low priority", true ) );
+ m_w->m_checkAudioVBR->setChecked( c->readBoolEntry( "vbr audio", true ) );
+ m_w->setSelectedAudioBitrate( c->readNumEntry( "audio bitrate", 128 ) );
+ m_w->setSelectedVideoCodec( videoCodecFromId( c->readEntry( "video codec", videoCodecId( K3bVideoDVDTitleTranscodingJob::VIDEO_CODEC_FFMPEG_MPEG4 ) ) ) );
+ m_w->setSelectedAudioCodec( audioCodecFromId( c->readEntry( "audio codec", audioCodecId( K3bVideoDVDTitleTranscodingJob::AUDIO_CODEC_MP3 ) ) ) );
+ m_w->m_checkBlankReplace->setChecked( c->readBoolEntry( "replace blanks", false ) );
+ m_w->m_editBlankReplace->setText( c->readEntry( "blank replace string", "_" ) );
+ m_w->m_comboFilenamePattern->setEditText( c->readEntry( "filename pattern", m_w->m_comboFilenamePattern->text(0) ) );
+ m_w->m_editBaseDir->setURL( c->readPathEntry( "base dir", K3b::defaultTempPath() ) );
+}
+
+
+void K3bVideoDVDRippingDialog::saveUserDefaults( KConfigBase* c )
+{
+ c->writeEntry( "video bitrate", m_w->m_spinVideoBitrate->value() );
+ c->writeEntry( "two pass encoding", m_w->m_checkTwoPassEncoding->isChecked() );
+ c->writeEntry( "audio resampling", m_w->m_checkAudioResampling->isChecked() );
+ c->writeEntry( "auto clipping", m_w->m_checkAutoClipping->isChecked() );
+ c->writeEntry( "low priority", m_w->m_checkLowPriority->isChecked() );
+ c->writeEntry( "vbr audio", m_w->m_checkAudioVBR->isChecked() );
+ c->writeEntry( "audio bitrate", m_w->selectedAudioBitrate() );
+ c->writeEntry( "video codec", videoCodecId( m_w->selectedVideoCodec() ) );
+ c->writeEntry( "audio codec", audioCodecId( m_w->selectedAudioCodec() ) );
+ c->writeEntry( "replace blanks", m_w->m_checkBlankReplace->isChecked() );
+ c->writeEntry( "blank replace string", m_w->m_editBlankReplace->text() );
+ c->writeEntry( "filename pattern", m_w->m_comboFilenamePattern->currentText() );
+ c->writePathEntry( "base dir", m_w->m_editBaseDir->url() );
+}
+
+
+void K3bVideoDVDRippingDialog::slotStartClicked()
+{
+ //
+ // check if the selected audio codec is usable for all selected audio streams
+ // We can only use the AC3 pass-through mode for AC3 streams
+ //
+ if( m_w->selectedAudioCodec() == K3bVideoDVDTitleTranscodingJob::AUDIO_CODEC_AC3_PASSTHROUGH ) {
+ for( QMap<QCheckListItem*, K3bVideoDVDRippingJob::TitleRipInfo>::iterator it = m_titleRipInfos.begin();
+ it != m_titleRipInfos.end(); ++it ) {
+ if( m_dvd[it.data().title-1].numAudioStreams() > 0 &&
+ m_dvd[it.data().title-1].audioStream(it.data().audioStream).format() != K3bVideoDVD::AUDIO_FORMAT_AC3 ) {
+ KMessageBox::sorry( this, i18n("<p>When using the <em>AC3 pass-through</em> audio codec all selected audio "
+ "streams need to be in AC3 format. Please select another audio codec or "
+ "choose AC3 audio streams for all ripped titles."),
+ i18n("AC3 Pass-through") );
+ return;
+ }
+ }
+ }
+
+ // check if we need to overwrite some files...
+ QStringList filesToOverwrite;
+ for( QMap<QCheckListItem*, K3bVideoDVDRippingJob::TitleRipInfo>::iterator it = m_titleRipInfos.begin();
+ it != m_titleRipInfos.end(); ++it ) {
+ if( QFile::exists( it.data().filename ) )
+ filesToOverwrite.append( it.data().filename );
+ }
+
+ if( !filesToOverwrite.isEmpty() )
+ if( KMessageBox::questionYesNoList( this,
+ i18n("Do you want to overwrite these files?"),
+ filesToOverwrite,
+ i18n("Files Exist"), i18n("Overwrite"), KStdGuiItem::cancel() ) == KMessageBox::No )
+ return;
+
+
+ QSize videoSize = m_w->selectedPictureSize();
+ int i = 0;
+ QValueVector<K3bVideoDVDRippingJob::TitleRipInfo> titles( m_titleRipInfos.count() );
+ for( QMapConstIterator<QCheckListItem*, K3bVideoDVDRippingJob::TitleRipInfo> it = m_titleRipInfos.begin();
+ it != m_titleRipInfos.end(); ++it ) {
+ titles[i] = it.data();
+ titles[i].videoBitrate = 0; // use the global bitrate set below
+ titles[i].width = videoSize.width();
+ titles[i].height = videoSize.height();
+ ++i;
+ }
+
+ // sort the titles which come from a map and are thus not sorted properly
+ // simple bubble sort for these small arrays is sufficient
+ for( unsigned int i = 0; i < titles.count(); ++i ) {
+ for( unsigned int j = i+1; j < titles.count(); ++j ) {
+ if( titles[i].title > titles[j].title ) {
+ K3bVideoDVDRippingJob::TitleRipInfo tmp = titles[i];
+ titles[i] = titles[j];
+ titles[j] = tmp;
+ }
+ }
+ }
+
+ // start the job
+ K3bJobProgressDialog dlg( parentWidget() );
+ K3bVideoDVDRippingJob* job = new K3bVideoDVDRippingJob( &dlg, &dlg );
+ job->setVideoDVD( m_dvd );
+ job->setTitles( titles );
+
+ job->setVideoBitrate( m_w->m_spinVideoBitrate->value() );
+ job->setTwoPassEncoding( m_w->m_checkTwoPassEncoding->isChecked() );
+ job->setResampleAudioTo44100( m_w->m_checkAudioResampling->isChecked() );
+ job->setAutoClipping( m_w->m_checkAutoClipping->isChecked() );
+ job->setVideoCodec( m_w->selectedVideoCodec() );
+ job->setAudioCodec( m_w->selectedAudioCodec() );
+ job->setLowPriority( m_w->m_checkLowPriority->isChecked() );
+ job->setAudioBitrate( m_w->selectedAudioBitrate() );
+ job->setAudioVBR( m_w->m_checkAudioVBR->isChecked() );
+
+ hide();
+ dlg.startJob( job );
+ close();
+}
+
+#include "k3bvideodvdrippingdialog.moc"
diff --git a/src/rip/videodvd/k3bvideodvdrippingdialog.h b/src/rip/videodvd/k3bvideodvdrippingdialog.h
new file mode 100644
index 0000000..1acad53
--- /dev/null
+++ b/src/rip/videodvd/k3bvideodvdrippingdialog.h
@@ -0,0 +1,82 @@
+/*
+ *
+ * $Id: sourceheader 511311 2006-02-19 14:51:05Z trueg $
+ * Copyright (C) 2006 Sebastian Trueg <trueg@k3b.org>
+ *
+ * This file is part of the K3b project.
+ * Copyright (C) 1998-2007 Sebastian Trueg <trueg@k3b.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ * See the file "COPYING" for the exact licensing terms.
+ */
+
+#ifndef _K3B_VIDEODVD_RIPPING_DIALOG_H_
+#define _K3B_VIDEODVD_RIPPING_DIALOG_H_
+
+#include <k3binteractiondialog.h>
+#include <k3bvideodvd.h>
+#include "k3bvideodvdrippingjob.h"
+
+#include <qvaluelist.h>
+#include <qmap.h>
+
+
+class K3bVideoDVDRippingWidget;
+class QCheckListItem;
+
+class K3bVideoDVDRippingDialog : public K3bInteractionDialog
+{
+ Q_OBJECT
+
+ public:
+ K3bVideoDVDRippingDialog( const K3bVideoDVD::VideoDVD& dvd,
+ const QValueList<int>& titles,
+ QWidget *parent = 0, const char *name = 0 );
+ ~K3bVideoDVDRippingDialog();
+
+ void setBaseDir( const QString& path );
+
+ enum FileNamingPattern {
+ PATTERN_TITLE_NUMBER = 't',
+ PATTERN_VOLUME_ID = 'i',
+ PATTERN_BEAUTIFIED_VOLUME_ID = 'b',
+ PATTERN_LANGUAGE_CODE = 'l',
+ PATTERN_LANGUAGE_NAME = 'n',
+ PATTERN_AUDIO_FORMAT = 'a',
+ PATTERN_AUDIO_CHANNELS = 'c',
+ PATTERN_ORIG_VIDEO_SIZE = 'v',
+ PATTERN_VIDEO_SIZE = 's',
+ PATTERN_ASPECT_RATIO = 'r',
+ PATTERN_CURRENT_DATE = 'd'
+ };
+
+ private slots:
+ void slotStartClicked();
+ void slotUpdateFilenames();
+ void slotUpdateFilesizes();
+ void slotUpdateVideoSizes();
+
+ private:
+ void populateTitleView( const QValueList<int>& titles );
+
+ QString createFilename( const K3bVideoDVDRippingJob::TitleRipInfo& info, const QString& pattern ) const;
+
+ void loadK3bDefaults();
+ void loadUserDefaults( KConfigBase* );
+ void saveUserDefaults( KConfigBase* );
+
+ K3bVideoDVDRippingWidget* m_w;
+
+ K3bVideoDVD::VideoDVD m_dvd;
+ QMap<QCheckListItem*, K3bVideoDVDRippingJob::TitleRipInfo> m_titleRipInfos;
+
+ class AudioStreamViewItem;
+
+ class Private;
+ Private* d;
+};
+
+#endif
diff --git a/src/rip/videodvd/k3bvideodvdrippingjob.cpp b/src/rip/videodvd/k3bvideodvdrippingjob.cpp
new file mode 100644
index 0000000..c10c127
--- /dev/null
+++ b/src/rip/videodvd/k3bvideodvdrippingjob.cpp
@@ -0,0 +1,385 @@
+/*
+ *
+ * $Id: sourceheader 511311 2006-02-19 14:51:05Z trueg $
+ * Copyright (C) 2006 Sebastian Trueg <trueg@k3b.org>
+ *
+ * This file is part of the K3b project.
+ * Copyright (C) 1998-2007 Sebastian Trueg <trueg@k3b.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ * See the file "COPYING" for the exact licensing terms.
+ */
+
+#include "k3bvideodvdrippingjob.h"
+
+#include <k3bvideodvdtitletranscodingjob.h>
+#include <k3bvideodvdtitledetectclippingjob.h>
+
+#include <kdebug.h>
+#include <klocale.h>
+
+
+K3bVideoDVDRippingJob::TitleRipInfo::TitleRipInfo()
+ : title(1),
+ audioStream(0),
+ width(0),
+ height(0),
+ videoBitrate(0),
+ clipTop(0),
+ clipLeft(0),
+ clipBottom(0),
+ clipRight(0)
+{
+}
+
+
+K3bVideoDVDRippingJob::TitleRipInfo::TitleRipInfo( int _title,
+ int _audioStream,
+ const QString& fn,
+ int _width,
+ int _height,
+ int _videoBitrate,
+ int _clipTop,
+ int _clipLeft,
+ int _clipBottom,
+ int _clipRight )
+ : title(_title),
+ audioStream(_audioStream),
+ filename(fn),
+ width(_width),
+ height(_height),
+ videoBitrate(_videoBitrate),
+ clipTop(_clipTop),
+ clipLeft(_clipLeft),
+ clipBottom(_clipBottom),
+ clipRight(_clipRight)
+{
+}
+
+
+
+class K3bVideoDVDRippingJob::Private {
+public:
+ Private()
+ : autoClipping( true ) {
+ }
+
+ unsigned int currentTitleInfoIndex;
+ bool autoClipping;
+
+ bool canceled;
+
+ int videoBitrate;
+
+ int failedTitles;
+
+ QValueVector<double> titleProgressParts;
+ QValueVector<double> titleClippingProgressParts;
+};
+
+
+
+K3bVideoDVDRippingJob::K3bVideoDVDRippingJob( K3bJobHandler* hdl, QObject* parent )
+ : K3bJob( hdl, parent )
+{
+ d = new Private();
+
+ m_transcodingJob = new K3bVideoDVDTitleTranscodingJob( this, this );
+ connectSubJob( m_transcodingJob,
+ SLOT(slotTranscodingJobFinished(bool)),
+ SIGNAL(newTask(const QString&)),
+ SIGNAL(newSubTask(const QString&)),
+ SLOT(slotTranscodingProgress(int)),
+ SIGNAL(subPercent(int)),
+ 0,
+ 0 );
+ m_detectClippingJob = 0;
+}
+
+
+K3bVideoDVDRippingJob::~K3bVideoDVDRippingJob()
+{
+ delete d;
+}
+
+
+QString K3bVideoDVDRippingJob::jobDescription() const
+{
+ return i18n("Ripping Video DVD Titles");
+}
+
+
+QString K3bVideoDVDRippingJob::jobDetails() const
+{
+ return i18n("Transcoding %n title to %1/%2", "Transcoding %n titles to %1/%2", m_titleRipInfos.count() )
+ .arg( K3bVideoDVDTitleTranscodingJob::videoCodecString( m_transcodingJob->videoCodec() ) )
+ .arg( K3bVideoDVDTitleTranscodingJob::audioCodecString( m_transcodingJob->audioCodec() ) );
+}
+
+
+void K3bVideoDVDRippingJob::start()
+{
+ jobStarted();
+ d->canceled = false;
+ d->failedTitles = 0;
+
+ initProgressInfo();
+
+ if( d->autoClipping )
+ startDetectClipping( 0 );
+ else
+ startTranscoding( 0 );
+}
+
+
+void K3bVideoDVDRippingJob::slotTranscodingJobFinished( bool success )
+{
+ if( d->canceled ) {
+ emit canceled();
+ jobFinished( false );
+ }
+ else {
+ if( success )
+ emit infoMessage( i18n("Successfully ripped title %1").arg(m_titleRipInfos[d->currentTitleInfoIndex].title), SUCCESS );
+ else {
+ d->failedTitles++;
+ emit infoMessage( i18n("Failed to rip title %1").arg(m_titleRipInfos[d->currentTitleInfoIndex].title), ERROR );
+ }
+
+ ++d->currentTitleInfoIndex ;
+ if( d->currentTitleInfoIndex < m_titleRipInfos.count() ) {
+ if( d->autoClipping )
+ startDetectClipping( d->currentTitleInfoIndex );
+ else
+ startTranscoding( d->currentTitleInfoIndex );
+ }
+ else {
+ jobFinished( d->failedTitles == 0 );
+ }
+ }
+}
+
+
+void K3bVideoDVDRippingJob::slotDetectClippingJobFinished( bool success )
+{
+ if( d->canceled ) {
+ emit canceled();
+ jobFinished( false );
+ }
+ else {
+ m_titleRipInfos[d->currentTitleInfoIndex].clipTop = 0;
+ m_titleRipInfos[d->currentTitleInfoIndex].clipLeft = 0;
+ m_titleRipInfos[d->currentTitleInfoIndex].clipBottom = 0;
+ m_titleRipInfos[d->currentTitleInfoIndex].clipRight = 0;
+
+ if( success ) {
+ emit infoMessage( i18n("Determined clipping values for title %1").arg(m_titleRipInfos[d->currentTitleInfoIndex].title), SUCCESS );
+ emit infoMessage( i18n("Top: %1, Bottom: %2")
+ .arg(m_detectClippingJob->clippingTop()).arg(m_detectClippingJob->clippingBottom()), INFO );
+ emit infoMessage( i18n("Left: %1, Right: %2")
+ .arg(m_detectClippingJob->clippingLeft()).arg(m_detectClippingJob->clippingRight()), INFO );
+
+ // let's see if the clipping values make sense
+ if( m_detectClippingJob->clippingTop() + m_detectClippingJob->clippingBottom()
+ >= (int)m_dvd[d->currentTitleInfoIndex].videoStream().pictureHeight() ||
+ m_detectClippingJob->clippingLeft() + m_detectClippingJob->clippingRight()
+ >= (int)m_dvd[d->currentTitleInfoIndex].videoStream().pictureWidth() ) {
+ emit infoMessage( i18n("Insane clipping values. No clipping will be done at all."), WARNING );
+ }
+ else {
+ m_titleRipInfos[d->currentTitleInfoIndex].clipTop = m_detectClippingJob->clippingTop();
+ m_titleRipInfos[d->currentTitleInfoIndex].clipLeft = m_detectClippingJob->clippingLeft();
+ m_titleRipInfos[d->currentTitleInfoIndex].clipBottom = m_detectClippingJob->clippingBottom();
+ m_titleRipInfos[d->currentTitleInfoIndex].clipRight = m_detectClippingJob->clippingRight();
+ }
+ }
+ else
+ emit infoMessage( i18n("Failed to determine clipping values for title %1").arg(m_titleRipInfos[d->currentTitleInfoIndex].title), ERROR );
+
+ startTranscoding( d->currentTitleInfoIndex );
+ }
+}
+
+
+void K3bVideoDVDRippingJob::startTranscoding( int ripInfoIndex )
+{
+ d->currentTitleInfoIndex = ripInfoIndex;
+
+ m_transcodingJob->setVideoDVD( m_dvd );
+ m_transcodingJob->setTitle( m_titleRipInfos[ripInfoIndex].title );
+ m_transcodingJob->setAudioStream( m_titleRipInfos[ripInfoIndex].audioStream );
+ m_transcodingJob->setClipping( m_titleRipInfos[ripInfoIndex].clipTop,
+ m_titleRipInfos[ripInfoIndex].clipLeft,
+ m_titleRipInfos[ripInfoIndex].clipBottom,
+ m_titleRipInfos[ripInfoIndex].clipRight );
+ m_transcodingJob->setSize( m_titleRipInfos[ripInfoIndex].width, m_titleRipInfos[ripInfoIndex].height );
+ m_transcodingJob->setFilename( m_titleRipInfos[ripInfoIndex].filename );
+
+ if( m_titleRipInfos[ripInfoIndex].videoBitrate > 0 )
+ m_transcodingJob->setVideoBitrate( m_titleRipInfos[ripInfoIndex].videoBitrate );
+ else
+ m_transcodingJob->setVideoBitrate( d->videoBitrate );
+
+ m_transcodingJob->start();
+}
+
+
+void K3bVideoDVDRippingJob::startDetectClipping( int ripInfoIndex )
+{
+ d->currentTitleInfoIndex = ripInfoIndex;
+
+ if( !m_detectClippingJob ) {
+ m_detectClippingJob = new K3bVideoDVDTitleDetectClippingJob( this, this );
+ connectSubJob( m_detectClippingJob,
+ SLOT(slotDetectClippingJobFinished(bool)),
+ SIGNAL(newTask(const QString&)),
+ SIGNAL(newSubTask(const QString&)),
+ SLOT(slotDetectClippingProgress(int)),
+ SIGNAL(subPercent(int)),
+ 0,
+ 0 );
+ }
+
+ m_detectClippingJob->setVideoDVD( m_dvd );
+ m_detectClippingJob->setTitle( m_titleRipInfos[ripInfoIndex].title );
+ m_detectClippingJob->setLowPriority( m_transcodingJob->lowPriority() );
+
+ m_detectClippingJob->start();
+}
+
+
+void K3bVideoDVDRippingJob::slotTranscodingProgress( int p )
+{
+ // calculate the part already done
+ double doneParts = 0.0;
+ for( unsigned int i = 0; i < d->currentTitleInfoIndex; ++i ) {
+ doneParts += d->titleProgressParts[i];
+ if( d->autoClipping )
+ doneParts += d->titleClippingProgressParts[i];
+ }
+ if( d->autoClipping )
+ doneParts += d->titleClippingProgressParts[d->currentTitleInfoIndex];
+
+ // and the current thing
+ doneParts += (double)p/100.0*d->titleProgressParts[d->currentTitleInfoIndex];
+
+ emit percent( (int)( 100.0*doneParts ) );
+}
+
+
+void K3bVideoDVDRippingJob::slotDetectClippingProgress( int p )
+{
+ // calculate the part already done
+ double doneParts = 0.0;
+ for( unsigned int i = 0; i < d->currentTitleInfoIndex; ++i ) {
+ doneParts += d->titleProgressParts[i];
+ doneParts += d->titleClippingProgressParts[i];
+ }
+
+ // and the current thing
+ doneParts += (double)p/100.0*d->titleClippingProgressParts[d->currentTitleInfoIndex];
+
+ emit percent( (int)( 100.0*doneParts ) );
+}
+
+
+void K3bVideoDVDRippingJob::cancel()
+{
+ d->canceled = true;
+ if( m_transcodingJob->active() )
+ m_transcodingJob->cancel();
+ else if( m_detectClippingJob && m_detectClippingJob->active() )
+ m_detectClippingJob->cancel();
+}
+
+
+void K3bVideoDVDRippingJob::setVideoCodec( K3bVideoDVDTitleTranscodingJob::VideoCodec codec )
+{
+ m_transcodingJob->setVideoCodec( codec );
+}
+
+
+void K3bVideoDVDRippingJob::setVideoBitrate( int bitrate )
+{
+ d->videoBitrate = bitrate;
+}
+
+
+void K3bVideoDVDRippingJob::setTwoPassEncoding( bool b )
+{
+ m_transcodingJob->setTwoPassEncoding( b );
+}
+
+
+void K3bVideoDVDRippingJob::setAudioCodec( K3bVideoDVDTitleTranscodingJob::AudioCodec codec )
+{
+ m_transcodingJob->setAudioCodec( codec );
+}
+
+
+void K3bVideoDVDRippingJob::setAudioBitrate( int bitrate )
+{
+ m_transcodingJob->setAudioBitrate( bitrate );
+}
+
+
+void K3bVideoDVDRippingJob::setAudioVBR( bool vbr )
+{
+ m_transcodingJob->setAudioVBR( vbr );
+}
+
+
+void K3bVideoDVDRippingJob::setResampleAudioTo44100( bool b )
+{
+ m_transcodingJob->setResampleAudioTo44100( b );
+}
+
+
+void K3bVideoDVDRippingJob::setLowPriority( bool b )
+{
+ m_transcodingJob->setLowPriority( b );
+}
+
+
+void K3bVideoDVDRippingJob::setAutoClipping( bool b )
+{
+ d->autoClipping = b;
+}
+
+
+void K3bVideoDVDRippingJob::initProgressInfo()
+{
+ d->titleProgressParts.resize( m_titleRipInfos.count() );
+ d->titleClippingProgressParts.resize( m_titleRipInfos.count() );
+
+ unsigned long long totalFrames = 0ULL;
+ for( unsigned int i = 0; i < m_titleRipInfos.count(); ++i ) {
+ if( m_transcodingJob->twoPassEncoding() )
+ totalFrames += m_dvd[m_titleRipInfos[i].title-1].playbackTime().totalFrames() * 2;
+ else
+ totalFrames += m_dvd[m_titleRipInfos[i].title-1].playbackTime().totalFrames();
+
+ // using my knowledge of the internals of the clipping detection job: it decodes 200 frames
+ // of every chapter
+ if( d->autoClipping )
+ totalFrames += m_dvd[m_titleRipInfos[i].title-1].numChapters() * 200;
+ }
+
+ for( unsigned int i = 0; i < m_titleRipInfos.count(); ++i ) {
+ unsigned long long titleFrames = m_dvd[m_titleRipInfos[i].title-1].playbackTime().totalFrames();
+ if( m_transcodingJob->twoPassEncoding() )
+ titleFrames *= 2;
+
+ // using my knowledge of the internals of the clipping detection job: it decodes 200 frames
+ // of every chapter
+ unsigned long long titleClippingFrames = m_dvd[m_titleRipInfos[i].title-1].numChapters() * 200;
+
+ d->titleProgressParts[i] = (double)titleFrames/(double)totalFrames;
+ d->titleClippingProgressParts[i] = (double)titleClippingFrames/(double)totalFrames;
+ }
+}
+
+#include "k3bvideodvdrippingjob.moc"
diff --git a/src/rip/videodvd/k3bvideodvdrippingjob.h b/src/rip/videodvd/k3bvideodvdrippingjob.h
new file mode 100644
index 0000000..7c9f4d2
--- /dev/null
+++ b/src/rip/videodvd/k3bvideodvdrippingjob.h
@@ -0,0 +1,106 @@
+/*
+ *
+ * $Id: sourceheader 511311 2006-02-19 14:51:05Z trueg $
+ * Copyright (C) 2006 Sebastian Trueg <trueg@k3b.org>
+ *
+ * This file is part of the K3b project.
+ * Copyright (C) 1998-2007 Sebastian Trueg <trueg@k3b.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ * See the file "COPYING" for the exact licensing terms.
+ */
+
+#ifndef _K3B_VIDEODVD_RIPPING_JOB_H_
+#define _K3B_VIDEODVD_RIPPING_JOB_H_
+
+#include <k3bjob.h>
+#include <k3bvideodvd.h>
+#include <k3bvideodvdtitletranscodingjob.h>
+
+#include <qvaluevector.h>
+
+
+class K3bVideoDVDTitleDetectClippingJob;
+
+
+/**
+ * For details on the options see K3bVideoDVDTitleTranscodingJob
+ */
+class K3bVideoDVDRippingJob : public K3bJob
+{
+ Q_OBJECT
+
+ public:
+ K3bVideoDVDRippingJob( K3bJobHandler* hdl, QObject* parent );
+ ~K3bVideoDVDRippingJob();
+
+ class TitleRipInfo {
+ public:
+ TitleRipInfo();
+ TitleRipInfo( int title,
+ int audioStream = 0,
+ const QString& fn = QString::null,
+ int width = 0, // 0 -> no resize
+ int height = 0, // 0 -> no resize
+ int videoBitrate = 0, // 0 -> use default from job settings
+ int clipTop = 0,
+ int clipLeft = 0,
+ int clipBottom = 0,
+ int clipRight = 0 );
+ int title;
+ int audioStream;
+ QString filename;
+ int width;
+ int height;
+ int videoBitrate;
+ int clipTop;
+ int clipLeft;
+ int clipBottom;
+ int clipRight;
+ };
+
+ QString jobDescription() const;
+ QString jobDetails() const;
+
+ public slots:
+ void start();
+ void cancel();
+
+ void setVideoDVD( const K3bVideoDVD::VideoDVD& dvd ) { m_dvd = dvd; }
+ void setTitles( const QValueVector<TitleRipInfo>& titles ) { m_titleRipInfos = titles; }
+
+ void setVideoCodec( K3bVideoDVDTitleTranscodingJob::VideoCodec codec );
+ void setVideoBitrate( int bitrate );
+ void setTwoPassEncoding( bool b );
+ void setAudioCodec( K3bVideoDVDTitleTranscodingJob::AudioCodec codec );
+ void setAudioBitrate( int bitrate );
+ void setAudioVBR( bool vbr );
+ void setResampleAudioTo44100( bool b );
+ void setLowPriority( bool b );
+ void setAutoClipping( bool b );
+
+ private slots:
+ void slotTranscodingJobFinished( bool );
+ void slotDetectClippingJobFinished( bool );
+ void slotTranscodingProgress( int );
+ void slotDetectClippingProgress( int );
+
+ private:
+ void startTranscoding( int ripInfoIndex );
+ void startDetectClipping( int ripInfoIndex );
+ void initProgressInfo();
+
+ K3bVideoDVD::VideoDVD m_dvd;
+ QValueVector<TitleRipInfo> m_titleRipInfos;
+
+ K3bVideoDVDTitleTranscodingJob* m_transcodingJob;
+ K3bVideoDVDTitleDetectClippingJob* m_detectClippingJob;
+
+ class Private;
+ Private* d;
+};
+
+#endif
diff --git a/src/rip/videodvd/k3bvideodvdrippingpreview.cpp b/src/rip/videodvd/k3bvideodvdrippingpreview.cpp
new file mode 100644
index 0000000..3ba7582
--- /dev/null
+++ b/src/rip/videodvd/k3bvideodvdrippingpreview.cpp
@@ -0,0 +1,135 @@
+/*
+ *
+ * $Id: sourceheader 511311 2006-02-19 14:51:05Z trueg $
+ * Copyright (C) 2006 Sebastian Trueg <trueg@k3b.org>
+ *
+ * This file is part of the K3b project.
+ * Copyright (C) 1998-2007 Sebastian Trueg <trueg@k3b.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ * See the file "COPYING" for the exact licensing terms.
+ */
+
+#include "k3bvideodvdrippingpreview.h"
+
+#include <k3bcore.h>
+#include <k3bexternalbinmanager.h>
+#include <k3bdevice.h>
+
+#include <kprocess.h>
+#include <ktempdir.h>
+#include <kdebug.h>
+
+#include <qdir.h>
+
+
+
+K3bVideoDVDRippingPreview::K3bVideoDVDRippingPreview( QObject* parent )
+ : QObject( parent ),
+ m_tempDir( 0 ),
+ m_process( 0 )
+{
+}
+
+
+K3bVideoDVDRippingPreview::~K3bVideoDVDRippingPreview()
+{
+ delete m_process;
+ delete m_tempDir;
+}
+
+
+void K3bVideoDVDRippingPreview::generatePreview( const K3bVideoDVD::VideoDVD& dvd, int title, int chapter )
+{
+ // cleanup first
+ delete m_process;
+ delete m_tempDir;
+ m_process = 0;
+ m_tempDir = 0;
+ m_canceled = false;
+
+ const K3bExternalBin* bin = k3bcore->externalBinManager()->binObject("transcode");
+ if( !bin ) {
+ emit previewDone( false );
+ return;
+ }
+
+ // auto-select a chapter
+ // choose the center chapter, but not the first or last if possible
+ if( chapter == 0 )
+ chapter = QMIN( QMAX( dvd[title-1].numChapters()/2, 2 ), QMAX( dvd[title-1].numChapters() - 1, 1 ) );
+
+ // select a frame number
+ unsigned int frame = 30;
+ if( dvd[title-1][chapter-1].playbackTime().totalFrames() < frame )
+ frame = dvd[title-1][chapter-1].playbackTime().totalFrames() / 2;
+
+ m_dvd = dvd;
+ m_title = title;
+ m_chapter = chapter;
+
+ m_tempDir = new KTempDir();
+ m_tempDir->setAutoDelete( true );
+
+ m_process = new KProcess();
+ *m_process << bin->path;
+ *m_process << "-i" << dvd.device()->blockDeviceName();
+ *m_process << "-T" << QString("%1,%2").arg(title).arg(chapter);
+ *m_process << "-x" << "dvd,null";
+ *m_process << "--dvd_access_delay" << "0";
+ *m_process << "-y" << "ppm,null";
+ *m_process << "-c" << QString("%1-%2").arg( frame ).arg( frame+1 );
+ *m_process << "-Z" << "x200";
+ *m_process << "-o" << m_tempDir->name();
+
+ connect( m_process, SIGNAL(processExited(KProcess*)),
+ this, SLOT(slotTranscodeFinished(KProcess*)) );
+ if( !m_process->start( KProcess::NotifyOnExit, KProcess::AllOutput ) ) { // we use AllOutput to not pollute stdout
+ // something went wrong when starting the program
+ // it "should" be the executable
+ kdDebug() << "(K3bVideoDVDRippingPreview) Could not start transcode." << endl;
+ delete m_process;
+ delete m_tempDir;
+ m_process = 0;
+ m_tempDir = 0;
+ emit previewDone( false );
+ }
+}
+
+
+void K3bVideoDVDRippingPreview::cancel()
+{
+ if( m_process && m_process->isRunning() ) {
+ m_canceled = true;
+ m_process->kill();
+ }
+}
+
+
+void K3bVideoDVDRippingPreview::slotTranscodeFinished( KProcess* )
+{
+ // read the image
+ QString filename = m_tempDir->name() + "000000.ppm";// + tempQDir->entryList( QDir::Files ).first();
+ kdDebug() << "(K3bVideoDVDRippingPreview) reading from file " << filename << endl;
+ m_preview = QImage( filename );
+ bool success = !m_preview.isNull() && !m_canceled;
+
+ // remove temp files
+ delete m_tempDir;
+ m_tempDir = 0;
+
+ // clean up
+ delete m_process;
+ m_process = 0;
+
+ // retry the first chapter in case another failed
+ if( !success && m_chapter > 1 )
+ generatePreview( m_dvd, m_title, 1 );
+ else
+ emit previewDone( success );
+}
+
+#include "k3bvideodvdrippingpreview.moc"
diff --git a/src/rip/videodvd/k3bvideodvdrippingpreview.h b/src/rip/videodvd/k3bvideodvdrippingpreview.h
new file mode 100644
index 0000000..f5beb69
--- /dev/null
+++ b/src/rip/videodvd/k3bvideodvdrippingpreview.h
@@ -0,0 +1,66 @@
+/*
+ *
+ * $Id: sourceheader 511311 2006-02-19 14:51:05Z trueg $
+ * Copyright (C) 2006 Sebastian Trueg <trueg@k3b.org>
+ *
+ * This file is part of the K3b project.
+ * Copyright (C) 1998-2007 Sebastian Trueg <trueg@k3b.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ * See the file "COPYING" for the exact licensing terms.
+ */
+
+#ifndef _K3B_VIDEODVD_RIPPING_PREVIEW_H_
+#define _K3B_VIDEODVD_RIPPING_PREVIEW_H_
+
+#include <qobject.h>
+#include <qimage.h>
+
+#include <k3bvideodvd.h>
+
+
+class KTempDir;
+class KProcess;
+
+class K3bVideoDVDRippingPreview : public QObject
+{
+ Q_OBJECT
+
+ public:
+ K3bVideoDVDRippingPreview( QObject* parent = 0 );
+ ~K3bVideoDVDRippingPreview();
+
+ const QImage& preview() const { return m_preview; }
+
+ public slots:
+ /**
+ * \param dvd The Video DVD object
+ * \param title The Video DVD title to generate the preview for
+ * \param chapter The Chapter number to use for the preview.
+ * If 0 the middle of the title is used.
+ */
+ void generatePreview( const K3bVideoDVD::VideoDVD& dvd, int title, int chapter = 0 );
+
+ void cancel();
+
+ signals:
+ void previewDone( bool );
+
+ private slots:
+ void slotTranscodeFinished( KProcess* );
+
+ private:
+ QImage m_preview;
+ KTempDir* m_tempDir;
+ KProcess* m_process;
+ int m_title;
+ int m_chapter;
+ K3bVideoDVD::VideoDVD m_dvd;
+
+ bool m_canceled;
+};
+
+#endif
diff --git a/src/rip/videodvd/k3bvideodvdrippingtitlelistview.cpp b/src/rip/videodvd/k3bvideodvdrippingtitlelistview.cpp
new file mode 100644
index 0000000..85379dc
--- /dev/null
+++ b/src/rip/videodvd/k3bvideodvdrippingtitlelistview.cpp
@@ -0,0 +1,410 @@
+/*
+ *
+ * $Id: sourceheader 511311 2006-02-19 14:51:05Z trueg $
+ * Copyright (C) 2006 Sebastian Trueg <trueg@k3b.org>
+ *
+ * This file is part of the K3b project.
+ * Copyright (C) 1998-2007 Sebastian Trueg <trueg@k3b.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ * See the file "COPYING" for the exact licensing terms.
+ */
+
+#include "k3bvideodvdrippingtitlelistview.h"
+#include "k3bvideodvdrippingpreview.h"
+
+#include <k3btooltip.h>
+#include <k3bapplication.h>
+#include <k3bmediacache.h>
+
+#include <k3bvideodvd.h>
+#include <k3bvideodvdaudiostream.h>
+#include <k3bvideodvdvideostream.h>
+#include <k3bvideodvdsubpicturestream.h>
+
+#include <qsimplerichtext.h>
+#include <qfontmetrics.h>
+#include <qpainter.h>
+#include <qheader.h>
+#include <qtooltip.h>
+
+#include <klocale.h>
+#include <kglobal.h>
+#include <kiconloader.h>
+#include <kapplication.h>
+
+
+static QString audioStreamString( const K3bVideoDVD::Title& title, unsigned int maxLines = 9999, bool includeExtInfo = true )
+{
+ QString s = "<p>";
+ for( unsigned int i = 0; i < QMIN( title.numAudioStreams(), maxLines ); ++i ) {
+ if( i > 0 )
+ s += "<br>";
+ s += QString::number(i+1) + ": "
+ + i18n("%1 %2Ch (%3<em>%4</em>)")
+ .arg( K3bVideoDVD::audioFormatString( title.audioStream(i).format() ) )
+ .arg( title.audioStream(i).channels() )
+ .arg( title.audioStream(i).langCode().isEmpty()
+ ? i18n("unknown language")
+ : KGlobal::locale()->twoAlphaToLanguageName( title.audioStream(i).langCode() ) )
+ .arg( includeExtInfo && title.audioStream(i).codeExtension() != K3bVideoDVD::AUDIO_CODE_EXT_UNSPECIFIED
+ ? QString(" ") + K3bVideoDVD::audioCodeExtensionString( title.audioStream(i).codeExtension() )
+ : QString::null );
+ }
+ if( title.numAudioStreams() > maxLines )
+ s += "...";
+
+ return s;
+}
+
+
+static QString subpictureStreamString( const K3bVideoDVD::Title& title, unsigned int maxLines = 9999, bool includeExtInfo = true )
+{
+ QString s = "<p>";
+ for( unsigned int i = 0; i < QMIN( title.numSubPictureStreams(), maxLines ); ++i ) {
+ if( i > 0 )
+ s += "<br>";
+ s += QString::number(i+1) + ": "
+ + QString("%1 (%2<em>%3</em>)")
+ .arg( title.subPictureStream(i).codeMode() == K3bVideoDVD::SUBPIC_CODE_MODE_RLE
+ ? i18n("RLE")
+ : i18n("Extended") )
+ .arg( title.subPictureStream(i).langCode().isEmpty()
+ ? i18n("unknown language")
+ : KGlobal::locale()->twoAlphaToLanguageName( title.subPictureStream(i).langCode() ) )
+ .arg( includeExtInfo && title.subPictureStream(i).codeExtension() != K3bVideoDVD::SUBPIC_CODE_EXT_UNSPECIFIED
+ ? QString(" ") + K3bVideoDVD::subPictureCodeExtensionString( title.subPictureStream(i).codeExtension() )
+ : QString::null );
+ }
+ if( title.numSubPictureStreams() > maxLines )
+ s += "...";
+
+ return s;
+}
+
+
+
+class K3bVideoDVDRippingTitleListView::TitleViewItem : public K3bCheckListViewItem
+{
+public:
+ TitleViewItem( K3bVideoDVDRippingTitleListView* parent, QListViewItem* after, const K3bVideoDVD::Title& title )
+ : K3bCheckListViewItem( parent, after ),
+ m_title( title ) {
+
+ setMarginVertical( 4 );
+ setMarginHorizontal( 1, 2 );
+ setMarginHorizontal( 2, 2 );
+ setMarginHorizontal( 3, 2 );
+ setMarginHorizontal( 4, 2 );
+ setMarginHorizontal( 5, 2 );
+ setChecked(true);
+
+ m_previewSet = false;
+ }
+
+ const K3bVideoDVD::Title& videoDVDTitle() const { return m_title; }
+
+ void setup() {
+ widthChanged();
+
+ // set a valid height
+ int maxH = 0;
+ for( int c = 1; c <= 4; ++c ) {
+ QSimpleRichText rt( text(c), listView()->font() );
+ rt.setWidth( 600 ); // way to big to avoid line breaks
+ maxH = QMAX( maxH, rt.height() );
+ }
+
+ setHeight( maxH + 2*marginVertical() );
+ }
+
+ int width( const QFontMetrics& fm, const QListView* lv, int c ) const {
+ if( c == 0 )
+ return K3bCheckListViewItem::width( fm, lv, c );
+ else {
+ QSimpleRichText rt( text(c), lv->font() );
+ rt.setWidth( 600 ); // way to big to avoid line breaks
+ return rt.widthUsed() + 2*marginHorizontal( c );
+ }
+ }
+
+ void setPreview( const QImage& preview ) {
+ m_preview = preview;
+ m_scaledPreview = QPixmap();
+
+ m_previewSet = true;
+
+ repaint();
+ }
+
+ const QImage& preview() const {
+ return m_preview;
+ }
+
+protected:
+ void paintK3bCell( QPainter* p, const QColorGroup& cg, int col, int w, int align ) {
+ p->save();
+
+ if( col == 0 ) {
+ // the check mark
+ K3bCheckListViewItem::paintK3bCell( p, cg, col, w, align );
+ }
+ else if( col == 2 ) {
+ if( isSelected() ) {
+ p->fillRect( 0, 0, w, height(),
+ cg.brush( QColorGroup::Highlight ) );
+ p->setPen( cg.highlightedText() );
+ }
+ else {
+ p->fillRect( 0, 0, w, height(), cg.base() );
+ p->setPen( cg.text() );
+ }
+
+ // draw the preview
+ int h = height();
+ h -= 2*marginVertical();
+ h -= 1; // the separator
+ if( !m_preview.isNull() ) {
+ if( m_scaledPreview.height() != h ) {
+ // recreate scaled preview
+ int preH = m_preview.height()*w/m_preview.width();
+ int preW = m_preview.width()*h/m_preview.height();
+ if( preH > h )
+ preH = m_preview.height()*preW/m_preview.width();
+ if( preW > w )
+ preW = m_preview.width()*preH/m_preview.height();
+ m_scaledPreview.convertFromImage( m_preview.smoothScale( preW, preH ), 0 );
+ }
+
+ // center the preview in the column
+ int yPos = ( height() - m_scaledPreview.height() ) / 2;
+ int xPos = ( w - m_scaledPreview.width() ) / 2;
+
+ p->drawPixmap( xPos, yPos, m_scaledPreview );
+ }
+ else if( m_previewSet ) {
+ int preW = 0;
+ if( m_title.videoStream().displayAspectRatio() == K3bVideoDVD::VIDEO_ASPECT_RATIO_4_3 )
+ preW = h*4/3;
+ else
+ preW = h*16/9;
+
+ p->drawRect( ( w - preW ) / 2, ( height() - h ) / 2, preW, h );
+ QPixmap noIcon = KApplication::kApplication()->iconLoader()->loadIcon( "no", KIcon::NoGroup, KIcon::SizeSmall, KIcon::DefaultState, 0, true );
+ p->drawPixmap( ( w - noIcon.width() ) / 2, ( height() - noIcon.height() ) / 2, noIcon );
+ }
+ else {
+ p->drawText( 0, 0, w, height(), Qt::AlignCenter, "..." );
+ }
+ }
+ else {
+ QString s = text( col );
+ if( s.isEmpty() )
+ K3bCheckListViewItem::paintK3bCell( p, cg, col, w, align );
+ else {
+ QColorGroup cg1( cg );
+ if( isSelected() ) {
+ p->fillRect( 0, 0, w, height(),
+ cg.brush( QColorGroup::Highlight ) );
+ cg1.setColor( QColorGroup::Text, cg.highlightedText() );
+ }
+ else {
+ p->fillRect( 0, 0, w, height(), cg.base() );
+ }
+
+ // paint using QSimpleRichText
+ QSimpleRichText rt( text(col), listView()->font() );
+ rt.setWidth( 600 ); // way to big to avoid line breaks
+ // normally we would have to clip the height to height()-2*marginVertical(). But if we do that
+ // some characters are cut (such as p or q). It seems as if QSimpleRichText does not properly
+ // calculate it's height...
+ rt.draw( p, 0, marginVertical(), QRect( 0, 0, w, height() ), cg1 );
+ }
+ }
+
+ // draw the separator
+ if( listView()->firstChild() != this ) {
+ p->translate( -1*marginHorizontal(col), 0 );
+ // FIXME: modify the value from palette().disabled().foreground() to be lighter (or darker, depending on the background color )
+ p->setPen( Qt::lightGray );
+ p->drawLine( 0, 0, w+2*marginHorizontal(col), 0 );
+ }
+
+ p->restore();
+ }
+
+private:
+ QString text( int col ) const {
+ switch( col ) {
+ case 1:
+ // Title X + length
+ return i18n("<p><b>Title %1 (%2)</b><br>"
+ "%3")
+ .arg( m_title.titleNumber(), 2 )
+ .arg( m_title.playbackTime().toString( false ) )
+ .arg( i18n("%n chapter", "%n chapters", m_title.numPTTs() ) );
+
+ case 3:
+ // video stream info
+ return QString("<p>%1 %2x%3<br>%4%5")
+ .arg( m_title.videoStream().mpegVersion() == 0 ? i18n("MPEG1") : i18n("MPEG2") )
+ .arg( m_title.videoStream().pictureWidth() )
+ .arg( m_title.videoStream().pictureHeight() )
+ .arg( m_title.videoStream().displayAspectRatio() == K3bVideoDVD::VIDEO_ASPECT_RATIO_4_3 ? "4:3" : "16:9" )
+ .arg( m_title.videoStream().letterboxed() ? QString(" - <em>") + i18n("letterboxed") + QString("</em>"):
+ m_title.videoStream().permittedDf() == K3bVideoDVD::VIDEO_PERMITTED_DF_LETTERBOXED
+ ? QString(" - <em>") + i18n("anamorph") + QString("</em>") : QString::null );
+
+ case 4:
+ // audio streams info
+ if( m_title.numAudioStreams() > 0 )
+ return audioStreamString( m_title, 2, false );
+ else
+ return "<p><small><em>" + i18n("No audio streams") + "</em>";
+
+ case 5:
+ // subpicture streams info
+ if( m_title.numSubPictureStreams() > 0 )
+ return subpictureStreamString( m_title, 2, false );
+ else
+ return "<p><small><em>" + i18n("No Subpicture streams") + "</em>";
+
+ default:
+ return K3bCheckListViewItem::text( col );
+ }
+ }
+
+ K3bVideoDVD::Title m_title;
+
+ bool m_previewSet;
+ QImage m_preview;
+ QPixmap m_scaledPreview;
+};
+
+
+class K3bVideoDVDRippingTitleListView::TitleToolTip : public K3bToolTip
+{
+public:
+ TitleToolTip( K3bVideoDVDRippingTitleListView* view )
+ : K3bToolTip( view->viewport() ),
+ m_view( view ) {
+ }
+
+ void maybeTip( const QPoint& pos ) {
+ TitleViewItem* item = static_cast<TitleViewItem*>( m_view->itemAt( pos ) );
+ QPoint contentsPos = m_view->viewportToContents( pos );
+ if( !item )
+ return;
+ int col = m_view->header()->sectionAt( contentsPos.x() );
+
+ QRect r = m_view->itemRect( item );
+ int headerPos = m_view->header()->sectionPos( col );
+ r.setLeft( headerPos );
+ r.setRight( headerPos + m_view->header()->sectionSize( col ) );
+
+ switch( col ) {
+ case 2:
+ if( !item->preview().isNull() ) {
+ QPixmap previewPix;
+ if( previewPix.convertFromImage( item->preview() ) )
+ tip( r, previewPix, 0 );
+ }
+ break;
+ case 4:
+ if( item->videoDVDTitle().numAudioStreams() > 0 )
+ tip( r, "<p><b>" + i18n("Audio Streams") + "</b><p>" + audioStreamString( item->videoDVDTitle() ), 0 );
+ break;
+ case 5:
+ if( item->videoDVDTitle().numSubPictureStreams() > 0 )
+ tip( r, "<p><b>" + i18n("Subpicture Streams") + "</b><p>" + subpictureStreamString( item->videoDVDTitle() ), 0 );
+ break;
+ }
+ }
+
+private:
+ K3bVideoDVDRippingTitleListView* m_view;
+};
+
+
+
+K3bVideoDVDRippingTitleListView::K3bVideoDVDRippingTitleListView( QWidget* parent )
+ : K3bListView( parent )
+{
+ setFullWidth(true);
+ setSorting(-1);
+ setAllColumnsShowFocus( true );
+ setSelectionModeExt( Single );
+
+ addColumn( "" );
+ addColumn( i18n("Title") );
+ addColumn( i18n("Preview") );
+ addColumn( i18n("Video") );
+ addColumn( i18n("Audio") );
+ addColumn( i18n("Subpicture") );
+
+ header()->setClickEnabled( false );
+ setColumnWidthMode( 0, QListView::Manual );
+ setColumnWidth( 0, 20 );
+ header()->setResizeEnabled( false, 0 );
+
+ m_toolTip = new TitleToolTip( this );
+
+ m_previewGen = new K3bVideoDVDRippingPreview( this );
+ connect( m_previewGen, SIGNAL(previewDone(bool)),
+ this, SLOT(slotPreviewDone(bool)) );
+}
+
+
+K3bVideoDVDRippingTitleListView::~K3bVideoDVDRippingTitleListView()
+{
+ delete m_toolTip;
+}
+
+
+void K3bVideoDVDRippingTitleListView::setVideoDVD( const K3bVideoDVD::VideoDVD& dvd )
+{
+ clear();
+
+ m_dvd = dvd;
+ m_medium = k3bappcore->mediaCache()->medium( m_dvd.device() );
+ m_itemMap.resize( dvd.numTitles() );
+
+ for( unsigned int i = 0; i < dvd.numTitles(); ++i )
+ m_itemMap[i] = new TitleViewItem( this, lastItem(), dvd.title(i) );
+
+ m_currentPreviewTitle = 1;
+ m_previewGen->generatePreview( m_dvd, 1 );
+}
+
+
+void K3bVideoDVDRippingTitleListView::slotPreviewDone( bool success )
+{
+ if( success )
+ m_itemMap[m_currentPreviewTitle-1]->setPreview( m_previewGen->preview() );
+ else
+ m_itemMap[m_currentPreviewTitle-1]->setPreview( QImage() );
+
+ // cancel if we got hidden or if the medium changed.
+ if( isVisible() && m_medium == k3bappcore->mediaCache()->medium( m_dvd.device() ) ) {
+ ++m_currentPreviewTitle;
+ if( m_currentPreviewTitle <= m_dvd.numTitles() )
+ m_previewGen->generatePreview( m_dvd, m_currentPreviewTitle );
+ }
+}
+
+
+void K3bVideoDVDRippingTitleListView::hideEvent( QHideEvent* e )
+{
+ //
+ // For now we do it the easy way: just stop the preview generation
+ // once this view is hidden
+ //
+ m_previewGen->cancel();
+
+ K3bListView::hideEvent( e );
+}
+
+#include "k3bvideodvdrippingtitlelistview.moc"
diff --git a/src/rip/videodvd/k3bvideodvdrippingtitlelistview.h b/src/rip/videodvd/k3bvideodvdrippingtitlelistview.h
new file mode 100644
index 0000000..7c21815
--- /dev/null
+++ b/src/rip/videodvd/k3bvideodvdrippingtitlelistview.h
@@ -0,0 +1,58 @@
+/*
+ *
+ * $Id: sourceheader 511311 2006-02-19 14:51:05Z trueg $
+ * Copyright (C) 2006 Sebastian Trueg <trueg@k3b.org>
+ *
+ * This file is part of the K3b project.
+ * Copyright (C) 1998-2007 Sebastian Trueg <trueg@k3b.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ * See the file "COPYING" for the exact licensing terms.
+ */
+
+#ifndef _K3B_VIDEODVD_RIPPING_TITLE_LISTVIEW_H_
+#define _K3B_VIDEODVD_RIPPING_TITLE_LISTVIEW_H_
+
+#include <k3blistview.h>
+#include <k3bvideodvd.h>
+#include <k3bmedium.h>
+
+#include <qvaluevector.h>
+
+
+class K3bVideoDVDRippingPreview;
+class QHideEvent;
+
+class K3bVideoDVDRippingTitleListView : public K3bListView
+{
+ Q_OBJECT
+
+ public:
+ K3bVideoDVDRippingTitleListView( QWidget* parent );
+ ~K3bVideoDVDRippingTitleListView();
+
+ void setVideoDVD( const K3bVideoDVD::VideoDVD& dvd );
+
+ private slots:
+ void slotPreviewDone( bool );
+
+ private:
+ void hideEvent( QHideEvent* );
+
+ class TitleViewItem;
+ class TitleToolTip;
+
+ TitleToolTip* m_toolTip;
+
+ QValueVector<TitleViewItem*> m_itemMap;
+ K3bVideoDVDRippingPreview* m_previewGen;
+ unsigned int m_currentPreviewTitle;
+
+ K3bVideoDVD::VideoDVD m_dvd;
+ K3bMedium m_medium;
+};
+
+#endif
diff --git a/src/rip/videodvd/k3bvideodvdrippingview.cpp b/src/rip/videodvd/k3bvideodvdrippingview.cpp
new file mode 100644
index 0000000..f6c8c8d
--- /dev/null
+++ b/src/rip/videodvd/k3bvideodvdrippingview.cpp
@@ -0,0 +1,256 @@
+/*
+ *
+ * $Id: sourceheader 511311 2006-02-19 14:51:05Z trueg $
+ * Copyright (C) 2006 Sebastian Trueg <trueg@k3b.org>
+ *
+ * This file is part of the K3b project.
+ * Copyright (C) 1998-2007 Sebastian Trueg <trueg@k3b.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ * See the file "COPYING" for the exact licensing terms.
+ */
+
+#include "k3bvideodvdrippingview.h"
+#include "k3bvideodvdrippingtitlelistview.h"
+#include "k3bvideodvdrippingdialog.h"
+
+#include <k3bvideodvd.h>
+#include <k3bvideodvdtitletranscodingjob.h>
+#include <k3btoolbox.h>
+#include <k3bthememanager.h>
+#include <k3bglobals.h>
+#include <k3blibdvdcss.h>
+#include <k3bcore.h>
+#include <k3bexternalbinmanager.h>
+
+#include <qcursor.h>
+#include <qlayout.h>
+#include <qlabel.h>
+
+#include <kapplication.h>
+#include <kmessagebox.h>
+#include <klocale.h>
+#include <kaction.h>
+#include <kconfig.h>
+
+
+K3bVideoDVDRippingView::K3bVideoDVDRippingView( QWidget* parent, const char * name )
+ : K3bMediaContentsView( true,
+ K3bMedium::CONTENT_VIDEO_DVD,
+ K3bDevice::MEDIA_DVD_ALL,
+ K3bDevice::STATE_INCOMPLETE|K3bDevice::STATE_COMPLETE,
+ parent, name )
+{
+ QGridLayout* mainGrid = new QGridLayout( mainWidget() );
+
+ // toolbox
+ // ----------------------------------------------------------------------------------
+ QHBoxLayout* toolBoxLayout = new QHBoxLayout( 0, 0, 0, "toolBoxLayout" );
+ m_toolBox = new K3bToolBox( mainWidget() );
+ toolBoxLayout->addWidget( m_toolBox );
+ QSpacerItem* spacer = new QSpacerItem( 10, 10, QSizePolicy::Expanding, QSizePolicy::Minimum );
+ toolBoxLayout->addItem( spacer );
+ m_labelLength = new QLabel( mainWidget() );
+ m_labelLength->setAlignment( int( QLabel::AlignVCenter | QLabel::AlignRight ) );
+ toolBoxLayout->addWidget( m_labelLength );
+
+
+ // the title view
+ // ----------------------------------------------------------------------------------
+ m_titleView = new K3bVideoDVDRippingTitleListView( mainWidget() );
+
+ connect( m_titleView, SIGNAL(contextMenu(KListView*, QListViewItem*, const QPoint&)),
+ this, SLOT(slotContextMenu(KListView*, QListViewItem*, const QPoint&)) );
+
+ // general layout
+ // ----------------------------------------------------------------------------------
+ mainGrid->addLayout( toolBoxLayout, 0, 0 );
+ mainGrid->addWidget( m_titleView, 1, 0 );
+
+
+ initActions();
+
+ m_toolBox->addButton( actionCollection()->action("start_rip"), true );
+
+ setLeftPixmap( K3bTheme::MEDIA_LEFT );
+ setRightPixmap( K3bTheme::MEDIA_VIDEO );
+}
+
+
+K3bVideoDVDRippingView::~K3bVideoDVDRippingView()
+{
+}
+
+
+void K3bVideoDVDRippingView::reloadMedium()
+{
+ //
+ // For VideoDVD reading it is important that the DVD is not mounted
+ //
+ if( K3b::isMounted( device() ) && !K3b::unmount( device() ) ) {
+ KMessageBox::error( this,
+ i18n("K3b was unable to unmount device '%1' containing medium '%2'. "
+ "Video DVD ripping will not work if the device is mounted. "
+ "Please unmount manually."),
+ i18n("Unmounting failed") );
+ }
+
+ //
+ // K3bVideoDVD::open does not necessarily fail on encrypted DVDs if dvdcss is not
+ // available. Thus, we test the availability of libdvdcss here
+ //
+ if( device()->copyrightProtectionSystemType() == 1 ) {
+ K3bLibDvdCss* css = K3bLibDvdCss::create();
+ if( !css ) {
+ KMessageBox::error( this, i18n("<p>Unable to read Video DVD contents: Found encrypted Video DVD."
+ "<p>Install <i>libdvdcss</i> to get Video DVD decryption support.") );
+ return;
+ }
+ else
+ delete css;
+ }
+
+ QApplication::setOverrideCursor( QCursor(Qt::WaitCursor) );
+
+ if( m_dvd.open( device() ) ) {
+ setTitle( medium().beautifiedVolumeId() + " (" + i18n("Video DVD") + ")" );
+ m_labelLength->setText( i18n("%n title", "%n titles", m_dvd.numTitles() ) );
+ m_titleView->setVideoDVD( m_dvd );
+ QApplication::restoreOverrideCursor();
+
+ bool transcodeUsable = true;
+
+ if( !k3bcore ->externalBinManager() ->foundBin( "transcode" ) ) {
+ KMessageBox::sorry( this,
+ i18n("K3b uses transcode to rip Video DVDs. "
+ "Please make sure it is installed.") );
+ transcodeUsable = false;
+ }
+ else {
+ int vc = 0, ac = 0;
+ for( int i = 0; i < K3bVideoDVDTitleTranscodingJob::VIDEO_CODEC_NUM_ENTRIES; ++i )
+ if( K3bVideoDVDTitleTranscodingJob::transcodeBinaryHasSupportFor( (K3bVideoDVDTitleTranscodingJob::VideoCodec)i ) )
+ ++vc;
+ for( int i = 0; i < K3bVideoDVDTitleTranscodingJob::AUDIO_CODEC_NUM_ENTRIES; ++i )
+ if( K3bVideoDVDTitleTranscodingJob::transcodeBinaryHasSupportFor( (K3bVideoDVDTitleTranscodingJob::AudioCodec)i ) )
+ ++ac;
+ if( !ac || !vc ) {
+ KMessageBox::sorry( this,
+ i18n("<p>K3b uses transcode to rip Video DVDs. "
+ "Your installation of transcode (<em>%1</em>) lacks support for any of the "
+ "codecs supported by K3b."
+ "<p>Please make sure it is installed properly.") );
+ transcodeUsable = false;
+ }
+ }
+
+ actionCollection()->action("start_rip")->setEnabled( transcodeUsable );
+ }
+ else {
+ QApplication::restoreOverrideCursor();
+
+ KMessageBox::error( this, i18n("Unable to read Video DVD contents.") );
+ }
+}
+
+
+void K3bVideoDVDRippingView::slotStartRipping()
+{
+ QValueList<int> titles;
+ int i = 1;
+ for( QListViewItemIterator it( m_titleView ); *it; ++it, ++i )
+ if( static_cast<K3bCheckListViewItem*>( *it )->isChecked() )
+ titles.append( i );
+
+ if( titles.isEmpty() ) {
+ KMessageBox::error( this, i18n("Please select the titles to rip."),
+ i18n("No Titles Selected") );
+ }
+ else {
+ K3bVideoDVDRippingDialog dlg( m_dvd, titles, this );
+ dlg.exec();
+ }
+}
+
+
+void K3bVideoDVDRippingView::slotContextMenu( KListView*, QListViewItem*, const QPoint& p )
+{
+ m_popupMenu->popup(p);
+}
+
+
+void K3bVideoDVDRippingView::slotCheckAll()
+{
+ for( QListViewItemIterator it( m_titleView ); it.current(); ++it )
+ dynamic_cast<K3bCheckListViewItem*>(it.current())->setChecked(true);
+}
+
+
+void K3bVideoDVDRippingView::slotUncheckAll()
+{
+ for( QListViewItemIterator it( m_titleView ); it.current(); ++it )
+ dynamic_cast<K3bCheckListViewItem*>(it.current())->setChecked(false);
+}
+
+
+void K3bVideoDVDRippingView::slotCheck()
+{
+ QPtrList<QListViewItem> items( m_titleView->selectedItems() );
+ for( QPtrListIterator<QListViewItem> it( items );
+ it.current(); ++it )
+ dynamic_cast<K3bCheckListViewItem*>(it.current())->setChecked(true);
+}
+
+
+void K3bVideoDVDRippingView::slotUncheck()
+{
+ QPtrList<QListViewItem> items( m_titleView->selectedItems() );
+ for( QPtrListIterator<QListViewItem> it( items );
+ it.current(); ++it )
+ dynamic_cast<K3bCheckListViewItem*>(it.current())->setChecked(false);
+}
+
+
+void K3bVideoDVDRippingView::initActions()
+{
+ m_actionCollection = new KActionCollection( this );
+
+ KAction* actionSelectAll = new KAction( i18n("Check All"), 0, 0, this,
+ SLOT(slotCheckAll()), actionCollection(),
+ "check_all" );
+ KAction* actionDeselectAll = new KAction( i18n("Uncheck All"), 0, 0, this,
+ SLOT(slotUncheckAll()), actionCollection(),
+ "uncheck_all" );
+ KAction* actionSelect = new KAction( i18n("Check Track"), 0, 0, this,
+ SLOT(slotCheck()), actionCollection(),
+ "select_track" );
+ KAction* actionDeselect = new KAction( i18n("Uncheck Track"), 0, 0, this,
+ SLOT(slotUncheck()), actionCollection(),
+ "deselect_track" );
+ KAction* actionStartRip = new KAction( i18n("Start Ripping"), "gear", 0, this,
+ SLOT(slotStartRipping()), m_actionCollection, "start_rip" );
+
+ actionStartRip->setToolTip( i18n("Open the Video DVD ripping dialog") );
+
+ // setup the popup menu
+ m_popupMenu = new KActionMenu( actionCollection(), "popup_menu" );
+ KAction* separator = new KActionSeparator( actionCollection(), "separator" );
+ m_popupMenu->insert( actionSelect );
+ m_popupMenu->insert( actionDeselect );
+ m_popupMenu->insert( actionSelectAll );
+ m_popupMenu->insert( actionDeselectAll );
+ m_popupMenu->insert( separator );
+ m_popupMenu->insert( actionStartRip );
+}
+
+
+void K3bVideoDVDRippingView::enableInteraction( bool enable )
+{
+ actionCollection()->action( "start_rip" )->setEnabled( enable );
+}
+
+
+#include "k3bvideodvdrippingview.moc"
diff --git a/src/rip/videodvd/k3bvideodvdrippingview.h b/src/rip/videodvd/k3bvideodvdrippingview.h
new file mode 100644
index 0000000..679ea09
--- /dev/null
+++ b/src/rip/videodvd/k3bvideodvdrippingview.h
@@ -0,0 +1,66 @@
+/*
+ *
+ * $Id: sourceheader 511311 2006-02-19 14:51:05Z trueg $
+ * Copyright (C) 2006 Sebastian Trueg <trueg@k3b.org>
+ *
+ * This file is part of the K3b project.
+ * Copyright (C) 1998-2007 Sebastian Trueg <trueg@k3b.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ * See the file "COPYING" for the exact licensing terms.
+ */
+
+#ifndef _K3B_VIDEODVD_RIPPING_VIEW_H_
+#define _K3B_VIDEODVD_RIPPING_VIEW_H_
+
+#include <k3bmediacontentsview.h>
+#include <k3bmedium.h>
+#include <k3bvideodvd.h>
+
+class K3bVideoDVDRippingTitleListView;
+class K3bToolBox;
+class QLabel;
+class KActionCollection;
+class KActionMenu;
+class KListView;
+class QListViewItem;
+
+class K3bVideoDVDRippingView : public K3bMediaContentsView
+{
+ Q_OBJECT
+
+ public:
+ K3bVideoDVDRippingView( QWidget* parent = 0, const char * name = 0 );
+ ~K3bVideoDVDRippingView();
+
+ KActionCollection* actionCollection() const { return m_actionCollection; }
+
+ private slots:
+ void slotStartRipping();
+
+ void slotContextMenu( KListView*, QListViewItem*, const QPoint& );
+
+ void slotCheckAll();
+ void slotUncheckAll();
+ void slotCheck();
+ void slotUncheck();
+
+ private:
+ void reloadMedium();
+ void enableInteraction( bool enable );
+ void initActions();
+
+ KActionCollection* m_actionCollection;
+ KActionMenu* m_popupMenu;
+
+ K3bToolBox* m_toolBox;
+ QLabel* m_labelLength;
+ K3bVideoDVDRippingTitleListView* m_titleView;
+
+ K3bVideoDVD::VideoDVD m_dvd;
+};
+
+#endif
diff --git a/src/rip/videodvd/k3bvideodvdrippingwidget.cpp b/src/rip/videodvd/k3bvideodvdrippingwidget.cpp
new file mode 100644
index 0000000..721d191
--- /dev/null
+++ b/src/rip/videodvd/k3bvideodvdrippingwidget.cpp
@@ -0,0 +1,375 @@
+/*
+ *
+ * $Id: sourceheader 511311 2006-02-19 14:51:05Z trueg $
+ * Copyright (C) 2006 Sebastian Trueg <trueg@k3b.org>
+ *
+ * This file is part of the K3b project.
+ * Copyright (C) 1998-2007 Sebastian Trueg <trueg@k3b.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ * See the file "COPYING" for the exact licensing terms.
+ */
+
+#include "k3bvideodvdrippingwidget.h"
+
+#include <k3bvideodvdtitletranscodingjob.h>
+#include <k3bglobals.h>
+#include <k3brichtextlabel.h>
+#include <k3bintmapcombobox.h>
+
+#include <klistview.h>
+#include <klocale.h>
+#include <kurlrequester.h>
+#include <kio/global.h>
+#include <kurllabel.h>
+#include <kdialogbase.h>
+#include <klineedit.h>
+
+#include <qcombobox.h>
+#include <qspinbox.h>
+#include <qlabel.h>
+#include <qtimer.h>
+#include <qwhatsthis.h>
+#include <qwidgetstack.h>
+#include <qpushbutton.h>
+#include <qcheckbox.h>
+#include <qlayout.h>
+
+
+static const int s_mp3Bitrates[] = {
+ 32,
+ 40,
+ 48,
+ 56,
+ 64,
+ 80,
+ 96,
+ 112,
+ 128,
+ 160,
+ 192,
+ 224,
+ 256,
+ 320,
+ 0 // just used for the loops below
+};
+
+
+static const int PICTURE_SIZE_ORIGINAL = 0;
+static const int PICTURE_SIZE_640 = 1;
+static const int PICTURE_SIZE_320 = 2;
+static const int PICTURE_SIZE_CUSTOM = 3;
+static const int PICTURE_SIZE_MAX = 4;
+
+static const char* s_pictureSizeNames[] = {
+ I18N_NOOP("Keep original dimensions"),
+ I18N_NOOP("640x? (automatic height)"),
+ I18N_NOOP("320x? (automatic height)"),
+ I18N_NOOP("Custom")
+};
+
+
+K3bVideoDVDRippingWidget::K3bVideoDVDRippingWidget( QWidget* parent )
+ : base_K3bVideoDVDRippingWidget( parent )
+{
+ m_editBaseDir->setMode( KFile::Directory | KFile::ExistingOnly | KFile::LocalOnly );
+
+ m_titleView->addColumn( i18n("Title") );
+ m_titleView->addColumn( i18n("Video Size") );
+ m_titleView->addColumn( i18n("File Size") );
+ m_titleView->addColumn( i18n("Filename") );
+ m_titleView->setSorting( -1 );
+
+ //
+ // Example filename pattern
+ //
+ m_comboFilenamePattern->insertItem( QString( "%b - %1 %t (%n %a %c)" ).arg(i18n("Title") ) );
+ m_comboFilenamePattern->insertItem( QString( "%{volumeid} (%{title})" ) );
+
+
+ //
+ // Add the Audio bitrates
+ //
+ for( int i = 0; s_mp3Bitrates[i]; ++i )
+ m_comboAudioBitrate->insertItem( i18n("%1 kbps" ).arg(s_mp3Bitrates[i]) );
+
+
+ for( int i = 0; i < K3bVideoDVDTitleTranscodingJob::VIDEO_CODEC_NUM_ENTRIES; ++i ) {
+ K3bVideoDVDTitleTranscodingJob::VideoCodec codec( (K3bVideoDVDTitleTranscodingJob::VideoCodec)i );
+ if( K3bVideoDVDTitleTranscodingJob::transcodeBinaryHasSupportFor( codec ) )
+ m_comboVideoCodec->insertItem( i,
+ K3bVideoDVDTitleTranscodingJob::videoCodecString( codec ),
+ K3bVideoDVDTitleTranscodingJob::videoCodecDescription( codec ) );
+ }
+ for( int i = 0; i < K3bVideoDVDTitleTranscodingJob::AUDIO_CODEC_NUM_ENTRIES; ++i ) {
+ K3bVideoDVDTitleTranscodingJob::AudioCodec codec( (K3bVideoDVDTitleTranscodingJob::AudioCodec)i );
+ if( K3bVideoDVDTitleTranscodingJob::transcodeBinaryHasSupportFor( codec ) )
+ m_comboAudioCodec->insertItem( i,
+ K3bVideoDVDTitleTranscodingJob::audioCodecString( codec ),
+ K3bVideoDVDTitleTranscodingJob::audioCodecDescription( codec ) );
+ }
+
+ for( int i = 0; i < PICTURE_SIZE_MAX; ++i ) {
+ m_comboVideoSize->insertItem( i18n( s_pictureSizeNames[i] ) );
+ }
+
+ slotAudioCodecChanged( m_comboAudioCodec->selectedValue() );
+
+ connect( m_comboAudioBitrate, SIGNAL(textChanged(const QString&)),
+ this, SIGNAL(changed()) );
+ connect( m_spinVideoBitrate, SIGNAL(valueChanged(int)),
+ this, SIGNAL(changed()) );
+ connect( m_checkBlankReplace, SIGNAL(toggled(bool)),
+ this, SIGNAL(changed()) );
+ connect( m_editBlankReplace, SIGNAL(textChanged(const QString&)),
+ this, SIGNAL(changed()) );
+ connect( m_comboFilenamePattern, SIGNAL(textChanged(const QString&)),
+ this, SIGNAL(changed()) );
+ connect( m_editBaseDir, SIGNAL(textChanged(const QString&)),
+ this, SIGNAL(changed()) );
+
+ connect( m_comboAudioCodec, SIGNAL(valueChanged(int)),
+ this, SLOT(slotAudioCodecChanged(int)) );
+ connect( m_specialStringsLabel, SIGNAL(leftClickedURL()),
+ this, SLOT(slotSeeSpecialStrings()) );
+ connect( m_buttonCustomPictureSize, SIGNAL(clicked()),
+ this, SLOT(slotCustomPictureSize()) );
+ connect( m_comboVideoSize, SIGNAL(activated(int)),
+ this, SLOT(slotVideoSizeChanged(int)) );
+
+ // refresh every 2 seconds
+ m_freeSpaceUpdateTimer = new QTimer( this );
+ connect( m_freeSpaceUpdateTimer, SIGNAL(timeout()),
+ this, SLOT(slotUpdateFreeTempSpace()) );
+ m_freeSpaceUpdateTimer->start(2000);
+ slotUpdateFreeTempSpace();
+}
+
+
+K3bVideoDVDRippingWidget::~K3bVideoDVDRippingWidget()
+{
+}
+
+
+K3bVideoDVDTitleTranscodingJob::VideoCodec K3bVideoDVDRippingWidget::selectedVideoCodec() const
+{
+ return (K3bVideoDVDTitleTranscodingJob::VideoCodec)m_comboVideoCodec->selectedValue();
+}
+
+
+QSize K3bVideoDVDRippingWidget::selectedPictureSize() const
+{
+ switch( m_comboVideoSize->currentItem() ) {
+ case PICTURE_SIZE_ORIGINAL:
+ return QSize(0,0);
+ case PICTURE_SIZE_640:
+ return QSize(640,0);
+ case PICTURE_SIZE_320:
+ return QSize(320,0);
+ default:
+ return m_customVideoSize;
+ }
+}
+
+
+void K3bVideoDVDRippingWidget::setSelectedPictureSize( const QSize& size )
+{
+ m_customVideoSize = size;
+ if( size == QSize(0,0) )
+ m_comboVideoSize->setCurrentItem( PICTURE_SIZE_ORIGINAL );
+ else if( size == QSize(640,0) )
+ m_comboVideoSize->setCurrentItem( PICTURE_SIZE_640 );
+ else if( size == QSize(320,0) )
+ m_comboVideoSize->setCurrentItem( PICTURE_SIZE_320 );
+ else {
+ m_comboVideoSize->changeItem( i18n(s_pictureSizeNames[PICTURE_SIZE_CUSTOM])
+ + QString(" (%1x%2)")
+ .arg(size.width() == 0 ? i18n("auto") : QString::number(size.width()))
+ .arg(size.height() == 0 ? i18n("auto") : QString::number(size.height())),
+ PICTURE_SIZE_CUSTOM );
+ m_comboVideoSize->setCurrentItem( PICTURE_SIZE_CUSTOM );
+ }
+}
+
+
+void K3bVideoDVDRippingWidget::setSelectedVideoCodec( K3bVideoDVDTitleTranscodingJob::VideoCodec codec )
+{
+ m_comboVideoCodec->setSelectedValue( (int)codec );
+}
+
+
+K3bVideoDVDTitleTranscodingJob::AudioCodec K3bVideoDVDRippingWidget::selectedAudioCodec() const
+{
+ return (K3bVideoDVDTitleTranscodingJob::AudioCodec)m_comboAudioCodec->selectedValue();
+}
+
+
+void K3bVideoDVDRippingWidget::setSelectedAudioCodec( K3bVideoDVDTitleTranscodingJob::AudioCodec codec )
+{
+ m_comboAudioCodec->setSelectedValue( (int)codec );
+ slotAudioCodecChanged( (int)codec );
+}
+
+
+int K3bVideoDVDRippingWidget::selectedAudioBitrate() const
+{
+ if( selectedAudioCodec() == K3bVideoDVDTitleTranscodingJob::AUDIO_CODEC_MP3 )
+ return s_mp3Bitrates[m_comboAudioBitrate->currentItem()];
+ else
+ return m_spinAudioBitrate->value();
+}
+
+
+void K3bVideoDVDRippingWidget::setSelectedAudioBitrate( int bitrate )
+{
+ m_spinAudioBitrate->setValue( bitrate );
+
+ // select the bitrate closest to "bitrate"
+ int bi = 0;
+ int diff = 1000;
+ for( int i = 0; s_mp3Bitrates[i]; ++i ) {
+ int newDiff = s_mp3Bitrates[i] - bitrate;
+ if( newDiff < 0 )
+ newDiff = -1 * newDiff;
+ if( newDiff < diff ) {
+ diff = newDiff;
+ bi = i;
+ }
+ }
+
+ m_comboAudioBitrate->setCurrentItem( bi );
+}
+
+
+void K3bVideoDVDRippingWidget::slotUpdateFreeTempSpace()
+{
+ QString path = m_editBaseDir->url();
+
+ if( !QFile::exists( path ) )
+ path.truncate( path.findRev('/') );
+
+ unsigned long size, avail;
+ if( K3b::kbFreeOnFs( path, size, avail ) ) {
+ m_labelFreeSpace->setText( KIO::convertSizeFromKB(avail) );
+ if( avail < m_neededSize/1024 )
+ m_labelNeededSpace->setPaletteForegroundColor( Qt::red );
+ else
+ m_labelNeededSpace->setPaletteForegroundColor( paletteForegroundColor() );
+ }
+ else {
+ m_labelFreeSpace->setText("-");
+ m_labelNeededSpace->setPaletteForegroundColor( paletteForegroundColor() );
+ }
+}
+
+
+void K3bVideoDVDRippingWidget::setNeededSize( KIO::filesize_t size )
+{
+ m_neededSize = size;
+ if( size > 0 )
+ m_labelNeededSpace->setText( KIO::convertSize( size ) );
+ else
+ m_labelNeededSpace->setText( i18n("unknown") );
+
+ slotUpdateFreeTempSpace();
+}
+
+
+void K3bVideoDVDRippingWidget::slotSeeSpecialStrings()
+{
+ QWhatsThis::display( i18n( "<p><b>Pattern special strings:</b>"
+ "<p>The following strings will be replaced with their respective meaning in every "
+ "track name.<br>"
+ "<p><table border=\"0\">"
+ "<tr><td></td><td><em>Meaning</em></td><td><em>Alternatives</em></td></tr>"
+ "<tr><td>%t</td><td>title number</td><td>%{t} or %{title_number}</td></tr>"
+ "<tr><td>%i</td><td>volume id (mostly the name of the Video DVD)</td><td>%{i} or %{volume_id}</td></tr>"
+ "<tr><td>%b</td><td>beautified volume id</td><td>%{b} or %{beautified_volume_id}</td></tr>"
+ "<tr><td>%l</td><td>two chars language code</td><td>%{l} or %{lang_code}</td></tr>"
+ "<tr><td>%n</td><td>language name</td><td>%{n} or %{lang_name}</td></tr>"
+ "<tr><td>%a</td><td>audio format (on the Video DVD)</td><td>%{a} or %{audio_format}</td></tr>"
+ "<tr><td>%c</td><td>number of audio channels (on the Video DVD)</td><td>%{c} or %{channels}</td></tr>"
+ "<tr><td>%v</td><td>size of the original video</td><td>%{v} or %{orig_video_size}</td></tr>"
+ "<tr><td>%s</td><td>size of the resulting video (<em>Caution: auto-clipping values are not taken into account!</em>)</td><td>%{s} or %{video_size}</td></tr>"
+ "<tr><td>%r</td><td>aspect ratio of the original video</td><td>%{r} or %{aspect_ratio}</td></tr>"
+ "<tr><td>%d</td><td>current date</td><td>%{d} or %{date}</td></tr>"
+ "</table>"
+ "<p><em>Hint: K3b also accepts slight variations of the long special strings. "
+ "One can, for example, leave out the underscores.</em>") );
+}
+
+
+void K3bVideoDVDRippingWidget::slotAudioCodecChanged( int codec )
+{
+ switch( codec ) {
+ case K3bVideoDVDTitleTranscodingJob::AUDIO_CODEC_MP3:
+ m_stackAudioQuality->raiseWidget( m_stackPageAudioQualityMp3 );
+ break;
+ case K3bVideoDVDTitleTranscodingJob::AUDIO_CODEC_AC3_STEREO:
+ m_stackAudioQuality->raiseWidget( m_stackPageAudioQualityAC3 );
+ break;
+ case K3bVideoDVDTitleTranscodingJob::AUDIO_CODEC_AC3_PASSTHROUGH:
+ m_stackAudioQuality->raiseWidget( m_stackPageAudioQualityAC3Pt );
+ break;
+ }
+
+ emit changed();
+}
+
+
+void K3bVideoDVDRippingWidget::slotVideoSizeChanged( int sizeIndex )
+{
+ if( sizeIndex == PICTURE_SIZE_CUSTOM )
+ slotCustomPictureSize();
+ else
+ emit changed();
+}
+
+
+void K3bVideoDVDRippingWidget::slotCustomPictureSize()
+{
+ KDialogBase dlg( KDialogBase::Plain,
+ i18n("Video Picture Size"),
+ KDialogBase::Ok|KDialogBase::Cancel,
+ KDialogBase::Ok,
+ this,
+ 0,
+ true,
+ true );
+ K3bRichTextLabel* label = new K3bRichTextLabel( i18n("<p>Please choose the width and height of the resulting video. "
+ "If one value is set to <em>Auto</em> K3b will choose this value "
+ "depending on the aspect ratio of the video picture.<br>"
+ "Be aware that setting both the width and the height to fixed values "
+ "will result in no aspect ratio correction to be performed."),
+ dlg.plainPage() );
+ QSpinBox* spinWidth = new QSpinBox( 0, 20000, 16, dlg.plainPage() );
+ QSpinBox* spinHeight = new QSpinBox( 0, 20000, 16, dlg.plainPage() );
+ spinWidth->setSpecialValueText( i18n("Auto") );
+ spinHeight->setSpecialValueText( i18n("Auto") );
+ QLabel* labelW = new QLabel( spinWidth, i18n("Width") + ':', dlg.plainPage() );
+ QLabel* labelH = new QLabel( spinHeight, i18n("Height") + ':', dlg.plainPage() );
+ labelW->setAlignment( Qt::AlignRight|Qt::AlignVCenter );
+ labelH->setAlignment( Qt::AlignRight|Qt::AlignVCenter );
+
+ QGridLayout* grid = new QGridLayout( dlg.plainPage() );
+ grid->setMargin( 0 );
+ grid->setSpacing( KDialog::spacingHint() );
+ grid->addMultiCellWidget( label, 0, 0, 0, 3 );
+ grid->addWidget( labelW, 1, 0 );
+ grid->addWidget( spinWidth, 1, 1 );
+ grid->addWidget( labelH, 1, 2 );
+ grid->addWidget( spinHeight, 1, 3 );
+
+ spinWidth->setValue( m_customVideoSize.width() );
+ spinHeight->setValue( m_customVideoSize.height() );
+
+ if( dlg.exec() ) {
+ setSelectedPictureSize( QSize( spinWidth->value(), spinHeight->value() ) );
+ emit changed();
+ }
+}
+
+#include "k3bvideodvdrippingwidget.moc"
diff --git a/src/rip/videodvd/k3bvideodvdrippingwidget.h b/src/rip/videodvd/k3bvideodvdrippingwidget.h
new file mode 100644
index 0000000..2d10da7
--- /dev/null
+++ b/src/rip/videodvd/k3bvideodvdrippingwidget.h
@@ -0,0 +1,67 @@
+/*
+ *
+ * $Id: sourceheader 511311 2006-02-19 14:51:05Z trueg $
+ * Copyright (C) 2006 Sebastian Trueg <trueg@k3b.org>
+ *
+ * This file is part of the K3b project.
+ * Copyright (C) 1998-2007 Sebastian Trueg <trueg@k3b.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ * See the file "COPYING" for the exact licensing terms.
+ */
+
+#ifndef _K3B_VIDEODVD_RIPPING_WIDGET_H_
+#define _K3B_VIDEODVD_RIPPING_WIDGET_H_
+
+#include "base_k3bvideodvdrippingwidget.h"
+
+#include <k3bvideodvdtitletranscodingjob.h>
+
+#include <qvaluevector.h>
+#include <qmap.h>
+
+#include <kio/global.h>
+
+class QTimer;
+
+class K3bVideoDVDRippingWidget : public base_K3bVideoDVDRippingWidget
+{
+ Q_OBJECT
+
+ public:
+ K3bVideoDVDRippingWidget( QWidget* parent );
+ ~K3bVideoDVDRippingWidget();
+
+ K3bVideoDVDTitleTranscodingJob::VideoCodec selectedVideoCodec() const;
+ K3bVideoDVDTitleTranscodingJob::AudioCodec selectedAudioCodec() const;
+ int selectedAudioBitrate() const;
+ QSize selectedPictureSize() const;
+
+ void setSelectedVideoCodec( K3bVideoDVDTitleTranscodingJob::VideoCodec codec );
+ void setSelectedAudioCodec( K3bVideoDVDTitleTranscodingJob::AudioCodec codec );
+ void setSelectedAudioBitrate( int bitrate );
+ void setSelectedPictureSize( const QSize& );
+
+ void setNeededSize( KIO::filesize_t );
+
+ signals:
+ void changed();
+
+ private slots:
+ void slotUpdateFreeTempSpace();
+ void slotSeeSpecialStrings();
+ void slotAudioCodecChanged( int codec );
+ void slotVideoSizeChanged( int sizeIndex );
+ void slotCustomPictureSize();
+
+ private:
+ QTimer* m_freeSpaceUpdateTimer;
+ KIO::filesize_t m_neededSize;
+
+ QSize m_customVideoSize;
+};
+
+#endif