diff options
author | Stefano Sabatini <stefasab@gmail.com> | 2012-08-16 14:48:54 +0200 |
---|---|---|
committer | Stefano Sabatini <stefasab@gmail.com> | 2012-08-16 15:02:09 +0200 |
commit | 419e1b746354afaba4f496a5a8fcf388cd05adda (patch) | |
tree | fd9108264aa5b621763a5e5f1e8f3402ded9f297 | |
parent | 191b77eb01addf008440531f8cab193b3c2c5a15 (diff) | |
download | ffmpeg-419e1b746354afaba4f496a5a8fcf388cd05adda.tar.gz |
lavfi/hue: apply misc fixes to default values setting
In particular: signal error in case of bogus h:s values.
-rw-r--r-- | libavfilter/vf_hue.c | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/libavfilter/vf_hue.c b/libavfilter/vf_hue.c index 0bc4d92c34..51fee3e392 100644 --- a/libavfilter/vf_hue.c +++ b/libavfilter/vf_hue.c @@ -65,16 +65,16 @@ AVFILTER_DEFINE_CLASS(hue); static av_cold int init(AVFilterContext *ctx, const char *args) { HueContext *hue = ctx->priv; - float h = HUE_DEFAULT_VAL, s = SAT_DEFAULT_VAL; int n, ret; char c1 = 0, c2 = 0; char *equal; hue->class = &hue_class; + av_opt_set_defaults(hue); /* named options syntax */ + if (args) { if (equal = strchr(args, '=')) { - av_opt_set_defaults(hue); if ((ret = av_set_options_string(hue, args, "=", ":")) < 0) return ret; if (hue->hue != -FLT_MAX && hue->hue_deg != -FLT_MAX) { @@ -83,30 +83,29 @@ static av_cold int init(AVFilterContext *ctx, const char *args) "at the same time\n"); return AVERROR(EINVAL); } - if (hue->hue == -FLT_MAX) - hue->hue = HUE_DEFAULT_VAL; /* compatibility syntax */ } else { - if (args) { - n = sscanf(args, "%f%c%f%c", &h, &c1, &s, &c2); - if (n != 0 && n != 1 && (n != 3 || c1 != ':')) { + n = sscanf(args, "%f%c%f%c", &hue->hue_deg, &c1, &hue->saturation, &c2); + if (n != 1 && (n != 3 || c1 != ':')) { av_log(ctx, AV_LOG_ERROR, "Invalid syntax for argument '%s': " "must be in the form 'hue[:saturation]'\n", args); return AVERROR(EINVAL); } - if (s < -10 || s > 10) { + if (hue->saturation < -10 || hue->saturation > 10) { av_log(ctx, AV_LOG_ERROR, "Invalid value for saturation %0.1f: " - "must be included between range -10 and +10\n", s); + "must be included between range -10 and +10\n", hue->saturation); return AVERROR(EINVAL); } } - hue->hue_deg = h; - hue->saturation = s; } + if (hue->saturation == -FLT_MAX) + hue->hue = SAT_DEFAULT_VAL; + if (hue->hue == -FLT_MAX) + hue->hue = HUE_DEFAULT_VAL; if (hue->hue_deg != -FLT_MAX) /* Convert angle from degrees to radians */ hue->hue = hue->hue_deg * M_PI / 180; |