~ubuntu-branches/ubuntu/trusty/gdk-pixbuf/trusty

« back to all changes in this revision

Viewing changes to debian/patches/0001-Fix-parsing-of-JPEG-orientation-tag.patch

  • Committer: Package Import Robot
  • Author(s): Tormod Volden
  • Date: 2012-11-17 11:36:17 UTC
  • mfrom: (42.1.4 raring-proposed)
  • Revision ID: package-import@ubuntu.com-20121117113617-q2esgsrbxmm7v43z
Tags: 2.26.5-0ubuntu2
Fix regression from 2.26.4: EXIF orientation tag is ignored
LP: #1077186

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
From eb81375d6c3924d0f430cdc47be1a88483c47104 Mon Sep 17 00:00:00 2001
 
2
From: Tormod Volden <debian.tormod@gmail.com>
 
3
Date: Thu, 15 Nov 2012 21:17:29 +0100
 
4
Subject: [PATCH] Fix parsing of JPEG orientation tag
 
5
 
 
6
Parsing the orientation tag in big-endian file formats got broken in
 
7
commit 0179dfd as reported in https://bugs.launchpad.net/bugs/1077186
 
8
 
 
9
A short (16 bit) value like the orientation value occupies the two first
 
10
bytes of the 4-byte offset field, independently of endianness. The
 
11
commit changed the code from using de_get16() to de_get32 to read out
 
12
this value, which broke on big-endian (MM/Motorola) byte order JPEG file
 
13
formats. I believe little-endian files would still work as long as the
 
14
two last, unused bytes were zero.
 
15
 
 
16
From http://www.cipa.jp/english/hyoujunka/kikaku/pdf/DC-008-2010_E.pdf
 
17
 
 
18
"Value Offset
 
19
This tag records the offset from the start of the TIFF header to the
 
20
position where the value itself is recorded. In cases where the value
 
21
fits in 4 Bytes, the value itself is recorded. If the value is smaller
 
22
than 4 Bytes, the value is stored in the 4-Byte area starting from the
 
23
left, i.e., from the lower end of the byte offset area. For example, in
 
24
big endian format, if the type is SHORT and the value is 1, it is
 
25
recorded as 00010000.H."
 
26
 
 
27
Also avoid the confusing recycling of the "offset" variable, use a
 
28
better name for the second use and make it and its siblings
 
29
local to the block where they are used.
 
30
 
 
31
Signed-off-by: Tormod Volden <debian.tormod@gmail.com>
 
32
---
 
33
 gdk-pixbuf/io-jpeg.c |   14 ++++++--------
 
34
 1 file changed, 6 insertions(+), 8 deletions(-)
 
35
 
 
36
diff --git a/gdk-pixbuf/io-jpeg.c b/gdk-pixbuf/io-jpeg.c
 
37
index bcdf0bb..910158b 100644
 
38
--- a/gdk-pixbuf/io-jpeg.c
 
39
+++ b/gdk-pixbuf/io-jpeg.c
 
40
@@ -393,9 +393,6 @@ jpeg_parse_exif_app1 (JpegExifContext *context, jpeg_saved_marker_ptr marker)
 
41
        guint ret = FALSE;
 
42
        guint offset;
 
43
        guint tags;        /* number of tags in current ifd */
 
44
-       guint tag;
 
45
-       guint type;
 
46
-       guint count;
 
47
        guint endian = 0;       /* detected endian of data */
 
48
        const char leth[]  = {0x49, 0x49, 0x2a, 0x00};  // Little endian TIFF header
 
49
        const char beth[]  = {0x4d, 0x4d, 0x00, 0x2a};  // Big endian TIFF header
 
50
@@ -472,10 +469,11 @@ jpeg_parse_exif_app1 (JpegExifContext *context, jpeg_saved_marker_ptr marker)
 
51
 
 
52
        /* check through IFD0 for tags */
 
53
        while (tags--){
 
54
-               tag    = de_get16(&marker->data[i + 0], endian);
 
55
-               type   = de_get16(&marker->data[i + 2], endian);
 
56
-               count  = de_get32(&marker->data[i + 4], endian);
 
57
-               offset = de_get32(&marker->data[i + 8], endian);
 
58
+               guint tag   = de_get16(&marker->data[i + 0], endian);
 
59
+               guint type  = de_get16(&marker->data[i + 2], endian);
 
60
+               guint count = de_get32(&marker->data[i + 4], endian);
 
61
+               /* values of types small enough to fit are stored directly in the (first) bytes of the Value Offset field */
 
62
+               guint short_value = de_get16(&marker->data[i + 8], endian);
 
63
 
 
64
                /* orientation tag? */
 
65
                if (tag == 0x112){
 
66
@@ -485,7 +483,7 @@ jpeg_parse_exif_app1 (JpegExifContext *context, jpeg_saved_marker_ptr marker)
 
67
                                continue;
 
68
 
 
69
                        /* get the orientation value */
 
70
-                       context->orientation = offset <= 8 ? offset : 0;
 
71
+                       context->orientation = short_value <= 8 ? short_value : 0;
 
72
                }
 
73
                /* move the pointer to the next 12-byte tag field. */
 
74
                i = i + 12;
 
75
-- 
 
76
1.7.9.5
 
77