2013-09-19 07:35:34 +00:00
|
|
|
#ifndef PICTURE_H_
|
|
|
|
#define PICTURE_H_
|
2012-06-05 11:01:47 +00:00
|
|
|
/**
|
2013-09-18 14:29:30 +00:00
|
|
|
* \file
|
|
|
|
* \brief Coding Unit (CU) and picture data related functions.
|
|
|
|
*
|
|
|
|
* \author Marko Viitanen ( fador@iki.fi ),
|
|
|
|
* Tampere University of Technology,
|
|
|
|
* Department of Pervasive Computing.
|
|
|
|
* \author Ari Koivula ( ari@koivu.la ),
|
|
|
|
* Tampere University of Technology,
|
|
|
|
* Department of Pervasive Computing.
|
2012-06-05 11:01:47 +00:00
|
|
|
*/
|
|
|
|
|
2013-09-18 09:16:03 +00:00
|
|
|
#include "global.h"
|
|
|
|
|
2012-06-05 11:01:47 +00:00
|
|
|
|
2013-09-20 08:07:31 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
// CONSTANTS
|
2013-09-16 14:34:20 +00:00
|
|
|
|
2013-09-20 08:07:31 +00:00
|
|
|
enum { CU_NOTSET = 0, CU_PCM, CU_SKIP, CU_SPLIT, CU_INTRA, CU_INTER };
|
|
|
|
enum { SLICE_B = 0, SLICE_P = 1, SLICE_I = 2 };
|
|
|
|
enum { REF_PIC_LIST_0 = 0, REF_PIC_LIST_1 = 1, REF_PIC_LIST_X = 100 };
|
2013-03-12 15:06:21 +00:00
|
|
|
|
2012-06-05 11:01:47 +00:00
|
|
|
|
2013-09-20 08:07:31 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
// TYPES
|
2012-06-11 12:26:32 +00:00
|
|
|
|
2013-09-20 08:07:31 +00:00
|
|
|
/**
|
|
|
|
* \brief Struct for CU intra info
|
|
|
|
*/
|
2012-06-11 12:26:32 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
2013-04-18 11:04:15 +00:00
|
|
|
int8_t mode;
|
2013-10-18 08:39:13 +00:00
|
|
|
int8_t mode_chroma;
|
2012-06-11 12:26:32 +00:00
|
|
|
uint32_t cost;
|
2013-09-20 09:49:44 +00:00
|
|
|
} cu_info_intra;
|
2012-06-11 12:26:32 +00:00
|
|
|
|
2013-09-20 08:07:31 +00:00
|
|
|
/**
|
|
|
|
* \brief Struct for CU inter info
|
|
|
|
*/
|
2013-04-10 13:55:31 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
2013-04-18 11:04:15 +00:00
|
|
|
int8_t mode;
|
2013-04-10 13:55:31 +00:00
|
|
|
uint32_t cost;
|
2013-10-22 13:53:18 +00:00
|
|
|
|
2013-04-10 13:55:31 +00:00
|
|
|
int16_t mv[2];
|
2013-10-22 13:53:18 +00:00
|
|
|
int16_t mvd[2];
|
2013-09-16 11:42:05 +00:00
|
|
|
uint8_t mv_ref; // \brief Index of the encoder_control.ref array.
|
|
|
|
uint8_t mv_dir; // \brief Probably describes if mv_ref is forward, backward or both. Might not be needed?
|
2013-09-20 09:49:44 +00:00
|
|
|
} cu_info_inter;
|
2013-04-10 13:55:31 +00:00
|
|
|
|
2013-09-20 08:07:31 +00:00
|
|
|
/**
|
|
|
|
* \brief Struct for CU info
|
|
|
|
*/
|
2012-06-11 12:26:32 +00:00
|
|
|
typedef struct
|
2013-04-17 14:08:52 +00:00
|
|
|
{
|
2013-10-17 12:14:22 +00:00
|
|
|
int8_t type; //!< \brief block type, CU_INTER / CU_INTRA
|
|
|
|
int8_t depth; //!< \brief depth / size of this block
|
|
|
|
int8_t part_size; //!< \brief Currently only 2Nx2N, TODO: AMP/SMP/NxN parts
|
|
|
|
int8_t tr_depth; //!< \brief transform depth
|
|
|
|
int8_t coded; //!< \brief flag to indicate this block is coded and reconstructed
|
2013-10-18 08:39:13 +00:00
|
|
|
int8_t skipped; //!< \brief flag to indicate this block is skipped
|
|
|
|
int8_t merged; //!< \brief flag to indicate this block is merged
|
2013-10-17 12:14:22 +00:00
|
|
|
int8_t coeff_y; //!< \brief is there coded coeffs Y
|
|
|
|
int8_t coeff_u; //!< \brief is there coded coeffs U
|
|
|
|
int8_t coeff_v; //!< \brief is there coded coeffs V
|
2013-10-18 08:39:13 +00:00
|
|
|
|
2013-10-22 09:09:18 +00:00
|
|
|
int8_t coeff_top_y[MAX_DEPTH+1]; //!< \brief is there coded coeffs Y in top level
|
|
|
|
int8_t coeff_top_u[MAX_DEPTH+1]; //!< \brief is there coded coeffs U in top level
|
|
|
|
int8_t coeff_top_v[MAX_DEPTH+1]; //!< \brief is there coded coeffs V in top level
|
2013-09-20 09:49:44 +00:00
|
|
|
cu_info_intra intra;
|
|
|
|
cu_info_inter inter;
|
|
|
|
} cu_info;
|
2012-06-11 12:26:32 +00:00
|
|
|
|
2013-09-20 08:07:31 +00:00
|
|
|
/**
|
|
|
|
* \brief Struct which contains all picture data
|
|
|
|
*/
|
2012-06-05 11:01:47 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
2013-10-17 12:14:22 +00:00
|
|
|
pixel* y_data; //!< \brief Pointer to luma pixel array.
|
|
|
|
pixel* u_data; //!< \brief Pointer to chroma U pixel array.
|
|
|
|
pixel* v_data; //!< \brief Pointer to chroma V pixel array.
|
2013-09-20 08:07:31 +00:00
|
|
|
|
2013-10-17 12:14:22 +00:00
|
|
|
pixel* y_recdata; //!< \brief Pointer to reconstructed Y-data.
|
|
|
|
pixel* u_recdata; //!< \brief Pointer to reconstructed U-data.
|
|
|
|
pixel* v_recdata; //!< \brief Pointer to reconstructed V-data.
|
2013-09-20 08:07:31 +00:00
|
|
|
|
2013-10-18 08:39:13 +00:00
|
|
|
pixel* pred_y; //!< \brief Pointer to predicted Y
|
|
|
|
pixel* pred_u; //!< \brief Pointer to predicted U
|
|
|
|
pixel* pred_v; //!< \brief Pointer to predicted V
|
|
|
|
|
|
|
|
coefficient* coeff_y; //!< \brief coefficient pointer Y
|
|
|
|
coefficient* coeff_u; //!< \brief coefficient pointer U
|
|
|
|
coefficient* coeff_v; //!< \brief coefficient pointer V
|
2013-10-15 14:56:50 +00:00
|
|
|
|
2013-10-17 12:14:22 +00:00
|
|
|
int32_t width; //!< \brief Luma pixel array width.
|
|
|
|
int32_t height; //!< \brief Luma pixel array height.
|
|
|
|
int32_t height_in_lcu; //!< \brief Picture width in number of LCU's.
|
|
|
|
int32_t width_in_lcu; //!< \brief Picture height in number of LCU's.
|
|
|
|
uint8_t referenced; //!< \brief Whether this picture is referenced.
|
|
|
|
cu_info** cu_array; //!< \brief Info for each CU at each depth.
|
2012-06-11 12:26:32 +00:00
|
|
|
uint8_t type;
|
2013-03-11 10:06:08 +00:00
|
|
|
uint8_t slicetype;
|
2012-06-05 11:01:47 +00:00
|
|
|
} picture;
|
|
|
|
|
2013-09-20 08:07:31 +00:00
|
|
|
/**
|
|
|
|
* \brief Struct which contains array of picture structs
|
|
|
|
*/
|
2012-06-05 11:01:47 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
2013-10-17 12:14:22 +00:00
|
|
|
picture** pics; //!< \brief Pointer to array of picture pointers.
|
|
|
|
unsigned int size; //!< \brief Array size.
|
2012-06-05 11:01:47 +00:00
|
|
|
unsigned int used_size;
|
|
|
|
} picture_list;
|
|
|
|
|
|
|
|
|
2013-09-20 08:07:31 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
// FUNCTIONS
|
2012-06-05 11:01:47 +00:00
|
|
|
|
2013-09-20 08:07:31 +00:00
|
|
|
picture * picture_init(int32_t width, int32_t height,
|
|
|
|
int32_t width_in_lcu, int32_t height_in_lcu);
|
2012-06-05 11:01:47 +00:00
|
|
|
int picture_destroy(picture *pic);
|
2013-09-20 08:07:31 +00:00
|
|
|
void picture_set_block_coded(picture *pic, uint32_t x_scu, uint32_t y_scu,
|
|
|
|
uint8_t depth, int8_t coded);
|
2013-10-09 11:09:49 +00:00
|
|
|
void picture_set_block_residual(picture *pic, uint32_t x_scu, uint32_t y_scu,
|
|
|
|
uint8_t depth, int8_t residual);
|
2013-09-20 08:07:31 +00:00
|
|
|
void picture_set_block_split(picture *pic, uint32_t x_scu, uint32_t y_scu,
|
|
|
|
uint8_t depth, int8_t split);
|
2012-06-05 11:01:47 +00:00
|
|
|
|
2013-09-20 08:07:31 +00:00
|
|
|
picture_list * picture_list_init(int size);
|
|
|
|
int picture_list_resize(picture_list *list, int size);
|
|
|
|
int picture_list_destroy(picture_list *list);
|
|
|
|
int picture_list_add(picture_list *list, picture *pic);
|
|
|
|
int picture_list_rem(picture_list *list, int n, int8_t destroy);
|
|
|
|
|
2013-10-18 11:23:21 +00:00
|
|
|
typedef unsigned (*cost_16bit_nxn_func)(pixel *block1, pixel *block2);
|
2013-10-16 12:08:53 +00:00
|
|
|
|
2013-10-18 08:39:13 +00:00
|
|
|
|
2013-10-16 12:08:53 +00:00
|
|
|
cost_16bit_nxn_func get_satd_16bit_nxn_func(unsigned n);
|
|
|
|
cost_16bit_nxn_func get_sad_16bit_nxn_func(unsigned n);
|
|
|
|
|
2013-10-18 11:23:21 +00:00
|
|
|
unsigned satd_16bit_nxn(pixel *block1, pixel *block2, unsigned n);
|
|
|
|
unsigned sad_16bit_nxn(pixel *block1, pixel *block2, unsigned n);
|
2013-10-10 15:51:10 +00:00
|
|
|
|
2013-10-11 12:31:55 +00:00
|
|
|
unsigned calc_sad(picture *pic, picture *ref,
|
|
|
|
int pic_x, int pic_y, int ref_x, int ref_y,
|
|
|
|
int block_width, int block_height);
|
2013-09-12 14:15:14 +00:00
|
|
|
|
2013-10-14 14:27:25 +00:00
|
|
|
double image_psnr(pixel *frame1, pixel *frame2, int32_t x, int32_t y);
|
2012-06-05 11:01:47 +00:00
|
|
|
|
2012-06-06 11:09:28 +00:00
|
|
|
|
2013-09-20 08:07:31 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
// MACROS
|
2013-08-02 13:35:30 +00:00
|
|
|
|
2013-09-20 08:07:31 +00:00
|
|
|
#define GET_SPLITDATA(CU,curDepth) ((CU)->depth > curDepth)
|
|
|
|
#define SET_SPLITDATA(CU,flag) { (CU)->split=(flag); }
|
2012-06-06 11:09:28 +00:00
|
|
|
|
2012-06-05 11:01:47 +00:00
|
|
|
|
2013-09-20 08:07:31 +00:00
|
|
|
#endif
|