Commit 3e949628 authored by Laurent Aimar's avatar Laurent Aimar Committed by Jean-Baptiste Kempf

Fixed potential unaligned access in vaapi/dxva2 picture copy.

It (probably) happens only when the video is non mod 16, or non mod 32
with YV12 hardware surface.
(cherry picked from commit 957409b2)

Close #3606
Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent 0e9bb2b6
...@@ -63,7 +63,6 @@ ...@@ -63,7 +63,6 @@
*/ */
static void CopyFromUswc(uint8_t *dst, size_t dst_pitch, static void CopyFromUswc(uint8_t *dst, size_t dst_pitch,
const uint8_t *src, size_t src_pitch, const uint8_t *src, size_t src_pitch,
unsigned unaligned,
unsigned width, unsigned height, unsigned width, unsigned height,
unsigned cpu) unsigned cpu)
{ {
...@@ -71,6 +70,7 @@ static void CopyFromUswc(uint8_t *dst, size_t dst_pitch, ...@@ -71,6 +70,7 @@ static void CopyFromUswc(uint8_t *dst, size_t dst_pitch,
ASM_SSE2(cpu, "mfence"); ASM_SSE2(cpu, "mfence");
for (unsigned y = 0; y < height; y++) { for (unsigned y = 0; y < height; y++) {
const unsigned unaligned = (intptr_t)src & 0x0f;
unsigned x; unsigned x;
for (x = 0; x < unaligned; x++) for (x = 0; x < unaligned; x++)
...@@ -237,13 +237,11 @@ static void CopyPlane(uint8_t *dst, size_t dst_pitch, const uint8_t *src, size_t ...@@ -237,13 +237,11 @@ static void CopyPlane(uint8_t *dst, size_t dst_pitch, const uint8_t *src, size_t
assert(hstep > 0); assert(hstep > 0);
for (unsigned y = 0; y < height; y += hstep) { for (unsigned y = 0; y < height; y += hstep) {
const unsigned unaligned = (intptr_t)src & 0x0f;
const unsigned hblock = __MIN(hstep, height - y); const unsigned hblock = __MIN(hstep, height - y);
/* Copy a bunch of line into our cache */ /* Copy a bunch of line into our cache */
CopyFromUswc(cache, w16, CopyFromUswc(cache, w16,
src, src_pitch, src, src_pitch,
unaligned,
width, hblock, cpu); width, hblock, cpu);
/* Copy from our cache to the destination */ /* Copy from our cache to the destination */
...@@ -270,13 +268,11 @@ static void SplitPlanes(uint8_t *dstu, size_t dstu_pitch, ...@@ -270,13 +268,11 @@ static void SplitPlanes(uint8_t *dstu, size_t dstu_pitch,
assert(hstep > 0); assert(hstep > 0);
for (unsigned y = 0; y < height; y += hstep) { for (unsigned y = 0; y < height; y += hstep) {
const unsigned unaligned = (intptr_t)src & 0x0f;
const unsigned hblock = __MIN(hstep, height - y); const unsigned hblock = __MIN(hstep, height - y);
/* Copy a bunch of line into our cache */ /* Copy a bunch of line into our cache */
CopyFromUswc(cache, w2_16, CopyFromUswc(cache, w2_16,
src, src_pitch, src, src_pitch,
unaligned,
2*width, hblock, cpu); 2*width, hblock, cpu);
/* Copy from our cache to the destination */ /* Copy from our cache to the destination */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment