d3d11decoder: Fix for VP9 decoding with odd resolution
authorSeungha Yang <seungha@centricular.com>
Mon, 31 Oct 2022 17:00:33 +0000 (02:00 +0900)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Mon, 31 Oct 2022 20:45:25 +0000 (20:45 +0000)
Fixing off by one mismatch when width and/or height of stream
is odd number

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3302>

subprojects/gst-plugins-bad/sys/d3d11/gstd3d11decoder.cpp

index 774c40e..765172b 100644 (file)
@@ -836,8 +836,8 @@ gst_d3d11_decoder_ensure_staging_texture (GstD3D11Decoder * self)
   device_handle = gst_d3d11_device_get_device_handle (self->device);
 
   /* create stage texture to copy out */
-  desc.Width = GST_ROUND_UP_2 (self->info.width);
-  desc.Height = GST_ROUND_UP_2 (self->info.height);
+  desc.Width = self->aligned_width;
+  desc.Height = self->aligned_height;
   desc.MipLevels = 1;
   desc.Format = self->decoder_format;
   desc.SampleDesc.Count = 1;
@@ -1495,10 +1495,12 @@ gst_d3d11_decoder_crop_and_copy_texture (GstD3D11Decoder * self,
   D3D11_BOX src_box = { 0, };
   GstD3D11DeviceLockGuard lk (device);
 
-  src_box.left = self->offset_x;
-  src_box.top = self->offset_y;
-  src_box.right = self->offset_x + self->info.width;
-  src_box.bottom = self->offset_y + self->info.height;
+  /* NOTE: this may be incorrect for non-4:2:0 formats, but we do support
+   * only 4:2:0 8/10 bits streams at the moment */
+  src_box.left = GST_ROUND_UP_2 (self->offset_x);
+  src_box.top = GST_ROUND_UP_2 (self->offset_y);
+  src_box.right = GST_ROUND_UP_2 (self->offset_x + self->info.width);
+  src_box.bottom = GST_ROUND_UP_2 (self->offset_y + self->info.height);
   src_box.front = 0;
   src_box.back = 1;