diff --git a/README.md b/README.md index d5ddf15f..133e87a3 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,7 @@ http://github.com/ultravideo/kvazaar/wiki/List-of-suggested-topics for a list of -n, --frames : Number of frames to code [all] --seek : First frame to code [0] --input-res x : Input resolution (width x height) + --input-fps : Framerate of the input video [25.0] -q, --qp : Quantization Parameter [32] -p, --period : Period of intra pictures [0] 0: only first picture is intra @@ -60,6 +61,9 @@ http://github.com/ultravideo/kvazaar/wiki/List-of-suggested-topics for a list of --no-info : Don't add information about the encoder to settings. --gop : Length of Group of Pictures, must be 8 or 0 [0] --bipred : Enable bi-prediction search + --bitrate : Target bitrate. [0] + 0: disable rate-control + N: target N bits per second Video Usability Information: --sar : Specify Sample Aspect Ratio diff --git a/src/config.c b/src/config.c index 4a9f097e..d1c0236f 100644 --- a/src/config.c +++ b/src/config.c @@ -60,6 +60,7 @@ int config_init(config_t *cfg) cfg->frames = 0; cfg->width = 0; cfg->height = 0; + cfg->framerate = 25; cfg->qp = 32; cfg->intra_period = 0; cfg->vps_period = 0; @@ -90,6 +91,7 @@ int config_init(config_t *cfg) cfg->seek = 0; cfg->gop_len = 0; cfg->bipred = 0; + cfg->target_bitrate = 0; cfg->tiles_width_count = 0; cfg->tiles_height_count = 0; @@ -344,6 +346,13 @@ static int config_parse(config_t *cfg, const char *name, const char *value) cfg->width = cfg->height = 0; } } + else if OPT("input-fps") { + cfg->framerate = atof(value); + if (cfg->framerate <= 0.0) { + fprintf(stderr, "Input error: --input-fps must be positive\n"); + error = 1; + } + } else if OPT("frames") cfg->frames = atoi(value); else if OPT("qp") @@ -566,6 +575,13 @@ static int config_parse(config_t *cfg, const char *name, const char *value) } else if OPT("bipred") cfg->bipred = atobool(value); + else if OPT("bitrate") { + cfg->target_bitrate = atoi(value); + if (cfg->target_bitrate < 0) { + fprintf(stderr, "Input error: --bitrate must be nonnegative\n"); + error = 1; + } + } else return 0; #undef OPT @@ -596,6 +612,7 @@ int config_read(config_t *cfg,int argc, char *argv[]) { "ref", required_argument, NULL, 'r' }, { "vps-period", required_argument, NULL, 0 }, { "input-res", required_argument, NULL, 0 }, + { "input-fps", required_argument, NULL, 0 }, { "no-deblock", no_argument, NULL, 0 }, { "deblock", required_argument, NULL, 0 }, { "no-sao", no_argument, NULL, 0 }, @@ -630,6 +647,7 @@ int config_read(config_t *cfg,int argc, char *argv[]) { "no-info", no_argument, NULL, 0 }, { "gop", required_argument, NULL, 0 }, { "bipred", no_argument, NULL, 0 }, + { "bitrate", required_argument, NULL, 0 }, {0, 0, 0, 0} }; diff --git a/src/config.h b/src/config.h index f1318420..65da7243 100644 --- a/src/config.h +++ b/src/config.h @@ -54,6 +54,7 @@ typedef struct int32_t frames; /*!< \brief Number of frames to decode */ int32_t width; /*!< \brief frame width */ int32_t height; /*!< \brief frame height */ + double framerate; /*!< \brief Input framerate */ int32_t deblock_enable; /*!< \brief Flag to enable deblocking filter */ int32_t sao_enable; /*!< \brief Flag to enable sample adaptive offset filter */ int32_t rdoq_enable; /*!< \brief Flag to enable RD optimized quantization. */ @@ -107,6 +108,7 @@ typedef struct int8_t gop_len; /*!< \brief length of GOP for the video sequence */ gop_config_t gop[MAX_GOP]; /*!< \brief Array of GOP settings */ + int32_t target_bitrate; } config_t; /* Function definitions */ diff --git a/src/encmain.c b/src/encmain.c index a984876b..730b382c 100644 --- a/src/encmain.c +++ b/src/encmain.c @@ -99,6 +99,7 @@ int main(int argc, char *argv[]) " -n, --frames : Number of frames to code [all]\n" " --seek : First frame to code [0]\n" " --input-res x : Input resolution (width x height)\n" + " --input-fps : Framerate of the input video [25.0]\n" " -q, --qp : Quantization Parameter [32]\n" " -p, --period : Period of intra pictures [0]\n" " 0: only first picture is intra\n" @@ -139,6 +140,9 @@ int main(int argc, char *argv[]) " --no-info : Don't add information about the encoder to settings.\n" " --gop : Length of Group of Pictures, must be 8 or 0 [0]\n" " --bipred : Enable bi-prediction search\n" + " --bitrate : Target bitrate. [0]\n" + " 0: disable rate-control\n" + " N: target N bits per second\n" "\n" " Video Usability Information:\n" " --sar : Specify Sample Aspect Ratio\n"