Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / ozone / media / vaapi_video_decode_accelerator.cc
index 6d95db2..3c5ac59 100644 (file)
@@ -186,6 +186,21 @@ bool VaapiVideoDecodeAccelerator::TFPPicture::Upload(VASurfaceID surface) {
   gfx::ScopedTextureBinder texture_binder(GL_TEXTURE_2D, texture_id_);
   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+
+  // See bug https://crosswalk-project.org/jira/browse/XWALK-2265.
+  // The following small piece of code is a workaround for the current VDA
+  // texture output implementation. It can be removed when zero buffer copy
+  // is implemented.
+  unsigned int al = 4 * size_.width();
+  if (al != va_image_.pitches[0]) {
+    // Not aligned phenomenon occurs only in special size video in None-X11.
+    // So re-check RGBA data alignment and realign filled video frame in need.
+    unsigned char* bhandle = static_cast<unsigned char*>(buffer);
+    for (int i = 0; i < size_.height(); i++) {
+      memcpy(bhandle + (i * al), bhandle + (i * (va_image_.pitches[0])), al);
+    }
+  }
+
   glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, size_.width(), size_.height(),
                0, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
 
@@ -244,7 +259,7 @@ bool VaapiVideoDecodeAccelerator::Initialize(media::VideoCodecProfile profile,
 
   vaapi_wrapper_ = VaapiWrapper::Create(
       profile,
-      gfx::GetPlatformDefaultEGLNativeDisplay(),
+      gfx::GLSurfaceEGL::GetNativeDisplay(),
       base::Bind(&ReportToUMA, VaapiH264Decoder::VAAPI_ERROR));
 
   if (!vaapi_wrapper_.get()) {