1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-28 20:53:54 +02:00

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.
This commit is contained in:
Niklas Haas 2024-07-04 13:14:46 +02:00
parent 6b40be941a
commit 18b9687308

View File

@ -713,12 +713,18 @@ static int config_props(AVFilterLink *outlink)
* 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 (desc->log2_chroma_h == 1) {
if (in_v_chr_pos == -513)
in_v_chr_pos = 128; /* explicitly default missing info */
in_v_chr_pos += 256 * (i == 2); /* offset by one luma row for odd rows */
in_v_chr_pos >>= i > 0; /* double luma row distance */
}
if (outdesc->log2_chroma_h == 1 && scale->out_v_chr_pos == -513) {
out_v_chr_pos = (i == 0) ? 128 : (i == 1) ? 64 : 192;
if (outdesc->log2_chroma_h == 1) {
if (out_v_chr_pos == -513)
out_v_chr_pos = 128;
out_v_chr_pos += 256 * (i == 2);
out_v_chr_pos >>= i > 0;
}
av_opt_set_int(s, "src_h_chr_pos", scale->in_h_chr_pos, 0);