diff options
Diffstat (limited to 'src/multimedia/video/qvideoframe.cpp')
-rw-r--r-- | src/multimedia/video/qvideoframe.cpp | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/multimedia/video/qvideoframe.cpp b/src/multimedia/video/qvideoframe.cpp index b466a3180..5e2d6df39 100644 --- a/src/multimedia/video/qvideoframe.cpp +++ b/src/multimedia/video/qvideoframe.cpp @@ -227,6 +227,11 @@ private: horizontally and vertically sub-sampled, i.e. the height and width of the U and V planes are half that of the Y plane. + \value Format_YUV422P + The frame is stored using an 8-bit per component planar YUV format with the U and V planes + horizontally sub-sampled, i.e. the width of the U and V planes are + half that of the Y plane, and height of U and V planes is the same as Y. + \value Format_YV12 The frame is stored using an 8-bit per component planar YVU format with the V and U planes horizontally and vertically sub-sampled, i.e. the height and width of the V and U planes are @@ -638,6 +643,7 @@ bool QVideoFrame::map(QAbstractVideoBuffer::MapMode mode) // Single plane or opaque format. break; case Format_YUV420P: + case Format_YUV422P: case Format_YV12: { // The UV stride is usually half the Y stride and is 32-bit aligned. // However it's not always the case, at least on Windows where the @@ -646,13 +652,14 @@ bool QVideoFrame::map(QAbstractVideoBuffer::MapMode mode) // have a correct stride. const int height = d->size.height(); const int yStride = d->bytesPerLine[0]; - const int uvStride = (d->mappedBytes - (yStride * height)) / height; + const int uvHeight = d->pixelFormat == Format_YUV422P ? height : height / 2; + const int uvStride = (d->mappedBytes - (yStride * height)) / uvHeight / 2; - // Three planes, the second and third vertically and horizontally subsampled. + // Three planes, the second and third vertically (and horizontally for other than Format_YUV422P formats) subsampled. d->planeCount = 3; d->bytesPerLine[2] = d->bytesPerLine[1] = uvStride; d->data[1] = d->data[0] + (yStride * height); - d->data[2] = d->data[1] + (uvStride * height / 2); + d->data[2] = d->data[1] + (uvStride * uvHeight); break; } case Format_NV12: @@ -1001,6 +1008,7 @@ QImage::Format QVideoFrame::imageFormatFromPixelFormat(PixelFormat format) case Format_AYUV444_Premultiplied: case Format_YUV444: case Format_YUV420P: + case Format_YUV422P: case Format_YV12: case Format_UYVY: case Format_YUYV: @@ -1072,7 +1080,7 @@ static VideoFrameConvertFunc qConvertFuncs[QVideoFrame::NPixelFormats] = { /* Format_CameraRaw */ nullptr, /* Format_AdobeDng */ nullptr, /* Format_ABGR32 */ nullptr, // ### Qt 6: reorder - + /* Format_YUV422P */ nullptr, }; static void qInitConvertFuncsAsm() @@ -1192,6 +1200,8 @@ QDebug operator<<(QDebug dbg, QVideoFrame::PixelFormat pf) return dbg << "Format_YUV444"; case QVideoFrame::Format_YUV420P: return dbg << "Format_YUV420P"; + case QVideoFrame::Format_YUV422P: + return dbg << "Format_YUV422P"; case QVideoFrame::Format_YV12: return dbg << "Format_YV12"; case QVideoFrame::Format_UYVY: |