From 7e0ae79f3fc242d8f64cfb08ee1c7db1a85ba5d3 Mon Sep 17 00:00:00 2001 From: Underground78 Date: Sun, 9 Nov 2014 23:49:19 +0100 Subject: Fix a crash for files with dimensions non-multiple of two. Always align the plane height to a factor 2. --- decoder/LAVVideo/decoders/pixfmt.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'decoder') diff --git a/decoder/LAVVideo/decoders/pixfmt.cpp b/decoder/LAVVideo/decoders/pixfmt.cpp index 3a0670e6..0b1d560c 100644 --- a/decoder/LAVVideo/decoders/pixfmt.cpp +++ b/decoder/LAVVideo/decoders/pixfmt.cpp @@ -102,11 +102,13 @@ HRESULT AllocLAVFrameBuffers(LAVFrame *pFrame, ptrdiff_t stride) stride *= desc.codedbytes; + int alignedHeight = FFALIGN(pFrame->height, 2); + memset(pFrame->data, 0, sizeof(pFrame->data)); memset(pFrame->stride, 0, sizeof(pFrame->stride)); for (int plane = 0; plane < desc.planes; plane++) { ptrdiff_t planeStride = stride / desc.planeWidth[plane]; - size_t size = planeStride * (pFrame->height / desc.planeHeight[plane]); + size_t size = planeStride * (alignedHeight / desc.planeHeight[plane]); pFrame->data[plane] = (BYTE *)_aligned_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE, 64); pFrame->stride[plane] = planeStride; } -- cgit v1.2.3