我的环境:
Qt: 5.3.1
OS: Yocto Poky 1.6.2
Device: Freescale iMX6Q
Decode: MFW_GST_V4LSINK
我正在尝试捕获MP4格式视频的视频帧。 我的问题是:
QVideoFrame
。但是Yocto是Format_YUV420P。为什么会有所不同?答案 0 :(得分:0)
我在Qt 5.9源代码中引用了这两个文件:
qvideoframeconversionhelper.cpp
qvideoframe.cpp
找到我需要的东西
void QT_FASTCALL qt_convert_YUV420P_to_ARGB32(const QVideoFrame &frame, uchar *output)
但是5.9中的QVideoFrame
与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);
}