summaryrefslogtreecommitdiff
authorsandman <sandman>2002-08-02 00:22:01 (UTC)
committer sandman <sandman>2002-08-02 00:22:01 (UTC)
commitca057e02c3bacb8226d5209fcd9aa24009cdb78e (patch) (unidiff)
tree46b4072715ec2f6fcd9affb5f5f3988dba4f3438
parentdae78cce45fb769720874562821d099d979b2c87 (diff)
downloadopie-ca057e02c3bacb8226d5209fcd9aa24009cdb78e.zip
opie-ca057e02c3bacb8226d5209fcd9aa24009cdb78e.tar.gz
opie-ca057e02c3bacb8226d5209fcd9aa24009cdb78e.tar.bz2
Video should work now in QVFB and on the iPAQ with all transformations
(0,90,180 and 270 deg)
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/xinevideowidget.cpp151
1 files changed, 57 insertions, 94 deletions
diff --git a/noncore/multimedia/opieplayer2/xinevideowidget.cpp b/noncore/multimedia/opieplayer2/xinevideowidget.cpp
index 8e8f139..4b69044 100644
--- a/noncore/multimedia/opieplayer2/xinevideowidget.cpp
+++ b/noncore/multimedia/opieplayer2/xinevideowidget.cpp
@@ -35,8 +35,9 @@
35#include <qimage.h> 35#include <qimage.h>
36#include <qpainter.h> 36#include <qpainter.h>
37#include <qgfx_qws.h> 37#include <qgfx_qws.h>
38#include <qdirectpainter_qws.h> 38#include <qdirectpainter_qws.h>
39#include <qgfx_qws.h>
39#include <qsize.h> 40#include <qsize.h>
40 41
41#include <qpe/resource.h> 42#include <qpe/resource.h>
42 43
@@ -54,12 +55,8 @@ static inline void memcpy_rev ( void *dst, void *src, size_t len )
54static inline void memcpy_step ( void *dst, void *src, size_t len, size_t step ) 55static inline void memcpy_step ( void *dst, void *src, size_t len, size_t step )
55{ 56{
56 len >>= 1; 57 len >>= 1;
57 while ( len-- ) { 58 while ( len-- ) {
58 // *((char *) dst ) = *((char *) src + 1);
59 // *((char *) dst + 1) = *((char *) src );
60 // ((char *) dst ) += 2;
61
62 *((short int *) dst )++ = *((short int *) src ); 59 *((short int *) dst )++ = *((short int *) src );
63 ((char *) src ) += step; 60 ((char *) src ) += step;
64 } 61 }
65} 62}
@@ -72,12 +69,8 @@ static inline void memcpy_step_rev ( void *dst, void *src, size_t len, size_t st
72 69
73 while ( len-- ) { 70 while ( len-- ) {
74 ((char *) src ) -= step; 71 ((char *) src ) -= step;
75 *((short int *) dst )++ = *((short int *) src ); 72 *((short int *) dst )++ = *((short int *) src );
76
77 // *((char *) dst ) = *((char *) src + 1);
78 // *((char *) dst + 1) = *((char *) src );
79 // ((char *) dst ) += 2;
80 } 73 }
81} 74}
82 75
83 76
@@ -108,14 +101,14 @@ void XineVideoWidget::clear ( )
108} 101}
109 102
110void XineVideoWidget::paintEvent ( QPaintEvent * ) 103void XineVideoWidget::paintEvent ( QPaintEvent * )
111{ 104{
112 qWarning( "painting <<<" ); 105 //qWarning( "painting <<<" );
113 if ( m_buff == 0 ) { 106 if ( m_buff == 0 ) {
114 QPainter p ( this ); 107 QPainter p ( this );
115 p. fillRect ( rect ( ), black ); 108 p. fillRect ( rect ( ), black );
116 p. drawImage ( 0, 0, *m_image ); 109 p. drawImage ( 0, 0, *m_image );
117 qWarning ( "logo\n" ); 110 //qWarning ( "logo\n" );
118 } 111 }
119 else { 112 else {
120 // qWarning ( "paintevent\n" ); 113 // qWarning ( "paintevent\n" );
121 114
@@ -128,111 +121,81 @@ void XineVideoWidget::paintEvent ( QPaintEvent * )
128 121
129 uchar *fb = dp. frameBuffer ( ); 122 uchar *fb = dp. frameBuffer ( );
130 uchar *frame = m_buff; // rot == 0 ? m_buff : m_buff + ( m_thisframe. height ( ) - 1 ) * m_bytes_per_line_frame; 123 uchar *frame = m_buff; // rot == 0 ? m_buff : m_buff + ( m_thisframe. height ( ) - 1 ) * m_bytes_per_line_frame;
131 124
132 QRect framerect = QRect ( mapToGlobal ( m_thisframe. topLeft ( )), m_thisframe. size ( )); 125 QRect framerect = qt_screen-> mapToDevice ( QRect ( mapToGlobal ( m_thisframe. topLeft ( )), m_thisframe. size ( )), QSize ( qt_screen-> width ( ), qt_screen-> height ( )));
133 126
134 qt_bug_workaround_clip_rects. resize ( dp. numRects ( )); 127 qt_bug_workaround_clip_rects. resize ( dp. numRects ( ));
135 128
136 for ( int i = dp. numRects ( ) - 1; i >= 0; i-- ) { 129 for ( int i = dp. numRects ( ) - 1; i >= 0; i-- ) {
137 const QRect &clip = dp. rect ( i ); 130 const QRect &clip = dp. rect ( i );
138 131
139 qt_bug_workaround_clip_rects [i] = clip; 132 qt_bug_workaround_clip_rects [i] = qt_screen-> mapFromDevice ( clip, QSize ( qt_screen-> width ( ), qt_screen-> height ( )));
140 133
141 if ( rot == 0 || rot == 180 ) { 134 uchar *dst = fb + ( clip. x ( ) * m_bytes_per_pixel ) + ( clip. y ( ) * m_bytes_per_line_fb );
142 uchar *dst = fb + ( clip. x ( ) * m_bytes_per_pixel ) + ( clip. y ( ) * m_bytes_per_line_fb ); 135 uchar *src = frame;
143 uchar *src = frame + (( clip. x ( ) - framerect. x ( )) * m_bytes_per_pixel ) + (( clip. y ( ) - framerect. y ( )) * m_bytes_per_line_frame ); 136
144 137 switch ( rot ) {
145 if ( rot == 180 ) 138 case 0: src += ( (( clip. x ( ) - framerect. x ( )) * m_bytes_per_pixel ) + (( clip. y ( ) - framerect. y ( )) * m_bytes_per_line_frame ) ); break;
146 src += (( framerect. height ( ) - 1 ) * m_bytes_per_line_frame ); 139 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;
147 140 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;
148 uint leftfill = 0; 141 case 3: src += ( (( clip. y ( ) - framerect. y ( )) * m_bytes_per_pixel ) + (( clip. x ( ) - framerect. x ( )) * m_bytes_per_line_frame ) ); break;
149 uint framefill = 0;
150 uint rightfill = 0;
151 uint clipwidth = clip. width ( ) * m_bytes_per_pixel;
152
153 if ( clip. left ( ) < framerect. left ( ))
154 leftfill = (( framerect. left ( ) - clip. left ( )) * m_bytes_per_pixel ) <? clipwidth;
155 if ( clip. right ( ) > framerect. right ( ))
156 rightfill = (( clip. right ( ) - framerect. right ( )) * m_bytes_per_pixel ) <? clipwidth;
157
158 framefill = clipwidth - ( leftfill + rightfill );
159
160 for ( int y = clip. top ( ); y <= clip. bottom ( ); y++ ) {
161 if (( y < framerect. top ( )) || ( y > framerect. bottom ( ))) {
162 memset ( dst, 0, clipwidth );
163 }
164 else {
165 if ( leftfill )
166 memset ( dst, 0, leftfill );
167
168 if ( framefill ) {
169 if ( rot == 0 )
170 memcpy ( dst + leftfill, src, framefill );
171 else
172 memcpy_rev ( dst + leftfill, src, framefill );
173 }
174 if ( rightfill )
175 memset ( dst + leftfill + framefill, 0, rightfill );
176 }
177
178 dst += m_bytes_per_line_fb;
179 src += ( rot == 0 ? m_bytes_per_line_frame : -m_bytes_per_line_frame );
180 }
181 } 142 }
182 else { // rot == 90 || rot == 270 143
183 uchar *dst = fb + ( clip. y ( ) * m_bytes_per_pixel ) + ( clip. x ( ) * m_bytes_per_line_fb ); 144 uint leftfill = 0;
184 uchar *src = frame + (( clip. x ( ) - framerect. x ( )) * m_bytes_per_pixel ) + (( clip. y ( ) - framerect. y ( )) * m_bytes_per_line_frame ); 145 uint framefill = 0;
185 146 uint rightfill = 0;
186 if ( rot == 270 ) 147 uint clipwidth = clip. width ( ) * m_bytes_per_pixel;
187 src += (( framerect. height ( ) - 1 ) * m_bytes_per_pixel ); 148
188 149 if ( clip. left ( ) < framerect. left ( ))
189 uint leftfill = 0; 150 leftfill = (( framerect. left ( ) - clip. left ( )) * m_bytes_per_pixel ) <? clipwidth;
190 uint framefill = 0; 151 if ( clip. right ( ) > framerect. right ( ))
191 uint rightfill = 0; 152 rightfill = (( clip. right ( ) - framerect. right ( )) * m_bytes_per_pixel ) <? clipwidth;
192 uint clipwidth = clip. height ( ) * m_bytes_per_pixel; 153
193 154 framefill = clipwidth - ( leftfill + rightfill );
194 if ( clip. bottom ( ) > framerect. bottom ( )) 155
195 leftfill = (( clip. bottom ( ) - framerect. bottom ( )) * m_bytes_per_pixel ) <? clipwidth; 156 for ( int y = clip. top ( ); y <= clip. bottom ( ); y++ ) {
196 if ( clip. top ( ) < framerect. top ( )) 157 if (( y < framerect. top ( )) || ( y > framerect. bottom ( ))) {
197 rightfill = (( framerect. top ( ) - framerect. top ( )) * m_bytes_per_pixel ) <? clipwidth; 158 memset ( dst, 0, clipwidth );
159 }
160 else {
161 if ( leftfill )
162 memset ( dst, 0, leftfill );
163
164 if ( framefill ) {
165 switch ( rot ) {
166 case 0: memcpy ( dst + leftfill, src, framefill ); break;
167 case 1: memcpy_step ( dst + leftfill, src, framefill, m_bytes_per_line_frame ); break;
168 case 2: memcpy_rev ( dst + leftfill, src, framefill ); break;
169 case 3: memcpy_step_rev ( dst + leftfill, src, framefill, m_bytes_per_line_frame ); break;
170 }
171 }
172 if ( rightfill )
173 memset ( dst + leftfill + framefill, 0, rightfill );
174 }
198 175
199 framefill = clipwidth - ( leftfill + rightfill ); 176 dst += m_bytes_per_line_fb;
200 177
201 for ( int y = clip. left ( ); y <= clip. right ( ); y++ ) { 178 switch ( rot ) {
202 if (( y < framerect. left ( )) || ( y > framerect. right ( ))) { 179 case 0: src += m_bytes_per_line_frame; break;
203 memset ( dst, 0, clipwidth ); 180 case 1: src -= m_bytes_per_pixel; break;
204 } 181 case 2: src -= m_bytes_per_line_frame; break;
205 else { 182 case 3: src += m_bytes_per_pixel; break;
206 if ( leftfill ) 183 }
207 memset ( dst, 0, leftfill );
208
209 if ( framefill ) {
210 if ( rot == 90 )
211 memcpy_step_rev ( dst + leftfill, src, framefill, m_bytes_per_line_frame );
212 else
213 memcpy_step ( dst + leftfill, src, framefill, m_bytes_per_line_frame );
214 }
215 if ( rightfill )
216 memset ( dst + leftfill + framefill, 0, rightfill );
217 }
218
219 dst += m_bytes_per_line_fb;
220 src += ( rot == 270 ? -m_bytes_per_pixel : m_bytes_per_pixel );
221 }
222 } 184 }
223 } 185 }
224 } 186 }
187 //qWarning ( " ||| painting |||" );
225 { 188 {
226 // QVFB hack by MArtin Jones 189 // QVFB hack by MArtin Jones
227 QPainter p ( this ); 190 QPainter p ( this );
228 191
229 for ( int i = qt_bug_workaround_clip_rects. size ( ) - 1; i >= 0; i-- ) { 192 for ( int i = qt_bug_workaround_clip_rects. size ( ) - 1; i >= 0; i-- ) {
230 p. fillRect ( QRect ( mapFromGlobal ( qt_bug_workaround_clip_rects [i]. topLeft ( )), qt_bug_workaround_clip_rects [i]. size ( )), QBrush ( NoBrush ) ); 193 p. fillRect ( QRect ( mapFromGlobal ( qt_bug_workaround_clip_rects [i]. topLeft ( )), qt_bug_workaround_clip_rects [i]. size ( )), QBrush ( NoBrush ) );
231 } 194 }
232 } 195 }
233 } 196 }
234 qWarning( "painting >>>" ); 197 //qWarning( "painting >>>" );
235} 198}
236 199
237int XineVideoWidget::height ( ) const 200int XineVideoWidget::height ( ) const
238{ 201{