Skip to content

Commit

Permalink
avfilter: use av_fopen_utf8() instead of plain fopen()
Browse files Browse the repository at this point in the history
Unify file access operations by replacing usages of direct calls to posix
fopen() to prepare for long filename support on Windows.

Signed-off-by: softworkz <softworkz@hotmail.com>
  • Loading branch information
softworkz committed May 17, 2022
1 parent e3580f6 commit 4f34284
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion libavfilter/af_firequalizer.c
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ static int generate_kernel(AVFilterContext *ctx, const char *gain, const char *g
if (ret < 0)
return ret;

if (s->dumpfile && (!s->dump_buf || !s->analysis_rdft || !(dump_fp = fopen(s->dumpfile, "w"))))
if (s->dumpfile && (!s->dump_buf || !s->analysis_rdft || !(dump_fp = av_fopen_utf8(s->dumpfile, "w"))))
av_log(ctx, AV_LOG_WARNING, "dumping failed.\n");

vars[VAR_CHS] = inlink->ch_layout.nb_channels;
Expand Down
2 changes: 1 addition & 1 deletion libavfilter/vf_deshake.c
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ static av_cold int init(AVFilterContext *ctx)
}

if (deshake->filename)
deshake->fp = fopen(deshake->filename, "w");
deshake->fp = av_fopen_utf8(deshake->filename, "w");
if (deshake->fp)
fwrite("Ori x, Avg x, Fin x, Ori y, Avg y, Fin y, Ori angle, Avg angle, Fin angle, Ori zoom, Avg zoom, Fin zoom\n", 1, 104, deshake->fp);

Expand Down
2 changes: 1 addition & 1 deletion libavfilter/vf_psnr.c
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ static av_cold int init(AVFilterContext *ctx)
if (!strcmp(s->stats_file_str, "-")) {
s->stats_file = stdout;
} else {
s->stats_file = fopen(s->stats_file_str, "w");
s->stats_file = av_fopen_utf8(s->stats_file_str, "w");
if (!s->stats_file) {
int err = AVERROR(errno);
char buf[128];
Expand Down
4 changes: 2 additions & 2 deletions libavfilter/vf_signature.c
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ static int xml_export(AVFilterContext *ctx, StreamContext *sc, const char* filen
FILE* f;
unsigned int pot3[5] = { 3*3*3*3, 3*3*3, 3*3, 3, 1 };

f = fopen(filename, "w");
f = av_fopen_utf8(filename, "w");
if (!f) {
int err = AVERROR(EINVAL);
char buf[128];
Expand Down Expand Up @@ -500,7 +500,7 @@ static int binary_export(AVFilterContext *ctx, StreamContext *sc, const char* fi
if (!buffer)
return AVERROR(ENOMEM);

f = fopen(filename, "wb");
f = av_fopen_utf8(filename, "wb");
if (!f) {
int err = AVERROR(EINVAL);
char buf[128];
Expand Down
2 changes: 1 addition & 1 deletion libavfilter/vf_ssim.c
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ static av_cold int init(AVFilterContext *ctx)
if (!strcmp(s->stats_file_str, "-")) {
s->stats_file = stdout;
} else {
s->stats_file = fopen(s->stats_file_str, "w");
s->stats_file = av_fopen_utf8(s->stats_file_str, "w");
if (!s->stats_file) {
int err = AVERROR(errno);
char buf[128];
Expand Down
2 changes: 1 addition & 1 deletion libavfilter/vf_vidstabdetect.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ static int config_input(AVFilterLink *inlink)
av_log(ctx, AV_LOG_INFO, " show = %d\n", s->conf.show);
av_log(ctx, AV_LOG_INFO, " result = %s\n", s->result);

s->f = fopen(s->result, "w");
s->f = av_fopen_utf8(s->result, "w");
if (s->f == NULL) {
av_log(ctx, AV_LOG_ERROR, "cannot open transform file %s\n", s->result);
return AVERROR(EINVAL);
Expand Down
2 changes: 1 addition & 1 deletion libavfilter/vf_vidstabtransform.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ static int config_input(AVFilterLink *inlink)
av_log(ctx, AV_LOG_INFO, " zoomspeed = %g\n", tc->conf.zoomSpeed);
av_log(ctx, AV_LOG_INFO, " interpol = %s\n", getInterpolationTypeName(tc->conf.interpolType));

f = fopen(tc->input, "r");
f = av_fopen_utf8(tc->input, "r");
if (!f) {
int ret = AVERROR(errno);
av_log(ctx, AV_LOG_ERROR, "cannot open input file %s\n", tc->input);
Expand Down
2 changes: 1 addition & 1 deletion libavfilter/vf_vmafmotion.c
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ static av_cold int init(AVFilterContext *ctx)
if (!strcmp(s->stats_file_str, "-")) {
s->stats_file = stdout;
} else {
s->stats_file = fopen(s->stats_file_str, "w");
s->stats_file = av_fopen_utf8(s->stats_file_str, "w");
if (!s->stats_file) {
int err = AVERROR(errno);
char buf[128];
Expand Down

0 comments on commit 4f34284

Please sign in to comment.