Skip to content

Commit 04ceabe

Browse files
committed
avfilter/vf_scale: set correct AVFrame SAR if reset_sar=1
This otherwise generates an inconsistency between the frame state and the link state, since the link state is set to 1:1 explicitly when `reset_sar` is enabled, but this line of code unconditionally overwrote the output frame SAR with the value that would be computed in the absence of `reset_sar`. cf. vf_scale_cuda, which does this correctly
1 parent e6fb8f3 commit 04ceabe

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

libavfilter/vf_scale.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -854,10 +854,14 @@ static int scale_frame(AVFilterLink *link, AVFrame **frame_in,
854854
AV_SIDE_DATA_PROP_COLOR_DEPENDENT);
855855
}
856856

857-
av_reduce(&out->sample_aspect_ratio.num, &out->sample_aspect_ratio.den,
858-
(int64_t)in->sample_aspect_ratio.num * outlink->h * link->w,
859-
(int64_t)in->sample_aspect_ratio.den * outlink->w * link->h,
860-
INT_MAX);
857+
if (scale->reset_sar) {
858+
out->sample_aspect_ratio = outlink->sample_aspect_ratio;
859+
} else {
860+
av_reduce(&out->sample_aspect_ratio.num, &out->sample_aspect_ratio.den,
861+
(int64_t)in->sample_aspect_ratio.num * outlink->h * link->w,
862+
(int64_t)in->sample_aspect_ratio.den * outlink->w * link->h,
863+
INT_MAX);
864+
}
861865

862866
if (sws_is_noop(out, in)) {
863867
av_frame_free(&out);

0 commit comments

Comments
 (0)