mirror of
https://github.com/ultravideo/uvg266.git
synced 2024-11-23 18:14:06 +00:00
Added commandline configuration of intra period (-p <intra_period>)
This commit is contained in:
parent
76f24408b6
commit
5d5fbb8704
|
@ -53,6 +53,7 @@ int config_init(config *cfg)
|
|||
cfg->width = 320;
|
||||
cfg->height = 240;
|
||||
cfg->qp = 32;
|
||||
cfg->intra_period = 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -118,6 +119,9 @@ int config_read(config *cfg,int argc, char *argv[])
|
|||
case 'q': // QP
|
||||
cfg->qp = atoi(argv[arg]);
|
||||
break;
|
||||
case 'p': // Intra period
|
||||
cfg->intra_period = atoi(argv[arg]);
|
||||
break;
|
||||
default:
|
||||
// Unknown command, print error message and ignore
|
||||
fprintf(stderr, "%c is not a known option\r\n", option);
|
||||
|
|
|
@ -37,6 +37,7 @@ typedef struct
|
|||
char *output; /*!< \brief Pointer to output filename */
|
||||
char *debug; /*!< \brief Pointer to debug output */
|
||||
int8_t qp; /*!< \brief Quantization parameter */
|
||||
int16_t intra_period; /*!< \brief the period of intra frames in stream */
|
||||
int32_t frames; /*!< \brief Number of frames to decode */
|
||||
int32_t width; /*!< \brief frame width */
|
||||
int32_t height; /*!< \brief frame height */
|
||||
|
|
|
@ -73,7 +73,7 @@ int main(int argc, char *argv[])
|
|||
if (!config_init(cfg) || !config_read(cfg,argc,argv)) {
|
||||
fprintf(stderr, "/***********************************************/\r\n");
|
||||
fprintf(stderr, " * HEVC Encoder v. " VERSION_STRING "*\r\n");
|
||||
fprintf(stderr, " * Tampere University of Technology 2013 *\r\n");
|
||||
fprintf(stderr, " * Tampere University of Technology 2014 *\r\n");
|
||||
fprintf(stderr, "/***********************************************/\r\n\r\n");
|
||||
|
||||
fprintf(stderr, "Usage:\r\n");
|
||||
|
@ -81,6 +81,10 @@ int main(int argc, char *argv[])
|
|||
fprintf(stderr, "Optional parameters:\r\n");
|
||||
fprintf(stderr, " -n <frames> : number of frames to decode\r\n");
|
||||
fprintf(stderr, " -q <QP> : Quantization Parameter, default 32\r\n");
|
||||
fprintf(stderr, " -p <intra period> : Period of intra pictures, default 0\r\n");
|
||||
fprintf(stderr, " 0: only first picture is intra\r\n");
|
||||
fprintf(stderr, " 1: all pictures are intra\r\n");
|
||||
fprintf(stderr, " 2-N: every Nth picture is intra\r\n");
|
||||
|
||||
config_destroy(cfg);
|
||||
return EXIT_FAILURE;
|
||||
|
@ -225,6 +229,7 @@ int main(int argc, char *argv[])
|
|||
MOVE_POINTER(encoder->in.cur_pic->pred_v,encoder->ref->pics[0]->pred_v);
|
||||
|
||||
encoder->frame++;
|
||||
encoder->poc++;
|
||||
}
|
||||
// Coding finished
|
||||
fgetpos(output,(fpos_t*)&curpos);
|
||||
|
|
|
@ -280,8 +280,15 @@ void init_encoder_input(encoder_input *input, FILE *inputfile,
|
|||
void encode_one_frame(encoder_control* encoder)
|
||||
{
|
||||
|
||||
// output parameters before first frame
|
||||
if (encoder->frame == 0) {
|
||||
/** IDR picture when: period == 0 and frame == 0
|
||||
* period == 1 && frame%2 == 0
|
||||
* period != 0 && frame%period == 0
|
||||
**/
|
||||
if ( (encoder->cfg->intra_period == 0 && encoder->frame == 0) ||
|
||||
(encoder->cfg->intra_period && encoder->frame % encoder->cfg->intra_period == 0 &&
|
||||
(encoder->cfg->intra_period != 1 || encoder->frame % 2 == 0 ) ) ) {
|
||||
encoder->poc = 0;
|
||||
|
||||
// Video Parameter Set (VPS)
|
||||
encode_vid_parameter_set(encoder);
|
||||
bitstream_align(encoder->stream);
|
||||
|
@ -324,7 +331,8 @@ void encode_one_frame(encoder_control* encoder)
|
|||
bitstream_clear_buffer(encoder->stream);
|
||||
} else {
|
||||
cabac_start(&cabac);
|
||||
encoder->in.cur_pic->slicetype = SLICE_P;
|
||||
// When intra period == 1, all pictures are intra
|
||||
encoder->in.cur_pic->slicetype = encoder->cfg->intra_period==1 ? SLICE_I : SLICE_P;
|
||||
encoder->in.cur_pic->type = NAL_TRAIL_R;
|
||||
scalinglist_process();
|
||||
search_slice_data(encoder);
|
||||
|
@ -754,7 +762,7 @@ void encode_slice_header(encoder_control* encoder)
|
|||
int j;
|
||||
int ref_negative = 1;
|
||||
int ref_positive = 0;
|
||||
WRITE_U(encoder->stream, encoder->frame&0xf, 4, "pic_order_cnt_lsb");
|
||||
WRITE_U(encoder->stream, encoder->poc&0xf, 4, "pic_order_cnt_lsb");
|
||||
WRITE_U(encoder->stream, 0, 1, "short_term_ref_pic_set_sps_flag");
|
||||
WRITE_UE(encoder->stream, ref_negative, "num_negative_pics");
|
||||
WRITE_UE(encoder->stream, ref_positive, "num_positive_pics");
|
||||
|
|
|
@ -61,6 +61,7 @@ typedef struct
|
|||
typedef struct
|
||||
{
|
||||
int32_t frame;
|
||||
int32_t poc; /*!< \brief picture order count */
|
||||
config *cfg;
|
||||
encoder_input in;
|
||||
encoder_me me;
|
||||
|
|
Loading…
Reference in a new issue