353 return false; |
355 return false; |
354 } else if (m_image->width != frame.width() || m_image->height != frame.height()) { |
356 } else if (m_image->width != frame.width() || m_image->height != frame.height()) { |
355 setError(IncorrectFormatError); |
357 setError(IncorrectFormatError); |
356 return false; |
358 return false; |
357 } else { |
359 } else { |
358 lastFrame = frame; |
360 m_lastFrame = frame; |
359 |
361 |
360 if (!lastFrame.map(QAbstractVideoBuffer::ReadOnly)) { |
362 if (!m_lastFrame.map(QAbstractVideoBuffer::ReadOnly)) { |
361 qWarning() << "Failed to map video frame"; |
363 qWarning() << "Failed to map video frame"; |
362 setError(IncorrectFormatError); |
364 setError(IncorrectFormatError); |
363 return false; |
365 return false; |
364 } else { |
366 } else { |
365 bool presented = false; |
367 bool presented = false; |
366 |
368 |
367 if (frame.handleType() != XvHandleType && |
369 if (frame.handleType() != XvHandleType && |
368 m_image->data_size > lastFrame.mappedBytes()) { |
370 m_image->data_size > m_lastFrame.mappedBytes()) { |
369 qWarning("Insufficient frame buffer size"); |
371 qWarning("Insufficient frame buffer size"); |
370 setError(IncorrectFormatError); |
372 setError(IncorrectFormatError); |
371 } else if (frame.handleType() != XvHandleType && |
373 } else if (frame.handleType() != XvHandleType && |
372 m_image->num_planes > 0 && |
374 m_image->num_planes > 0 && |
373 m_image->pitches[0] != lastFrame.bytesPerLine()) { |
375 m_image->pitches[0] != m_lastFrame.bytesPerLine()) { |
374 qWarning("Incompatible frame pitches"); |
376 qWarning("Incompatible frame pitches"); |
375 setError(IncorrectFormatError); |
377 setError(IncorrectFormatError); |
376 } else { |
378 } else { |
377 XvImage *img = 0; |
379 XvImage *img = 0; |
378 |
380 |
379 if (frame.handleType() == XvHandleType) { |
381 if (frame.handleType() == XvHandleType) { |
380 img = frame.handle().value<XvImage*>(); |
382 img = frame.handle().value<XvImage*>(); |
381 } else { |
383 } else { |
382 img = m_image; |
384 img = m_image; |
383 memcpy(m_image->data, lastFrame.bits(), qMin(lastFrame.mappedBytes(), m_image->data_size)); |
385 memcpy(m_image->data, m_lastFrame.bits(), qMin(m_lastFrame.mappedBytes(), m_image->data_size)); |
384 } |
386 } |
385 |
387 |
386 if (img) |
388 if (img) |
387 XvShmPutImage( |
389 XvShmPutImage( |
388 QX11Info::display(), |
390 QX11Info::display(), |