[Interest] Qt6: how to construct QVideoFrame from QImage ?

David M. Cotter dave at kjams.com
Wed Jul 7 18:38:49 CEST 2021


does this seem right?

	const QImage&	image(pix);

	#if _QT6_
		QVideoFrameFormat	frameFormat(
			image.size(),
			QVideoFrameFormat::pixelFormatFromImageFormat(image.format()));
		QVideoFrame		vidFrame(frameFormat); vidFrame.map(QVideoFrame::WriteOnly);
		uchar*			memBitsP(vidFrame.bits());
		const uchar*		imageBitsP(image.bits());
		size_t			memSizeL(vidFrame.mappedBytes());
		size_t			imgSizeL(image.sizeInBytes());

		CF_ASSERT(memSizeL == imgSizeL);
		std::copy(imageBitsP, imageBitsP + memSizeL, memBitsP);
		vidFrame.unmap();
	#else
		// qt5 version
		QVideoFrame		vidFrame(image);
	#endif

	present(vidFrame, opacityF);

seems like a lot of convolution just to get an image into a video frame. also why was the API designed to have the unnecessary copy? the api should take a bits* directly, rather than forcing you to copy your bits into yet another buffer.

am i missing something?

> On Jul 7, 2021, at 8:48 AM, David M. Cotter <dave at kjams.com> wrote:
> 
> seems the API to so so has been removed, so how do i do it?
> 
> i can't find any documentation on porting guidance

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20210707/8c75ac09/attachment.html>


More information about the Interest mailing list