From 2db7d3c6881108eaffda73ef77f74ac7bb11edc8 Mon Sep 17 00:00:00 2001 From: wang-bin Date: Fri, 20 Nov 2015 10:27:39 +0800 Subject: [PATCH] vaapi: use va image pitch to compute frame strides using planeWidth() is wrong. plane width is different with plane stride, e.g. nv12 plane1 width == plane0width/2, but strides are the same --- src/codec/video/VideoDecoderVAAPI.cpp | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/codec/video/VideoDecoderVAAPI.cpp b/src/codec/video/VideoDecoderVAAPI.cpp index 42fc0df3..867ec563 100644 --- a/src/codec/video/VideoDecoderVAAPI.cpp +++ b/src/codec/video/VideoDecoderVAAPI.cpp @@ -390,13 +390,9 @@ VideoFrame VideoDecoderVAAPI::frame() // img.pitches[i] is 16 aligned f.setBytesPerLine(d.width*fmt.bytesPerPixel(0), 0); //used by gl to compute texture size if (display() == EGL) { - if (fmt.planeCount() == 2) { //nv12 - f.setBytesPerLine(f.bytesPerLine(0), 1); - } else { - for (int i = 0; i < fmt.planeCount(); ++i) { - //f.setBytesPerLine(img.pitches[i], i); - f.setBytesPerLine(fmt.width(f.bytesPerLine(0), i), i); - } + for (int i = 1; i < fmt.planeCount(); ++i) { + // img.pitchs[] are 16 aligned + f.setBytesPerLine(f.bytesPerLine(0)/(img.pitches[i-1]/(img.pitches[i]-15)), i); } vaDestroyImage(d.display->get(), img.image_id); } @@ -527,7 +523,7 @@ bool VideoDecoderVAAPIPrivate::open() qWarning("XInitThreads failed!"); continue; } - display_x11 = XOpenDisplay(NULL);; + display_x11 = XOpenDisplay(NULL); if (!display_x11) { qWarning("Could not connect to X server"); continue; @@ -543,7 +539,7 @@ bool VideoDecoderVAAPIPrivate::open() qWarning("XInitThreads failed!"); continue; } - display_x11 = XOpenDisplay(NULL);; + display_x11 = XOpenDisplay(NULL); if (!display_x11) { qWarning("Could not connect to X server"); continue; @@ -561,7 +557,7 @@ bool VideoDecoderVAAPIPrivate::open() continue; } // TODO: vaGetDisplayWl - display_x11 = XOpenDisplay(NULL);; + display_x11 = XOpenDisplay(NULL); if (!display_x11) { qWarning("Could not connect to X server"); continue;