diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2015-05-03 23:53:32 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2015-05-04 00:14:36 +0200 |
commit | 800df6a849c81ee74ad770e4551327aa2159336c (patch) | |
tree | 2b40250a2e2aada3276906b531433e4e214db457 | |
parent | 4351c288b9841d02a55e7b836796d7da6d19cac8 (diff) | |
download | ffmpeg-800df6a849c81ee74ad770e4551327aa2159336c.tar.gz |
ffmpeg_filter: use get_rotation()
This unifies the rotation extraction code between ffplay and ffmpeg
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r-- | ffmpeg_filter.c | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/ffmpeg_filter.c b/ffmpeg_filter.c index 6a891d3d10..0be49bea87 100644 --- a/ffmpeg_filter.c +++ b/ffmpeg_filter.c @@ -700,23 +700,24 @@ static int configure_input_video_filter(FilterGraph *fg, InputFilter *ifilter, last_filter = ifilter->filter; if (ist->autorotate) { - uint8_t* displaymatrix = av_stream_get_side_data(ist->st, - AV_PKT_DATA_DISPLAYMATRIX, NULL); - if (displaymatrix) { - double rot = av_display_rotation_get((int32_t*) displaymatrix); - if (rot < -135 || rot > 135) { - ret = insert_filter(&last_filter, &pad_idx, "vflip", NULL); - if (ret < 0) - return ret; - ret = insert_filter(&last_filter, &pad_idx, "hflip", NULL); - } else if (rot < -45) { - ret = insert_filter(&last_filter, &pad_idx, "transpose", "dir=clock"); - } else if (rot > 45) { - ret = insert_filter(&last_filter, &pad_idx, "transpose", "dir=cclock"); - } + double theta = get_rotation(ist->st); + + if (fabs(theta - 90) < 1.0) { + 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); + } else if (fabs(theta - 270) < 1.0) { + 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); } + if (ret < 0) + return ret; } if (ist->framerate.num) { |