uvg266/src/encoder.h

130 lines
3.9 KiB
C
Raw Normal View History

2012-06-04 10:47:12 +00:00
/**
* HEVC Encoder
* - Marko Viitanen ( fador at iki.fi ), Tampere University of Technology, Department of Computer Systems.
*/
2012-06-01 12:31:06 +00:00
/*! \file encoder.h
\brief Encoding related functions
\author Marko Viitanen
\date 2012-06
Structures for encoding
*/
#ifndef __ENCODER_H
#define __ENCODER_H
2012-06-01 12:31:06 +00:00
#include "picture.h"
#include "bitstream.h"
2012-06-04 10:47:12 +00:00
typedef struct encoder_control;
2012-06-13 15:08:15 +00:00
/* ToDo: add ME data */
2012-06-01 12:31:06 +00:00
typedef struct
{
void (*IME)();
void (*FME)();
2012-06-04 10:47:12 +00:00
int range;
2012-06-01 12:31:06 +00:00
} encoder_me;
enum { FORMAT_400 = 0, FORMAT_420, FORMAT_422, FORMAT_444 };
/* Input info struct */
2012-06-01 12:31:06 +00:00
typedef struct
{
FILE* file;
uint32_t width;
uint32_t height;
uint32_t height_in_LCU;
uint32_t width_in_LCU;
picture cur_pic;
uint8_t video_format;
2012-06-01 12:31:06 +00:00
} encoder_input;
2012-06-13 15:08:15 +00:00
/* Encoder control options, the main struct */
2012-06-01 12:31:06 +00:00
typedef struct
{
uint32_t frame;
config *cfg;
2012-06-01 12:31:06 +00:00
encoder_input in;
encoder_me me;
bitstream* stream;
FILE *output;
picture_list *ref;
uint8_t QP;
2012-06-01 12:31:06 +00:00
} encoder_control;
void init_encoder_control(encoder_control* control,bitstream* output);
void init_encoder_input(encoder_input* input,FILE* inputfile, uint32_t width, uint32_t height);
void encode_one_frame(encoder_control* encoder);
2012-06-01 12:31:06 +00:00
void encode_seq_parameter_set(encoder_control* encoder);
void encode_pic_parameter_set(encoder_control* encoder);
void encode_slice_data(encoder_control* encoder);
void encode_slice_header(encoder_control* encoder);
void encode_coding_tree(encoder_control* encoder,uint16_t xCtb,uint16_t yCtb, uint8_t depth);
static const uint8_t INIT_SPLIT_FLAG[3][3] =
2012-06-13 15:08:15 +00:00
{ { 107, 139, 126 },
{ 107, 139, 126 },
{ 139, 141, 157 } };
static const uint8_t INIT_INTRA_PRED_MODE[3] = { 183,154,184 };
static const uint8_t INIT_CHROMA_PRED_MODE[3][2] = { { 152, 139 }, { 152, 139 }, { 63, 139 } };
#define CNU 154
static const uint8_t INIT_TRANS_SUBDIV_FLAG[3][4] =
{
{ CNU, 153, 138, 138 },
{ CNU, 124, 138, 94 },
{ CNU, 224, 167, 122 }
};
2012-06-12 14:41:03 +00:00
static const uint8_t INIT_QT_CBF[3][6] =
{
2012-06-12 14:41:03 +00:00
{ 153, 111, CNU, 149, 92, 167 },
{ 153, 111, CNU, 149, 107, 167 },
{ 111, 141, CNU, 94, 138, 182 }
};
static const uint8_t INIT_SIG_CG_FLAG[3][4] =
{ { 121, 140, 61, 154 }, { 121, 140, 61, 154 }, { 91, 171, 134, 141 } };
static const uint8_t INIT_SIG_FLAG[3][45] =
2012-06-13 15:08:15 +00:00
{{170,154,139,153,139,123,123, 63,124,153,153,152,152,152,137,152,137,137,166,183,140,136,153,
154,170,153,138,138,122,121,122,121,167,153,167,136,121,122,136,121,122, 91,151,183,140,},
{155,154,139,153,139,123,123, 63,153,153,153,152,152,152,137,152,137,122,166,183,140,136,153,
154,170,153,123,123,107,121,107,121,167,153,167,136,149,107,136,121,122, 91,151,183,140,},
{111,111,125,110,110, 94,124,108,124,139,139,139,168,124,138,124,138,107,107,125,141,179,153,
125,140,139,182,182,152,136,152,136,153,182,137,149,192,152,224,136, 31,136,136,139,111,} };
2012-06-13 12:15:07 +00:00
static const uint8_t INIT_LAST[3][30] =
{
{ 125, 110, 124, 110, 95, 94, 125, 111, 111, 79, 125, 126, 111, 111, 79,
108, 123, 93, CNU, CNU, CNU, CNU, CNU, CNU, CNU, CNU, CNU, CNU, CNU, CNU },
{ 125, 110, 94, 110, 95, 79, 125, 111, 110, 78, 110, 111, 111, 95, 94,
108, 123, 108, CNU, CNU, CNU, CNU, CNU, CNU, CNU, CNU, CNU, CNU, CNU, CNU },
{ 110, 110, 124, 125, 140, 153, 125, 127, 140, 109, 111, 143, 127, 111, 79,
108, 123, 63, CNU, CNU, CNU, CNU, CNU, CNU, CNU, CNU, CNU, CNU, CNU, CNU }
};
2012-06-13 12:15:07 +00:00
static const uint8_t g_uiGroupIdx[ 32 ] = {0,1,2,3,4,4,5,5,6,6,6,6,7,7,7,7,8,8,8,8,8,8,8,8,9,9,9,9,9,9,9,9};
static const uint8_t g_uiMinInGroup[ 10 ] = {0,1,2,3,4,6,8,12,16,24};
2012-06-13 15:08:15 +00:00
static const uint8_t g_sigLastScanCG32x32[ 64 ] =
{ 0, 8, 1,16, 9, 2,24,17,
10, 3,32,25,18,11, 4,40,
33,26,19,12, 5,48,41,34,
27,20,13, 6,56,49,42,35,
28,21,14, 7,57,50,43,36,
29,22,15,58,51,44,37,30,
23,59,52,45,38,31,60,53,
46,39,61,54,47,62,55,63 };
2012-06-01 12:31:06 +00:00
#endif