Diffstat (limited to 'noncore/multimedia/opieplayer2/videowidget.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/multimedia/opieplayer2/videowidget.cpp | 171 |
1 files changed, 41 insertions, 130 deletions
diff --git a/noncore/multimedia/opieplayer2/videowidget.cpp b/noncore/multimedia/opieplayer2/videowidget.cpp index 5625c0e..8fdb3d3 100644 --- a/noncore/multimedia/opieplayer2/videowidget.cpp +++ b/noncore/multimedia/opieplayer2/videowidget.cpp | |||
@@ -1,3 +1,35 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | |||
4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> | ||
5 | Copyright (c) 2002 L. Potter <ljp@llornkcor.com> | ||
6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> | ||
7 | =. | ||
8 | .=l. | ||
9 | .>+-= | ||
10 | _;:, .> :=|. This program is free software; you can | ||
11 | .> <`_, > . <= redistribute it and/or modify it under | ||
12 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | ||
13 | .="- .-=="i, .._ License as published by the Free Software | ||
14 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
15 | ._= =} : or (at your option) any later version. | ||
16 | .%`+i> _;_. | ||
17 | .i_,=:_. -<s. This program is distributed in the hope that | ||
18 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
19 | : .. .:, . . . without even the implied warranty of | ||
20 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
21 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
22 | ..}^=.= = ; Library General Public License for more | ||
23 | ++= -. .` .: details. | ||
24 | : = ...= . :.=- | ||
25 | -. .:....=;==+<; You should have received a copy of the GNU | ||
26 | -_. . . )=. = Library General Public License along with | ||
27 | -- :-=` this library; see the file COPYING.LIB. | ||
28 | If not, write to the Free Software Foundation, | ||
29 | Inc., 59 Temple Place - Suite 330, | ||
30 | Boston, MA 02111-1307, USA. | ||
31 | |||
32 | */ | ||
1 | 33 | ||
2 | #include <qpe/resource.h> | 34 | #include <qpe/resource.h> |
3 | #include <qpe/mediaplayerplugininterface.h> | 35 | #include <qpe/mediaplayerplugininterface.h> |
@@ -73,8 +105,8 @@ VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) : | |||
73 | slider->setFocusPolicy( QWidget::NoFocus ); | 105 | slider->setFocusPolicy( QWidget::NoFocus ); |
74 | slider->setGeometry( QRect( 7, 250, 220, 20 ) ); | 106 | slider->setGeometry( QRect( 7, 250, 220, 20 ) ); |
75 | 107 | ||
76 | connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); | 108 | connect( slider, SIGNAL( sliderPressed() ), this, SLOT( sliderPressed() ) ); |
77 | connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); | 109 | connect( slider, SIGNAL( sliderReleased() ), this, SLOT( sliderReleased() ) ); |
78 | 110 | ||
79 | connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); | 111 | connect( mediaPlayerState, SIGNAL( lengthChanged(long) ), this, SLOT( setLength(long) ) ); |
80 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); | 112 | connect( mediaPlayerState, SIGNAL( positionChanged(long) ),this, SLOT( setPosition(long) ) ); |
@@ -89,6 +121,9 @@ VideoWidget::VideoWidget(QWidget* parent, const char* name, WFlags f) : | |||
89 | setFullscreen( mediaPlayerState->fullscreen() ); | 121 | setFullscreen( mediaPlayerState->fullscreen() ); |
90 | setPaused( mediaPlayerState->paused() ); | 122 | setPaused( mediaPlayerState->paused() ); |
91 | setPlaying( mediaPlayerState->playing() ); | 123 | setPlaying( mediaPlayerState->playing() ); |
124 | |||
125 | videoFrame = new XineVideoWidget( 200, 150 ,this, "Video frame" ); | ||
126 | videoFrame->setGeometry( QRect( 10, 20, 220, 160 ) ); | ||
92 | } | 127 | } |
93 | 128 | ||
94 | 129 | ||
@@ -256,8 +291,6 @@ void VideoWidget::paintEvent( QPaintEvent * ) { | |||
256 | p.setBrush( QBrush( Qt::black ) ); | 291 | p.setBrush( QBrush( Qt::black ) ); |
257 | p.drawRect( rect() ); | 292 | p.drawRect( rect() ); |
258 | 293 | ||
259 | // Draw the current frame | ||
260 | //p.drawImage( ); // If using directpainter we won't have a copy except whats on the screen | ||
261 | } else { | 294 | } else { |
262 | // draw border | 295 | // draw border |
263 | qDrawShadePanel( &p, 4, 15, 230, 170, colorGroup(), TRUE, 5, NULL ); | 296 | qDrawShadePanel( &p, 4, 15, 230, 170, colorGroup(), TRUE, 5, NULL ); |
@@ -267,7 +300,7 @@ void VideoWidget::paintEvent( QPaintEvent * ) { | |||
267 | p.drawRect( 9, 20, 220, 160 ); | 300 | p.drawRect( 9, 20, 220, 160 ); |
268 | 301 | ||
269 | // draw current frame (centrally positioned from scaling to maintain aspect ratio) | 302 | // draw current frame (centrally positioned from scaling to maintain aspect ratio) |
270 | p.drawImage( 9 + (220 - scaledWidth) / 2, 20 + (160 - scaledHeight) / 2, *currentFrame, 0, 0, scaledWidth, scaledHeight ); | 303 | //p.drawImage( 9 + (220 - scaledWidth) / 2, 20 + (160 - scaledHeight) / 2, *currentFrame, 0, 0, scaledWidth, scaledHeight ); |
271 | 304 | ||
272 | // draw the buttons | 305 | // draw the buttons |
273 | for ( int i = 0; i < numButtons; i++ ) { | 306 | for ( int i = 0; i < numButtons; i++ ) { |
@@ -290,135 +323,13 @@ bool VideoWidget::playVideo() { | |||
290 | 323 | ||
291 | int stream = 0; | 324 | int stream = 0; |
292 | 325 | ||
293 | int sw = 240; //mediaPlayerState->curDecoder()->videoWidth( stream ); | 326 | int sw = 240; |
294 | int sh = 320; //mediaPlayerState->curDecoder()->videoHeight( stream ); | 327 | int sh = 320; |
295 | int dd = QPixmap::defaultDepth(); | 328 | int dd = QPixmap::defaultDepth(); |
296 | int w = height(); | 329 | int w = height(); |
297 | int h = width(); | 330 | int h = width(); |
298 | 331 | ||
299 | ColorFormat format = (dd == 16) ? RGB565 : BGRA8888; | 332 | return true; |
300 | |||
301 | if ( mediaPlayerState->fullscreen() ) { | ||
302 | #ifdef USE_DIRECT_PAINTER | ||
303 | QDirectPainter p(this); | ||
304 | |||
305 | if ( ( qt_screen->transformOrientation() == 3 ) && | ||
306 | ( ( dd == 16 ) || ( dd == 32 ) ) && ( p.numRects() == 1 ) ) { | ||
307 | |||
308 | w = 320; | ||
309 | h = 240; | ||
310 | |||
311 | if ( mediaPlayerState->scaled() ) { | ||
312 | // maintain aspect ratio | ||
313 | if ( w * sh > sw * h ) | ||
314 | w = sw * h / sh; | ||
315 | else | ||
316 | h = sh * w / sw; | ||
317 | } else { | ||
318 | w = sw; | ||
319 | h = sh; | ||
320 | } | ||
321 | |||
322 | w--; // we can't allow libmpeg to overwrite. | ||
323 | QPoint roff = qt_screen->mapToDevice( p.offset(), QSize( qt_screen->width(), qt_screen->height() ) ); | ||
324 | |||
325 | int ox = roff.x() - height() + 2 + (height() - w) / 2; | ||
326 | int oy = roff.y() + (width() - h) / 2; | ||
327 | int sx = 0, sy = 0; | ||
328 | |||
329 | uchar* fp = p.frameBuffer() + p.lineStep() * oy; | ||
330 | fp += dd * ox / 8; | ||
331 | uchar **jt = new uchar*[h]; | ||
332 | for ( int i = h; i; i-- ) { | ||
333 | jt[h - i] = fp; | ||
334 | fp += p.lineStep(); | ||
335 | } | ||
336 | |||
337 | result = 42; //mediaPlayerState->curDecoder()->videoReadScaledFrame( jt, sx, sy, sw, sh, w, h, format, 0) == 0; | ||
338 | |||
339 | delete [] jt; | ||
340 | } else { | ||
341 | #endif | ||
342 | QPainter p(this); | ||
343 | |||
344 | w = 320; | ||
345 | h = 240; | ||
346 | |||
347 | if ( mediaPlayerState->scaled() ) { | ||
348 | // maintain aspect ratio | ||
349 | if ( w * sh > sw * h ) { | ||
350 | w = sw * h / sh; | ||
351 | } else { | ||
352 | h = sh * w / sw; | ||
353 | } | ||
354 | } else { | ||
355 | w = sw; | ||
356 | h = sh; | ||
357 | } | ||
358 | |||
359 | int bytes = ( dd == 16 ) ? 2 : 4; | ||
360 | QImage tempFrame( w, h, bytes << 3 ); | ||
361 | result = 42; // mediaPlayerState->curDecoder()->videoReadScaledFrame( tempFrame.jumpTable(), | ||
362 | // 0, 0, sw, sh, w, h, format, 0) == 0; | ||
363 | if ( result && mediaPlayerState->fullscreen() ) { | ||
364 | |||
365 | int rw = h, rh = w; | ||
366 | QImage rotatedFrame( rw, rh, bytes << 3 ); | ||
367 | |||
368 | ushort* in = (ushort*)tempFrame.bits(); | ||
369 | ushort* out = (ushort*)rotatedFrame.bits(); | ||
370 | int spl = rotatedFrame.bytesPerLine() / bytes; | ||
371 | for (int x=0; x<h; x++) { | ||
372 | if ( bytes == 2 ) { | ||
373 | ushort* lout = out++ + (w - 1)*spl; | ||
374 | for (int y=0; y<w; y++) { | ||
375 | *lout=*in++; | ||
376 | lout-=spl; | ||
377 | } | ||
378 | } else { | ||
379 | ulong* lout = ((ulong *)out)++ + (w - 1)*spl; | ||
380 | for (int y=0; y<w; y++) { | ||
381 | *lout=*((ulong*)in)++; | ||
382 | lout-=spl; | ||
383 | } | ||
384 | } | ||
385 | } | ||
386 | |||
387 | p.drawImage( (240 - rw) / 2, (320 - rh) / 2, rotatedFrame, 0, 0, rw, rh ); | ||
388 | } | ||
389 | #ifdef USE_DIRECT_PAINTER | ||
390 | } | ||
391 | #endif | ||
392 | } else { | ||
393 | |||
394 | w = 220; | ||
395 | h = 160; | ||
396 | |||
397 | // maintain aspect ratio | ||
398 | if ( w * sh > sw * h ) { | ||
399 | w = sw * h / sh; | ||
400 | } else { | ||
401 | h = sh * w / sw; | ||
402 | } | ||
403 | |||
404 | result = 42 ; //mediaPlayerState->curDecoder()->videoReadScaledFrame( currentFrame->jumpTable(), 0, 0, sw, sh, w, h, format, 0) == 0; | ||
405 | |||
406 | QPainter p( this ); | ||
407 | |||
408 | // Image changed size, therefore need to blank the possibly unpainted regions first | ||
409 | if ( scaledWidth != w || scaledHeight != h ) { | ||
410 | p.setBrush( QBrush( Qt::black ) ); | ||
411 | p.drawRect( 9, 20, 220, 160 ); | ||
412 | } | ||
413 | |||
414 | scaledWidth = w; | ||
415 | scaledHeight = h; | ||
416 | |||
417 | if ( result ) { | ||
418 | p.drawImage( 9 + (220 - scaledWidth) / 2, 20 + (160 - scaledHeight) / 2, *currentFrame, 0, 0, scaledWidth, scaledHeight ); | ||
419 | } | ||
420 | } | ||
421 | return result; | ||
422 | } | 333 | } |
423 | 334 | ||
424 | 335 | ||