author | sandman <sandman> | 2002-09-24 18:55:16 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-09-24 18:55:16 (UTC) |
commit | 844325085130e79ec503a0ab5b8eeafa25a7bdb1 (patch) (unidiff) | |
tree | aa1c45bf90036f9a5077f63b478e77069e64b5f1 | |
parent | 262dfbf10d031ab8a80948cd1485d747ad2c931b (diff) | |
download | opie-844325085130e79ec503a0ab5b8eeafa25a7bdb1.zip opie-844325085130e79ec503a0ab5b8eeafa25a7bdb1.tar.gz opie-844325085130e79ec503a0ab5b8eeafa25a7bdb1.tar.bz2 |
Documentation for the video magic (for Holger ;)
Small interface changes (better method names)
-rw-r--r-- | noncore/multimedia/opieplayer2/lib.cpp | 6 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/xinevideowidget.cpp | 126 | ||||
-rw-r--r-- | noncore/multimedia/opieplayer2/xinevideowidget.h | 15 |
3 files changed, 68 insertions, 79 deletions
diff --git a/noncore/multimedia/opieplayer2/lib.cpp b/noncore/multimedia/opieplayer2/lib.cpp index 748ae1f..d8a0694 100644 --- a/noncore/multimedia/opieplayer2/lib.cpp +++ b/noncore/multimedia/opieplayer2/lib.cpp | |||
@@ -95,3 +95,3 @@ Lib::Lib(XineVideoWidget* widget) { | |||
95 | ::null_set_mode( m_videoOutput, qt_screen->depth(), qt_screen->pixelType() ); | 95 | ::null_set_mode( m_videoOutput, qt_screen->depth(), qt_screen->pixelType() ); |
96 | m_wid-> setImage ( new QImage ( Resource::loadImage("") ) ); | 96 | m_wid-> setLogo ( new QImage ( Resource::loadImage(""))); |
97 | m_wid->repaint(); | 97 | m_wid->repaint(); |
@@ -230,5 +230,3 @@ void Lib::drawFrame( uint8_t* frame, int width, int height, int bytes ) { | |||
230 | 230 | ||
231 | m_wid->setImage( frame, width, height, bytes ); | 231 | m_wid-> setVideoFrame ( frame, width, height, bytes ); |
232 | // m_wid->repaint(false); | ||
233 | |||
234 | } | 232 | } |
diff --git a/noncore/multimedia/opieplayer2/xinevideowidget.cpp b/noncore/multimedia/opieplayer2/xinevideowidget.cpp index d06d62a..9b26d41 100644 --- a/noncore/multimedia/opieplayer2/xinevideowidget.cpp +++ b/noncore/multimedia/opieplayer2/xinevideowidget.cpp | |||
@@ -4,4 +4,3 @@ | |||
4 | 4 | ||
5 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> | 5 | Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> |
6 | Copyright (c) 2002 LJP <> | ||
7 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> | 6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> |
@@ -47,2 +46,5 @@ | |||
47 | 46 | ||
47 | // 0 deg rot: copy a line from src to dst (use libc memcpy) | ||
48 | |||
49 | // 180 deg rot: copy a line from src to dst reversed | ||
48 | 50 | ||
@@ -57,3 +59,5 @@ static inline void memcpy_rev ( void *dst, void *src, size_t len ) | |||
57 | 59 | ||
58 | static inline void memcpy_step ( void *dst, void *src, size_t len, size_t step ) | 60 | // 90 deg rot: copy a column from src to dst |
61 | |||
62 | static inline void memcpy_step ( void *dst, void *src, size_t len, size_t linestep ) | ||
59 | { | 63 | { |
@@ -62,3 +66,3 @@ static inline void memcpy_step ( void *dst, void *src, size_t len, size_t step ) | |||
62 | *((short int *) dst )++ = *((short int *) src ); | 66 | *((short int *) dst )++ = *((short int *) src ); |
63 | ((char *) src ) += step; | 67 | ((char * ) src) += linestep; |
64 | } | 68 | } |
@@ -66,3 +70,5 @@ static inline void memcpy_step ( void *dst, void *src, size_t len, size_t step ) | |||
66 | 70 | ||
67 | static inline void memcpy_step_rev ( void *dst, void *src, size_t len, size_t step ) | 71 | // 270 deg rot: copy a column from src to dst reversed |
72 | |||
73 | static inline void memcpy_step_rev ( void *dst, void *src, size_t len, size_t linestep ) | ||
68 | { | 74 | { |
@@ -70,6 +76,6 @@ static inline void memcpy_step_rev ( void *dst, void *src, size_t len, size_t st | |||
70 | 76 | ||
71 | ((char *) src ) += ( len * step ); | 77 | ((char *) src) += ( len * linestep ); |
72 | 78 | ||
73 | while ( len-- ) { | 79 | while ( len-- ) { |
74 | ((char *) src ) -= step; | 80 | ((char *) src) -= linestep; |
75 | *((short int *) dst )++ = *((short int *) src ); | 81 | *((short int *) dst )++ = *((short int *) src ); |
@@ -84,3 +90,3 @@ XineVideoWidget::XineVideoWidget ( QWidget* parent, const char* name ) | |||
84 | 90 | ||
85 | m_image = 0; | 91 | m_logo = 0; |
86 | m_buff = 0; | 92 | m_buff = 0; |
@@ -94,3 +100,3 @@ XineVideoWidget::~XineVideoWidget ( ) | |||
94 | { | 100 | { |
95 | delete m_image; | 101 | delete m_logo; |
96 | } | 102 | } |
@@ -105,3 +111,2 @@ void XineVideoWidget::paintEvent ( QPaintEvent * ) | |||
105 | { | 111 | { |
106 | //qWarning( "painting <<<" ); | ||
107 | if ( m_buff == 0 ) { | 112 | if ( m_buff == 0 ) { |
@@ -109,9 +114,7 @@ void XineVideoWidget::paintEvent ( QPaintEvent * ) | |||
109 | p. fillRect ( rect ( ), black ); | 114 | p. fillRect ( rect ( ), black ); |
110 | if ( m_image ) | 115 | if ( m_logo ) |
111 | p. drawImage ( 0, 0, *m_image ); | 116 | p. drawImage ( 0, 0, *m_logo ); |
112 | //qWarning ( "logo\n" ); | ||
113 | } | 117 | } |
114 | else { | 118 | else { |
115 | // qWarning ( "paintevent\n" ); | 119 | // Qt needs to be notified which areas were really updated .. strange |
116 | |||
117 | QArray <QRect> qt_bug_workaround_clip_rects; | 120 | QArray <QRect> qt_bug_workaround_clip_rects; |
@@ -121,7 +124,8 @@ void XineVideoWidget::paintEvent ( QPaintEvent * ) | |||
121 | 124 | ||
122 | int rot = dp. transformOrientation ( ) + m_rotation; | 125 | int rot = dp. transformOrientation ( ) + m_rotation; // device rotation + custom rotation |
123 | 126 | ||
124 | uchar *fb = dp. frameBuffer ( ); | 127 | uchar *fb = dp. frameBuffer ( ); |
125 | uchar *frame = m_buff; // rot == 0 ? m_buff : m_buff + ( m_thisframe. height ( ) - 1 ) * m_bytes_per_line_frame; | 128 | uchar *frame = m_buff; |
126 | 129 | ||
130 | // where is the video frame in fb coordinates | ||
127 | QRect framerect = qt_screen-> mapToDevice ( QRect ( mapToGlobal ( m_thisframe. topLeft ( )), m_thisframe. size ( )), QSize ( qt_screen-> width ( ), qt_screen-> height ( ))); | 131 | QRect framerect = qt_screen-> mapToDevice ( QRect ( mapToGlobal ( m_thisframe. topLeft ( )), m_thisframe. size ( )), QSize ( qt_screen-> width ( ), qt_screen-> height ( ))); |
@@ -135,5 +139,6 @@ void XineVideoWidget::paintEvent ( QPaintEvent * ) | |||
135 | 139 | ||
136 | uchar *dst = fb + ( clip. x ( ) * m_bytes_per_pixel ) + ( clip. y ( ) * m_bytes_per_line_fb ); | 140 | uchar *dst = fb + ( clip. x ( ) * m_bytes_per_pixel ) + ( clip. y ( ) * m_bytes_per_line_fb ); // clip x/y in the fb |
137 | uchar *src = frame; | 141 | uchar *src = frame; |
138 | 142 | ||
143 | // Adjust the start the source data based on the rotation (xine frame) | ||
139 | switch ( rot ) { | 144 | switch ( rot ) { |
@@ -146,6 +151,8 @@ void XineVideoWidget::paintEvent ( QPaintEvent * ) | |||
146 | 151 | ||
147 | uint leftfill = 0; | 152 | // all of the following widths/heights are fb relative (0deg rotation) |
148 | uint framefill = 0; | 153 | |
149 | uint rightfill = 0; | 154 | uint leftfill = 0; // black border on the "left" side of the video frame |
150 | uint clipwidth = clip. width ( ) * m_bytes_per_pixel; | 155 | uint framefill = 0; // "width" of the video frame |
156 | uint rightfill = 0; // black border on the "right" side of the video frame | ||
157 | uint clipwidth = clip. width ( ) * m_bytes_per_pixel; // "width" of the current clip rect | ||
151 | 158 | ||
@@ -160,2 +167,3 @@ void XineVideoWidget::paintEvent ( QPaintEvent * ) | |||
160 | if (( y < framerect. top ( )) || ( y > framerect. bottom ( ))) { | 167 | if (( y < framerect. top ( )) || ( y > framerect. bottom ( ))) { |
168 | // "above" or "below" the video -> black | ||
161 | memset ( dst, 0, clipwidth ); | 169 | memset ( dst, 0, clipwidth ); |
@@ -164,5 +172,7 @@ void XineVideoWidget::paintEvent ( QPaintEvent * ) | |||
164 | if ( leftfill ) | 172 | if ( leftfill ) |
165 | memset ( dst, 0, leftfill ); | 173 | memset ( dst, 0, leftfill ); // "left" border -> black |
174 | |||
175 | if ( framefill ) { // blit in the video frame | ||
176 | // see above for an explanation of the different memcpys | ||
166 | 177 | ||
167 | if ( framefill ) { | ||
168 | switch ( rot ) { | 178 | switch ( rot ) { |
@@ -174,9 +184,9 @@ void XineVideoWidget::paintEvent ( QPaintEvent * ) | |||
174 | } | 184 | } |
175 | } | ||
176 | if ( rightfill ) | 185 | if ( rightfill ) |
177 | memset ( dst + leftfill + framefill, 0, rightfill ); | 186 | memset ( dst + leftfill + framefill, 0, rightfill ); // "right" border -> black |
178 | } | 187 | } |
179 | 188 | ||
180 | dst += m_bytes_per_line_fb; | 189 | dst += m_bytes_per_line_fb; // advance one line in the framebuffer |
181 | 190 | ||
191 | // advance one "line" in the xine frame data | ||
182 | switch ( rot ) { | 192 | switch ( rot ) { |
@@ -190,6 +200,7 @@ void XineVideoWidget::paintEvent ( QPaintEvent * ) | |||
190 | } | 200 | } |
191 | } | 201 | |
192 | //qWarning ( " ||| painting |||" ); | ||
193 | { | 202 | { |
194 | // QVFB hack by MArtin Jones | 203 | // QVFB hack by Martin Jones |
204 | // We need to "touch" all affected clip rects with a normal QPainter in addition to the QDirectPainter | ||
205 | |||
195 | QPainter p ( this ); | 206 | QPainter p ( this ); |
@@ -201,17 +212,17 @@ void XineVideoWidget::paintEvent ( QPaintEvent * ) | |||
201 | } | 212 | } |
202 | //qWarning( "painting >>>" ); | ||
203 | } | 213 | } |
204 | 214 | ||
215 | QImage *XineVideoWidget::logo ( ) const { | ||
216 | return m_logo; | ||
217 | } | ||
205 | 218 | ||
206 | void XineVideoWidget::setImage ( QImage* image ) | 219 | void XineVideoWidget::setLogo ( QImage * image ) { |
207 | { | 220 | delete m_logo; |
208 | delete m_image; | 221 | m_logo = image; |
209 | m_image = image; | ||
210 | } | 222 | } |
211 | 223 | ||
212 | void XineVideoWidget::setImage ( uchar* img, int w, int h, int bpl ) | 224 | void XineVideoWidget::setVideoFrame ( uchar * img, int w, int h, int bpl ) { |
213 | { | ||
214 | bool rot90 = (( -m_rotation ) & 1 ); | 225 | bool rot90 = (( -m_rotation ) & 1 ); |
215 | 226 | ||
216 | if ( rot90 ) { | 227 | if ( rot90 ) { // if the rotation is 90 or 270 we have to swap width / height |
217 | int d = w; | 228 | int d = w; |
@@ -224,4 +235,2 @@ void XineVideoWidget::setImage ( uchar* img, int w, int h, int bpl ) | |||
224 | 235 | ||
225 | // qDebug ( "Frame: %d,%d - %dx%d", ( width ( ) - w ) / 2, ( height ( ) - h ) / 2, w , h ); | ||
226 | |||
227 | m_buff = img; | 236 | m_buff = img; |
@@ -229,7 +238,8 @@ void XineVideoWidget::setImage ( uchar* img, int w, int h, int bpl ) | |||
229 | 238 | ||
230 | repaint ((( m_thisframe & m_lastframe ) != m_lastframe ) ? m_lastframe : m_thisframe, false ); | 239 | // only repaint the area that *really* needs to be repainted |
240 | |||
241 | repaint (( | ||
231 | } | 242 | } |
232 | 243 | ||
233 | void XineVideoWidget::resizeEvent ( QResizeEvent * ) | 244 | void XineVideoWidget::resizeEvent ( QResizeEvent * ) { |
234 | { | ||
235 | QSize s = size ( ); | 245 | QSize s = size ( ); |
@@ -237,9 +247,9 @@ void XineVideoWidget::resizeEvent ( QResizeEvent * ) | |||
237 | 247 | ||
248 | // if we are in fullscreen mode, do not rotate the video | ||
249 | // (!! the paint routine uses m_rotation + qt_screen-> transformOrientation() !!) | ||
250 | |||
238 | m_rotation = fs ? -qt_screen-> transformOrientation ( ) : 0; | 251 | m_rotation = fs ? -qt_screen-> transformOrientation ( ) : 0; |
239 | 252 | ||
240 | if ( fs && qt_screen-> isTransformed ( )) { | 253 | if ( fs && qt_screen-> isTransformed ( )) |
241 | s = qt_screen-> mapToDevice ( s ); | 254 | s = qt_screen-> mapToDevice ( s ); |
242 | } | ||
243 | |||
244 | // qDebug ( "\n\nResize: %dx%d, Rot: %d", s.width(),s.height(),m_rotation ); | ||
245 | 255 | ||
@@ -249,25 +259,5 @@ void XineVideoWidget::resizeEvent ( QResizeEvent * ) | |||
249 | 259 | ||
250 | void XineVideoWidget::mousePressEvent ( QMouseEvent * /*me*/ ) | 260 | void XineVideoWidget::mouseReleaseEvent ( QMouseEvent * ) { |
251 | { | ||
252 | QWidget *p = parentWidget ( ); | ||
253 | |||
254 | if ( p ) { | ||
255 | // QMouseEvent pme ( QEvent::MouseButtonPress, mapToParent ( me-> pos ( )), me-> globalPos ( ), me-> button ( ), me-> state ( )); | ||
256 | |||
257 | // QApplication::sendEvent ( p, &pme ); | ||
258 | // emit clicked(); | ||
259 | } | ||
260 | } | ||
261 | |||
262 | void XineVideoWidget::mouseReleaseEvent ( QMouseEvent * /*me*/ ) | ||
263 | { | ||
264 | QWidget *p = parentWidget ( ); | ||
265 | |||
266 | if ( p ) { | ||
267 | // QMouseEvent pme ( QEvent::MouseButtonRelease, mapToParent ( me-> pos ( )), me-> globalPos ( ), me-> button ( ), me-> state ( )); | ||
268 | |||
269 | // QApplication::sendEvent ( p, &pme ); | ||
270 | emit clicked(); | 261 | emit clicked(); |
271 | } | 262 | } |
272 | } | ||
273 | 263 | ||
diff --git a/noncore/multimedia/opieplayer2/xinevideowidget.h b/noncore/multimedia/opieplayer2/xinevideowidget.h index c5101da..33f1470 100644 --- a/noncore/multimedia/opieplayer2/xinevideowidget.h +++ b/noncore/multimedia/opieplayer2/xinevideowidget.h | |||
@@ -3,4 +3,3 @@ | |||
3 | 3 | ||
4 | Copyright (c) 2002 Max Reiss <harlekin@handhelds.org> | 4 | Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> |
5 | Copyright (c) 2002 LJP <> | ||
6 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> | 5 | Copyright (c) 2002 Holger Freyther <zecke@handhelds.org> |
@@ -40,4 +39,7 @@ | |||
40 | class QImage; | 39 | class QImage; |
40 | |||
41 | |||
41 | class XineVideoWidget : public QWidget { | 42 | class XineVideoWidget : public QWidget { |
42 | Q_OBJECT | 43 | Q_OBJECT |
44 | |||
43 | public: | 45 | public: |
@@ -45,5 +47,5 @@ public: | |||
45 | ~XineVideoWidget(); | 47 | ~XineVideoWidget(); |
46 | QImage *image() { return m_image; }; | 48 | QImage *logo ( ) const; |
47 | void setImage( QImage* image ); | 49 | void setLogo ( QImage *image ); |
48 | void setImage( uchar* image, int width, int height, int linestep); | 50 | void setVideoFrame ( uchar *image, int width, int height, int linestep ); |
49 | void clear() ; | 51 | void clear() ; |
@@ -54,3 +56,2 @@ protected: | |||
54 | 56 | ||
55 | void mousePressEvent ( QMouseEvent *e ); | ||
56 | void mouseReleaseEvent ( QMouseEvent *e ); | 57 | void mouseReleaseEvent ( QMouseEvent *e ); |
@@ -69,3 +70,3 @@ private: | |||
69 | int m_bytes_per_pixel; | 70 | int m_bytes_per_pixel; |
70 | QImage* m_image; | 71 | QImage *m_logo; |
71 | int m_rotation; | 72 | int m_rotation; |