0

My Environment:

Qt: 5.3.1 
OS: Yocto Poky 1.6.2
Device: Freescale iMX6Q
Decode: MFW_GST_V4LSINK

I am trying to capture the video frame of MP4 format video. My problem is:

  1. Same source code and same video run on Windows, I fetch Format_RGB32 QVideoFrame. But Yocto is Format_YUV420P. Why it's different?
  2. Is there any way make Video output RGB colour video frame?
  3. The format of QVideoFrame depend on system or video?
JustWe
  • 4,250
  • 3
  • 39
  • 90
  • https://stackoverflow.com/questions/43106069/how-to-convert-qvideoframe-with-yuv-data-to-qvideoframe-with-rgba32-data-in – Alexander V Jul 07 '17 at 23:06
  • @AlexanderVX Thanks, but problem this I am using Qt 5.3.1, the solution require Qt 5.4 – JustWe Jul 10 '17 at 07:40

1 Answers1

0

I referred these two files in Qt 5.9 source code:

qvideoframeconversionhelper.cpp
qvideoframe.cpp

And find what I need

void QT_FASTCALL qt_convert_YUV420P_to_ARGB32(const QVideoFrame &frame, uchar *output)

But QVideoFrame in 5.9 is different with 5.3, so this function needs some modifying:

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);
}
JustWe
  • 4,250
  • 3
  • 39
  • 90