aboutsummaryrefslogtreecommitdiffstats
path: root/libavfilter
diff options
context:
space:
mode:
authorJan Ekström <jeebjp@gmail.com>2021-10-28 00:38:18 +0300
committerJan Ekström <jeebjp@gmail.com>2021-10-28 23:13:51 +0300
commitcd1d09e81b53d47380b494acd3432fd4abb3c17b (patch)
tree254b20c07eeaba2e71f1ce58f986d0b510f50056 /libavfilter
parent8c2f142bd91362710fcd42be44dedcafc6d535b8 (diff)
downloadffmpeg-cd1d09e81b53d47380b494acd3432fd4abb3c17b.tar.gz
avfilter/vf_zscale: deduplicate output color information setting
This way a piece of logic is not missed in one location or the other, such as the case with chroma location outside the if.
Diffstat (limited to 'libavfilter')
-rw-r--r--libavfilter/vf_zscale.c45
1 files changed, 20 insertions, 25 deletions
diff --git a/libavfilter/vf_zscale.c b/libavfilter/vf_zscale.c
index 3f7dba489a..439c0c8548 100644
--- a/libavfilter/vf_zscale.c
+++ b/libavfilter/vf_zscale.c
@@ -554,6 +554,24 @@ fail:
return ret;
}
+static void update_output_color_information(ZScaleContext *s, AVFrame *frame)
+{
+ if (s->colorspace != -1)
+ frame->colorspace = (int)s->dst_format.matrix_coefficients;
+
+ if (s->primaries != -1)
+ frame->color_primaries = (int)s->dst_format.color_primaries;
+
+ if (s->range != -1)
+ frame->color_range = convert_range_from_zimg(s->dst_format.pixel_range);
+
+ if (s->trc != -1)
+ frame->color_trc = (int)s->dst_format.transfer_characteristics;
+
+ if (s->chromal != -1)
+ frame->chroma_location = (int)s->dst_format.chroma_location - 1;
+}
+
static int filter_frame(AVFilterLink *link, AVFrame *in)
{
ZScaleContext *s = link->dst->priv;
@@ -621,20 +639,7 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
format_init(&s->dst_format, out, odesc, s->colorspace,
s->primaries, s->trc, s->range, s->chromal);
- if (s->colorspace != -1)
- out->colorspace = (int)s->dst_format.matrix_coefficients;
-
- if (s->primaries != -1)
- out->color_primaries = (int)s->dst_format.color_primaries;
-
- if (s->range != -1)
- out->color_range = convert_range_from_zimg(s->dst_format.pixel_range);
-
- if (s->trc != -1)
- out->color_trc = (int)s->dst_format.transfer_characteristics;
-
- if (s->chromal != -1)
- out->chroma_location = (int)s->dst_format.chroma_location - 1;
+ update_output_color_information(s, out);
ret = graph_build(&s->graph, &s->params, &s->src_format, &s->dst_format,
&s->tmp, &s->tmp_size);
@@ -680,17 +685,7 @@ static int filter_frame(AVFilterLink *link, AVFrame *in)
}
}
- if (s->colorspace != -1)
- out->colorspace = (int)s->dst_format.matrix_coefficients;
-
- if (s->primaries != -1)
- out->color_primaries = (int)s->dst_format.color_primaries;
-
- if (s->range != -1)
- out->color_range = convert_range_from_zimg(s->dst_format.pixel_range);
-
- if (s->trc != -1)
- out->color_trc = (int)s->dst_format.transfer_characteristics;
+ update_output_color_information(s, out);
av_reduce(&out->sample_aspect_ratio.num, &out->sample_aspect_ratio.den,
(int64_t)in->sample_aspect_ratio.num * outlink->h * link->w,