On 29/04/15 21:44, Martin Storsjö wrote:
> This is enabled by default, but can be disbled via the -noautorotate
> option.
>
> Based on a patch by Clément Bœsch.
> ---
> avplay.c | 24 ++++++++++++++++++++++++
> configure | 2 +-
> doc/avplay.texi | 2 ++
> 3 files changed, 27 insertions(+), 1 deletion(-)
>
> diff --git a/avplay.c b/avplay.c
> index 54708e2..b1876b8 100644
> --- a/avplay.c
> +++ b/avplay.c
> @@ -27,6 +27,7 @@
>
> #include "libavutil/avstring.h"
> #include "libavutil/colorspace.h"
> +#include "libavutil/display.h"
> #include "libavutil/mathematics.h"
> #include "libavutil/pixdesc.h"
> #include "libavutil/imgutils.h"
> @@ -265,6 +266,7 @@ static int rdftspeed = 20;
> #if CONFIG_AVFILTER
> static char *vfilters = NULL;
> #endif
> +static int autorotate = 1;
>
> /* current context */
> static int is_full_screen;
> @@ -1548,6 +1550,27 @@ static int configure_video_filters(AVFilterGraph
> *graph, VideoState *is, const c
>
> INSERT_FILT("format", "yuv420p");
>
> + if (autorotate) {
> + double rot = 0;
> + int i;
> + for (i = 0; i < is->video_st->nb_side_data; i++) {
> + const AVPacketSideData* sd = &is->video_st->side_data[i];
> + switch (sd->type) {
> + case AV_PKT_DATA_DISPLAYMATRIX:
> + rot = av_display_rotation_get((int32_t *) sd->data);
> + break;
> + }
> + }
> + if (rot < -135 || rot > 135) {
> + INSERT_FILT("vflip", NULL);
> + INSERT_FILT("hflip", NULL);
> + } else if (rot < -45) {
> + INSERT_FILT("transpose", "dir=clock");
> + } else if (rot > 45) {
> + INSERT_FILT("transpose", "dir=cclock");
> + }
> + }
> +
I see why you used a macro and not a function. Fine for me.
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel