[FFmpeg-devel] [PATCH v1] fftools/ffmpeg: Add support for per frame rotation and flip

Jun Li junli1026 at gmail.com
Wed May 15 08:40:22 EEST 2019


On Mon, May 13, 2019 at 2:58 AM Michael Niedermayer <michael at niedermayer.cc>
wrote:

> On Sat, May 11, 2019 at 10:57:01PM -0700, Jun Li wrote:
> > On Sat, May 11, 2019 at 10:47 PM Jun Li <junli1026 at gmail.com> wrote:
> >
> > > Fix #6945
> > > Current implementaion for autorotate works fine for stream
> > > level rotataion but no support for frame level operation
> > > and frame flip. This patch is for adding flip support and
> > > per frame operations.
> > > ---
> > >  fftools/cmdutils.c        |  9 ++---
> > >  fftools/cmdutils.h        |  2 +-
> > >  fftools/ffmpeg.c          | 21 +++++++++-
> > >  fftools/ffmpeg.h          |  2 +
> > >  fftools/ffmpeg_filter.c   | 81 ++++++++++++++++++++++++++++++++++++---
> > >  fftools/ffplay.c          | 28 +++++++++++---
> > >  libavutil/display.c       | 14 +++++++
> > >  libavutil/display.h       | 14 +++++++
> > >  libavutil/tests/display.c |  8 ++++
> > >  tests/ref/fate/display    |  4 ++
> > >  10 files changed, 166 insertions(+), 17 deletions(-)
> [...]
>
> > > \ No newline at end of file
>
> > > diff --git a/libavutil/display.h b/libavutil/display.h
> > > index 515adad795..23d71a0bc5 100644
> > > --- a/libavutil/display.h
> > > +++ b/libavutil/display.h
> > > @@ -106,6 +106,20 @@ void av_display_rotation_set(int32_t matrix[9],
> > > double angle);
> > >   */
> > >  void av_display_matrix_flip(int32_t matrix[9], int hflip, int vflip);
> > >
> > > +/**
> > > + * Extract the rotation component and hflip status of the
> transformation
> > > matrix.
> > > + *
> > > + * @param matrix the transformation matrix
> > > + * @param hflip wille be set to 1 if the matrix need horizontal
> flipped
> > > + * @return the angle (in degrees) by which the transformation rotates
> the
> > > frame
> > > + *         counterclockwise. The angle will be in range [-180.0,
> 180.0],
> > > + *         or NaN if the matrix is singular.
> > > + *
> > > + * @note floating point numbers are inherently inexact, so callers are
> > > + *       recommended to round the return value to nearest integer
> before
> > > use.
> > > + */
> > > +double av_display_rotation_hflip_get(const int32_t matrix[9], int*
> hflip);
> > > +
> > >  /**
> > >   * @}
> > >   * @}
> > > diff --git a/libavutil/tests/display.c b/libavutil/tests/display.c
> > > index 893ebb5543..65a0971e7b 100644
> > > --- a/libavutil/tests/display.c
> > > +++ b/libavutil/tests/display.c
> > > @@ -35,6 +35,8 @@ static void print_matrix(int32_t matrix[9])
> > >  int main(void)
> > >  {
> > >      int32_t matrix[9];
> > > +    int hflip = 0;
> > > +    double degree;
> > >
> > >      // Set the matrix to 90 degrees
> > >      av_display_rotation_set(matrix, 90);
> > > @@ -56,6 +58,12 @@ int main(void)
> > >      print_matrix(matrix);
> > >      printf("degrees: %f\n", av_display_rotation_get(matrix));
> > >
> > > +    // flip vertical
> > > +    av_display_matrix_flip(matrix, 0, 1);
> > > +    print_matrix(matrix);
> > > +    degree = av_display_rotation_hflip_get(matrix, &hflip);
> > > +    printf("degrees: %f, hflip: %i\n", degree, hflip);
> > > +
> > >      return 0;
> > >
> > >  }
>
> [...]
>
> > This change is to address the feedback of last patch using 1st frame's
> > orientation as stream rotation.
> > Thanks again for review. I added the support for per frame rotation.
> >
> > (I know it involves too many file changes and not easy to read. Sorry
> about
> > that I tried to
> >  separate them but failed since due to some dependencies).
>
> The libavutil changes should be in a seperate patch and need a version
> and APIChanges update
>

Thanks Michael for the review. I updated the version to address the
feedback:
https://patchwork.ffmpeg.org/patch/13120/
https://patchwork.ffmpeg.org/patch/13119/
Thanks!

-Jun


> [...]
>
> --
> Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> If a bugfix only changes things apparently unrelated to the bug with no
> further explanation, that is a good sign that the bugfix is wrong.
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".


More information about the ffmpeg-devel mailing list