From 3e5e0a8e26cfeec86d61a185301ff39b86dd21a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20C=C3=B4rte-Real?= Date: Sun, 24 Aug 2014 20:35:04 +0100 Subject: [PATCH 1/2] Expose metadata for rotation/scaling post-demosaic --- RawSpeed/RafDecoder.cpp | 13 ++++++++++--- RawSpeed/RawDecoder.cpp | 4 ++++ RawSpeed/RawImage.cpp | 6 ++++-- RawSpeed/RawImage.h | 10 +++++++++- 4 files changed, 27 insertions(+), 6 deletions(-) diff --git a/RawSpeed/RafDecoder.cpp b/RawSpeed/RafDecoder.cpp index 639375f..e0a8c1d 100644 --- a/RawSpeed/RafDecoder.cpp +++ b/RawSpeed/RafDecoder.cpp @@ -161,14 +161,21 @@ void RafDecoder::decodeMetaDataInternal(CameraMetaData *meta) { if (rotate && !this->uncorrectedRawValues) { // Calculate the 45 degree rotated size; uint32 rotatedsize; - if (alt_layout) + uint32 rotationPos; + if (alt_layout) { rotatedsize = new_size.y+new_size.x/2; - else + rotationPos = new_size.x/2 - 1; + } + else { rotatedsize = new_size.x+new_size.y/2; + rotationPos = new_size.x - 1; + } - iPoint2D final_size(rotatedsize, rotatedsize); + iPoint2D final_size(rotatedsize, rotatedsize-1); RawImage rotated = RawImage::create(final_size, TYPE_USHORT16, 1); rotated->clearArea(iRectangle2D(iPoint2D(0,0), rotated->dim)); + rotated->fujiRotationPos = rotationPos; + int dest_pitch = (int)rotated->pitch / 2; ushort16 *dst = (ushort16*)rotated->getData(0,0); diff --git a/RawSpeed/RawDecoder.cpp b/RawSpeed/RawDecoder.cpp index 32d3ebd..0d9d0e0 100644 --- a/RawSpeed/RawDecoder.cpp +++ b/RawSpeed/RawDecoder.cpp @@ -569,6 +569,10 @@ RawSpeed::RawImage RawDecoder::decodeRaw() { try { RawImage raw = decodeRawInternal(); + if(hints.find("pixel_aspect_ratio") != hints.end()) { + stringstream convert(hints.find("pixel_aspect_ratio")->second); + convert >> raw->pixelAspectRatio; + } if (interpolateBadPixels) raw->fixBadPixels(); return raw; diff --git a/RawSpeed/RawImage.cpp b/RawSpeed/RawImage.cpp index 3528217..b6f1119 100644 --- a/RawSpeed/RawImage.cpp +++ b/RawSpeed/RawImage.cpp @@ -41,7 +41,8 @@ RawImageData::RawImageData(void): pthread_mutex_init(&errMutex, NULL); pthread_mutex_init(&mBadPixelMutex, NULL); mDitherScale = TRUE; - fujiWidth = 0; + fujiRotationPos = 0; + pixelAspectRatio = 1; } RawImageData::RawImageData(iPoint2D _dim, uint32 _bpc, uint32 _cpp) : @@ -54,7 +55,8 @@ RawImageData::RawImageData(iPoint2D _dim, uint32 _bpc, uint32 _cpp) : isoSpeed = 0; mBadPixelMap = NULL; mDitherScale = TRUE; - fujiWidth = 0; + fujiRotationPos = 0; + pixelAspectRatio = 1; createData(); pthread_mutex_init(&mymutex, NULL); pthread_mutex_init(&errMutex, NULL); diff --git a/RawSpeed/RawImage.h b/RawSpeed/RawImage.h index b34e413..6756dff 100644 --- a/RawSpeed/RawImage.h +++ b/RawSpeed/RawImage.h @@ -97,7 +97,15 @@ class RawImageData uchar8 *mBadPixelMap; uint32 mBadPixelMapPitch; bool mDitherScale; // Should upscaling be done with dither to minimize banding? - uint32 fujiWidth; // Similar to dcraw. + + // How many pixels far down the left edge and far up the right edge the image + // corners are when the image is rotated 45 degrees in Fuji rotated sensors. + uint32 fujiRotationPos; + + // Aspect ratio of the pixels, usually 1 but some cameras need scaling + // <1 means the image needs to be stretched vertically, (0.5 means 2x) + // >1 means the image needs to be stretched horizontally (2 mean 2x) + double pixelAspectRatio; protected: RawImageType dataType; From e04c3c57c895ddb5a1d3cd5ce06e1f131e65af8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20C=C3=B4rte-Real?= Date: Sun, 24 Aug 2014 20:37:35 +0100 Subject: [PATCH 2/2] Enable the D1X and set the correct aspect ratio --- data/cameras.xml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/data/cameras.xml b/data/cameras.xml index df4b90e..ac65e71 100644 --- a/data/cameras.xml +++ b/data/cameras.xml @@ -950,7 +950,7 @@ - + BLUE GREEN @@ -959,6 +959,9 @@ + + +