Beep6581 / RawTherapee

A powerful cross-platform raw photo processing program
https://rawtherapee.com
GNU General Public License v3.0
2.91k stars 324 forks source link

Fix wrong borders for Canon EOS 80D mRaw files #4522

Open heckflosse opened 6 years ago

heckflosse commented 6 years ago

Canon EOS 80D mRaw files show a black border top and left

Here's a first experimental patch:

diff --git a/rtengine/dcraw.cc b/rtengine/dcraw.cc
index 05f1a32a2..3f3808564 100644
--- a/rtengine/dcraw.cc
+++ b/rtengine/dcraw.cc
@@ -9128,6 +9128,10 @@ void CLASS identify()
             dimensions.pop_back();
         }
     }
+    if (!strcmp(model,"EOS 80D")) {
+        left_margin = 28;
+        top_margin = 8;
+    }
     filters = 0;
     tiff_samples = colors = 3;
     load_raw = &CLASS canon_sraw_load_raw;
diff --git a/rtengine/rawimage.cc b/rtengine/rawimage.cc
index 1e8cb02ad..7deba0cb9 100644
--- a/rtengine/rawimage.cc
+++ b/rtengine/rawimage.cc
@@ -488,8 +488,13 @@ int RawImage::loadRaw (bool loadData, unsigned int imageNum, bool closeFile, Pro
             printf ("Loading %s %s image from %s...\n", make, model, filename.c_str());
         }

-        iheight = height;
-        iwidth  = width;
+        if(load_raw != &RawImage::canon_sraw_load_raw) {
+            iheight = height;
+            iwidth  = width;
+        } else {
+            iheight = raw_height;
+            iwidth  = raw_width;
+        }

         if (filters || colors == 1) {
             raw_image = (ushort *) calloc ((raw_height + 7) * raw_width, 2);
@@ -497,8 +502,13 @@ int RawImage::loadRaw (bool loadData, unsigned int imageNum, bool closeFile, Pro
         }

         // dcraw needs this global variable to hold pixel data
-        image = (dcrawImage_t)calloc (height * width * sizeof * image + meta_length, 1);
-        meta_data = (char *) (image + height * width);
+        if(load_raw != &RawImage::canon_sraw_load_raw) {
+            image = (dcrawImage_t)calloc (height * width * sizeof * image + meta_length, 1);
+            meta_data = (char *) (image + height * width);
+        } else {
+            image = (dcrawImage_t)calloc (raw_height * raw_width * sizeof * image + meta_length, 1);
+            meta_data = (char *) (image + raw_height * raw_width);
+        }

         if(!image) {
             return 200;
@@ -519,6 +529,10 @@ int RawImage::loadRaw (bool loadData, unsigned int imageNum, bool closeFile, Pro
         if (plistener) {
             plistener->setProgress(0.9 * progressRange);
         }
+        if(load_raw == &RawImage::canon_sraw_load_raw) {
+            width -= left_margin;
+            height -= top_margin;
+        }

         CameraConstantsStore* ccs = CameraConstantsStore::getInstance();
         CameraConst *cc = ccs->get(make, model);
Beep6581 commented 6 years ago

Changing milestone due to lack of testing and possibility of side-effects.

Beep6581 commented 5 years ago

@heckflosse as the 5.6 feature-freeze is in 2-4 weeks, ok to commit the patch to get more testing?

heckflosse commented 5 years ago

@Beep6581 Ok

Lawrence37 commented 3 years ago

Can this be committed for 5.9?

Thanatomanic commented 1 year ago

I tried to fix this by making use of our new option to have multiple crops per camera, but couldn't get it to work. Who wants to take a go at this?

Lawrence37 commented 1 year ago

The mRAW images are demosaiced. I'm guessing camconst raw_crops are not used for such images.