From 17d720363a280e9f898ce6e7892bc69b9a4bd826 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arttu=20Yl=C3=A4-Outinen?= Date: Tue, 30 Jun 2015 10:56:29 +0300 Subject: [PATCH] Rename struct image_t to kvz_picture. --- src/encmain.c | 4 ++-- src/encoderstate.c | 4 ++-- src/encoderstate.h | 2 +- src/image.c | 16 ++++++++-------- src/image.h | 10 +++++----- src/imagelist.c | 6 +++--- src/imagelist.h | 4 ++-- src/inter.c | 4 ++-- src/inter.h | 4 ++-- src/kvazaar.h | 8 +++----- src/nal.c | 2 +- src/nal.h | 2 +- src/search.c | 12 ++++++------ src/videoframe.h | 6 +++--- src/yuv_io.c | 4 ++-- src/yuv_io.h | 4 ++-- tests/sad_tests.c | 8 ++++---- 17 files changed, 49 insertions(+), 51 deletions(-) diff --git a/src/encmain.c b/src/encmain.c index f93933a2..668b60ee 100644 --- a/src/encmain.c +++ b/src/encmain.c @@ -172,7 +172,7 @@ int main(int argc, char *argv[]) for (;;) { encoder_state_t *state = &enc->states[enc->cur_state_num]; - image_t *img_in = NULL; + kvz_picture *img_in = NULL; if (!feof(input) && (cfg->frames == 0 || frames_read < cfg->frames)) { // Try to read an input frame. img_in = image_alloc(encoder->in.width, encoder->in.height); @@ -195,7 +195,7 @@ int main(int argc, char *argv[]) } bitstream_chunk_t* chunks_out = NULL; - image_t *img_out = NULL; + kvz_picture *img_out = NULL; if (!api->encoder_encode(enc, img_in, &img_out, &chunks_out)) { fprintf(stderr, "Failed to encode image.\n"); image_free(img_in); diff --git a/src/encoderstate.c b/src/encoderstate.c index 6cdf8b4b..10a8d33f 100644 --- a/src/encoderstate.c +++ b/src/encoderstate.c @@ -869,13 +869,13 @@ void encode_one_frame(encoder_state_t * const state) * \param img_in input frame or NULL * \return 1 if the source image was set, 0 if not */ -int encoder_feed_frame(encoder_state_t* const state, image_t* const img_in) +int encoder_feed_frame(encoder_state_t *const state, kvz_picture *const img_in) { const encoder_control_t* const encoder = state->encoder_control; const config_t* const cfg = encoder->cfg; // TODO: Get rid of static variables. - static image_t *gop_buffer[2 * KVZ_MAX_GOP_LENGTH] = { NULL }; + static kvz_picture *gop_buffer[2 * KVZ_MAX_GOP_LENGTH] = { NULL }; static int gop_buf_write_idx = 0; static int gop_buf_read_idx = 0; static int gop_pictures_available = 0; diff --git a/src/encoderstate.h b/src/encoderstate.h index a0581434..782058a5 100644 --- a/src/encoderstate.h +++ b/src/encoderstate.h @@ -207,7 +207,7 @@ typedef struct encoder_state_t { void encode_one_frame(encoder_state_t *state); -int encoder_feed_frame(encoder_state_t* const state, image_t* const img_in); +int encoder_feed_frame(encoder_state_t *const state, kvz_picture *const img_in); void encoder_compute_stats(encoder_state_t *state, FILE * const recout, double psnr[3], uint64_t *bitstream_length); void encoder_next_frame(encoder_state_t *state); diff --git a/src/image.c b/src/image.c index 56d811d3..2610a8ba 100644 --- a/src/image.c +++ b/src/image.c @@ -39,13 +39,13 @@ * \brief Allocate a new image. * \return image pointer or NULL on failure */ -image_t *image_alloc(const int32_t width, const int32_t height) +kvz_picture *image_alloc(const int32_t width, const int32_t height) { //Assert that we have a well defined image assert((width % 2) == 0); assert((height % 2) == 0); - image_t *im = MALLOC(image_t, 1); + kvz_picture *im = MALLOC(kvz_picture, 1); if (!im) return NULL; unsigned int luma_size = width * height; @@ -79,7 +79,7 @@ image_t *image_alloc(const int32_t width, const int32_t height) * * \param im image to free */ -void image_free(image_t * const im) +void image_free(kvz_picture *const im) { if (im == NULL) return; @@ -109,7 +109,7 @@ void image_free(image_t * const im) * * Increment reference count and return the image. */ -image_t *image_copy_ref(image_t *im) +kvz_picture *image_copy_ref(kvz_picture *im) { int32_t new_refcount = ATOMIC_INC(&(im->refcount)); @@ -119,7 +119,7 @@ image_t *image_copy_ref(image_t *im) return im; } -image_t *image_make_subimage(image_t *const orig_image, +kvz_picture *image_make_subimage(kvz_picture *const orig_image, const unsigned x_offset, const unsigned y_offset, const unsigned width, @@ -135,7 +135,7 @@ image_t *image_make_subimage(image_t *const orig_image, assert(x_offset + width <= orig_image->width); assert(y_offset + height <= orig_image->height); - image_t *im = MALLOC(image_t, 1); + kvz_picture *im = MALLOC(kvz_picture, 1); if (!im) return NULL; im->base_image = image_copy_ref(orig_image->base_image); @@ -265,7 +265,7 @@ static unsigned hor_sad(const pixel_t *pic_data, const pixel_t *ref_data, * \param block_width Width of the blocks. * \param block_height Height of the blocks. */ -static unsigned image_interpolated_sad(const image_t *pic, const image_t *ref, +static unsigned image_interpolated_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) { @@ -400,7 +400,7 @@ static unsigned image_interpolated_sad(const image_t *pic, const image_t *ref, * * \returns */ -unsigned image_calc_sad(const image_t *pic, const image_t *ref, int pic_x, int pic_y, int ref_x, int ref_y, +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) { assert(pic_x >= 0 && pic_x <= pic->width - block_width); assert(pic_y >= 0 && pic_y <= pic->height - block_height); diff --git a/src/image.h b/src/image.h index eb22523e..d58a8b1d 100644 --- a/src/image.h +++ b/src/image.h @@ -42,13 +42,13 @@ typedef struct { } yuv_t; -image_t *image_alloc(const int32_t width, const int32_t height); +kvz_picture *image_alloc(const int32_t width, const int32_t height); -void image_free(image_t *im); +void image_free(kvz_picture *im); -image_t *image_copy_ref(image_t *im); +kvz_picture *image_copy_ref(kvz_picture *im); -image_t *image_make_subimage(image_t *const orig_image, +kvz_picture *image_make_subimage(kvz_picture *const orig_image, const unsigned x_offset, const unsigned y_offset, const unsigned width, @@ -58,7 +58,7 @@ yuv_t * yuv_t_alloc(int luma_size); void yuv_t_free(yuv_t * yuv); //Algorithms -unsigned image_calc_sad(const image_t *pic, const image_t *ref, int pic_x, int pic_y, int ref_x, int ref_y, +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); diff --git a/src/imagelist.c b/src/imagelist.c index 8fe3fc08..205cd872 100644 --- a/src/imagelist.c +++ b/src/imagelist.c @@ -42,7 +42,7 @@ image_list_t * image_list_alloc(int size) image_list_t *list = (image_list_t *)malloc(sizeof(image_list_t)); list->size = size; if (size > 0) { - list->images = (image_t**)malloc(sizeof(image_t*) * size); + list->images = (kvz_picture**)malloc(sizeof(kvz_picture*) * size); list->cu_arrays = (cu_array_t**)malloc(sizeof(cu_array_t*) * size); list->pocs = (int32_t*)malloc(sizeof(int32_t) * size); } @@ -60,7 +60,7 @@ image_list_t * image_list_alloc(int size) */ int image_list_resize(image_list_t *list, unsigned size) { - list->images = (image_t**)realloc(list->images, sizeof(image_t*) * size); + list->images = (kvz_picture**)realloc(list->images, sizeof(kvz_picture*) * size); list->cu_arrays = (cu_array_t**)realloc(list->cu_arrays, sizeof(cu_array_t*) * size); list->pocs = (int32_t*)realloc(list->pocs, sizeof(int32_t*) * size); list->size = size; @@ -103,7 +103,7 @@ int image_list_destroy(image_list_t *list) * \param picture_list list to use * \return 1 on success */ -int image_list_add(image_list_t *list, image_t* im, cu_array_t* cua, int32_t poc) +int image_list_add(image_list_t *list, kvz_picture *im, cu_array_t *cua, int32_t poc) { int i = 0; if (ATOMIC_INC(&(im->refcount)) == 1) { diff --git a/src/imagelist.h b/src/imagelist.h index ffce69de..c0eef3c5 100644 --- a/src/imagelist.h +++ b/src/imagelist.h @@ -33,7 +33,7 @@ */ typedef struct { - struct image_t* *images; //!< \brief Pointer to array of picture pointers. + struct kvz_picture* *images; //!< \brief Pointer to array of picture pointers. cu_array_t* *cu_arrays; int32_t *pocs; uint32_t size; //!< \brief Array size. @@ -43,7 +43,7 @@ typedef struct image_list_t * image_list_alloc(int size); int image_list_resize(image_list_t *list, unsigned size); int image_list_destroy(image_list_t *list); -int image_list_add(image_list_t *list, image_t *im, cu_array_t* cua, int32_t poc); +int image_list_add(image_list_t *list, kvz_picture *im, cu_array_t* cua, int32_t poc); int image_list_rem(image_list_t *list, unsigned n); int image_list_copy_contents(image_list_t *target, image_list_t *source); diff --git a/src/inter.c b/src/inter.c index b3468d44..14742f10 100644 --- a/src/inter.c +++ b/src/inter.c @@ -72,7 +72,7 @@ void inter_set_block(videoframe_t* frame, uint32_t x_cu, uint32_t y_cu, uint8_t * \param lcu destination lcu * \returns Void */ -void inter_recon_lcu(const encoder_state_t * const state, const image_t * const ref, int32_t xpos, int32_t ypos,int32_t width, const int16_t mv_param[2], lcu_t *lcu) +void inter_recon_lcu(const encoder_state_t * const state, const kvz_picture * const ref, int32_t xpos, int32_t ypos,int32_t width, const int16_t mv_param[2], lcu_t *lcu) { int x,y,coord_x,coord_y; int16_t mv[2] = { mv_param[0], mv_param[1] }; @@ -338,7 +338,7 @@ void inter_recon_lcu(const encoder_state_t * const state, const image_t * const * \returns Void */ -void inter_recon_lcu_bipred(const encoder_state_t * const state, const image_t * ref1, const image_t * ref2, int32_t xpos, int32_t ypos, int32_t width, int16_t mv_param[2][2], lcu_t* lcu) { +void inter_recon_lcu_bipred(const encoder_state_t * const state, const kvz_picture * ref1, const kvz_picture * ref2, int32_t xpos, int32_t ypos, int32_t width, int16_t mv_param[2][2], lcu_t* lcu) { pixel_t temp_lcu_y[64 * 64]; pixel_t temp_lcu_u[32 * 32]; pixel_t temp_lcu_v[32 * 32]; diff --git a/src/inter.h b/src/inter.h index 2b1e484a..74caf719 100644 --- a/src/inter.h +++ b/src/inter.h @@ -40,8 +40,8 @@ typedef struct { //void inter_set_block(image* im,uint32_t x_cu, uint32_t y_cu, uint8_t depth, cu_info *cur_cu); -void inter_recon_lcu(const encoder_state_t * const state, const image_t * ref, int32_t xpos, int32_t ypos, int32_t width, const int16_t mv_param[2], lcu_t* lcu); -void inter_recon_lcu_bipred(const encoder_state_t * const state, const image_t * ref1, const image_t * ref2, int32_t xpos, int32_t ypos, int32_t width, int16_t mv_param[2][2], lcu_t* lcu); +void inter_recon_lcu(const encoder_state_t * const state, const kvz_picture * ref, int32_t xpos, int32_t ypos, int32_t width, const int16_t mv_param[2], lcu_t* lcu); +void inter_recon_lcu_bipred(const encoder_state_t * const state, const kvz_picture * ref1, const kvz_picture * ref2, int32_t xpos, int32_t ypos, int32_t width, int16_t mv_param[2][2], lcu_t* lcu); void inter_get_spatial_merge_candidates(int32_t x, int32_t y, int8_t depth, cu_info_t **b0, cu_info_t **b1, cu_info_t **b2, cu_info_t **a0, cu_info_t **a1, lcu_t *lcu); diff --git a/src/kvazaar.h b/src/kvazaar.h index 53545cec..095d3ea0 100644 --- a/src/kvazaar.h +++ b/src/kvazaar.h @@ -135,13 +135,12 @@ typedef struct config_t typedef struct config_t kvz_cfg; typedef struct encoder_state_t encoder_state_t; typedef struct encoder_control_t encoder_control_t; -typedef struct image_t kvz_picture; typedef struct bitstream_chunk_t kvz_payload; /** * \brief Struct which contains all picture data */ -typedef struct image_t { +typedef struct kvz_picture { pixel_t *fulldata; //!< \brief Allocated buffer (only used in the base_image) pixel_t *y; //!< \brief Pointer to luma pixel array. @@ -154,10 +153,9 @@ typedef struct image_t { int32_t stride; //!< \brief Luma pixel array width for the full picture (should be used as stride) - struct image_t * base_image; //!< \brief Pointer to the image to which the pixels belong + struct kvz_picture *base_image; //!< \brief Pointer to the picture which owns the pixels int32_t refcount; //!< \brief Number of references to the picture - -} image_t; +} kvz_picture; /** * Main datastructure representing one instance of the encoder. diff --git a/src/nal.c b/src/nal.c index 38d434fc..f6681fdf 100644 --- a/src/nal.c +++ b/src/nal.c @@ -72,7 +72,7 @@ void nal_write(bitstream_t * const bitstream, const uint8_t nal_type, \param checksum_out Result of the calculation. \returns Void */ -void image_checksum(const image_t* im, unsigned char checksum_out[][SEI_HASH_MAX_LENGTH]) +void image_checksum(const kvz_picture *im, unsigned char checksum_out[][SEI_HASH_MAX_LENGTH]) { array_checksum(im->y, im->height, im->width, im->width, checksum_out[0]); diff --git a/src/nal.h b/src/nal.h index 687a74dc..934d6f7f 100644 --- a/src/nal.h +++ b/src/nal.h @@ -96,7 +96,7 @@ enum { // FUNCTIONS void nal_write(bitstream_t * const bitstream, const uint8_t nal_type, const uint8_t temporal_id, const int long_start_code); -void image_checksum(const image_t *im, +void image_checksum(const kvz_picture *im, unsigned char checksum_out[][SEI_HASH_MAX_LENGTH]); diff --git a/src/search.c b/src/search.c index 8af1e19e..f90099c4 100644 --- a/src/search.c +++ b/src/search.c @@ -207,7 +207,7 @@ static int calc_mvd_cost(const encoder_state_t * const state, int x, int y, int return temp_bitcost*(int32_t)(state->global->cur_lambda_cost_sqrt+0.5); } -unsigned tz_pattern_search(const encoder_state_t * const state, const image_t *pic, const image_t *ref, unsigned pattern_type, +unsigned tz_pattern_search(const encoder_state_t * const state, const kvz_picture *pic, const kvz_picture *ref, unsigned pattern_type, const vector2d_t *orig, const int iDist, vector2d_t *mv, unsigned best_cost, int *best_dist, int16_t mv_cand[2][2], inter_merge_cand_t merge_cand[MRG_MAX_NUM_CANDS], int16_t num_cand, int32_t ref_idx, uint32_t *best_bitcost, int block_width, int max_lcu_below) @@ -360,7 +360,7 @@ unsigned tz_pattern_search(const encoder_state_t * const state, const image_t *p } -unsigned tz_raster_search(const encoder_state_t * const state, const image_t *pic, const image_t *ref, +unsigned tz_raster_search(const encoder_state_t * const state, const kvz_picture *pic, const kvz_picture *ref, const vector2d_t *orig, vector2d_t *mv, unsigned best_cost, int16_t mv_cand[2][2], inter_merge_cand_t merge_cand[MRG_MAX_NUM_CANDS], int16_t num_cand, int32_t ref_idx, uint32_t *best_bitcost, int block_width, int iSearchRange, int iRaster, int max_lcu_below) @@ -412,7 +412,7 @@ unsigned tz_raster_search(const encoder_state_t * const state, const image_t *pi } static unsigned tz_search(const encoder_state_t * const state, unsigned depth, - const image_t *pic, const image_t *ref, + const kvz_picture *pic, const kvz_picture *ref, const vector2d_t *orig, vector2d_t *mv_in_out, int16_t mv_cand[2][2], inter_merge_cand_t merge_cand[MRG_MAX_NUM_CANDS], int16_t num_cand, int32_t ref_idx, uint32_t *bitcost_out) @@ -571,7 +571,7 @@ static unsigned tz_search(const encoder_state_t * const state, unsigned depth, * points like 0,0 might be used, such as vectors from top or left. */ static unsigned hexagon_search(const encoder_state_t * const state, unsigned depth, - const image_t *pic, const image_t *ref, + const kvz_picture *pic, const kvz_picture *ref, const vector2d_t *orig, vector2d_t *mv_in_out, int16_t mv_cand[2][2], inter_merge_cand_t merge_cand[MRG_MAX_NUM_CANDS], int16_t num_cand, int32_t ref_idx, uint32_t *bitcost_out) @@ -835,7 +835,7 @@ static unsigned search_mv_full(unsigned depth, */ static unsigned search_frac(const encoder_state_t * const state, unsigned depth, - const image_t *pic, const image_t *ref, + const kvz_picture *pic, const kvz_picture *ref, const vector2d_t *orig, vector2d_t *mv_in_out, int16_t mv_cand[2][2], inter_merge_cand_t merge_cand[MRG_MAX_NUM_CANDS], int16_t num_cand, int32_t ref_idx, uint32_t *bitcost_out) @@ -997,7 +997,7 @@ static int search_cu_inter(const encoder_state_t * const state, int x, int y, in cur_cu->inter.cost = UINT_MAX; for (ref_idx = 0; ref_idx < state->global->ref->used_size; ref_idx++) { - image_t *ref_image = state->global->ref->images[ref_idx]; + kvz_picture *ref_image = state->global->ref->images[ref_idx]; uint32_t temp_bitcost = 0; uint32_t temp_cost = 0; vector2d_t orig, mvd; diff --git a/src/videoframe.h b/src/videoframe.h index e8aa8601..1ee4fe59 100644 --- a/src/videoframe.h +++ b/src/videoframe.h @@ -36,9 +36,9 @@ struct sao_info_t; */ typedef struct videoframe { - image_t* source; //!< \brief Source image. - image_t* rec; //!< \brief Reconstructed image. - + kvz_picture *source; //!< \brief Source image. + kvz_picture *rec; //!< \brief Reconstructed image. + coeff_t* coeff_y; //!< \brief coefficient pointer Y coeff_t* coeff_u; //!< \brief coefficient pointer U coeff_t* coeff_v; //!< \brief coefficient pointer V diff --git a/src/yuv_io.c b/src/yuv_io.c index 33da011b..a3e04280 100644 --- a/src/yuv_io.c +++ b/src/yuv_io.c @@ -83,7 +83,7 @@ static int read_and_fill_frame_data(FILE *file, */ int yuv_io_read(FILE* file, unsigned input_width, unsigned input_height, - image_t *img_out) + kvz_picture *img_out) { const unsigned y_size = input_width * input_height; const unsigned uv_input_width = input_width / 2; @@ -161,7 +161,7 @@ int yuv_io_seek(FILE* file, unsigned frames, * \return 1 on success, 0 on failure */ int yuv_io_write(FILE* file, - image_t const* img, + const kvz_picture *img, unsigned output_width, unsigned output_height) { const int width = img->width; diff --git a/src/yuv_io.h b/src/yuv_io.h index 6fcd2081..e953c3db 100644 --- a/src/yuv_io.h +++ b/src/yuv_io.h @@ -30,13 +30,13 @@ int yuv_io_read(FILE* file, unsigned input_width, unsigned input_height, - image_t *img_out); + kvz_picture *img_out); int yuv_io_seek(FILE* file, unsigned frames, unsigned input_width, unsigned input_height); int yuv_io_write(FILE* file, - image_t const* img, + const kvz_picture *img, unsigned output_width, unsigned output_height); #endif // YUV_IO_H_ diff --git a/tests/sad_tests.c b/tests/sad_tests.c index cbc03cd8..db3a890e 100644 --- a/tests/sad_tests.c +++ b/tests/sad_tests.c @@ -57,8 +57,8 @@ const uint8_t pic_data[64] = { 1,1,1,1,1,1,1,1 }; -image_t *g_pic = 0; -image_t *g_ref = 0; +kvz_picture *g_pic = 0; +kvz_picture *g_ref = 0; ////////////////////////////////////////////////////////////////////////// // SETUP, TEARDOWN AND HELPER FUNCTIONS @@ -226,8 +226,8 @@ TEST test_bottomright_out(void) struct sad_test_env_t { - image_t *g_pic; - image_t *g_ref; + kvz_picture *g_pic; + kvz_picture *g_ref; };