summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/lib.cpp90
-rw-r--r--noncore/multimedia/opieplayer2/lib.h49
-rw-r--r--noncore/multimedia/opieplayer2/xinevideowidget.cpp180
-rw-r--r--noncore/multimedia/opieplayer2/xinevideowidget.h1
4 files changed, 163 insertions, 157 deletions
diff --git a/noncore/multimedia/opieplayer2/lib.cpp b/noncore/multimedia/opieplayer2/lib.cpp
index e3289bc..9f7a9c5 100644
--- a/noncore/multimedia/opieplayer2/lib.cpp
+++ b/noncore/multimedia/opieplayer2/lib.cpp
@@ -1,35 +1,35 @@
1/* 1/*
2                This file is part of the Opie Project 2 This file is part of the Opie Project
3 3
4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> 4 Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
5 Copyright (c) 2002 LJP <> 5 Copyright (c) 2002 LJP <>
6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> 6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
7 =. 7 =.
8 .=l. 8 .=l.
9           .>+-= 9 .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10_;:, .> :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_, > . <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU General Public 12:`=1 )Y*s>-.-- : the terms of the GNU General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i, .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14- . .-<_> .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15 ._= =} : or (at your option) any later version.
16    .%`+i>       _;_. 16 .%`+i> _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 17 .i_,=:_. -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19 : .. .:, . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more 22..}^=.= = ; Library General Public License for more
23++=   -.     .`     .: details. 23++= -. .` .: details.
24 :     =  ...= . :.=- 24: = ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25-. .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with 26 -_. . . )=. = Library General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 27 -- :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34#include "xinevideowidget.h" 34#include "xinevideowidget.h"
35#include "lib.h" 35#include "lib.h"
@@ -43,17 +43,17 @@
43#include <qdir.h> 43#include <qdir.h>
44#include <qgfx_qws.h> 44#include <qgfx_qws.h>
45 45
46/* STD */ 46/* STD */
47#include <assert.h> 47#include <assert.h>
48#include <unistd.h> 48#include <unistd.h>
49 49
50typedef void (*display_xine_frame_t) (void *user_data, uint8_t* frame, 50typedef void (*display_xine_frame_t) (void *user_data, uint8_t* frame,
51 int width, int height,int bytes ); 51 int width, int height,int bytes );
52 52
53extern "C" { 53extern "C" {
54 xine_vo_driver_t* init_video_out_plugin( xine_t *xine, void* video, display_xine_frame_t, void * ); 54 xine_vo_driver_t* init_video_out_plugin( xine_t *xine, void* video, display_xine_frame_t, void * );
55 int null_is_showing_video( const xine_vo_driver_t* self ); 55 int null_is_showing_video( const xine_vo_driver_t* self );
56 void null_set_show_video( const xine_vo_driver_t* self, int show ); 56 void null_set_show_video( const xine_vo_driver_t* self, int show );
57 int null_is_fullscreen( const xine_vo_driver_t* self ); 57 int null_is_fullscreen( const xine_vo_driver_t* self );
58 void null_set_fullscreen( const xine_vo_driver_t* self, int screen ); 58 void null_set_fullscreen( const xine_vo_driver_t* self, int screen );
59 int null_is_scaling( const xine_vo_driver_t* self ); 59 int null_is_scaling( const xine_vo_driver_t* self );
@@ -184,16 +184,27 @@ int Lib::minorVersion() {
184} 184}
185 185
186int Lib::subVersion() { 186int Lib::subVersion() {
187 int major, minor, sub; 187 int major, minor, sub;
188 xine_get_version ( &major, &minor, &sub ); 188 xine_get_version ( &major, &minor, &sub );
189 return sub; 189 return sub;
190} 190}
191 191
192int Lib::setfile(const QString& fileName)
193{
194 QString str = fileName.stripWhiteSpace();
195
196
197 if ( !xine_open( m_stream, str.utf8().data() ) ) {
198 return 0;
199 }
200 return 1;
201}
202
192int Lib::play( const QString& fileName, int startPos, int start_time ) { 203int Lib::play( const QString& fileName, int startPos, int start_time ) {
193 assert( m_initialized ); 204 assert( m_initialized );
194 205
195 QString str = fileName.stripWhiteSpace(); 206 QString str = fileName.stripWhiteSpace();
196 207
197 208
198 if ( !xine_open( m_stream, str.utf8().data() ) ) { 209 if ( !xine_open( m_stream, str.utf8().data() ) ) {
199 return 0; 210 return 0;
@@ -209,17 +220,17 @@ void Lib::stop() {
209 220
210void Lib::pause( bool toggle ) { 221void Lib::pause( bool toggle ) {
211 assert( m_initialized ); 222 assert( m_initialized );
212 223
213 if ( toggle ) { 224 if ( toggle ) {
214 xine_set_param( m_stream, XINE_PARAM_SPEED, XINE_SPEED_PAUSE ); 225 xine_set_param( m_stream, XINE_PARAM_SPEED, XINE_SPEED_PAUSE );
215 xine_set_param( m_stream, XINE_PARAM_AUDIO_CLOSE_DEVICE, 1); 226 xine_set_param( m_stream, XINE_PARAM_AUDIO_CLOSE_DEVICE, 1);
216 } 227 }
217 228
218 else { 229 else {
219 xine_set_param( m_stream, XINE_PARAM_SPEED, XINE_SPEED_NORMAL ); 230 xine_set_param( m_stream, XINE_PARAM_SPEED, XINE_SPEED_NORMAL );
220 } 231 }
221} 232}
222 233
223int Lib::speed() const { 234int Lib::speed() const {
224 assert( m_initialized ); 235 assert( m_initialized );
225 236
@@ -261,26 +272,26 @@ int Lib::currentTime() const {
261int Lib::length() const { 272int Lib::length() const {
262 assert( m_initialized ); 273 assert( m_initialized );
263 274
264 int pos, time, length; 275 int pos, time, length;
265/* dilb: patch to solve the wrong stream length reported to the GUI*/ 276/* dilb: patch to solve the wrong stream length reported to the GUI*/
266 int iRetVal=0, iTestLoop=0; 277 int iRetVal=0, iTestLoop=0;
267 278
268 do 279 do
269 { 280 {
270 iRetVal = xine_get_pos_length( m_stream, &pos, &time, &length ); 281 iRetVal = xine_get_pos_length( m_stream, &pos, &time, &length );
271 if (iRetVal) 282 if (iRetVal)
272 {/* if the function didn't return 0, then pos, time and length are valid.*/ 283 {/* if the function didn't return 0, then pos, time and length are valid.*/
273 return length/1000; 284 return length/1000;
274 } 285 }
275 /*don't poll too much*/ 286 /*don't poll too much*/
276 usleep(100000); 287 usleep(100000);
277 iTestLoop++; 288 iTestLoop++;
278 } 289 }
279 while ( iTestLoop < 10 ); /* if after 1s, we still don't have any 290 while ( iTestLoop < 10 ); /* if after 1s, we still don't have any
280valid stream, then return -1 (this value could be used to make the stream 291valid stream, then return -1 (this value could be used to make the stream
281unseekable, but it should never occur!! Mr. Murphy ? :) ) */ 292unseekable, but it should never occur!! Mr. Murphy ? :) ) */
282 293
283 return -1; 294 return -1;
284} 295}
285 296
286bool Lib::isSeekable() const { 297bool Lib::isSeekable() const {
@@ -297,17 +308,17 @@ void Lib::seekTo( int time ) {
297 if ( xine_get_param( m_stream, XINE_PARAM_SPEED ) ) { 308 if ( xine_get_param( m_stream, XINE_PARAM_SPEED ) ) {
298 xine_play( m_stream, 0, time*1000 ); 309 xine_play( m_stream, 0, time*1000 );
299 } 310 }
300 311
301 else { 312 else {
302 xine_play( m_stream, 0, time*1000 ); 313 xine_play( m_stream, 0, time*1000 );
303 xine_set_param( m_stream, XINE_PARAM_SPEED, XINE_SPEED_PAUSE ); 314 xine_set_param( m_stream, XINE_PARAM_SPEED, XINE_SPEED_PAUSE );
304 } 315 }
305 316
306} 317}
307 318
308 319
309QString Lib::metaInfo( int number) const { 320QString Lib::metaInfo( int number) const {
310 assert( m_initialized ); 321 assert( m_initialized );
311 322
312 return xine_get_meta_info( m_stream, number ); 323 return xine_get_meta_info( m_stream, number );
313} 324}
@@ -326,19 +337,20 @@ void Lib::ensureInitialized()
326 odebug << "waiting for initialization thread to finish" << oendl; 337 odebug << "waiting for initialization thread to finish" << oendl;
327 wait(); 338 wait();
328 odebug << "initialization thread finished!" << oendl; 339 odebug << "initialization thread finished!" << oendl;
329} 340}
330 341
331void Lib::setWidget( XineVideoWidget *widget ) 342void Lib::setWidget( XineVideoWidget *widget )
332{ 343{
333 m_wid = widget; 344 m_wid = widget;
334 resize ( m_wid-> size ( ) ); 345 if (m_wid) {
335 ::null_set_mode( m_videoOutput, qt_screen->depth(), qt_screen->pixelType() ); 346 resize ( m_wid-> size ( ) );
336 m_wid->repaint(); 347 ::null_set_mode( m_videoOutput, qt_screen->depth(), qt_screen->pixelType() );
348 }
337} 349}
338 350
339void Lib::receiveMessage( ThreadUtil::ChannelMessage *msg, SendType sendType ) 351void Lib::receiveMessage( ThreadUtil::ChannelMessage *msg, SendType sendType )
340{ 352{
341 assert( sendType == ThreadUtil::Channel::OneWay ); 353 assert( sendType == ThreadUtil::Channel::OneWay );
342 handleXineEvent( msg->type(), msg->data(), msg->msg() ); 354 handleXineEvent( msg->type(), msg->data(), msg->msg() );
343 delete msg; 355 delete msg;
344} 356}
@@ -426,12 +438,12 @@ void Lib::xine_display_frame( void* user_data, uint8_t *frame,
426 438
427void Lib::drawFrame( uint8_t* frame, int width, int height, int bytes ) { 439void Lib::drawFrame( uint8_t* frame, int width, int height, int bytes ) {
428 assert( m_initialized ); 440 assert( m_initialized );
429 441
430 if ( !m_video ) { 442 if ( !m_video ) {
431 return; 443 return;
432 } 444 }
433 445
434 assert( m_wid ); 446// assert( m_wid );
435 447
436 m_wid-> setVideoFrame ( frame, width, height, bytes ); 448 if (m_wid) m_wid-> setVideoFrame ( frame, width, height, bytes );
437} 449}
diff --git a/noncore/multimedia/opieplayer2/lib.h b/noncore/multimedia/opieplayer2/lib.h
index ab432a0..2f5bf86 100644
--- a/noncore/multimedia/opieplayer2/lib.h
+++ b/noncore/multimedia/opieplayer2/lib.h
@@ -1,35 +1,35 @@
1/* 1/*
2                This file is part of the Opie Project 2 This file is part of the Opie Project
3 3
4              Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> 4 Copyright (c) 2002 Max Reiss <harlekin@handhelds.org>
5 Copyright (c) 2002 LJP <> 5 Copyright (c) 2002 LJP <>
6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> 6 Copyright (c) 2002 Holger Freyther <zecke@handhelds.org>
7 =. 7 =.
8 .=l. 8 .=l.
9           .>+-= 9 .>+-=
10 _;:,     .>    :=|. This program is free software; you can 10_;:, .> :=|. This program is free software; you can
11.> <`_,   >  .   <= redistribute it and/or modify it under 11.> <`_, > . <= redistribute it and/or modify it under
12:`=1 )Y*s>-.--   : the terms of the GNU General Public 12:`=1 )Y*s>-.-- : the terms of the GNU General Public
13.="- .-=="i,     .._ License as published by the Free Software 13.="- .-=="i, .._ License as published by the Free Software
14 - .   .-<_>     .<> Foundation; either version 2 of the License, 14- . .-<_> .<> Foundation; either version 2 of the License,
15     ._= =}       : or (at your option) any later version. 15 ._= =} : or (at your option) any later version.
16    .%`+i>       _;_. 16 .%`+i> _;_.
17    .i_,=:_.      -<s. This program is distributed in the hope that 17 .i_,=:_. -<s. This program is distributed in the hope that
18     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 18 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
19    : ..    .:,     . . . without even the implied warranty of 19 : .. .:, . . . without even the implied warranty of
20    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 20 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
21  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 21 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
22..}^=.=       =       ; Library General Public License for more 22..}^=.= = ; Library General Public License for more
23++=   -.     .`     .: details. 23++= -. .` .: details.
24 :     =  ...= . :.=- 24: = ...= . :.=-
25 -.   .:....=;==+<; You should have received a copy of the GNU 25-. .:....=;==+<; You should have received a copy of the GNU
26  -_. . .   )=.  = Library General Public License along with 26 -_. . . )=. = Library General Public License along with
27    --        :-=` this library; see the file COPYING.LIB. 27 -- :-=` this library; see the file COPYING.LIB.
28 If not, write to the Free Software Foundation, 28 If not, write to the Free Software Foundation,
29 Inc., 59 Temple Place - Suite 330, 29 Inc., 59 Temple Place - Suite 330,
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34#ifndef XINE_VIDEO_LIB_H 34#ifndef XINE_VIDEO_LIB_H
35#define XINE_VIDEO_LIB_H 35#define XINE_VIDEO_LIB_H
@@ -60,16 +60,17 @@ namespace XINE {
60 ~Lib(); 60 ~Lib();
61 static int majorVersion(); 61 static int majorVersion();
62 static int minorVersion(); 62 static int minorVersion();
63 static int subVersion(); 63 static int subVersion();
64 64
65 65
66 void resize ( const QSize &s ); 66 void resize ( const QSize &s );
67 67
68 int setfile(const QString& fileName);
68 int play( const QString& fileName, 69 int play( const QString& fileName,
69 int startPos = 0, 70 int startPos = 0,
70 int start_time = 0 ); 71 int start_time = 0 );
71 void stop(); 72 void stop();
72 void pause( bool toggle ); 73 void pause( bool toggle );
73 74
74 int speed() const; 75 int speed() const;
75 76
@@ -185,24 +186,24 @@ namespace XINE {
185 void initialize(); 186 void initialize();
186 187
187 int m_bytes_per_pixel; 188 int m_bytes_per_pixel;
188 bool m_initialized:1; 189 bool m_initialized:1;
189 bool m_duringInitialization:1; 190 bool m_duringInitialization:1;
190 bool m_video:1; 191 bool m_video:1;
191 XineVideoWidget *m_wid; 192 XineVideoWidget *m_wid;
192 xine_t *m_xine; 193 xine_t *m_xine;
193 xine_stream_t *m_stream; 194 xine_stream_t *m_stream;
194 xine_cfg_entry_t *m_config; 195 xine_cfg_entry_t *m_config;
195 xine_vo_driver_t *m_videoOutput; 196 xine_vo_driver_t *m_videoOutput;
196 xine_ao_driver_t* m_audioOutput; 197 xine_ao_driver_t* m_audioOutput;
197 xine_event_queue_t *m_queue; 198 xine_event_queue_t *m_queue;
198 199
199 void handleXineEvent( const xine_event_t* t ); 200 void handleXineEvent( const xine_event_t* t );
200 void handleXineEvent( int type, int data, const char* name ); 201 void handleXineEvent( int type, int data, const char* name );
201 void drawFrame( uint8_t* frame, int width, int height, int bytes ); 202 void drawFrame( uint8_t* frame, int width, int height, int bytes );
202 // C -> C++ bridge for the event system 203 // C -> C++ bridge for the event system
203 static void xine_event_handler( void* user_data, const xine_event_t* t); 204 static void xine_event_handler( void* user_data, const xine_event_t* t);
204 static void xine_display_frame( void* user_data, uint8_t* frame , 205 static void xine_display_frame( void* user_data, uint8_t* frame ,
205 int width, int height, int bytes ); 206 int width, int height, int bytes );
206 }; 207 };
207}; 208};
208 209
diff --git a/noncore/multimedia/opieplayer2/xinevideowidget.cpp b/noncore/multimedia/opieplayer2/xinevideowidget.cpp
index 211791b..7f59085 100644
--- a/noncore/multimedia/opieplayer2/xinevideowidget.cpp
+++ b/noncore/multimedia/opieplayer2/xinevideowidget.cpp
@@ -166,173 +166,165 @@ QSize XineVideoWidget::videoSize() const
166 if ( fs && qt_screen->isTransformed() ) 166 if ( fs && qt_screen->isTransformed() )
167 s = qt_screen->mapToDevice( s ); 167 s = qt_screen->mapToDevice( s );
168 168
169 return s; 169 return s;
170} 170}
171 171
172void XineVideoWidget::paintEvent ( QPaintEvent * ) 172void XineVideoWidget::paintEvent ( QPaintEvent * )
173{ 173{
174 if (m_bufmutex.isLocked()) {
175 return;
176 }
174 ThreadUtil::AutoLock a(m_bufmutex); 177 ThreadUtil::AutoLock a(m_bufmutex);
175 QPainter p ( this ); 178 QPainter p ( this );
176 p. fillRect ( rect (), black ); 179 p. fillRect ( rect (), black );
177 if (m_logo) 180 if (m_logo)
178 p. drawImage ( 0, 0, *m_logo ); 181 p. drawImage ( 0, 0, *m_logo );
179} 182}
180 183
181void XineVideoWidget::paintEvent2 ( QPaintEvent * ) 184void XineVideoWidget::paintEvent2 ( QPaintEvent * )
182{ 185{
183 ThreadUtil::AutoLock a(m_bufmutex); 186 ThreadUtil::AutoLock a(m_bufmutex);
187 QPainter p (this);
184 if ( m_buff == 0 ) { 188 if ( m_buff == 0 ) {
185 QPainter p ( this );
186 p. fillRect ( rect ( ), black ); 189 p. fillRect ( rect ( ), black );
187 if ( m_logo ) 190 if ( m_logo )
188 p. drawImage ( 0, 0, *m_logo ); 191 p. drawImage ( 0, 0, *m_logo );
189 } 192 } else if (m_lastsize){
190 else {
191 // Qt needs to be notified which areas were really updated .. strange 193 // Qt needs to be notified which areas were really updated .. strange
192 QArray <QRect> qt_bug_workaround_clip_rects; 194 QArray <QRect> qt_bug_workaround_clip_rects;
193 195
194 { 196 {
195 QDirectPainter dp ( this ); 197 QDirectPainter dp ( this );
196 198
197 int rot = dp. transformOrientation ( ) + m_rotation; // device rotation + custom rotation 199 int rot = dp. transformOrientation ( ) + m_rotation; // device rotation + custom rotation
198 200
201 bool rot90 = (( -m_rotation ) & 1 );
202
203 int _vw,_vh;
204 switch (rot90) {
205 case true:
206 _vh = m_framesize.width();
207 _vw = m_framesize.height();
208 break;
209 default:
210 _vw = m_framesize.width();
211 _vh = m_framesize.height();
212 break;
213 break;
214 }
215 int middle_w = _vw/2;
216 int middle_h = _vh/2;
217 m_thisframe.setRect(width()/2-middle_w,height()/2-middle_h,_vw,_vh);
218 QRect topFill,rightFill,leftFill,downFill;
219 topFill. setRect(0,0 ,width(),m_thisframe.top());
220 downFill.setCoords(0,m_thisframe.bottom(),width(),height());
221 rightFill.setCoords(m_thisframe.right(),0,width(),height());
222 leftFill.setCoords(0,0,m_thisframe.left(),height());
223
224 if (topFill.isValid()) {
225 p.fillRect(topFill,black);
226 }
227 if (downFill.isValid()) {
228 p.fillRect(downFill,black);
229 }
230 if (rightFill.isValid()) {
231 p.fillRect(rightFill,black);
232 }
233 if (leftFill.isValid()) {
234 p.fillRect(leftFill,black);
235 }
199 uchar *fb = dp. frameBuffer ( ); 236 uchar *fb = dp. frameBuffer ( );
200 uchar *frame = m_buff; 237 uchar *frame = m_buff;
201 238
202 // where is the video frame in fb coordinates 239 // where is the video frame in fb coordinates
203 QRect framerect = qt_screen-> mapToDevice ( QRect ( mapToGlobal ( m_thisframe. topLeft ( )), m_thisframe. size ( )), QSize ( qt_screen-> width ( ), qt_screen-> height ( ))); 240 QRect framerect = qt_screen-> mapToDevice ( QRect ( mapToGlobal ( m_thisframe. topLeft ( )), m_thisframe. size ( )), QSize ( qt_screen-> width ( ),
204 241 qt_screen-> height ( )));
205 qt_bug_workaround_clip_rects. resize ( dp. numRects ( )); 242
206 243 uchar * src = frame;
207 for ( int i = dp. numRects ( ) - 1; i >= 0; i-- ) { 244 uchar * dst = fb+framerect.y()*m_bytes_per_line_fb+framerect.x()*m_bytes_per_pixel;
208 const QRect &clip = dp. rect ( i ); 245
209 246 for (int y=framerect.top();y<=framerect.bottom();++y) {
210 qt_bug_workaround_clip_rects [ i ] = qt_screen-> mapFromDevice ( clip, QSize ( qt_screen-> width ( ), qt_screen-> height ( ))); 247 switch (rot) {
211 248 case 0:
212 uchar *dst = fb + ( clip. x ( ) * m_bytes_per_pixel ) + ( clip. y ( ) * m_bytes_per_line_fb ); // clip x/y in the fb 249 memcpy(dst,src,m_bytes_per_line_frame);
213 uchar *src = frame; 250 src+=m_bytes_per_line_frame;
214 251 break;
215 // Adjust the start the source data based on the rotation (xine frame) 252 case 1:
216 switch ( rot ) { 253 memcpy_step ( dst, src, m_thisframe.size().width(), m_bytes_per_line_frame );
217 case 0: src += ((( clip. x ( ) - framerect. x ( )) * m_bytes_per_pixel ) + (( clip. y ( ) - framerect. y ( )) * m_bytes_per_line_frame )); break; 254 src -= m_bytes_per_pixel;
218 case 1: src += ((( clip. y ( ) - framerect. y ( )) * m_bytes_per_pixel ) + (( clip. x ( ) - framerect. x ( )) * m_bytes_per_line_frame ) + (( framerect. height ( ) - 1 ) * m_bytes_per_pixel )); break; 255 break;
219 case 2: src += ((( clip. x ( ) - framerect. x ( )) * m_bytes_per_pixel ) + (( clip. y ( ) - framerect. y ( )) * m_bytes_per_line_frame ) + (( framerect. height ( ) - 1 ) * m_bytes_per_line_frame )); break; 256 case 2:
220 case 3: src += ((( clip. y ( ) - framerect. y ( )) * m_bytes_per_pixel ) + (( clip. x ( ) - framerect. x ( )) * m_bytes_per_line_frame )); break; 257 memcpy_rev ( dst, src, m_thisframe.size().width());
221 default: break; 258 src-=m_bytes_per_line_frame;
222 } 259 break;
223 260 case 3:
224 // all of the following widths/heights are fb relative (0deg rotation) 261 memcpy_step_rev ( dst, src, m_thisframe.size().width(), m_bytes_per_line_frame );
225 262 src += m_bytes_per_pixel;
226 uint leftfill = 0; // black border on the "left" side of the video frame 263 break;
227 uint framefill = 0; // "width" of the video frame 264 default:
228 uint rightfill = 0; // black border on the "right" side of the video frame 265 break;
229 uint clipwidth = clip. width ( ) * m_bytes_per_pixel; // "width" of the current clip rect
230
231 if ( clip. left ( ) < framerect. left ( ))
232 leftfill = (( framerect. left ( ) - clip. left ( )) * m_bytes_per_pixel ) <? clipwidth;
233 if ( clip. right ( ) > framerect. right ( ))
234 rightfill = (( clip. right ( ) - framerect. right ( )) * m_bytes_per_pixel ) <? clipwidth;
235
236 framefill = clipwidth - ( leftfill + rightfill );
237
238 for ( int y = clip. top ( ); y <= clip. bottom ( ); y++ ) {
239 if (( y < framerect. top ( )) || ( y > framerect. bottom ( ))) {
240 // "above" or "below" the video -> black
241 memset ( dst, 0, clipwidth );
242 }
243 else {
244 if ( leftfill )
245 memset ( dst, 0, leftfill ); // "left" border -> black
246
247 if ( framefill ) { // blit in the video frame
248 // see above for an explanation of the different memcpys
249
250 switch ( rot ) {
251 case 0: memcpy ( dst + leftfill, src, framefill & ~1 ); break;
252 case 1: memcpy_step ( dst + leftfill, src, framefill, m_bytes_per_line_frame ); break;
253 case 2: memcpy_rev ( dst + leftfill, src, framefill ); break;
254 case 3: memcpy_step_rev ( dst + leftfill, src, framefill, m_bytes_per_line_frame ); break;
255 default: break;
256 }
257 }
258 if ( rightfill )
259 memset ( dst + leftfill + framefill, 0, rightfill ); // "right" border -> black
260 }
261
262 dst += m_bytes_per_line_fb; // advance one line in the framebuffer
263
264 // advance one "line" in the xine frame data
265 switch ( rot ) {
266 case 0: src += m_bytes_per_line_frame; break;
267 case 1: src -= m_bytes_per_pixel; break;
268 case 2: src -= m_bytes_per_line_frame; break;
269 case 3: src += m_bytes_per_pixel; break;
270 default: break;
271 }
272 } 266 }
267 dst += m_bytes_per_line_fb;
273 } 268 }
274 } 269 }
275 270
271
276 { 272 {
277 // QVFB hack by Martin Jones 273 // QVFB hack by Martin Jones
278 // We need to "touch" all affected clip rects with a normal QPainter in addition to the QDirectPainter 274 // We need to "touch" all affected clip rects with a normal QPainter in addition to the QDirectPainter
279 275 p.fillRect(QRect(mapFromGlobal (m_thisframe. topLeft ( )), m_thisframe.size ()),QBrush(NoBrush));
280 QPainter p ( this );
281
282 for ( int i = qt_bug_workaround_clip_rects. size ( ) - 1; i >= 0; i-- ) {
283 p. fillRect ( QRect ( mapFromGlobal ( qt_bug_workaround_clip_rects [ i ]. topLeft ( )), qt_bug_workaround_clip_rects [ i ]. size ( )), QBrush ( NoBrush ));
284 }
285 } 276 }
286 } 277 }
287} 278}
288 279
289
290QImage *XineVideoWidget::logo ( ) const 280QImage *XineVideoWidget::logo ( ) const
291{ 281{
292 return m_logo; 282 return m_logo;
293} 283}
294 284
295 285
296void XineVideoWidget::setLogo ( QImage* logo ) 286void XineVideoWidget::setLogo ( QImage* logo )
297{ 287{
298 delete m_logo; 288 delete m_logo;
299 m_logo = logo; 289 m_logo = logo;
300} 290}
301 291
302void XineVideoWidget::setVideoFrame ( uchar* img, int w, int h, int bpl ) 292void XineVideoWidget::setVideoFrame ( uchar* img, int w, int h, int bpl )
303{ 293{
304 // mutex area for AutoLock 294 // mutex area for AutoLock
305 { 295 {
306 if (m_bufmutex.isLocked()) { 296 if (m_bufmutex.isLocked()||w>width()||h>height()) {
307 // no time to wait - drop frame 297 // no time to wait - drop frame
308 return; 298 return;
309 } 299 }
310 ThreadUtil::AutoLock a(m_bufmutex); 300 ThreadUtil::AutoLock a(m_bufmutex);
311 bool rot90 = (( -m_rotation ) & 1 ); 301 bool rot90 = (( -m_rotation ) & 1 );
312 int l = h*m_bytes_per_pixel*w; 302 int l = h*bpl;
313 if (l>m_lastsize) { 303 if (l!=m_lastsize) {
314 if (m_buff) { 304 if (m_buff) {
315 delete[]m_buff; 305 delete[]m_buff;
316 } 306 }
317 m_buff = new uchar[l]; 307 if (l>0) {
318 m_lastsize=l; 308 m_buff = new uchar[l];
309 odebug << "Point to: " << (unsigned long)m_buff << oendl;
310 m_lastsize=l;
311 } else {
312 m_buff = 0;
313 }
314 } else if (l==0){
315 delete[] m_buff;
316 m_buff = 0;
319 } 317 }
320 318 m_lastsize = l;
321 if ( rot90 ) { // if the rotation is 90 or 270 we have to swap width / height 319 m_framesize = QSize(w,h);
322 int d = w; 320 if (m_buff && m_lastsize) {
323 w = h; 321 memcpy(m_buff,img,m_lastsize);
324 h = d;
325 } 322 }
326
327 m_lastframe = m_thisframe;
328 m_thisframe. setRect (( width ( ) - w ) / 2, ( height ( ) - h ) / 2, w , h );
329
330 memcpy(m_buff,img,m_lastsize);
331 m_bytes_per_line_frame = bpl; 323 m_bytes_per_line_frame = bpl;
332 } // Release Mutex 324 } // Release Mutex
333 325
334 paintEvent2(0); 326 paintEvent2(0);
335} 327}
336 328
337void XineVideoWidget::resizeEvent ( QResizeEvent * ) 329void XineVideoWidget::resizeEvent ( QResizeEvent * )
338{ 330{
diff --git a/noncore/multimedia/opieplayer2/xinevideowidget.h b/noncore/multimedia/opieplayer2/xinevideowidget.h
index 7f00aaa..eccff1a 100644
--- a/noncore/multimedia/opieplayer2/xinevideowidget.h
+++ b/noncore/multimedia/opieplayer2/xinevideowidget.h
@@ -68,13 +68,14 @@ private:
68 QRect m_lastframe; 68 QRect m_lastframe;
69 QRect m_thisframe; 69 QRect m_thisframe;
70 70
71 uchar *m_buff; 71 uchar *m_buff;
72 int m_bytes_per_line_fb; 72 int m_bytes_per_line_fb;
73 int m_bytes_per_line_frame; 73 int m_bytes_per_line_frame;
74 int m_bytes_per_pixel; 74 int m_bytes_per_pixel;
75 int m_lastsize; 75 int m_lastsize;
76 QSize m_framesize;
76 QImage *m_logo; 77 QImage *m_logo;
77 mutable int m_rotation; 78 mutable int m_rotation;
78 ThreadUtil::Mutex m_bufmutex; 79 ThreadUtil::Mutex m_bufmutex;
79}; 80};
80 81