[FFmpeg-devel] [PATCH] Fix chroma positioning for 4:2:0 pixel format
Maksym Veremeyenko
verem at m1stereo.tv
Mon Feb 6 17:14:14 EET 2017
Hi,
Attached patch fixes chroma positioning during scaling interlaced 4:2:0.
On a first iteration default context value been overwritten by new value
and not been update on next iterations for fields. This mean that
vertical chroma position remain 128 for field#0 and field#1 instead of
*64* and *192*.
Attached patch use local variable for storing this intermediate value of
chroma vertical position not modifying default context value.
--
Maksym Veremeyenko
-------------- next part --------------
From 912ecf538b6b2f7a8df4afdfed2d34052162335c Mon Sep 17 00:00:00 2001
From: Maksym Veremeyenko <verem at m1.tv>
Date: Mon, 6 Feb 2017 17:03:17 +0200
Subject: [PATCH] Fix chroma positioning for 4:2:0 pixel format
---
libavfilter/vf_scale.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c
index 22bee96..a7dfd3d 100644
--- a/libavfilter/vf_scale.c
+++ b/libavfilter/vf_scale.c
@@ -374,6 +374,7 @@ static int config_props(AVFilterLink *outlink)
int i;
for (i = 0; i < 3; i++) {
+ int in_v_chr_pos = scale->in_v_chr_pos, out_v_chr_pos = scale->out_v_chr_pos;
struct SwsContext **s = swscs[i];
*s = sws_alloc_context();
if (!*s)
@@ -406,17 +407,17 @@ static int config_props(AVFilterLink *outlink)
* MPEG-2 chroma positions are used by convention
* XXX: support other 4:2:0 pixel formats */
if (inlink0->format == AV_PIX_FMT_YUV420P && scale->in_v_chr_pos == -513) {
- scale->in_v_chr_pos = (i == 0) ? 128 : (i == 1) ? 64 : 192;
+ in_v_chr_pos = (i == 0) ? 128 : (i == 1) ? 64 : 192;
}
if (outlink->format == AV_PIX_FMT_YUV420P && scale->out_v_chr_pos == -513) {
- scale->out_v_chr_pos = (i == 0) ? 128 : (i == 1) ? 64 : 192;
+ out_v_chr_pos = (i == 0) ? 128 : (i == 1) ? 64 : 192;
}
av_opt_set_int(*s, "src_h_chr_pos", scale->in_h_chr_pos, 0);
- av_opt_set_int(*s, "src_v_chr_pos", scale->in_v_chr_pos, 0);
+ av_opt_set_int(*s, "src_v_chr_pos", in_v_chr_pos, 0);
av_opt_set_int(*s, "dst_h_chr_pos", scale->out_h_chr_pos, 0);
- av_opt_set_int(*s, "dst_v_chr_pos", scale->out_v_chr_pos, 0);
+ av_opt_set_int(*s, "dst_v_chr_pos", out_v_chr_pos, 0);
if ((ret = sws_init_context(*s, NULL, NULL)) < 0)
return ret;
--
2.9.3
More information about the ffmpeg-devel
mailing list