[FFmpeg-cvslog] ffmpeg: take into account image flipping in the display matrix
James Almer
git at videolan.org
Thu Sep 16 19:40:49 EEST 2021
ffmpeg | branch: master | James Almer <jamrial at gmail.com> | Wed Sep 8 15:34:26 2021 -0300| [42fce6fffe2010a0d5eab454aa04813995f4222f] | committer: James Almer
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 at gmail.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=42fce6fffe2010a0d5eab454aa04813995f4222f
---
fftools/ffmpeg_filter.c | 26 ++++++++++++++++++++++----
1 file 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;
More information about the ffmpeg-cvslog
mailing list