Signed-off-by: Anton Baskanov baskanov@gmail.com --- dlls/quartz/vmr9.c | 60 +++++++++++++++++++++++++++------------------- 1 file changed, 35 insertions(+), 25 deletions(-)
diff --git a/dlls/quartz/vmr9.c b/dlls/quartz/vmr9.c index 2562b74932a..546af3d2a39 100644 --- a/dlls/quartz/vmr9.c +++ b/dlls/quartz/vmr9.c @@ -206,6 +206,37 @@ static inline struct quartz_vmr *impl_from_IBaseFilter(IBaseFilter *iface) return CONTAINING_RECORD(iface, struct quartz_vmr, renderer.filter.IBaseFilter_iface); }
+static void copy_plane(int height, int row_size, int src_pitch, int dst_pitch, BYTE *src, BYTE *dst) +{ + BYTE *row_src; + BYTE *row_dst; + int row; + + if (src_pitch >= 0) + { + if (src_pitch == dst_pitch) + { + memcpy(dst, src, src_pitch * height); + return; + } + TRACE("Source pitch %d does not match dest pitch %d; copying manually.\n", + src_pitch, dst_pitch); + } + else + { + TRACE("Inverting image.\n"); + } + + row_src = src; + row_dst = dst; + for (row = 0; row < height; ++row) + { + memcpy(row_dst, row_src, row_size); + row_src += src_pitch; + row_dst += dst_pitch; + } +} + static HRESULT vmr_render(struct strmbase_renderer *iface, IMediaSample *sample) { struct quartz_vmr *filter = impl_from_IBaseFilter(&iface->filter.IBaseFilter_iface); @@ -273,34 +304,13 @@ static HRESULT vmr_render(struct strmbase_renderer *iface, IMediaSample *sample)
if (height > 0 && bitmap_header->biCompression == BI_RGB) { - BYTE *dst = (BYTE *)locked_rect.pBits + (height * locked_rect.Pitch); - const BYTE *src = data; - - TRACE("Inverting image.\n"); - - while (height--) - { - dst -= locked_rect.Pitch; - memcpy(dst, src, width * depth / 8); - src += src_pitch; - } + copy_plane(height, width * depth / 8, -(int)src_pitch, locked_rect.Pitch, + data + src_pitch * (height - 1), locked_rect.pBits); } else if (locked_rect.Pitch != src_pitch) { - BYTE *dst = locked_rect.pBits; - const BYTE *src = data; - - height = abs(height); - - TRACE("Source pitch %u does not match dest pitch %u; copying manually.\n", - src_pitch, locked_rect.Pitch); - - while (height--) - { - memcpy(dst, src, width * depth / 8); - src += src_pitch; - dst += locked_rect.Pitch; - } + copy_plane(abs(height), width * depth / 8, src_pitch, locked_rect.Pitch, + data, locked_rect.pBits); } else {