From: Niklas Haas <ffmpeg@haasn.xyz> To: ffmpeg-devel@ffmpeg.org Cc: Niklas Haas <git@haasn.dev> Subject: [FFmpeg-devel] [PATCH] avfilter/vf_scale: fix interlaced chroma for other formats Date: Fri, 13 Oct 2023 16:22:05 +0200 Message-ID: <20231013142205.60658-1-ffmpeg@haasn.xyz> (raw) From: Niklas Haas <git@haasn.dev> 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. (To be fixed in a separate commit) --- libavfilter/vf_scale.c | 12 +++++++----- 1 file 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; } -- 2.42.0 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
next reply other threads:[~2023-10-13 14:22 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-10-13 14:22 Niklas Haas [this message] 2023-10-13 22:52 ` Michael Niedermayer 2023-10-13 23:00 ` Niklas Haas 2023-10-13 23:15 ` Michael Niedermayer [not found] ` <6DC2A4C9-2A92-4CA4-8AC7-F8F0C2C41A5B@cosmin.at> 2023-10-14 5:06 ` Cosmin Stejerean via ffmpeg-devel
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20231013142205.60658-1-ffmpeg@haasn.xyz \ --to=ffmpeg@haasn.xyz \ --cc=ffmpeg-devel@ffmpeg.org \ --cc=git@haasn.dev \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git