Commit 79d5bd6306 for ffmpeg
commit 79d5bd63067f5c25ae9f981a9381e44a2a11989a
Author: Michael Niedermayer <michael@niedermayer.cc>
Date: Thu Oct 22 16:06:38 2026 +0000
fftools/ffmpeg_filter: preserve display matrix when hardware autorotation is skipped
configure_input_video_filter() does not apply autorotation to hardware
pixel formats. Match that condition when deciding whether to remove the
global display matrix in ifilter_parameters_from_frame(), so transcoding
hardware frames does not discard their unapplied orientation.
The matrix was preserved before 7b18beb477f1716b8abac15df91410dc967be2e9.
631ac6d055b273c87feceb0c19ed62f211e8ef3b restored propagation with
-noautorotate, but left hardware inputs using the default setting affected.
Related to issue #25089. This preserves orientation metadata; automatic
insertion of hardware rotation filters remains unimplemented.
Tested with CUDA decoding and HEVC NVENC encoding at 0, 90, 180 and 270
degrees, with software decoding and with -noautorotate. fate-autorotate
also passes.
Assisted-by: Fairy
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index 1b9befe046..232ffbfff4 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -2393,7 +2393,8 @@ static int ifilter_parameters_from_frame(InputFilter *ifilter, const AVFrame *fr
sd = av_frame_get_side_data(frame, AV_FRAME_DATA_DISPLAYMATRIX);
if (sd) {
memcpy(ifp->displaymatrix, sd->data, sizeof(ifp->displaymatrix));
- if (ifp->opts.flags & IFILTER_FLAG_AUTOROTATE)
+ if ((ifp->opts.flags & IFILTER_FLAG_AUTOROTATE) &&
+ !(av_pix_fmt_desc_get(ifp->format)->flags & AV_PIX_FMT_FLAG_HWACCEL))
av_frame_side_data_remove(&ifp->side_data, &ifp->nb_side_data, AV_FRAME_DATA_DISPLAYMATRIX);
}
ifp->displaymatrix_present = !!sd;