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
713713 * chroma positions. MPEG chroma positions are used by convention.
714714 * Note that this works for both MPEG-1/JPEG and MPEG-2/4 chroma
715715 * locations, since they share a vertical alignment */
716− if (desc->log2_chroma_h == 1 && scale->in_v_chr_pos == -513) {
717− in_v_chr_pos = (i == 0) ? 128 : (i == 1) ? 64 : 192;
716+ if (desc->log2_chroma_h == 1) {
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 */
718721 }
719722
720− if (outdesc->log2_chroma_h == 1 && scale->out_v_chr_pos == -513) {
721− out_v_chr_pos = (i == 0) ? 128 : (i == 1) ? 64 : 192;
723+ if (outdesc->log2_chroma_h == 1) {
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;
722728 }
723729
724730 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