提交 0c7b44a0 编写于 作者: R Ronald S. Bultje

vf_psnr/ssim: don't crash if stats_file is NULL.

上级 a60539bb
...@@ -193,17 +193,19 @@ static av_cold int init(AVFilterContext *ctx) ...@@ -193,17 +193,19 @@ static av_cold int init(AVFilterContext *ctx)
s->min_mse = +INFINITY; s->min_mse = +INFINITY;
s->max_mse = -INFINITY; s->max_mse = -INFINITY;
if (!strcmp(s->stats_file_str, "-")) { if (s->stats_file_str) {
s->stats_file = stdout; if (!strcmp(s->stats_file_str, "-")) {
} else if (s->stats_file_str) { s->stats_file = stdout;
s->stats_file = fopen(s->stats_file_str, "w"); } else {
if (!s->stats_file) { s->stats_file = fopen(s->stats_file_str, "w");
int err = AVERROR(errno); if (!s->stats_file) {
char buf[128]; int err = AVERROR(errno);
av_strerror(err, buf, sizeof(buf)); char buf[128];
av_log(ctx, AV_LOG_ERROR, "Could not open stats file %s: %s\n", av_strerror(err, buf, sizeof(buf));
s->stats_file_str, buf); av_log(ctx, AV_LOG_ERROR, "Could not open stats file %s: %s\n",
return err; s->stats_file_str, buf);
return err;
}
} }
} }
......
...@@ -223,17 +223,19 @@ static av_cold int init(AVFilterContext *ctx) ...@@ -223,17 +223,19 @@ static av_cold int init(AVFilterContext *ctx)
{ {
SSIMContext *s = ctx->priv; SSIMContext *s = ctx->priv;
if (!strcmp(s->stats_file_str, "-")) { if (s->stats_file_str) {
s->stats_file = stdout; if (!strcmp(s->stats_file_str, "-")) {
} else if (s->stats_file_str) { s->stats_file = stdout;
s->stats_file = fopen(s->stats_file_str, "w"); } else {
if (!s->stats_file) { s->stats_file = fopen(s->stats_file_str, "w");
int err = AVERROR(errno); if (!s->stats_file) {
char buf[128]; int err = AVERROR(errno);
av_strerror(err, buf, sizeof(buf)); char buf[128];
av_log(ctx, AV_LOG_ERROR, "Could not open stats file %s: %s\n", av_strerror(err, buf, sizeof(buf));
s->stats_file_str, buf); av_log(ctx, AV_LOG_ERROR, "Could not open stats file %s: %s\n",
return err; s->stats_file_str, buf);
return err;
}
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册