2017-07-07 51 views
0

我的環境:如何指示supportedPixelFormats爲QAbstractVideoSurface

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

我試圖捕捉到MP4格式視頻的視頻幀。 我的問題是:

  1. 相同的源代碼和相同的視頻在Windows上運行,我取Format_RGB32 QVideoFrame。但Yocto是Format_YUV420P。爲什麼它不同?
  2. 有沒有辦法制作視頻輸出RGB彩色視頻幀?
  3. QVideoFrame的格式取決於系統還是視頻?
+0

https://stackoverflow.com/questions/43106069/how-to-convert-qvideoframe-with-yuv-data-to-qvideoframe-with-rgba32-data-in – AlexanderVX

+0

@AlexanderVX謝謝,但問題,我正在使用Qt 5.3.1,解決方案需要Qt 5.4 – Jiu

回答

0

我的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); 
}