[vlc-devel] [PATCH] Automatically orient JPEG image based on orientation flag, if set

Jean-Baptiste Kempf jb at videolan.org
Mon Apr 18 11:49:59 CEST 2016


I am very sorry, but I cannot apply this patch. It is corrupted for me
everytime, because of wrapping and line endings.

On 18 Apr, Wayne McDougall wrote :
> Update patch to
> a) reflect correction to ORIENT_FROM_EXIF
> b) avoid unnecessary call to ORIENT_FROM_EXIF when normal orientation or no
> orientation tag (most common cases)
> 
> [PATCH] Automatically orient JPEG images using embedded orientation tag, if
> present
> 
> ---
>  modules/codec/jpeg.c | 242
> ++++++++++++++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 241 insertions(+), 1 deletion(-)
> 
> diff --git a/modules/codec/jpeg.c b/modules/codec/jpeg.c
> index fdb91c7..1e275cd 100644
> --- a/modules/codec/jpeg.c
> +++ b/modules/codec/jpeg.c
> @@ -1,7 +1,7 @@
>  /*****************************************************************************
>   * jpeg.c: jpeg decoder module making use of libjpeg.
> 
> *****************************************************************************
> - * Copyright (C) 2013-2014 VLC authors and VideoLAN
> + * Copyright (C) 2013-2014,2016 VLC authors and VideoLAN
>   *
>   * Authors: Maxim Bublis <b at codemonkey.ru>
>   *
> @@ -50,6 +50,22 @@
>  #define ENC_QUALITY_LONGTEXT N_("Quality level " \
>      "for encoding (this can enlarge or reduce output image size).")
> 
> +#define DEC_CFG_PREFIX "jpeg-"
> +#define DEC_AUTOORIENT_TEXT N_( "Automatic Orientation" )
> +#define DEC_AUTOORIENT_LONGTEXT N_( "Automatic rotation based on EXIF
> orientation tag." )

"Automatic Orientation using EXIF tag" should be enough for both long
and short.

> +#define G_LITTLE_ENDIAN     1234
> +#define G_BIG_ENDIAN        4321
> +
> +#define EXIF_JPEG_MARKER    0xE1
> +#define EXIF_IDENT_STRING   "Exif\000\000"
> 
>  /*
>   * jpeg common descriptor
> @@ -110,6 +126,13 @@ vlc_module_begin()
>      set_capability("decoder", 1000)
>      set_callbacks(OpenDecoder, CloseDecoder)
>      add_shortcut("jpeg")
> +    /*
> +     * Some JPEG get transformed to a normal orientation without resetting
> +     * embedded orientation tag to reflect that.
> +     * Allow disabling of autoorientation in case we have to work with
> such images.
> +    */
> +    add_bool( DEC_CFG_PREFIX "autoorient", true,
> +              DEC_AUTOORIENT_TEXT, DEC_AUTOORIENT_LONGTEXT, true )
> 
>      /* encoder submodule */
>      add_submodule()
> @@ -181,6 +204,201 @@ static int OpenDecoder(vlc_object_t *p_this)
>      return VLC_SUCCESS;
>  }
> 
> +/* jpeg_GetOrientation function based on code from GdkPixbuf library -
> JPEG image loader
> + *
> http://src.gnu-darwin.org/ports/x11-toolkits/gtk20/work/gtk+-2.12.3/gdk-pixbuf/io-jpeg.c
> + *
> + * Copyright (C) 1999 Michael Zucchi
> + * Copyright (C) 1999 The Free Software Foundation

You should mention the license (LGPL)

> @@ -192,6 +410,9 @@ static picture_t *DecodeBlock(decoder_t *p_dec, block_t
> **pp_block)
> 
>      JSAMPARRAY p_row_pointers = NULL;
> 
> +    bool b_autoorient;
> +    int i_otag;

define i_otag in the scope where you do need it.

The rest starts looking really good... (mention it in NEWS?)

With my kindest regards,

-- 
Jean-Baptiste Kempf
http://www.jbkempf.com/ - +33 672 704 734
Sent from my Electronic Device


More information about the vlc-devel mailing list