1 /* ***** BEGIN LICENSE BLOCK *****
5 * Copyright (c) 2008 BBC Research
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to deal
9 * in the Software without restriction, including without limitation the rights
10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 * copies of the Software, and to permit persons to whom the Software is
12 * furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 * ***** END LICENSE BLOCK ***** */
27 #include "mainwindow.h"
29 #include "GLvideo_mt.h"
30 #include "videoTransport.h"
32 MainWindow::MainWindow(GLvideo_params
& vr_params
, Qt_params
& qt_params
, VideoTransport
*vt
) :
33 vr_params(vr_params
), vr_params_orig(vr_params
), video_transport(vt
)
35 QPalette p
= palette();
36 p
.setColor(QPalette::Window
, Qt::black
);
39 if (qt_params
.hidemouse
) {
40 //hide the mouse pointer from the start if requestes
41 setCursor(QCursor(Qt::BlankCursor
));
44 setWindowTitle("VideoPlayer");
45 setFullScreen(qt_params
.start_fullscreen
);
47 //central widget is the threaded openGL video widget
48 //which pulls video from the videoRead
49 //and gets stats for the OSD from the readThread
50 glvideo_mt
= new GLvideo_mt(this, vt
, vr_params
);
52 setCentralWidget(glvideo_mt
);
59 //generate actions for menus and keypress handlers
60 void MainWindow::createActions()
62 #define ADDACT(str, key, target, fn) \
63 do { QAction *a = new QAction(str, this); \
64 a->setShortcut(tr(key)); \
66 connect(a, SIGNAL(triggered()), target, SLOT(fn())); \
69 ADDACT("Quit", "Q", qApp
, quit
);
70 ADDACT("Use user Matrix", "k", this, setUserMatrix
);
71 ADDACT("Set HDTV Matrix", "h", this, setHDTVMatrix
);
72 ADDACT("Set SDTV Matrix", "j", this, setSDTVMatrix
);
73 ADDACT("Use user matrix scaling", "m", this, setUserMatrixScaling
);
74 ADDACT("Use computer graphics matrix scaling", "b", this, setCgrMatrixScaling
);
75 ADDACT("Use video levels matrix scaling", "n", this, setVideoMatrixScaling
);
76 ADDACT("Toggle deinterlacing", "i", this, toggleDeinterlace
);
77 ADDACT("Toggle OSD", "o", this, toggleOSD
);
78 ADDACT("Toggle performance", "?", this, togglePerf
);
79 ADDACT("Toggle luma", "y", this, toggleLuminance
);
80 ADDACT("Toggle chroma", "c", this, toggleChrominance
);
81 ADDACT("Toggle aspect ratio Lock", "a", this, toggleAspectLock
);
82 ADDACT("Toggle full screen", "f", this, toggleFullScreen
);
83 ADDACT("Escape full screen", "Escape", this, escapeFullScreen
);
84 ADDACT("Forward 1x", "1", video_transport
, transportFwd1
);
85 ADDACT("Forward 2x", "2", video_transport
, transportFwd2
);
86 ADDACT("Forward 5x", "3", video_transport
, transportFwd5
);
87 ADDACT("Forward 10x", "4", video_transport
, transportFwd10
);
88 ADDACT("Forward 20x", "5", video_transport
, transportFwd20
);
89 ADDACT("Forward 50x", "6", video_transport
, transportFwd50
);
90 ADDACT("Forward 100x", "7", video_transport
, transportFwd100
);
91 ADDACT("Stop", "s", video_transport
, transportStop
);
92 ADDACT("Reverse 1x", "Ctrl+1", video_transport
, transportRev1
);
93 ADDACT("Reverse 2x", "Ctrl+2", video_transport
, transportRev2
);
94 ADDACT("Reverse 5x", "Ctrl+3", video_transport
, transportRev5
);
95 ADDACT("Reverse 10x", "Ctrl+4", video_transport
, transportRev10
);
96 ADDACT("Reverse 20x", "Ctrl+5", video_transport
, transportRev20
);
97 ADDACT("Reverse 50x", "Ctrl+6", video_transport
, transportRev50
);
98 ADDACT("Reverse 100x", "Ctrl+7", video_transport
, transportRev100
);
99 ADDACT("Play/Pause", "Space", video_transport
, transportPlayPause
);
100 ADDACT("Jog Forward", ".", video_transport
, transportJogFwd
);
101 ADDACT("Jog Reverse", ",", video_transport
, transportJogRev
);
104 //slot to receive full screen toggle command
105 void MainWindow::toggleFullScreen()
107 setFullScreen(!isFullScreen());
110 void MainWindow::escapeFullScreen()
113 setFullScreen(false);
116 //full screen toggle worker
117 void MainWindow::setFullScreen(bool fullscreen
)
127 void MainWindow::setHDTVMatrix()
129 SetLumaCoeffsRec709(vr_params
);
130 vr_params
.matrix_valid
= false;
133 void MainWindow::setSDTVMatrix()
135 SetLumaCoeffsRec601(vr_params
);
136 vr_params
.matrix_valid
= false;
139 void MainWindow::setUserMatrix()
141 vr_params
.matrix_Kr
= vr_params_orig
.matrix_Kr
;
142 vr_params
.matrix_Kg
= vr_params_orig
.matrix_Kg
;
143 vr_params
.matrix_Kb
= vr_params_orig
.matrix_Kb
;
144 vr_params
.matrix_valid
= false;
147 void MainWindow::setUserMatrixScaling()
149 vr_params
.output_range
= vr_params_orig
.output_range
;
150 vr_params
.output_blacklevel
= vr_params_orig
.output_blacklevel
;
151 vr_params
.matrix_valid
= false;
154 void MainWindow::setVideoMatrixScaling()
156 vr_params
.output_range
= 220;
157 vr_params
.output_blacklevel
= 16;
158 vr_params
.matrix_valid
= false;
161 void MainWindow::setCgrMatrixScaling()
163 vr_params
.output_range
= 256;
164 vr_params
.output_blacklevel
= 0;
165 vr_params
.matrix_valid
= false;
168 void MainWindow::togglePerf()
170 vr_params
.osd_perf
^= 1;
173 void MainWindow::toggleOSD()
178 void MainWindow::toggleAspectLock()
180 vr_params
.aspect_ratio_lock
^= 1;
181 vr_params
.view_valid
= false;
184 void MainWindow::toggleLuminance()
186 vr_params
.show_luma
^= 1;
187 if (vr_params
.show_luma
) {
188 vr_params
.luminance_mul
= vr_params_orig
.luminance_mul
;
189 vr_params
.luminance_offset2
= vr_params_orig
.luminance_offset2
;
192 vr_params
.luminance_mul
= 0.;
193 vr_params
.luminance_offset2
= 128./255.;
195 vr_params
.matrix_valid
= false;
198 void MainWindow::toggleChrominance()
200 vr_params
.show_chroma
^= 1;
201 if (vr_params
.show_chroma
) {
202 vr_params
.chrominance_mul
= vr_params_orig
.chrominance_mul
;
203 vr_params
.chrominance_offset2
= vr_params_orig
.chrominance_offset2
;
206 vr_params
.chrominance_mul
= 0.;
207 vr_params
.chrominance_offset2
= 0.;
209 vr_params
.matrix_valid
= false;
212 void MainWindow::toggleDeinterlace()
214 vr_params
.deinterlace
^= 1;