summaryrefslogtreecommitdiff
authorsandman <sandman>2002-12-11 18:35:16 (UTC)
committer sandman <sandman>2002-12-11 18:35:16 (UTC)
commit8ca42b97de03ac84da04b9be84f9bbb8eb17b52d (patch) (unidiff)
tree07e9ed49638eadda2dc475aa965562d199932826
parentb8db7cfea977d20f2d491b0a208a237efb15019a (diff)
downloadopie-8ca42b97de03ac84da04b9be84f9bbb8eb17b52d.zip
opie-8ca42b97de03ac84da04b9be84f9bbb8eb17b52d.tar.gz
opie-8ca42b97de03ac84da04b9be84f9bbb8eb17b52d.tar.bz2
valgrind complained and here are some off-by-1 fixes
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/multimedia/opieplayer2/xinevideowidget.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/noncore/multimedia/opieplayer2/xinevideowidget.cpp b/noncore/multimedia/opieplayer2/xinevideowidget.cpp
index 791818e..0833784 100644
--- a/noncore/multimedia/opieplayer2/xinevideowidget.cpp
+++ b/noncore/multimedia/opieplayer2/xinevideowidget.cpp
@@ -30,51 +30,52 @@
30 Boston, MA 02111-1307, USA. 30 Boston, MA 02111-1307, USA.
31 31
32*/ 32*/
33 33
34#include <qimage.h> 34#include <qimage.h>
35#include <qpainter.h> 35#include <qpainter.h>
36#include <qgfx_qws.h> 36#include <qgfx_qws.h>
37#include <qdirectpainter_qws.h> 37#include <qdirectpainter_qws.h>
38#include <qgfx_qws.h> 38#include <qgfx_qws.h>
39#include <qsize.h> 39#include <qsize.h>
40#include <qapplication.h> 40#include <qapplication.h>
41#include <qpainter.h> 41#include <qpainter.h>
42 42
43#include <qpe/resource.h> 43#include <qpe/resource.h>
44 44
45#include "xinevideowidget.h" 45#include "xinevideowidget.h"
46 46
47 47
48// 0 deg rot: copy a line from src to dst (use libc memcpy) 48// 0 deg rot: copy a line from src to dst (use libc memcpy)
49 49
50// 180 deg rot: copy a line from src to dst reversed 50// 180 deg rot: copy a line from src to dst reversed
51 51
52static inline void memcpy_rev ( void *dst, void *src, size_t len ) 52static inline void memcpy_rev ( void *dst, void *src, size_t len )
53{ 53{
54 ((char *) src ) += len;
55
56 len >>= 1; 54 len >>= 1;
55
56 ((char *) src ) += ( len << 1 );
57
57 while ( len-- ) 58 while ( len-- )
58 *((short int *) dst )++ = *--((short int *) src ); 59 *((short int *) dst )++ = *--((short int *) src );
59} 60}
60 61
61// 90 deg rot: copy a column from src to dst 62// 90 deg rot: copy a column from src to dst
62 63
63static inline void memcpy_step ( void *dst, void *src, size_t len, size_t step ) 64static inline void memcpy_step ( void *dst, void *src, size_t len, size_t step )
64{ 65{
65 len >>= 1; 66 len >>= 1;
66 while ( len-- ) { 67 while ( len-- ) {
67 *((short int *) dst )++ = *((short int *) src ); 68 *((short int *) dst )++ = *((short int *) src );
68 ((char *) src ) += step; 69 ((char *) src ) += step;
69 } 70 }
70} 71}
71 72
72// 270 deg rot: copy a column from src to dst reversed 73// 270 deg rot: copy a column from src to dst reversed
73 74
74static inline void memcpy_step_rev ( void *dst, void *src, size_t len, size_t step ) 75static inline void memcpy_step_rev ( void *dst, void *src, size_t len, size_t step )
75{ 76{
76 len >>= 1; 77 len >>= 1;
77 78
78 ((char *) src ) += ( len * step ); 79 ((char *) src ) += ( len * step );
79 80
80 while ( len-- ) { 81 while ( len-- ) {
@@ -171,49 +172,49 @@ void XineVideoWidget::paintEvent ( QPaintEvent * )
171 uint framefill = 0; // "width" of the video frame 172 uint framefill = 0; // "width" of the video frame
172 uint rightfill = 0; // black border on the "right" side of the video frame 173 uint rightfill = 0; // black border on the "right" side of the video frame
173 uint clipwidth = clip. width ( ) * m_bytes_per_pixel; // "width" of the current clip rect 174 uint clipwidth = clip. width ( ) * m_bytes_per_pixel; // "width" of the current clip rect
174 175
175 if ( clip. left ( ) < framerect. left ( )) 176 if ( clip. left ( ) < framerect. left ( ))
176 leftfill = (( framerect. left ( ) - clip. left ( )) * m_bytes_per_pixel ) <? clipwidth; 177 leftfill = (( framerect. left ( ) - clip. left ( )) * m_bytes_per_pixel ) <? clipwidth;
177 if ( clip. right ( ) > framerect. right ( )) 178 if ( clip. right ( ) > framerect. right ( ))
178 rightfill = (( clip. right ( ) - framerect. right ( )) * m_bytes_per_pixel ) <? clipwidth; 179 rightfill = (( clip. right ( ) - framerect. right ( )) * m_bytes_per_pixel ) <? clipwidth;
179 180
180 framefill = clipwidth - ( leftfill + rightfill ); 181 framefill = clipwidth - ( leftfill + rightfill );
181 182
182 for ( int y = clip. top ( ); y <= clip. bottom ( ); y++ ) { 183 for ( int y = clip. top ( ); y <= clip. bottom ( ); y++ ) {
183 if (( y < framerect. top ( )) || ( y > framerect. bottom ( ))) { 184 if (( y < framerect. top ( )) || ( y > framerect. bottom ( ))) {
184 // "above" or "below" the video -> black 185 // "above" or "below" the video -> black
185 memset ( dst, 0, clipwidth ); 186 memset ( dst, 0, clipwidth );
186 } 187 }
187 else { 188 else {
188 if ( leftfill ) 189 if ( leftfill )
189 memset ( dst, 0, leftfill ); // "left" border -> black 190 memset ( dst, 0, leftfill ); // "left" border -> black
190 191
191 if ( framefill ) { // blit in the video frame 192 if ( framefill ) { // blit in the video frame
192 // see above for an explanation of the different memcpys 193 // see above for an explanation of the different memcpys
193 194
194 switch ( rot ) { 195 switch ( rot ) {
195 case 0: memcpy ( dst + leftfill, src, framefill ); break; 196 case 0: memcpy ( dst + leftfill, src, framefill & ~1 ); break;
196 case 1: memcpy_step ( dst + leftfill, src, framefill, m_bytes_per_line_frame ); break; 197 case 1: memcpy_step ( dst + leftfill, src, framefill, m_bytes_per_line_frame ); break;
197 case 2: memcpy_rev ( dst + leftfill, src, framefill ); break; 198 case 2: memcpy_rev ( dst + leftfill, src, framefill ); break;
198 case 3: memcpy_step_rev ( dst + leftfill, src, framefill, m_bytes_per_line_frame ); break; 199 case 3: memcpy_step_rev ( dst + leftfill, src, framefill, m_bytes_per_line_frame ); break;
199 default: break; 200 default: break;
200 } 201 }
201 } 202 }
202 if ( rightfill ) 203 if ( rightfill )
203 memset ( dst + leftfill + framefill, 0, rightfill ); // "right" border -> black 204 memset ( dst + leftfill + framefill, 0, rightfill ); // "right" border -> black
204 } 205 }
205 206
206 dst += m_bytes_per_line_fb; // advance one line in the framebuffer 207 dst += m_bytes_per_line_fb; // advance one line in the framebuffer
207 208
208 // advance one "line" in the xine frame data 209 // advance one "line" in the xine frame data
209 switch ( rot ) { 210 switch ( rot ) {
210 case 0: src += m_bytes_per_line_frame;break; 211 case 0: src += m_bytes_per_line_frame;break;
211 case 1: src -= m_bytes_per_pixel; break; 212 case 1: src -= m_bytes_per_pixel; break;
212 case 2: src -= m_bytes_per_line_frame; break; 213 case 2: src -= m_bytes_per_line_frame; break;
213 case 3: src += m_bytes_per_pixel; break; 214 case 3: src += m_bytes_per_pixel; break;
214 default: break; 215 default: break;
215 } 216 }
216 } 217 }
217 } 218 }
218 } 219 }
219 220