diff options
author | James Almer <jamrial@gmail.com> | 2021-09-08 15:34:26 -0300 |
---|---|---|
committer | James Almer <jamrial@gmail.com> | 2021-09-16 12:57:06 -0300 |
commit | 42fce6fffe2010a0d5eab454aa04813995f4222f (patch) | |
tree | cf73ee933ba44a069d4c5e72a1e1a4f36cfc5917 /fftools/ffmpeg_filter.c | |
parent | 535a835e5176a5f2d5e03776030bacbc3e19d604 (diff) | |
download | ffmpeg-42fce6fffe2010a0d5eab454aa04813995f4222f.tar.gz |
ffmpeg: take into account image flipping in the display matrix
This covers only standard rotations.
Fixes part of ticket #6945.
Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'fftools/ffmpeg_filter.c')
-rw-r--r-- | fftools/ffmpeg_filter.c | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c index a4c2de07da..da0d4faf54 100644 --- a/fftools/ffmpeg_filter.c +++ b/fftools/ffmpeg_filter.c @@ -765,18 +765,36 @@ static int configure_input_video_filter(FilterGraph *fg, InputFilter *ifilter, theta = get_rotation(displaymatrix); if (fabs(theta - 90) < 1.0) { + if (displaymatrix[3] > 0) { + ret = insert_filter(&last_filter, &pad_idx, "hflip", NULL); + if (ret < 0) + return ret; + } ret = insert_filter(&last_filter, &pad_idx, "transpose", "clock"); } else if (fabs(theta - 180) < 1.0) { - ret = insert_filter(&last_filter, &pad_idx, "hflip", NULL); - if (ret < 0) - return ret; - ret = insert_filter(&last_filter, &pad_idx, "vflip", NULL); + if (displaymatrix[0] < 0) { + ret = insert_filter(&last_filter, &pad_idx, "hflip", NULL); + if (ret < 0) + return ret; + } + if (displaymatrix[4] < 0) { + ret = insert_filter(&last_filter, &pad_idx, "vflip", NULL); + } } else if (fabs(theta - 270) < 1.0) { + if (displaymatrix[3] < 0) { + ret = insert_filter(&last_filter, &pad_idx, "hflip", NULL); + if (ret < 0) + return ret; + } ret = insert_filter(&last_filter, &pad_idx, "transpose", "cclock"); } else if (fabs(theta) > 1.0) { char rotate_buf[64]; snprintf(rotate_buf, sizeof(rotate_buf), "%f*PI/180", theta); ret = insert_filter(&last_filter, &pad_idx, "rotate", rotate_buf); + } else if (fabs(theta) < 1.0) { + if (displaymatrix && displaymatrix[4] < 0) { + ret = insert_filter(&last_filter, &pad_idx, "vflip", NULL); + } } if (ret < 0) return ret; |