mirror of
https://github.com/ultravideo/uvg266.git
synced 2024-11-27 11:24:05 +00:00
Rename struct image_t to kvz_picture.
This commit is contained in:
parent
fab07d80da
commit
17d720363a
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
16
src/image.c
16
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);
|
||||
|
|
10
src/image.h
10
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);
|
||||
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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];
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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]);
|
||||
|
||||
|
|
|
@ -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]);
|
||||
|
||||
|
||||
|
|
12
src/search.c
12
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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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_
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue