[Bug 215743] New: Endianness bug loading 16 bits raw images

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

[Bug 215743] New: Endianness bug loading 16 bits raw images

pochini
https://bugs.kde.org/show_bug.cgi?id=215743

           Summary: Endianness bug loading 16 bits raw images
           Product: digikam
           Version: 1.0.0-beta6
          Platform: Compiled Sources
        OS/Version: Linux
            Status: UNCONFIRMED
          Severity: normal
          Priority: NOR
         Component: general
        AssignedTo: [hidden email]
        ReportedBy: [hidden email]


Version:           1.0.0-beta6 (using KDE 4.3.3)
Compiler:          gcc (GCC) 4.1.2 (Gentoo 4.1.2 p1.0.2)  powerpc
OS:                Linux
Installed from:    Compiled From Sources

On big-endian systems digikam does not load 16 bits raw files correctly. The
following simple patch fixes the bug (it breaks little-endian archs), but I'm
not sure if the bug is here or if libkdcraw needs a fix instead.


--- digikam-1.0.0-beta6/libs/dimg/loaders/rawloader.cpp__orig   2009-11-22
19:49:05.000000000 +0100
+++ digikam-1.0.0-beta6/libs/dimg/loaders/rawloader.cpp 2009-11-22
21:37:29.000000000 +0100
@@ -182,9 +182,9 @@ bool RAWLoader::loadedFromDcraw(QByteArr
                 dst[1] = (unsigned short)((src[2]*256 + src[3]) * fac);    
// Green
                 dst[2] = (unsigned short)((src[0]*256 + src[1]) * fac);    
// Red
 #else
-                dst[0] = (unsigned short)((src[5]*256 + src[4]) * fac);    
// Blue
-                dst[1] = (unsigned short)((src[3]*256 + src[2]) * fac);    
// Green
-                dst[2] = (unsigned short)((src[1]*256 + src[0]) * fac);    
// Red
+                dst[0] = (unsigned short)((src[4]*256 + src[5]) * fac);    
// Blue
+                dst[1] = (unsigned short)((src[2]*256 + src[3]) * fac);    
// Green
+                dst[2] = (unsigned short)((src[0]*256 + src[1]) * fac);    
// Blue
 #endif
                 dst[3] = 0xFFFF;

--
Configure bugmail: https://bugs.kde.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
_______________________________________________
Digikam-devel mailing list
[hidden email]
https://mail.kde.org/mailman/listinfo/digikam-devel
Reply | Threaded
Open this post in threaded view
|

[Bug 215743] Endianness bug loading 16 bits raw images

Gilles Caulier-4
https://bugs.kde.org/show_bug.cgi?id=215743





--- Comment #1 from Gilles Caulier <caulier gilles gmail com>  2009-11-22 22:39:24 ---
Yes, it's libkdcraw as well...

Gilles Caulier

--
Configure bugmail: https://bugs.kde.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
_______________________________________________
Digikam-devel mailing list
[hidden email]
https://mail.kde.org/mailman/listinfo/digikam-devel
Reply | Threaded
Open this post in threaded view
|

[Bug 215743] Endianness bug loading 16 bits raw images

Gilles Caulier-4
In reply to this post by pochini
https://bugs.kde.org/show_bug.cgi?id=215743





--- Comment #2 from Gilles Caulier <caulier gilles gmail com>  2009-11-22 22:41:39 ---
probably in this loop:

http://lxr.kde.org/source/KDE/kdegraphics/libs/libkdcraw/libkdcraw/kdcraw.cpp#323

--
Configure bugmail: https://bugs.kde.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
_______________________________________________
Digikam-devel mailing list
[hidden email]
https://mail.kde.org/mailman/listinfo/digikam-devel
Reply | Threaded
Open this post in threaded view
|

[Bug 215743] Endianness bug loading 16 bits raw images

Gilles Caulier-4
In reply to this post by pochini
https://bugs.kde.org/show_bug.cgi?id=215743


Gilles Caulier <[hidden email]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |[hidden email]
          Component|general                     |RAW files management




--
Configure bugmail: https://bugs.kde.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
_______________________________________________
Digikam-devel mailing list
[hidden email]
https://mail.kde.org/mailman/listinfo/digikam-devel
Reply | Threaded
Open this post in threaded view
|

[Bug 215743] Endianness bug loading 16 bits raw images

pochini
In reply to this post by pochini
https://bugs.kde.org/show_bug.cgi?id=215743


[hidden email] changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |[hidden email]




--- Comment #3 from  <pochini shiny it>  2009-11-23 23:53:23 ---
Thanks for the link.
Uhm... no, digikam does not use KDcraw::extractRAWData(). It uses
KDcraw::loadFromDcraw() instead, which then calls dcraw_make_mem_image()
(http://lxr.kde.org/source/KDE/kdegraphics/libs/libkdcraw/libkdcraw/kdcraw.cpp#679).
LibRaw docs do not mention the format of the data, but in
LibRaw-0.8.4/samples/mem_image.cpp there is a comment that says: "data in
img->data is not converted to network byte order. So, we should swap values on
some architectures for dcraw compatibility".

I think we should fix digikam. If we change libkdcraw we may break some other
apps which already convert the data.

--
Configure bugmail: https://bugs.kde.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
_______________________________________________
Digikam-devel mailing list
[hidden email]
https://mail.kde.org/mailman/listinfo/digikam-devel
Reply | Threaded
Open this post in threaded view
|

[Bug 215743] Endianness bug loading 16 bits raw images

pochini
In reply to this post by pochini
https://bugs.kde.org/show_bug.cgi?id=215743





--- Comment #4 from  <pochini shiny it>  2009-11-24 22:19:34 ---
I propose another patch that fixes the bug and does not break anything, except,
perhaps, big-endian machines with KDCRAW_VERSION<0x000400 (I didn't test).
Little-endian archs are not affected.


--- digikam-1.0.0-beta6/libs/dimg/loaders/rawloader.cpp__orig   2009-11-24
21:51:58.000000000 +0100
+++ digikam-1.0.0-beta6/libs/dimg/loaders/rawloader.cpp 2009-11-24
22:03:02.000000000 +0100
@@ -177,7 +177,7 @@ bool RAWLoader::loadedFromDcraw(QByteArr

             for (int w = 0; w < width; ++w)
             {
-#if KDCRAW_VERSION < 0x000400
+#if (KDCRAW_VERSION < 0x000400) ^ (Q_BYTE_ORDER == Q_BIG_ENDIAN)
                 dst[0] = (unsigned short)((src[4]*256 + src[5]) * fac);    
// Blue
                 dst[1] = (unsigned short)((src[2]*256 + src[3]) * fac);    
// Green
                 dst[2] = (unsigned short)((src[0]*256 + src[1]) * fac);    
// Red

--
Configure bugmail: https://bugs.kde.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
_______________________________________________
Digikam-devel mailing list
[hidden email]
https://mail.kde.org/mailman/listinfo/digikam-devel
Reply | Threaded
Open this post in threaded view
|

[Bug 215743] Endianness bug loading 16 bits raw images

Marcel Wiesweg
In reply to this post by pochini
https://bugs.kde.org/show_bug.cgi?id=215743


Marcel Wiesweg <[hidden email]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |FIXED




--- Comment #5 from Marcel Wiesweg <marcel wiesweg gmx de>  2009-12-20 16:11:06 ---
SVN commit 1064293 by mwiesweg:

Fix 16bit raw loading on big endian.
Patch from [hidden email] slightly modified.

BUG: 215743

 M  +2 -1      NEWS  
 M  +18 -9     libs/dimg/loaders/rawloader.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1064293

--
Configure bugmail: https://bugs.kde.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
_______________________________________________
Digikam-devel mailing list
[hidden email]
https://mail.kde.org/mailman/listinfo/digikam-devel
Reply | Threaded
Open this post in threaded view
|

[Bug 215743] Endianness bug loading 16 bits raw images

Gilles Caulier-4
In reply to this post by pochini
https://bugs.kde.org/show_bug.cgi?id=215743


Gilles Caulier <[hidden email]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Version|1.0.0-beta6                 |1.0.0




--
Configure bugmail: https://bugs.kde.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
_______________________________________________
Digikam-devel mailing list
[hidden email]
https://mail.kde.org/mailman/listinfo/digikam-devel
Reply | Threaded
Open this post in threaded view
|

[digikam] [Bug 215743] Endianness bug loading 16 bits raw images

bugzilla_noreply
In reply to this post by pochini
https://bugs.kde.org/show_bug.cgi?id=215743

[hidden email] changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|Workflow                    |FilesIO-RAW

--
You are receiving this mail because:
You are the assignee for the bug.