Moved GOP defining to config.c and added parameter --gop

* Checking that intra period and gop_len match
This commit is contained in:
Marko Viitanen 2015-03-30 09:54:22 +03:00
parent c82915761f
commit f28ebbcd41
3 changed files with 58 additions and 36 deletions

View file

@ -57,6 +57,7 @@ http://github.com/ultravideo/kvazaar/wiki/List-of-suggested-topics for a list of
0: 64x64, 1: 32x32, 2: 16x16, 3: 8x8 0: 64x64, 1: 32x32, 2: 16x16, 3: 8x8
--pu-depth-intra <int>-<int> : Range for sizes of intra prediction units to try. --pu-depth-intra <int>-<int> : Range for sizes of intra prediction units to try.
0: 64x64, 1: 32x32, 2: 16x16, 3: 8x8, 4: 4x4 0: 64x64, 1: 32x32, 2: 16x16, 3: 8x8, 4: 4x4
--gop <int> : Length of Group of Pictures, must be 8 or 0 [0]
Video Usability Information: Video Usability Information:
--sar <width:height> : Specify Sample Aspect Ratio --sar <width:height> : Specify Sample Aspect Ratio

View file

@ -88,6 +88,7 @@ int config_init(config_t *cfg)
cfg->cqmfile = NULL; cfg->cqmfile = NULL;
cfg->ref_frames = DEFAULT_REF_PIC_COUNT; cfg->ref_frames = DEFAULT_REF_PIC_COUNT;
cfg->seek = 0; cfg->seek = 0;
cfg->gop_len = 0;
cfg->tiles_width_count = 0; cfg->tiles_width_count = 0;
cfg->tiles_height_count = 0; cfg->tiles_height_count = 0;
@ -344,8 +345,13 @@ static int config_parse(config_t *cfg, const char *name, const char *value)
cfg->frames = atoi(value); cfg->frames = atoi(value);
else if OPT("qp") else if OPT("qp")
cfg->qp = atoi(value); cfg->qp = atoi(value);
else if OPT("period") else if OPT("period") {
cfg->intra_period = atoi(value); cfg->intra_period = atoi(value);
if (cfg->gop_len && cfg->intra_period && cfg->intra_period%cfg->gop_len != 0) {
fprintf(stderr, "Input error: Intra period (%d) not equal to goplen (%d)\n", cfg->intra_period, atoi(value));
return 0;
}
}
else if OPT("vps-period") else if OPT("vps-period")
cfg->vps_period = atoi(value); cfg->vps_period = atoi(value);
else if OPT("ref") { else if OPT("ref") {
@ -505,6 +511,54 @@ static int config_parse(config_t *cfg, const char *name, const char *value)
} }
} }
} }
else if OPT("gop") {
// ToDo: Defining the whole GOp structure via parameters
// Check for intra period, must be equal to goplen
if (atoi(value) && cfg->intra_period && cfg->intra_period%atoi(value) != 0) {
fprintf(stderr, "Input error: Intra period (%d) not equal to goplen (%d)\n", cfg->intra_period, atoi(value));
return 0;
}
if(atoi(value) == 8) {
// GOP
cfg->gop_len = 8;
cfg->gop[0].poc_offset = 8; cfg->gop[0].qp_offset = 1; cfg->gop[0].layer = 1; cfg->gop[0].qp_factor = 0.442; cfg->gop[0].is_ref = 1;
cfg->gop[0].ref_pos_count = 0;
cfg->gop[0].ref_neg_count = 3; cfg->gop[0].ref_neg[0] = 8; cfg->gop[0].ref_neg[1] = 12; cfg->gop[0].ref_neg[2] = 16;
cfg->gop[1].poc_offset = 4; cfg->gop[1].qp_offset = 2; cfg->gop[1].layer = 2; cfg->gop[1].qp_factor = 0.3536; cfg->gop[1].is_ref = 1;
cfg->gop[1].ref_neg_count = 2; cfg->gop[1].ref_neg[0] = 4; cfg->gop[1].ref_neg[1] = 8;
cfg->gop[1].ref_pos_count = 1; cfg->gop[1].ref_pos[0] = 4;
cfg->gop[2].poc_offset = 2; cfg->gop[2].qp_offset = 3; cfg->gop[2].layer = 3; cfg->gop[2].qp_factor = 0.3536; cfg->gop[2].is_ref = 1;
cfg->gop[2].ref_neg_count = 2; cfg->gop[2].ref_neg[0] = 2; cfg->gop[2].ref_neg[1] = 6;
cfg->gop[2].ref_pos_count = 2; cfg->gop[2].ref_pos[0] = 2; cfg->gop[2].ref_pos[1] = 6;
cfg->gop[3].poc_offset = 1; cfg->gop[3].qp_offset = 4; cfg->gop[3].layer = 4; cfg->gop[3].qp_factor = 0.68; cfg->gop[3].is_ref = 0;
cfg->gop[3].ref_neg_count = 1; cfg->gop[3].ref_neg[0] = 1;
cfg->gop[3].ref_pos_count = 3; cfg->gop[3].ref_pos[0] = 1; cfg->gop[3].ref_pos[1] = 3; cfg->gop[3].ref_pos[2] = 7;
cfg->gop[4].poc_offset = 3; cfg->gop[4].qp_offset = 4; cfg->gop[4].layer = 4; cfg->gop[4].qp_factor = 0.68; cfg->gop[4].is_ref = 0;
cfg->gop[4].ref_neg_count = 2; cfg->gop[4].ref_neg[0] = 1; cfg->gop[4].ref_neg[1] = 3;
cfg->gop[4].ref_pos_count = 2; cfg->gop[4].ref_pos[0] = 1; cfg->gop[4].ref_pos[1] = 5;
cfg->gop[5].poc_offset = 6; cfg->gop[5].qp_offset = 3; cfg->gop[5].layer = 3; cfg->gop[5].qp_factor = 0.3536; cfg->gop[5].is_ref = 1;
cfg->gop[5].ref_neg_count = 2; cfg->gop[5].ref_neg[0] = 2; cfg->gop[5].ref_neg[1] = 6;
cfg->gop[5].ref_pos_count = 1; cfg->gop[5].ref_pos[0] = 2;
cfg->gop[6].poc_offset = 5; cfg->gop[6].qp_offset = 4; cfg->gop[6].layer = 4; cfg->gop[6].qp_factor = 0.68; cfg->gop[6].is_ref = 0;
cfg->gop[6].ref_neg_count = 2; cfg->gop[6].ref_neg[0] = 1; cfg->gop[6].ref_neg[1] = 5;
cfg->gop[6].ref_pos_count = 2; cfg->gop[6].ref_pos[0] = 1; cfg->gop[6].ref_pos[1] = 3;
cfg->gop[7].poc_offset = 7; cfg->gop[7].qp_offset = 4; cfg->gop[7].layer = 4; cfg->gop[7].qp_factor = 0.68; cfg->gop[7].is_ref = 0;
cfg->gop[7].ref_neg_count = 3; cfg->gop[7].ref_neg[0] = 1; cfg->gop[7].ref_neg[1] = 3; cfg->gop[7].ref_neg[2] = 7;
cfg->gop[7].ref_pos_count = 1; cfg->gop[7].ref_pos[0] = 1;
} else if(atoi(value)) {
fprintf(stderr, "Input error: goplen must be 8\n");
return 0;
}
}
else else
return 0; return 0;
#undef OPT #undef OPT
@ -566,6 +620,7 @@ int config_read(config_t *cfg,int argc, char *argv[])
{ "cpuid", required_argument, NULL, 0 }, { "cpuid", required_argument, NULL, 0 },
{ "pu-depth-inter", required_argument, NULL, 0 }, { "pu-depth-inter", required_argument, NULL, 0 },
{ "pu-depth-intra", required_argument, NULL, 0 }, { "pu-depth-intra", required_argument, NULL, 0 },
{ "gop", required_argument, NULL, 0 },
{0, 0, 0, 0} {0, 0, 0, 0}
}; };

View file

@ -136,6 +136,7 @@ int main(int argc, char *argv[])
" 0: 64x64, 1: 32x32, 2: 16x16, 3: 8x8\n" " 0: 64x64, 1: 32x32, 2: 16x16, 3: 8x8\n"
" --pu-depth-intra <int>-<int> : Range for sizes of intra prediction units to try.\n" " --pu-depth-intra <int>-<int> : Range for sizes of intra prediction units to try.\n"
" 0: 64x64, 1: 32x32, 2: 16x16, 3: 8x8, 4: 4x4\n" " 0: 64x64, 1: 32x32, 2: 16x16, 3: 8x8, 4: 4x4\n"
" --gop <int> : Length of Group of Pictures, must be 8 or 0 [0]\n"
"\n" "\n"
" Video Usability Information:\n" " Video Usability Information:\n"
" --sar <width:height> : Specify Sample Aspect Ratio\n" " --sar <width:height> : Specify Sample Aspect Ratio\n"
@ -267,41 +268,6 @@ int main(int argc, char *argv[])
goto exit_failure; goto exit_failure;
} }
// GOP
cfg->gop_len = 8;
cfg->gop[0].poc_offset = 8; cfg->gop[0].qp_offset = 1; cfg->gop[0].layer = 1; cfg->gop[0].qp_factor = 0.442; cfg->gop[0].is_ref = 1;
cfg->gop[0].ref_pos_count = 0;
cfg->gop[0].ref_neg_count = 3; cfg->gop[0].ref_neg[0] = 8; cfg->gop[0].ref_neg[1] = 12; cfg->gop[0].ref_neg[2] = 16;
cfg->gop[1].poc_offset = 4; cfg->gop[1].qp_offset = 2; cfg->gop[1].layer = 2; cfg->gop[1].qp_factor = 0.3536; cfg->gop[1].is_ref = 1;
cfg->gop[1].ref_neg_count = 2; cfg->gop[1].ref_neg[0] = 4; cfg->gop[1].ref_neg[1] = 8;
cfg->gop[1].ref_pos_count = 1; cfg->gop[1].ref_pos[0] = 4;
cfg->gop[2].poc_offset = 2; cfg->gop[2].qp_offset = 3; cfg->gop[2].layer = 3; cfg->gop[2].qp_factor = 0.3536; cfg->gop[2].is_ref = 1;
cfg->gop[2].ref_neg_count = 2; cfg->gop[2].ref_neg[0] = 2; cfg->gop[2].ref_neg[1] = 6;
cfg->gop[2].ref_pos_count = 2; cfg->gop[2].ref_pos[0] = 2; cfg->gop[2].ref_pos[1] = 6;
cfg->gop[3].poc_offset = 1; cfg->gop[3].qp_offset = 4; cfg->gop[3].layer = 4; cfg->gop[3].qp_factor = 0.68; cfg->gop[3].is_ref = 0;
cfg->gop[3].ref_neg_count = 1; cfg->gop[3].ref_neg[0] = 1;
cfg->gop[3].ref_pos_count = 3; cfg->gop[3].ref_pos[0] = 1; cfg->gop[3].ref_pos[1] = 3; cfg->gop[3].ref_pos[2] = 7;
cfg->gop[4].poc_offset = 3; cfg->gop[4].qp_offset = 4; cfg->gop[4].layer = 4; cfg->gop[4].qp_factor = 0.68; cfg->gop[4].is_ref = 0;
cfg->gop[4].ref_neg_count = 2; cfg->gop[4].ref_neg[0] = 1; cfg->gop[4].ref_neg[1] = 3;
cfg->gop[4].ref_pos_count = 2; cfg->gop[4].ref_pos[0] = 1; cfg->gop[4].ref_pos[1] = 5;
cfg->gop[5].poc_offset = 6; cfg->gop[5].qp_offset = 3; cfg->gop[5].layer = 3; cfg->gop[5].qp_factor = 0.3536; cfg->gop[5].is_ref = 1;
cfg->gop[5].ref_neg_count = 2; cfg->gop[5].ref_neg[0] = 2; cfg->gop[5].ref_neg[1] = 6;
cfg->gop[5].ref_pos_count = 1; cfg->gop[5].ref_pos[0] = 2;
cfg->gop[6].poc_offset = 5; cfg->gop[6].qp_offset = 4; cfg->gop[6].layer = 4; cfg->gop[6].qp_factor = 0.68; cfg->gop[6].is_ref = 0;
cfg->gop[6].ref_neg_count = 2; cfg->gop[6].ref_neg[0] = 1; cfg->gop[6].ref_neg[1] = 5;
cfg->gop[6].ref_pos_count = 2; cfg->gop[6].ref_pos[0] = 1; cfg->gop[6].ref_pos[1] = 3;
cfg->gop[7].poc_offset = 7; cfg->gop[7].qp_offset = 4; cfg->gop[7].layer = 4; cfg->gop[7].qp_factor = 0.68; cfg->gop[7].is_ref = 0;
cfg->gop[7].ref_neg_count = 3; cfg->gop[7].ref_neg[0] = 1; cfg->gop[7].ref_neg[1] = 3; cfg->gop[7].ref_neg[2] = 7;
cfg->gop[7].ref_pos_count = 1; cfg->gop[7].ref_pos[0] = 1;
if (!encoder_control_init(&encoder, cfg)) { if (!encoder_control_init(&encoder, cfg)) {
goto exit_failure; goto exit_failure;
} }