diff mbox series

[FFmpeg-devel,07/12] fftools/ffmpeg_filter: remove display matrix if we have applied it

Message ID 20240322202841.31730-7-anton@khirnov.net
State New
Headers show
Series [FFmpeg-devel,01/12] tests/fate/ffmpeg: evaluate thread count in fate-run.sh rather than make | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Anton Khirnov March 22, 2024, 8:28 p.m. UTC
---
 fftools/ffmpeg_filter.c | 7 +++++++
 1 file changed, 7 insertions(+)
diff mbox series

Patch

diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index 3d88482d07..9aa499a89e 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -143,6 +143,7 @@  typedef struct InputFilterPriv {
     AVBufferRef        *hw_frames_ctx;
 
     int                 displaymatrix_present;
+    int                 displaymatrix_applied;
     int32_t             displaymatrix[9];
 
     // fallback parameters to use when no input is ever sent
@@ -1568,6 +1569,7 @@  static int configure_input_video_filter(FilterGraph *fg, AVFilterGraph *graph,
     av_assert0(desc);
 
     // TODO: insert hwaccel enabled filters like transpose_vaapi into the graph
+    ifp->displaymatrix_applied = 0;
     if ((ifp->opts.flags & IFILTER_FLAG_AUTOROTATE) &&
         !(desc->flags & AV_PIX_FMT_FLAG_HWACCEL)) {
         int32_t *displaymatrix = ifp->displaymatrix;
@@ -1601,6 +1603,8 @@  static int configure_input_video_filter(FilterGraph *fg, AVFilterGraph *graph,
         }
         if (ret < 0)
             return ret;
+
+        ifp->displaymatrix_applied = 1;
     }
 
     snprintf(name, sizeof(name), "trim_in_%s", ifp->opts.name);
@@ -2697,6 +2701,9 @@  static int send_frame(FilterGraph *fg, FilterGraphThread *fgt,
     frame->duration  = av_rescale_q(frame->duration, frame->time_base, ifp->time_base);
     frame->time_base = ifp->time_base;
 
+    if (ifp->displaymatrix_applied)
+        av_frame_remove_side_data(frame, AV_FRAME_DATA_DISPLAYMATRIX);
+
     fd = frame_data(frame);
     if (!fd)
         return AVERROR(ENOMEM);