mirror of
https://github.com/ultravideo/uvg266.git
synced 2024-11-24 02:24:07 +00:00
Change kvz_cu_array_alloc to use pixel dimensions.
Changes function kvz_cu_array_alloc to take width and height parameters in pixels instead of SCUs.
This commit is contained in:
parent
b276a347c0
commit
2c85a00a55
35
src/cu.c
35
src/cu.c
|
@ -120,18 +120,29 @@ unsigned kvz_coefficients_calc_abs(const coeff_t *const buf, const int buf_strid
|
||||||
return sum;
|
return sum;
|
||||||
}
|
}
|
||||||
|
|
||||||
cu_array_t * kvz_cu_array_alloc(const int width_in_scu, const int height_in_scu) {
|
/**
|
||||||
unsigned cu_array_size = height_in_scu * width_in_scu;
|
* \brief Allocate a CU array.
|
||||||
cu_array_t *cua;
|
*
|
||||||
cua = MALLOC(cu_array_t, 1);
|
* \param width width of the array in luma pixels
|
||||||
cua->data = (cu_info_t*)malloc(sizeof(cu_info_t) * cu_array_size);
|
* \param height height of the array in luma pixels
|
||||||
cua->width = width_in_scu << 3;
|
*/
|
||||||
cua->height = height_in_scu << 3;
|
cu_array_t * kvz_cu_array_alloc(const int width, const int height) {
|
||||||
|
cu_array_t *cua = MALLOC(cu_array_t, 1);
|
||||||
|
|
||||||
|
const int width_scu = (width + 7) >> 3;
|
||||||
|
const int height_scu = (height + 7) >> 3;
|
||||||
|
assert(width_scu * 8 >= width);
|
||||||
|
assert(height_scu * 8 >= height);
|
||||||
|
const unsigned cu_array_size = width_scu * height_scu;
|
||||||
|
cua->data = calloc(cu_array_size, sizeof(cu_info_t));
|
||||||
|
cua->width = width_scu << 3;
|
||||||
|
cua->height = height_scu << 3;
|
||||||
cua->refcount = 1;
|
cua->refcount = 1;
|
||||||
FILL_ARRAY(cua->data, 0, cu_array_size);
|
|
||||||
return cua;
|
return cua;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int kvz_cu_array_free(cu_array_t * const cua)
|
int kvz_cu_array_free(cu_array_t * const cua)
|
||||||
{
|
{
|
||||||
int32_t new_refcount;
|
int32_t new_refcount;
|
||||||
|
@ -175,6 +186,14 @@ void kvz_cu_array_copy(cu_array_t* dst, int dst_x, int dst_y,
|
||||||
// Number of bytes to copy per row.
|
// Number of bytes to copy per row.
|
||||||
const size_t row_size = sizeof(cu_info_t) * (width >> 3);
|
const size_t row_size = sizeof(cu_info_t) * (width >> 3);
|
||||||
|
|
||||||
|
width = MIN(width, MIN(src->width - src_x, dst->width - dst_x));
|
||||||
|
height = MIN(height, MIN(src->height - src_y, dst->height - dst_y));
|
||||||
|
|
||||||
|
assert(src_x + width <= src->width);
|
||||||
|
assert(src_y + height <= src->height);
|
||||||
|
assert(dst_x + width <= dst->width);
|
||||||
|
assert(dst_y + height <= dst->height);
|
||||||
|
|
||||||
for (int i = 0; i < (height >> 3); ++i) {
|
for (int i = 0; i < (height >> 3); ++i) {
|
||||||
memcpy(dst_ptr, src_ptr, row_size);
|
memcpy(dst_ptr, src_ptr, row_size);
|
||||||
src_ptr += src_stride;
|
src_ptr += src_stride;
|
||||||
|
|
2
src/cu.h
2
src/cu.h
|
@ -184,7 +184,7 @@ typedef struct {
|
||||||
int32_t refcount; //!< \brief number of references to this cu_array
|
int32_t refcount; //!< \brief number of references to this cu_array
|
||||||
} cu_array_t;
|
} cu_array_t;
|
||||||
|
|
||||||
cu_array_t * kvz_cu_array_alloc(int width_in_scu, int height_in_scu);
|
cu_array_t * kvz_cu_array_alloc(int width, int height);
|
||||||
int kvz_cu_array_free(cu_array_t *cua);
|
int kvz_cu_array_free(cu_array_t *cua);
|
||||||
void kvz_cu_array_copy(cu_array_t* dst, int dst_x, int dst_y,
|
void kvz_cu_array_copy(cu_array_t* dst, int dst_x, int dst_y,
|
||||||
const cu_array_t* src, int src_x, int src_y,
|
const cu_array_t* src, int src_x, int src_y,
|
||||||
|
|
|
@ -956,10 +956,9 @@ void kvz_encoder_next_frame(encoder_state_t *state)
|
||||||
state->tile->frame->rec = kvz_image_alloc(state->tile->frame->width, state->tile->frame->height);
|
state->tile->frame->rec = kvz_image_alloc(state->tile->frame->width, state->tile->frame->height);
|
||||||
assert(state->tile->frame->rec);
|
assert(state->tile->frame->rec);
|
||||||
{
|
{
|
||||||
// Allocate height_in_scu x width_in_scu x sizeof(CU_info)
|
unsigned width = state->tile->frame->width_in_lcu * LCU_WIDTH;
|
||||||
unsigned height_in_scu = state->tile->frame->height_in_lcu << MAX_DEPTH;
|
unsigned height = state->tile->frame->height_in_lcu * LCU_WIDTH;
|
||||||
unsigned width_in_scu = state->tile->frame->width_in_lcu << MAX_DEPTH;
|
state->tile->frame->cu_array = kvz_cu_array_alloc(width, height);
|
||||||
state->tile->frame->cu_array = kvz_cu_array_alloc(width_in_scu, height_in_scu);
|
|
||||||
}
|
}
|
||||||
kvz_videoframe_set_poc(state->tile->frame, state->global->poc);
|
kvz_videoframe_set_poc(state->tile->frame, state->global->poc);
|
||||||
kvz_image_list_copy_contents(state->global->ref, prev_state->global->ref);
|
kvz_image_list_copy_contents(state->global->ref, prev_state->global->ref);
|
||||||
|
|
|
@ -46,10 +46,9 @@ videoframe_t *kvz_videoframe_alloc(const int32_t width, const int32_t height, co
|
||||||
if (frame->height_in_lcu * LCU_WIDTH < frame->height) frame->height_in_lcu++;
|
if (frame->height_in_lcu * LCU_WIDTH < frame->height) frame->height_in_lcu++;
|
||||||
|
|
||||||
{
|
{
|
||||||
// Allocate height_in_scu x width_in_scu x sizeof(CU_info)
|
unsigned cu_array_width = frame->width_in_lcu * LCU_WIDTH;
|
||||||
unsigned height_in_scu = frame->height_in_lcu << MAX_DEPTH;
|
unsigned cu_array_height = frame->height_in_lcu * LCU_WIDTH;
|
||||||
unsigned width_in_scu = frame->width_in_lcu << MAX_DEPTH;
|
frame->cu_array = kvz_cu_array_alloc(cu_array_width, cu_array_height);
|
||||||
frame->cu_array = kvz_cu_array_alloc(width_in_scu, height_in_scu);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
frame->coeff_y = NULL; frame->coeff_u = NULL; frame->coeff_v = NULL;
|
frame->coeff_y = NULL; frame->coeff_u = NULL; frame->coeff_v = NULL;
|
||||||
|
|
Loading…
Reference in a new issue