diff options
author | Niklas Haas <git@haasn.dev> | 2023-10-13 14:31:57 +0200 |
---|---|---|
committer | Niklas Haas <git@haasn.dev> | 2023-10-20 15:20:09 +0200 |
commit | 2d1aeba8f26869dff6857087f48066f76dba8dc5 (patch) | |
tree | 14d5dcdba77e9fa623ef67b7cc8082b3278625b4 /libavfilter/vf_scale.c | |
parent | d799ad24045f2ae005c8b4c90bee5330ff15fea8 (diff) | |
download | ffmpeg-2d1aeba8f26869dff6857087f48066f76dba8dc5.tar.gz |
avfilter/vf_scale: fix interlaced chroma for other formats
This logic only covers the case of yuv420p. Extend this logic to cover
*all* vertically subsampled YUV formats, which require the same
interlaced scaling logic.
Fortunately, we can get away with re-using the same code for both JPEG
and MPEG range YUV, because the only difference here is the horizontal
alignment. (Which I omit touching for now, to avoid introducing possibly
unintended changes in default behavior)
Diffstat (limited to 'libavfilter/vf_scale.c')
-rw-r--r-- | libavfilter/vf_scale.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c index b0221e8538..23335cef4b 100644 --- a/libavfilter/vf_scale.c +++ b/libavfilter/vf_scale.c @@ -518,6 +518,7 @@ static int config_props(AVFilterLink *outlink) outlink->src->inputs[0]; enum AVPixelFormat outfmt = outlink->format; const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format); + const AVPixFmtDescriptor *outdesc = av_pix_fmt_desc_get(outfmt); ScaleContext *scale = ctx->priv; uint8_t *flags_val = NULL; int ret; @@ -588,14 +589,15 @@ static int config_props(AVFilterLink *outlink) av_opt_set_int(s, "dst_range", scale->out_range == AVCOL_RANGE_JPEG, 0); - /* Override YUV420P default settings to have the correct (MPEG-2) chroma positions - * 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) { + /* Override chroma location default settings to have the correct + * 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 (outlink->format == AV_PIX_FMT_YUV420P && scale->out_v_chr_pos == -513) { + if (outdesc->log2_chroma_h == 1 && scale->out_v_chr_pos == -513) { out_v_chr_pos = (i == 0) ? 128 : (i == 1) ? 64 : 192; } |