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

Showing the changes to libavfilter (1 of 1 file). Show all

Unified · Split

libavfilter/vf_scale.c+7−5
@@ -518,6 +518,7 @@ static int config_props(AVFilterLink *outlink) · 517 unmodified lines
518 outlink->src->inputs[0];518 outlink->src->inputs[0];
519 enum AVPixelFormat outfmt = outlink->format;519 enum AVPixelFormat outfmt = outlink->format;
520 const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format);520 const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format);
521 const AVPixFmtDescriptor *outdesc = av_pix_fmt_desc_get(outfmt);
521 ScaleContext *scale = ctx->priv;522 ScaleContext *scale = ctx->priv;
522 uint8_t *flags_val = NULL;523 uint8_t *flags_val = NULL;
523 int ret;524 int ret;
@@ -588,14 +589,15 @@ static int config_props(AVFilterLink *outlink) · 64 unmodified lines
588 av_opt_set_int(s, "dst_range",589 av_opt_set_int(s, "dst_range",
589 scale->out_range == AVCOL_RANGE_JPEG, 0);590 scale->out_range == AVCOL_RANGE_JPEG, 0);
590 591
591 /* Override YUV420P default settings to have the correct (MPEG-2) chroma positions592 /* Override chroma location default settings to have the correct
592 * MPEG-2 chroma positions are used by convention593 * chroma positions. MPEG chroma positions are used by convention.
593 * XXX: support other 4:2:0 pixel formats */594 * Note that this works for both MPEG-1/JPEG and MPEG-2/4 chroma
594 if (inlink0->format == AV_PIX_FMT_YUV420P && scale->in_v_chr_pos == -513) {595 * locations, since they share a vertical alignment */
596 if (desc->log2_chroma_h == 1 && scale->in_v_chr_pos == -513) {
595 in_v_chr_pos = (i == 0) ? 128 : (i == 1) ? 64 : 192;597 in_v_chr_pos = (i == 0) ? 128 : (i == 1) ? 64 : 192;
596 }598 }
597 599
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) {
599 out_v_chr_pos = (i == 0) ? 128 : (i == 1) ? 64 : 192;601 out_v_chr_pos = (i == 0) ? 128 : (i == 1) ? 64 : 192;
600 }602 }
601 603

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