From 89800d3690b3f60e1e675fb4473af6d3eb45ce2d Mon Sep 17 00:00:00 2001 From: Yusuke Nakamura Date: Tue, 4 Feb 2014 07:16:42 +0900 Subject: [PATCH] config: Add --no-deblock to disable deblocking filter. --- src/config.c | 26 ++++++++++++++++++++++++++ src/config.h | 1 + src/encmain.c | 7 ++++--- 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/config.c b/src/config.c index 1798ff1d..7334207b 100644 --- a/src/config.c +++ b/src/config.c @@ -60,6 +60,7 @@ int config_init(config *cfg) cfg->height = 240; cfg->qp = 32; cfg->intra_period = 0; + cfg->deblock_enable = 1; return 1; } @@ -98,10 +99,32 @@ char *copy_string(const char *string) return allocated_string; } +static int atobool(const char *str) +{ + if (!strcmp(str, "1") || + !strcmp(str, "true") || + !strcmp(str, "yes")) + return 1; + if (!strcmp(str, "0") || + !strcmp(str, "false") || + !strcmp(str, "no")) + return 0; + return 0; +} + static int config_parse(config *cfg, const char *name, const char *value) { + int i; + if (!name) return 0; + if (!value) + value = "true"; + + if ((!strncmp(name, "no-", 3) && (i = 3))) { + name += i; + value = atobool(value) ? "false" : "true"; + } #define OPT(STR) else if (!strcmp(name, STR)) if (0); @@ -121,6 +144,8 @@ static int config_parse(config *cfg, const char *name, const char *value) cfg->qp = atoi(value); OPT("period") cfg->intra_period = atoi(value); + OPT("deblock") + cfg->deblock_enable = atobool(value); else return 0; #undef OPT @@ -152,6 +177,7 @@ int config_read(config *cfg,int argc, char *argv[]) { "frames", required_argument, NULL, 'n' }, { "qp", required_argument, NULL, 'q' }, { "period", required_argument, NULL, 'p' }, + { "no-deblock", no_argument, NULL, 0 }, {0, 0, 0, 0} }; diff --git a/src/config.h b/src/config.h index 449030db..d292185b 100644 --- a/src/config.h +++ b/src/config.h @@ -41,6 +41,7 @@ typedef struct int32_t frames; /*!< \brief Number of frames to decode */ int32_t width; /*!< \brief frame width */ int32_t height; /*!< \brief frame height */ + int8_t deblock_enable; /*!< \brief Flag to enable deblocking filter */ } config; /* Function definitions */ diff --git a/src/encmain.c b/src/encmain.c index 26a642db..d4d3b814 100644 --- a/src/encmain.c +++ b/src/encmain.c @@ -100,6 +100,7 @@ int main(int argc, char *argv[]) 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"); + fprintf(stderr, " --no-deblock : Disable deblocking filter\r\n"); if (cfg) config_destroy(cfg); @@ -162,9 +163,9 @@ int main(int argc, char *argv[]) encoder->QP = encoder->cfg->qp; encoder->in.video_format = FORMAT_420; // deblocking filter - encoder->deblock_enable = 1; - encoder->beta_offset_div2 = 0; - encoder->tc_offset_div2 = 0; + encoder->deblock_enable = encoder->cfg->deblock_enable; + encoder->beta_offset_div2 = 0; + encoder->tc_offset_div2 = 0; // SAO encoder->sao_enable = 1;