Recent comments

Reply to: Getting SIG_SEGV in xtrans_decode_block (libraw_fuji_compressed.cpp)   3 hours 27 min ago

Is there any way to get exact code point that fails with exception? maybe coredump or so?

Reply to: Getting SIG_SEGV in xtrans_decode_block (libraw_fuji_compressed.cpp)   6 hours 47 min ago

Hi Alex,

yes, it's the line, I put it behind the bracket:

{__android_log_print(ANDROID_LOG_INFO,"libraw","decode_block %d %d %d",g_even_pos,g_odd_pos,line_width);
...

This is the output I see:

10-23 17:45:33.390 25527-25749/com.tssystems.photomate3 I/libraw: libraw_unpack /storage/6CE4-CA17/raw/raf/DSCF3128.RAF
10-23 17:45:33.391 25527-25749/com.tssystems.photomate3 I/libraw: decode_block 0 1 512
10-23 17:45:33.391 25527-25749/com.tssystems.photomate3 I/libraw: decode_block 2 1 512
10-23 17:45:33.391 25527-25749/com.tssystems.photomate3 I/libraw: decode_block 4 1 512
10-23 17:45:33.391 25527-25749/com.tssystems.photomate3 I/libraw: decode_block 6 1 512
10-23 17:45:33.391 25527-25749/com.tssystems.photomate3 I/libraw: decode_block 8 1 512
10-23 17:45:33.391 25527-25749/com.tssystems.photomate3 I/libraw: decode_block 10 3 512
10-23 17:45:33.391 25527-25749/com.tssystems.photomate3 I/libraw: decode_block 12 5 512
10-23 17:45:33.391 25527-25749/com.tssystems.photomate3 I/libraw: decode_block 14 7 512
10-23 17:45:33.391 25527-25749/com.tssystems.photomate3 I/libraw: decode_block 16 9 512
10-23 17:45:33.391 25527-25749/com.tssystems.photomate3 I/libraw: decode_block 18 11 512
10-23 17:45:33.391 25527-25749/com.tssystems.photomate3 I/libraw: decode_block 20 13 512
10-23 17:45:33.391 25527-25749/com.tssystems.photomate3 I/libraw: decode_block 22 15 512
10-23 17:45:33.638 25773-25773/? A/DEBUG:     #00 pc 00000000000e3c8c  /data/app/com.tssystems.photomate3-2/lib/arm64/liblibraw.so
10-23 17:45:33.638 25773-25773/? A/DEBUG:     #01 pc 00000000000e31ec  /data/app/com.tssystems.photomate3-2/lib/arm64/liblibraw.so (_ZN6LibRaw19xtrans_decode_blockEP21fuji_compressed_blockPK22fuji_compressed_paramsi+2344)
10-23 17:45:33.638 25773-25773/? A/DEBUG:     #02 pc 00000000000e4a30  /data/app/com.tssystems.photomate3-2/lib/arm64/liblibraw.so (_ZN6LibRaw17fuji_decode_stripEPK22fuji_compressed_paramsixj+284)
10-23 17:45:33.639 25773-25773/? A/DEBUG:     #03 pc 00000000000e515c  /data/app/com.tssystems.photomate3-2/lib/arm64/liblibraw.so (_ZN6LibRaw16fuji_decode_loopEPK22fuji_compressed_paramsiPxPj+120)
10-23 17:45:33.639 25773-25773/? A/DEBUG:     #04 pc 00000000000e5040  /data/app/com.tssystems.photomate3-2/lib/arm64/liblibraw.so (_ZN6LibRaw24fuji_compressed_load_rawEv+748)
10-23 17:45:33.639 25773-25773/? A/DEBUG:     #05 pc 00000000000efa84  /data/app/com.tssystems.photomate3-2/lib/arm64/liblibraw.so (_ZN6LibRaw6unpackEv+1944)
10-23 17:45:33.639 25773-25773/? A/DEBUG:     #06 pc 0000000000101b18  /data/app/com.tssystems.photomate3-2/lib/arm64/liblibraw.so (libraw_unpack+64)

I'm also a little irritated. I basically changed nothing and used the latest git (just from today). The only thing I changed for Android is to manually implement the "swab" function, but the implementation I use should be the same as the original from c. I could also see no calls on this function when the xtrans decoding is going on.

Regards
Torsten

Reply to: Getting SIG_SEGV in xtrans_decode_block (libraw_fuji_compressed.cpp)   7 hours 43 min ago

Run the file through valgrind (under FreeBSD), do not see any fuji-decoder problems (buffer overrun, etc), so no idea.

BTW, what exact version do you use (in my working version line 712 is { bracket after while operator)?

Reply to: Question about "use_camera_matrix"   1 week 2 days ago

1) If use_camera_matrix value suggests to use camera (raw metadata) color, than this color data is copied over rgb_cam array at open_file() stage.

2) If camera matrix is not available, embedded color data (from adobe_coeff() large array) is used.

Reply to: DNG and cam_xyz   1 week 2 days ago

Camera color matrix is parsed into imgdata.color.cmatrix

Sorry, wrong. If use_camera_matrix is set, so camera matrix should be used, camera color matrix is copied to rgb_cam

Reply to: LibRaw 0.18.5 (update: was 0.18.3 and 0.184)   1 week 3 days ago

C++ standard defines arrays as dense arrays, no spacing or extra rows padding.

Also, because xtrans/_abs arrays are defined in LibRaw class definition, and it is possible that we compile two source files with different -O.. switches, array layout should not changed from -O0 (no warning) to -O2 (warning issued).
So, I think this is gcc problem: it should either show this warning with any -O.. setting, or do not show it with -O2

Anyway, this loop was already changed to to 6-wide loops in master branch with commit message 'to make gcc happy' :)

Reply to: How to covert raw RGB to sRGB   1 week 3 days ago

You need to apply white balance (usually, before demosaic stage)

Reply to: LibRaw 0.18.5 (update: was 0.18.3 and 0.184)   3 weeks 9 hours ago

That is a very common optimization and is not likely to be the issue. The problem is usually found in the expression itself, commonly either the right-side array element is undefined or the result overflows the variable.

On the 6th iteration of that loop the result of this expression is undefined:

imgdata.idata.xtrans

 = imgdata.idata.xtrans_abs[c];  
Reply to: DNG and cam_xyz   3 weeks 3 days ago

Hi Alex,

Thanks for the quick reply!

Can you point me to a matrix that "libraw" will use to convert DNG file? (to XYZ) The "cam_xyz" contain all zeros, there should be some matrix being used.

Regards,

Mio

Reply to: LibRaw 0.18.5 (update: was 0.18.3 and 0.184)   3 weeks 3 days ago

what is wrong with

for(int c = 0; c < 36; c++) 

loop if both xtrans and xtrans_abs are [6][6] arrays, so xtrans[0][35] is equal to xtrans[5][5]?

Reply to: DNG and cam_xyz   3 weeks 3 days ago

"libraw" does not average/weight DNG color data

cmatrix is camera color data, it used according to use_camera_matrix value.

Reply to: LibRaw 0.18.5 (update: was 0.18.3 and 0.184)   3 weeks 4 days ago

gcc preprocessor does not count blank and comment lines, and I gave the wrong code section. sorry.

I pulled the rest of the warnings from the build log:

/tmp/portage/portage/media-libs/libraw-0.18.5/work/LibRaw-0.18.5/src/libraw_cxx.cpp: In member function ‘virtual int LibRaw::open_datastream(LibRaw_abstract_datastream*)’:

/tmp/portage/portage/media-libs/libraw-0.18.5/work/LibRaw-0.18.5/src/libraw_cxx.cpp:1784:64: warning: iteration 6 invokes undefined behavior [-Waggressive-loop-optimizations]

imgdata.idata.xtrans[0]

 = imgdata.idata.xtrans_abs[0][c];
                                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
 
 
/tmp/portage/portage/media-libs/libraw-0.18.5/work/LibRaw-0.18.5/src/libraw_cxx.cpp:1783:22: note: within this loop
 
     for(int c = 0; c < 36; c++)
                    ~~^~~~
 
So it appears the actual code section begins at line 1999:
 
 
    // XTrans Compressed?
    if (!imgdata.idata.dng_version && !strcasecmp(imgdata.idata.make, "Fujifilm") &&
        (load_raw == &LibRaw::unpacked_load_raw))
    {
      if (imgdata.sizes.raw_width * imgdata.sizes.raw_height * 2 != libraw_internal_data.unpacker_data.data_size)
      {
        if (imgdata.sizes.raw_width * imgdata.sizes.raw_height * 7 / 4 == libraw_internal_data.unpacker_data.data_size)
          load_raw = &LibRaw::fuji_14bit_load_raw;
        else
          parse_fuji_compressed_header();
      }
      if (imgdata.idata.filters == 9)
      {
        // Adjust top/left margins for X-Trans
        int newtm = imgdata.sizes.top_margin % 6 ? (imgdata.sizes.top_margin / 6 + 1) * 6 : imgdata.sizes.top_margin;
        int newlm = imgdata.sizes.left_margin % 6 ? (imgdata.sizes.left_margin / 6 + 1) * 6 : imgdata.sizes.left_margin;
        if (newtm != imgdata.sizes.top_margin || newlm != imgdata.sizes.left_margin)
        {
          imgdata.sizes.height -= (newtm - imgdata.sizes.top_margin);
          imgdata.sizes.top_margin = newtm;
          imgdata.sizes.width -= (newlm - imgdata.sizes.left_margin);
          imgdata.sizes.left_margin = newlm;
          for (int c1 = 0; c1 < 6; c1++)
            for (int c2 = 0; c2 < 6; c2++)
              imgdata.idata.xtrans[c1][c2] = imgdata.idata.xtrans_abs[c1][c2];
        }
      }
}
 
 
gcc optimizes the nested 6x6 loop to:   for(int c = 0; c < 36; c++)
 
on the 6th iteration of that loop the result of  imgdata.idata.xtrans[c] = imgdata.idata.xtrans_abs[c];  
is undefined. 
Reply to: LibRaw 0.18.5 (update: was 0.18.3 and 0.184)   3 weeks 5 days ago

what 'iteration 6' mean in this context?

Reply to: LibRaw 0.18.5 (update: was 0.18.3 and 0.184)   3 weeks 5 days ago

Hi, I'm getting the following warning from gcc-6.4.0 in libraw_cpp.cxx:

* /tmp/portage/portage/media-libs/libraw-0.18.5/work/LibRaw-0.18.5/src/libraw_cxx.cpp:1784:64: warning: iteration 6 invokes undefined behavior [-Waggressive-loop-optimizations]

CFLAGS="-O2 -march=native -ftree-vectorize -mprefer-avx128 -mvzeroupper -fstack-protector -ftree-loop-distribution -ftree-loop-distribute-patterns -pipe"

Code:

static inline void unpack28bytesto16x16ns(unsigned char *src, unsigned short *dest)
{
dest[0] = (src[3] << 6) | (src[2] >> 2);
dest[1] = ((src[2] & 0x3) << 12) | (src[1] << 4) | (src[0] >> 4);
dest[2] = (src[0] & 0xf) << 10 | (src[7] << 2) | (src[6] >> 6);
dest[3] = ((src[6] & 0x3f) << 8) | src[5];
dest[4] = (src[4] << 6) | (src[11] >> 2);
dest[5] = ((src[11] & 0x3) << 12) | (src[10] << 4) | (src[9] >> 4);
dest[6] = (src[9] & 0xf) << 10 | (src[8] << 2) | (src[15] >> 6);
dest[7] = ((src[15] & 0x3f) << 8) | src[14];
dest[8] = (src[13] << 6) | (src[12] >> 2);
dest[9] = ((src[12] & 0x3) << 12) | (src[19] << 4) | (src[18] >> 4);
dest[10] = (src[18] & 0xf) << 10 | (src[17] << 2) | (src[16] >> 6);
dest[11] = ((src[16] & 0x3f) << 8) | src[23]; ## line 1784
dest[12] = (src[22] << 6) | (src[21] >> 2);
dest[13] = ((src[21] & 0x3) << 12) | (src[20] << 4) | (src[27] >> 4);
dest[14] = (src[27] & 0xf) << 10 | (src[26] << 2) | (src[25] >> 6);
dest[15] = ((src[25] & 0x3f) << 8) | src[24];
}

Reply to: RAW to grayscale   4 weeks 1 day ago

use samples/unprocessed_raw.cpp as a starting point

Reply to: L* gamma   1 month 4 days ago

Thanks for the quick response.
I found the answer to my question. It's very simple. For L *, use gamm [0] = 1/3 and gamm [1] = 9.033.

With best wishes, Konstantin

Reply to: L* gamma   1 month 4 days ago

Output curve is used only on output phase (dcraw_make_mem_image or dcraw_ppm_tiff_writer)

So, you may modify source and replace calls to gamma_curve(...) by own output curve creation.

No direct way in LibRaw to do that, we'll consider to add some interface for user-defined curve in 0.19 release.

Reply to: What is the best way to decode X-Trans RAW?   1 month 1 week ago

all postprocessing is done at dcraw_process() step.

Unpack only unpacks (uncompress for compressed formats) raw data and stores it without any modification

Reply to: What is the best way to decode X-Trans RAW?   1 month 1 week ago

You mean demosaic the X-Trans CFA is done at the dcraw_process() step?

Reply to: What is the best way to decode X-Trans RAW?   1 month 1 week ago

unpack only unpacks raw data ('as is')
interpolation is performed on dcraw_process() step

To use bilinear set
half_size to 0
user_qual to 0

Reply to: What is the best way to decode X-Trans RAW?   1 month 1 week ago

So how do I specify bilinear filter?

When I execute unpack(), does it perform demosaic of the X-Trans CFA automatically?

Reply to: What is the best way to decode X-Trans RAW?   1 month 1 week ago

Use bilinear. It is fast enough (but not perfect too)

Reply to: What is the best way to decode X-Trans RAW?   1 month 1 week ago

Like the output of FastRawViewer?

Reply to: What is the best way to decode X-Trans RAW?   1 month 1 week ago

What is criteria for 'best'?

Reply to: How to compile LibRaw with RawSpeed?   1 month 1 week ago

Glad to hear.

Yes, LibRaw object is large

Pages