Commit 466b524b authored by Ronald S. Bultje's avatar Ronald S. Bultje

Slightly over-allocate picture buffers

Allows simplified SIMD function implementations that don't exactly
respect picture boundaries when reading picture data. Fixes #251 and
#250.
parent 07f818fb
......@@ -34,6 +34,11 @@
#include "common.h"
#include "headers.h"
/* Number of bytes to align AND pad picture memory buffers by, so that SIMD
* implementations can over-read by a few bytes, and use aligned read/write
* instructions. */
#define DAV1D_PICTURE_ALIGNMENT 32
typedef struct Dav1dPictureParameters {
int w; ///< width (in pixels)
int h; ///< height (in pixels)
......@@ -85,8 +90,10 @@ typedef struct Dav1dPicAllocator {
/**
* Allocate the picture buffer based on the Dav1dPictureParameters.
*
* The data[0], data[1] and data[2] must be 32 byte aligned and with a
* pixel width/height multiple of 128 pixels.
* The data[0], data[1] and data[2] must be DAV1D_PICTURE_ALIGNMENT byte
* aligned and with a pixel width/height multiple of 128 pixels. Any
* allocated memory area should also be padded by DAV1D_PICTURE_ALIGNMENT
* bytes.
* data[1] and data[2] must share the same stride[1].
*
* This function will be called on the main thread (the thread which calls
......
......@@ -59,7 +59,8 @@ int default_picture_allocator(Dav1dPicture *const p, void *cookie) {
const size_t uv_sz = p->stride[1] * (aligned_h >> ss_ver);
const size_t pic_size = y_sz + 2 * uv_sz;
uint8_t *data = dav1d_alloc_aligned(pic_size, 32);
uint8_t *data = dav1d_alloc_aligned(pic_size + DAV1D_PICTURE_ALIGNMENT,
DAV1D_PICTURE_ALIGNMENT);
if (data == NULL) {
return -1;
}
......
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