mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2024-12-22 07:20:45 +00:00
ffmpeg_filter: use get_rotation()
This unifies the rotation extraction code between ffplay and ffmpeg Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
parent
4351c288b9
commit
800df6a849
@ -700,24 +700,25 @@ 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;
|
||||
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);
|
||||
} 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");
|
||||
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) {
|
||||
AVFilterContext *setpts;
|
||||
|
Loading…
Reference in New Issue
Block a user