aboutsummaryrefslogtreecommitdiffstats
path: root/libavfilter
diff options
context:
space:
mode:
authorNiklas Haas <git@haasn.dev>2024-07-04 13:14:46 +0200
committerNiklas Haas <git@haasn.dev>2024-08-16 11:43:37 +0200
commit18b9687308202ea05044cb9b723e72b67be62bc6 (patch)
tree560b463886fa0d994363997fe9830d562fe0248b /libavfilter
parent6b40be941a00b99fa895adcdffa5f638c739ecd1 (diff)
downloadffmpeg-18b9687308202ea05044cb9b723e72b67be62bc6.tar.gz
avfilter/swscale: always fix interlaced chroma location
The current logic only fixes it when the user does not explicitly specify the chroma location. However, this does not make a lot of sense. Since there is no way to specify this property per-field, it effectively *prevents* the user from being able to correctly scale interlaced frames with top-aligned chroma. It makes more sense to consider the user setting in the progressive case only, and automatically adapt it to the correct interlaced field positions, following the details of the MPEG specification.
Diffstat (limited to 'libavfilter')
-rw-r--r--libavfilter/vf_scale.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c
index 454fb812e4..2a5478aeb2 100644
--- a/libavfilter/vf_scale.c
+++ b/libavfilter/vf_scale.c
@@ -713,12 +713,18 @@ static int config_props(AVFilterLink *outlink)
* chroma positions. MPEG chroma positions are used by convention.
* Note that this works for both MPEG-1/JPEG and MPEG-2/4 chroma
* locations, since they share a vertical alignment */
- if (desc->log2_chroma_h == 1 && scale->in_v_chr_pos == -513) {
- in_v_chr_pos = (i == 0) ? 128 : (i == 1) ? 64 : 192;
+ if (desc->log2_chroma_h == 1) {
+ if (in_v_chr_pos == -513)
+ in_v_chr_pos = 128; /* explicitly default missing info */
+ in_v_chr_pos += 256 * (i == 2); /* offset by one luma row for odd rows */
+ in_v_chr_pos >>= i > 0; /* double luma row distance */
}
- if (outdesc->log2_chroma_h == 1 && scale->out_v_chr_pos == -513) {
- out_v_chr_pos = (i == 0) ? 128 : (i == 1) ? 64 : 192;
+ if (outdesc->log2_chroma_h == 1) {
+ if (out_v_chr_pos == -513)
+ out_v_chr_pos = 128;
+ out_v_chr_pos += 256 * (i == 2);
+ out_v_chr_pos >>= i > 0;
}
av_opt_set_int(s, "src_h_chr_pos", scale->in_h_chr_pos, 0);