From a87dafb27a7f78c934b5c65f1c9dde9b6a139619 Mon Sep 17 00:00:00 2001 From: Ari Lemmetti Date: Tue, 4 Aug 2015 15:42:18 +0300 Subject: [PATCH] Add hi_prec_buf_t for higher precision intermediate values for interpolation filter. --- src/image.c | 22 ++++++++++++++++++++++ src/image.h | 11 +++++++++++ 2 files changed, 33 insertions(+) diff --git a/src/image.c b/src/image.c index 48f623ba..2c0e87cc 100644 --- a/src/image.c +++ b/src/image.c @@ -172,6 +172,28 @@ void yuv_t_free(yuv_t * yuv) free(yuv); } +hi_prec_buf_t * hi_prec_buf_t_alloc(int luma_size) +{ + // Get buffers with separate mallocs in order to take advantage of + // automatic buffer overrun checks. + hi_prec_buf_t *yuv = (hi_prec_buf_t *)malloc(sizeof(*yuv)); + yuv->y = (int16_t *)malloc(luma_size * sizeof(*yuv->y)); + yuv->u = (int16_t *)malloc(luma_size / 2 * sizeof(*yuv->u)); + yuv->v = (int16_t *)malloc(luma_size / 2 * sizeof(*yuv->v)); + yuv->size = luma_size; + + return yuv; +} + +void hi_prec_buf_t_free(hi_prec_buf_t * yuv) +{ + free(yuv->y); + free(yuv->u); + free(yuv->v); + free(yuv); +} + + /** * \brief Diagonally interpolate SAD outside the frame. * diff --git a/src/image.h b/src/image.h index a7946e69..bed97e5f 100644 --- a/src/image.h +++ b/src/image.h @@ -34,6 +34,13 @@ typedef struct { kvz_pixel v[LCU_CHROMA_SIZE]; } lcu_yuv_t; +typedef struct { + int size; + int16_t *y; + int16_t *u; + int16_t *v; +} hi_prec_buf_t; + typedef struct { int size; kvz_pixel *y; @@ -57,6 +64,10 @@ kvz_picture *image_make_subimage(kvz_picture *const orig_image, yuv_t * yuv_t_alloc(int luma_size); void yuv_t_free(yuv_t * yuv); +hi_prec_buf_t * hi_prec_buf_t_alloc(int luma_size); +void hi_prec_buf_t_free(hi_prec_buf_t * yuv); + + //Algorithms unsigned image_calc_sad(const kvz_picture *pic, const kvz_picture *ref, int pic_x, int pic_y, int ref_x, int ref_y, int block_width, int block_height, int max_lcu_below);