我的Qt 5.9的源代碼,稱這兩個文件:
qvideoframeconversionhelper.cpp
qvideoframe.cpp
並找到我所需要的
void QT_FASTCALL qt_convert_YUV420P_to_ARGB32(const QVideoFrame &frame, uchar *output)
但QVideoFrame
在5.9與5.3不同,所以這個功能需要一些修改:
void QT_FASTCALL qt_convert_YUV420P_to_ARGB32(const QVideoFrame &frame, uchar *output)
{
//FETCH_INFO_TRIPLANAR(frame) ← this's not provided in 5.3
// Add this ↓
const int width = frame.width();
const int height = frame.height();
int yStride = frame.bytesPerLine();
int uvStride = (frame.mappedBytes() - (yStride * height))/height;
const uchar *plane1 = frame.bits();
const uchar *plane2 = plane1 + (yStride * height);
const uchar *plane3 = plane2 + (uvStride * height/2);
int plane1Stride = yStride;
int plane2Stride = uvStride;
int plane3Stride = uvStride;
// Add this ↑
planarYUV420_to_ARGB32(plane1, plane1Stride,
plane2, plane2Stride,
plane3, plane3Stride,
1,
reinterpret_cast<quint32*>(output),
width, height);
}
來源
2017-07-13 07:56:57
Jiu
https://stackoverflow.com/questions/43106069/how-to-convert-qvideoframe-with-yuv-data-to-qvideoframe-with-rgba32-data-in – AlexanderVX
@AlexanderVX謝謝,但問題,我正在使用Qt 5.3.1,解決方案需要Qt 5.4 – Jiu