On Tue, 15 Apr 2014 05:16:29 +0200, Vittorio Giovara 
<[email protected]> wrote:
> ---
>  libavcodec/h264.c     | 17 +++++++++++++++++
>  libavcodec/h264.h     |  7 +++++++
>  libavcodec/h264_sei.c | 22 ++++++++++++++++++++++
>  3 files changed, 46 insertions(+)
> 
> diff --git a/libavcodec/h264.c b/libavcodec/h264.c
> index c4ce278..fdb2487 100644
> --- a/libavcodec/h264.c
> +++ b/libavcodec/h264.c
> @@ -26,6 +26,7 @@
>   */
>  
>  #include "libavutil/avassert.h"
> +#include "libavutil/display.h"
>  #include "libavutil/imgutils.h"
>  #include "libavutil/stereo3d.h"
>  #include "libavutil/timer.h"
> @@ -822,6 +823,22 @@ static void decode_postinit(H264Context *h, int 
> setup_finished)
>              stereo->flags = AV_STEREO3D_FLAG_INVERT;
>      }
>  
> +    if (h->sei_display_orientation_present && h->sei_anticlockwise_rotation) 
> {
> +        double angle = h->sei_anticlockwise_rotation * 360 / (1 << 16);
> +        AVFrameSideData *rotation = av_frame_new_side_data(&cur->f,
> +                                                           
> AV_FRAME_DATA_DISPLAYMATRIX,
> +                                                           sizeof(int32_t) * 
> 3 * 3);
> +        uint8_t *display_matrix = av_display_angle_to_matrix(angle);
> +
> +        if (!rotation || !display_matrix) {
> +            av_free(rotation);
> +            av_free(display_matrix);
> +            return;
> +        }
> +        memcpy(rotation->data, display_matrix, sizeof(int32_t) * 3 * 3);
> +        av_free(display_matrix);
> +    }
> +
>      // FIXME do something with unavailable reference frames
>  
>      /* Sort B-frames into display order */
> diff --git a/libavcodec/h264.h b/libavcodec/h264.h
> index e259d0d..a8ea191 100644
> --- a/libavcodec/h264.h
> +++ b/libavcodec/h264.h
> @@ -131,6 +131,7 @@ typedef enum {
>      SEI_TYPE_USER_DATA_UNREGISTERED = 5,   ///< unregistered user data
>      SEI_TYPE_RECOVERY_POINT         = 6,   ///< recovery point (frame # to 
> decoder sync)
>      SEI_TYPE_FRAME_PACKING          = 45,  ///< frame packing arrangement
> +    SEI_TYPE_DISPLAY_ORIENTATION    = 47,  ///< display orientation
>  } SEI_Type;
>  
>  /**
> @@ -633,6 +634,12 @@ typedef struct H264Context {
>      int quincunx_subsampling;
>  
>      /**
> +     * display orientation SEI message
> +     */
> +    int sei_display_orientation_present;
> +    int sei_anticlockwise_rotation;
> +
> +    /**
>       * Bit set of clock types for fields/frames in picture timing SEI 
> message.
>       * For each found ct_type, appropriate bit is set (e.g., bit 1 for
>       * interlaced).
> diff --git a/libavcodec/h264_sei.c b/libavcodec/h264_sei.c
> index 6fca2c3..16fc4e7 100644
> --- a/libavcodec/h264_sei.c
> +++ b/libavcodec/h264_sei.c
> @@ -41,6 +41,7 @@ void ff_h264_reset_sei(H264Context *h)
>      h->sei_cpb_removal_delay        = -1;
>      h->sei_buffering_period_present =  0;
>      h->sei_frame_packing_present    =  0;
> +    h->sei_display_orientation_present = 0;
>  }
>  
>  static int decode_picture_timing(H264Context *h)
> @@ -199,6 +200,22 @@ static int decode_frame_packing_arrangement(H264Context 
> *h)
>      return 0;
>  }
>  
> +static int decode_display_orientation(H264Context *h)
> +{
> +    h->sei_display_orientation_present = !get_bits1(&h->gb);
> +
> +    if (h->sei_display_orientation_present) {
> +        skip_bits1(&h->gb);     // hor_flip
> +        skip_bits1(&h->gb);     // ver_flip

Why are you skipping those?

-- 
Anton Khirnov
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to