author | alwin <alwin> | 2005-03-31 14:24:17 (UTC) |
---|---|---|
committer | alwin <alwin> | 2005-03-31 14:24:17 (UTC) |
commit | b135ff0f8c4d1876eea8ecc81e2a821ec8e9cb9a (patch) (unidiff) | |
tree | 8cc7536354402f62dd99aac590dd91365abe5183 | |
parent | db876361603ccf1664698df926a3c61d32315101 (diff) | |
download | opie-b135ff0f8c4d1876eea8ecc81e2a821ec8e9cb9a.zip opie-b135ff0f8c4d1876eea8ecc81e2a821ec8e9cb9a.tar.gz opie-b135ff0f8c4d1876eea8ecc81e2a821ec8e9cb9a.tar.bz2 |
fix for the segfaults when displaying videos (it just had sometimes
invalid inputimages when repainting)
-rw-r--r-- | noncore/multimedia/opieplayer2/xinevideowidget.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/noncore/multimedia/opieplayer2/xinevideowidget.cpp b/noncore/multimedia/opieplayer2/xinevideowidget.cpp index 1ac9277..9e86041 100644 --- a/noncore/multimedia/opieplayer2/xinevideowidget.cpp +++ b/noncore/multimedia/opieplayer2/xinevideowidget.cpp | |||
@@ -196,109 +196,111 @@ void XineVideoWidget::paintEvent ( QPaintEvent * ) | |||
196 | 196 | ||
197 | uint leftfill = 0; // black border on the "left" side of the video frame | 197 | uint leftfill = 0; // black border on the "left" side of the video frame |
198 | uint framefill = 0; // "width" of the video frame | 198 | uint framefill = 0; // "width" of the video frame |
199 | uint rightfill = 0; // black border on the "right" side of the video frame | 199 | uint rightfill = 0; // black border on the "right" side of the video frame |
200 | uint clipwidth = clip. width ( ) * m_bytes_per_pixel; // "width" of the current clip rect | 200 | uint clipwidth = clip. width ( ) * m_bytes_per_pixel; // "width" of the current clip rect |
201 | 201 | ||
202 | if ( clip. left ( ) < framerect. left ( )) | 202 | if ( clip. left ( ) < framerect. left ( )) |
203 | leftfill = (( framerect. left ( ) - clip. left ( )) * m_bytes_per_pixel ) <? clipwidth; | 203 | leftfill = (( framerect. left ( ) - clip. left ( )) * m_bytes_per_pixel ) <? clipwidth; |
204 | if ( clip. right ( ) > framerect. right ( )) | 204 | if ( clip. right ( ) > framerect. right ( )) |
205 | rightfill = (( clip. right ( ) - framerect. right ( )) * m_bytes_per_pixel ) <? clipwidth; | 205 | rightfill = (( clip. right ( ) - framerect. right ( )) * m_bytes_per_pixel ) <? clipwidth; |
206 | 206 | ||
207 | framefill = clipwidth - ( leftfill + rightfill ); | 207 | framefill = clipwidth - ( leftfill + rightfill ); |
208 | 208 | ||
209 | for ( int y = clip. top ( ); y <= clip. bottom ( ); y++ ) { | 209 | for ( int y = clip. top ( ); y <= clip. bottom ( ); y++ ) { |
210 | if (( y < framerect. top ( )) || ( y > framerect. bottom ( ))) { | 210 | if (( y < framerect. top ( )) || ( y > framerect. bottom ( ))) { |
211 | // "above" or "below" the video -> black | 211 | // "above" or "below" the video -> black |
212 | memset ( dst, 0, clipwidth ); | 212 | memset ( dst, 0, clipwidth ); |
213 | } | 213 | } |
214 | else { | 214 | else { |
215 | if ( leftfill ) | 215 | if ( leftfill ) |
216 | memset ( dst, 0, leftfill ); // "left" border -> black | 216 | memset ( dst, 0, leftfill ); // "left" border -> black |
217 | 217 | ||
218 | if ( framefill ) { // blit in the video frame | 218 | if ( framefill ) { // blit in the video frame |
219 | // see above for an explanation of the different memcpys | 219 | // see above for an explanation of the different memcpys |
220 | 220 | ||
221 | switch ( rot ) { | 221 | switch ( rot ) { |
222 | case 0: memcpy ( dst + leftfill, src, framefill & ~1 ); break; | 222 | case 0: memcpy ( dst + leftfill, src, framefill & ~1 ); break; |
223 | case 1: memcpy_step ( dst + leftfill, src, framefill, m_bytes_per_line_frame ); break; | 223 | case 1: memcpy_step ( dst + leftfill, src, framefill, m_bytes_per_line_frame ); break; |
224 | case 2: memcpy_rev ( dst + leftfill, src, framefill ); break; | 224 | case 2: memcpy_rev ( dst + leftfill, src, framefill ); break; |
225 | case 3: memcpy_step_rev ( dst + leftfill, src, framefill, m_bytes_per_line_frame ); break; | 225 | case 3: memcpy_step_rev ( dst + leftfill, src, framefill, m_bytes_per_line_frame ); break; |
226 | default: break; | 226 | default: break; |
227 | } | 227 | } |
228 | } | 228 | } |
229 | if ( rightfill ) | 229 | if ( rightfill ) |
230 | memset ( dst + leftfill + framefill, 0, rightfill ); // "right" border -> black | 230 | memset ( dst + leftfill + framefill, 0, rightfill ); // "right" border -> black |
231 | } | 231 | } |
232 | 232 | ||
233 | dst += m_bytes_per_line_fb; // advance one line in the framebuffer | 233 | dst += m_bytes_per_line_fb; // advance one line in the framebuffer |
234 | 234 | ||
235 | // advance one "line" in the xine frame data | 235 | // advance one "line" in the xine frame data |
236 | switch ( rot ) { | 236 | switch ( rot ) { |
237 | case 0: src += m_bytes_per_line_frame;break; | 237 | case 0: src += m_bytes_per_line_frame;break; |
238 | case 1: src -= m_bytes_per_pixel; break; | 238 | case 1: src -= m_bytes_per_pixel; break; |
239 | case 2: src -= m_bytes_per_line_frame; break; | 239 | case 2: src -= m_bytes_per_line_frame; break; |
240 | case 3: src += m_bytes_per_pixel; break; | 240 | case 3: src += m_bytes_per_pixel; break; |
241 | default: break; | 241 | default: break; |
242 | } | 242 | } |
243 | } | 243 | } |
244 | } | 244 | } |
245 | } | 245 | } |
246 | 246 | ||
247 | { | 247 | { |
248 | // QVFB hack by Martin Jones | 248 | // QVFB hack by Martin Jones |
249 | // We need to "touch" all affected clip rects with a normal QPainter in addition to the QDirectPainter | 249 | // We need to "touch" all affected clip rects with a normal QPainter in addition to the QDirectPainter |
250 | 250 | ||
251 | QPainter p ( this ); | 251 | QPainter p ( this ); |
252 | 252 | ||
253 | for ( int i = qt_bug_workaround_clip_rects. size ( ) - 1; i >= 0; i-- ) { | 253 | for ( int i = qt_bug_workaround_clip_rects. size ( ) - 1; i >= 0; i-- ) { |
254 | p. fillRect ( QRect ( mapFromGlobal ( qt_bug_workaround_clip_rects [ i ]. topLeft ( )), qt_bug_workaround_clip_rects [ i ]. size ( )), QBrush ( NoBrush )); | 254 | p. fillRect ( QRect ( mapFromGlobal ( qt_bug_workaround_clip_rects [ i ]. topLeft ( )), qt_bug_workaround_clip_rects [ i ]. size ( )), QBrush ( NoBrush )); |
255 | } | 255 | } |
256 | } | 256 | } |
257 | } | 257 | } |
258 | } | 258 | } |
259 | 259 | ||
260 | 260 | ||
261 | QImage *XineVideoWidget::logo ( ) const | 261 | QImage *XineVideoWidget::logo ( ) const |
262 | { | 262 | { |
263 | return m_logo; | 263 | return m_logo; |
264 | } | 264 | } |
265 | 265 | ||
266 | 266 | ||
267 | void XineVideoWidget::setLogo ( QImage* logo ) | 267 | void XineVideoWidget::setLogo ( QImage* logo ) |
268 | { | 268 | { |
269 | delete m_logo; | 269 | delete m_logo; |
270 | m_logo = logo; | 270 | m_logo = logo; |
271 | } | 271 | } |
272 | 272 | ||
273 | void XineVideoWidget::setVideoFrame ( uchar* img, int w, int h, int bpl ) | 273 | void XineVideoWidget::setVideoFrame ( uchar* img, int w, int h, int bpl ) |
274 | { | 274 | { |
275 | bool rot90 = (( -m_rotation ) & 1 ); | 275 | bool rot90 = (( -m_rotation ) & 1 ); |
276 | 276 | ||
277 | if ( rot90 ) { // if the rotation is 90 or 270 we have to swap width / height | 277 | if ( rot90 ) { // if the rotation is 90 or 270 we have to swap width / height |
278 | int d = w; | 278 | int d = w; |
279 | w = h; | 279 | w = h; |
280 | h = d; | 280 | h = d; |
281 | } | 281 | } |
282 | 282 | ||
283 | m_lastframe = m_thisframe; | 283 | m_lastframe = m_thisframe; |
284 | m_thisframe. setRect (( width ( ) - w ) / 2, ( height ( ) - h ) / 2, w , h ); | 284 | m_thisframe. setRect (( width ( ) - w ) / 2, ( height ( ) - h ) / 2, w , h ); |
285 | 285 | ||
286 | m_buff = img; | 286 | m_buff = img; |
287 | m_bytes_per_line_frame = bpl; | 287 | m_bytes_per_line_frame = bpl; |
288 | 288 | ||
289 | // only repaint the area that *really* needs to be repainted | 289 | // only repaint the area that *really* needs to be repainted |
290 | 290 | ||
291 | repaint ((( m_thisframe & m_lastframe ) != m_lastframe ) ? m_lastframe : m_thisframe, false ); | 291 | repaint ((( m_thisframe & m_lastframe ) != m_lastframe ) ? m_lastframe : m_thisframe, false ); |
292 | // ensure that we always have a valid frame! | ||
293 | m_buff = 0; | ||
292 | } | 294 | } |
293 | 295 | ||
294 | void XineVideoWidget::resizeEvent ( QResizeEvent * ) | 296 | void XineVideoWidget::resizeEvent ( QResizeEvent * ) |
295 | { | 297 | { |
296 | emit videoResized( videoSize() ); | 298 | emit videoResized( videoSize() ); |
297 | } | 299 | } |
298 | 300 | ||
299 | 301 | ||
300 | void XineVideoWidget::mouseReleaseEvent ( QMouseEvent * /*me*/ ) | 302 | void XineVideoWidget::mouseReleaseEvent ( QMouseEvent * /*me*/ ) |
301 | { | 303 | { |
302 | emit clicked(); | 304 | emit clicked(); |
303 | } | 305 | } |
304 | 306 | ||