[vlc-devel] [RFC] [PATCH 1/1] Add orientation to video format
Laurent Aimar
fenrir at elivagar.org
Sat Mar 17 19:59:38 CET 2012
Hi,
On Sat, Mar 17, 2012 at 04:06:29PM +0200, Rémi Denis-Courmont wrote:
> This is a proposal to reserve 3-bits from the video format to carry the
> picture orientation if known. Video outputs could use it to rotate the picture
> automatically if they can, with fallback to the transform filter.
Great,
> Most importantly, with the bits reserved, demuxers and codecs can set the
> data, even if it is not yet used.
I agree.
> diff --git a/include/vlc_es.h b/include/vlc_es.h
> index 21d7724..ba83968 100644
> --- a/include/vlc_es.h
> +++ b/include/vlc_es.h
> @@ -150,7 +150,8 @@ struct video_format_t
> unsigned int i_visible_width; /**< width of visible area */
> unsigned int i_visible_height; /**< height of visible area */
>
> - unsigned int i_bits_per_pixel; /**< number of bits per pixel */
> + uint8_t i_bits_per_pixel; /**< number of bits per pixel */
> + unsigned orientation:3; /**< picture orientation */
I honestly don't think the 3 bits optimisation is needed in the video format_t
structure (it is not allocated a lot). But if you think otherwise, I don't mind.
> +/** Values for video_format_t.orientation. */
> +enum video_orientation_t
> +{
> + ORIENT_TOP_LEFT = 0, /**< Top line represents top, left column left. */
> + ORIENT_TOP_RIGHT = 1,
> + ORIENT_BOTTOM_RIGHT = 2,
> + ORIENT_BOTTOM_LEFT = 3,
> + ORIENT_LEFT_TOP = 4,
> + ORIENT_RIGHT_TOP = 5,
> + ORIENT_RIGHT_BOTTOM = 6,
> + ORIENT_LEFT_BOTTOM = 7,
> +
> + ORIENT_NORMAL = ORIENT_TOP_LEFT, /**< Orientated normally */
> + ORIENT_90 = ORIENT_RIGHT_TOP, /**< Rotated 90 degrees anti-clockwise */
> + ORIENT_180 = ORIENT_BOTTOM_RIGHT, /**< Rotated 180 degrees */
> + ORIENT_270 = ORIENT_LEFT_BOTTOM, /**< Rotated 90 degrees clockwise */
> + ORIENT_HFLIP = ORIENT_TOP_RIGHT, /**< Flipped horizontally */
> + ORIENT_VFLIP = ORIENT_BOTTOM_LEFT, /**< Flipped vertically */
> +};
> +/** Convert VLC orientation to EXIF */
> +#define EXIF_ORIENT(orient) ((orient) + 1)
> +/** Convert EXIF orientation to VLC */
> +#define ORIENT_EXIF(exif) ((exif) - 1)
> +/** If the orientation is natural or mirrored */
> +#define ORIENT_MIRROR(orient) (((1 << (orient)) & 0x5A) != 0)
> +/** If the orientation swaps dimensions */
> +#define ORIENT_SWAP(orient) ((orient) >= 4)
I would prefer more expressive macros, something like:
EXIF_ORIENT -> EXIF_FROM_ORIENT
ORIENT_MIRROR -> IS_ORIENT_MIRROR
to make them self descriptive.
--
fenrir
More information about the vlc-devel
mailing list