History

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.

Niklas Haas committed 2 years ago

Commit 18b96871 parent 6b40be91 file · +10 −4Browse files

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

Unified · Split

libavfilter/vf_scale.c+10−4
@@ -713,12 +713,18 @@ static int config_props(AVFilterLink *outlink) · 712 unmodified lines
713 * chroma positions. MPEG chroma positions are used by convention.713 * chroma positions. MPEG chroma positions are used by convention.
714 * Note that this works for both MPEG-1/JPEG and MPEG-2/4 chroma714 * Note that this works for both MPEG-1/JPEG and MPEG-2/4 chroma
715 * locations, since they share a vertical alignment */715 * locations, since they share a vertical alignment */
716 if (desc->log2_chroma_h == 1 && scale->in_v_chr_pos == -513) {716 if (desc->log2_chroma_h == 1) {
717 in_v_chr_pos = (i == 0) ? 128 : (i == 1) ? 64 : 192;717 if (in_v_chr_pos == -513)
718 in_v_chr_pos = 128; /* explicitly default missing info */
719 in_v_chr_pos += 256 * (i == 2); /* offset by one luma row for odd rows */
720 in_v_chr_pos >>= i > 0; /* double luma row distance */
718 }721 }
719 722
720 if (outdesc->log2_chroma_h == 1 && scale->out_v_chr_pos == -513) {723 if (outdesc->log2_chroma_h == 1) {
721 out_v_chr_pos = (i == 0) ? 128 : (i == 1) ? 64 : 192;724 if (out_v_chr_pos == -513)
725 out_v_chr_pos = 128;
726 out_v_chr_pos += 256 * (i == 2);
727 out_v_chr_pos >>= i > 0;
722 }728 }
723 729
724 av_opt_set_int(s, "src_h_chr_pos", scale->in_h_chr_pos, 0);730 av_opt_set_int(s, "src_h_chr_pos", scale->in_h_chr_pos, 0);

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