History

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)

Niklas Haas committed 3 years ago

Commit 2d1aeba1 parent d799ad21 file · +7 −5Browse files

Unified · Split

libavfilter/vf_scale.c+7−5
@@ -518,6 +518,7 @@ static int config_props(AVFilterLink *outlink) · 517 unmodified lines
518518 outlink->src->inputs[0];
519519 enum AVPixelFormat outfmt = outlink->format;
520520 const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format);
521+ const AVPixFmtDescriptor *outdesc = av_pix_fmt_desc_get(outfmt);
521522 ScaleContext *scale = ctx->priv;
522523 uint8_t *flags_val = NULL;
523524 int ret;
@@ -588,14 +589,15 @@ static int config_props(AVFilterLink *outlink) · 64 unmodified lines
588589 av_opt_set_int(s, "dst_range",
589590 scale->out_range == AVCOL_RANGE_JPEG, 0);
590591
591− /* Override YUV420P default settings to have the correct (MPEG-2) chroma positions
592− * MPEG-2 chroma positions are used by convention
593− * XXX: support other 4:2:0 pixel formats */
594− if (inlink0->format == AV_PIX_FMT_YUV420P && scale->in_v_chr_pos == -513) {
592+ /* Override chroma location default settings to have the correct
593+ * chroma positions. MPEG chroma positions are used by convention.
594+ * Note that this works for both MPEG-1/JPEG and MPEG-2/4 chroma
595+ * locations, since they share a vertical alignment */
596+ if (desc->log2_chroma_h == 1 && scale->in_v_chr_pos == -513) {
595597 in_v_chr_pos = (i == 0) ? 128 : (i == 1) ? 64 : 192;
596598 }
597599
598− if (outlink->format == AV_PIX_FMT_YUV420P && scale->out_v_chr_pos == -513) {
600+ if (outdesc->log2_chroma_h == 1 && scale->out_v_chr_pos == -513) {
599601 out_v_chr_pos = (i == 0) ? 128 : (i == 1) ? 64 : 192;
600602 }
601603

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t