Permalink
Browse files

XTrans Compressed support

1 parent 2d6fbb3 commit aeab4d8ea58f85050d1253bdc41f51baa79ffe65 @alextutubalin alextutubalin committed May 2, 2016
View
@@ -135,7 +135,7 @@ object/dcraw_common.o: internal/dcraw_common.cpp ${LR_INCLUDES}
object/dcraw_fileio.o: internal/dcraw_fileio.cpp ${LR_INCLUDES}
$(CXX) -c -DLIBRAW_NOTHREADS ${CFLAGS} ${LCMS_DEF} -o object/dcraw_fileio.o internal/dcraw_fileio.cpp
-object/libraw_cxx.o: src/libraw_cxx.cpp ${LR_INCLUDES} RawSpeed/rawspeed_xmldata.cpp
+object/libraw_cxx.o: src/libraw_cxx.cpp ${LR_INCLUDES} RawSpeed/rawspeed_xmldata.cpp src/libraw_xtrans_compressed.cpp
$(CXX) -c -DLIBRAW_NOTHREADS ${LCMS_DEF} ${CFLAGS} -o object/libraw_cxx.o src/libraw_cxx.cpp
object/libraw_datastream.o: src/libraw_datastream.cpp ${LR_INCLUDES}
@@ -160,7 +160,7 @@ object/dcraw_common_mt.o: internal/dcraw_common.cpp ${LR_INCLUDES}
object/dcraw_fileio_mt.o: internal/dcraw_fileio.cpp ${LR_INCLUDES}
$(CXX) -c -pthread ${LCMS_DEF} ${CFLAGS} -o object/dcraw_fileio_mt.o internal/dcraw_fileio.cpp
-object/libraw_cxx_mt.o: src/libraw_cxx.cpp ${LR_INCLUDES}
+object/libraw_cxx_mt.o: src/libraw_cxx.cpp ${LR_INCLUDES} src/libraw_xtrans_compressed.cpp
$(CXX) -c ${LCMS_DEF} -pthread ${CFLAGS} -o object/libraw_cxx_mt.o src/libraw_cxx.cpp
object/libraw_datastream_mt.o: src/libraw_datastream.cpp ${LR_INCLUDES}
View
@@ -105,7 +105,7 @@ object/dcraw_common.o: internal/dcraw_common.cpp
object/dcraw_fileio.o: internal/dcraw_fileio.cpp
g++ -c -DLIBRAW_NOTHREADS ${CFLAGS} -o object/dcraw_fileio.o internal/dcraw_fileio.cpp
-object/libraw_cxx.o: src/libraw_cxx.cpp RawSpeed/rawspeed_xmldata.cpp
+object/libraw_cxx.o: src/libraw_cxx.cpp RawSpeed/rawspeed_xmldata.cpp src/libraw_xtrans_compressed.cpp
g++ -c -DLIBRAW_NOTHREADS ${CFLAGS} -o object/libraw_cxx.o src/libraw_cxx.cpp
object/libraw_datastream.o: src/libraw_datastream.cpp
@@ -140,7 +140,7 @@ object/dcraw_common_mt.o: internal/dcraw_common.cpp
object/dcraw_fileio_mt.o: internal/dcraw_fileio.cpp
g++ -c -pthread ${CFLAGS} -o object/dcraw_fileio_mt.o internal/dcraw_fileio.cpp
-object/libraw_cxx_mt.o: src/libraw_cxx.cpp RawSpeed/rawspeed_xmldata.cpp
+object/libraw_cxx_mt.o: src/libraw_cxx.cpp RawSpeed/rawspeed_xmldata.cpp src/libraw_xtrans_compressed.cpp
g++ -c -pthread ${CFLAGS} -o object/libraw_cxx_mt.o src/libraw_cxx.cpp
object/libraw_datastream_mt.o: src/libraw_datastream.cpp
View
@@ -93,7 +93,7 @@ object/demosaic_packs.o: internal/demosaic_packs.cpp
object/dcraw_fileio.o: internal/dcraw_fileio.cpp
g++ -c ${LCMS_DEF} ${CFLAGS} -o object/dcraw_fileio.o internal/dcraw_fileio.cpp
-object/libraw_cxx.o: src/libraw_cxx.cpp
+object/libraw_cxx.o: src/libraw_cxx.cpp src/libraw_xtrans_compressed.cpp
g++ -c ${LCMS_DEF} ${CFLAGS} -o object/libraw_cxx.o src/libraw_cxx.cpp
object/libraw_datastream.o: src/libraw_datastream.cpp
View
@@ -98,7 +98,7 @@ object\dcraw_fileio.obj: internal\dcraw_fileio.cpp
object\demosaic_packs.obj: internal\demosaic_packs.cpp
$(CC) $(COPT) $(CFLAGS_DP2) $(CFLAGS_DP3) /DLIBRAW_BUILDLIB /Fo"object\\demosaic_packs.obj" /c internal\demosaic_packs.cpp
-object\libraw_cxx.obj: src\libraw_cxx.cpp
+object\libraw_cxx.obj: src\libraw_cxx.cpp src\libraw_xtrans_compressed.cpp
$(CC) $(COPT) /DLIBRAW_BUILDLIB /Fo"object\\libraw_cxx.obj" /c src\libraw_cxx.cpp
object\libraw_datastream.obj: src\libraw_datastream.cpp
@@ -122,7 +122,7 @@ object\dcraw_fileio_st.obj: internal\dcraw_fileio.cpp
object\demosaic_packs_st.obj: internal\demosaic_packs.cpp
$(CC) $(COPT) $(CFLAGS_DP2) $(CFLAGS_DP3) /DLIBRAW_NODLL /Fo"object\\demosaic_packs_st.obj" /c internal\demosaic_packs.cpp
-object\libraw_cxx_st.obj: src\libraw_cxx.cpp
+object\libraw_cxx_st.obj: src\libraw_cxx.cpp src\libraw_xtrans_compressed.cpp
$(CC) $(COPT) /DLIBRAW_NODLL /Fo"object\\libraw_cxx_st.obj" /c src\libraw_cxx.cpp
object\libraw_datastream_st.obj: src\libraw_datastream.cpp
@@ -30,7 +30,7 @@ it under the terms of the one of three licenses as you choose:
double wf_filter_energy (int r1_greenmode, int r1, int r2_greenmode, int r2);
-// inline functions
+/* inline functions */
ushort sget2 (uchar *s);
ushort sget2Rev(uchar *s);
void setCanonBodyFeatures (unsigned id);
@@ -56,7 +56,7 @@ it under the terms of the one of three licenses as you choose:
double getreal (int type);
void read_shorts (ushort *pixel, int count);
-// Canon P&S cameras
+/* Canon P&S cameras */
void canon_600_fixed_wb (int temp);
int canon_600_color (int ratio[2], int mar);
void canon_600_auto_wb();
@@ -260,6 +260,13 @@ void crw_init_tables (unsigned table, ushort *huff[2]);
#undef TS
+ void parse_xtrans_header();
+ void xtrans_compressed_load_raw();
+ void init_xtrans(struct xtrans_params* info);
+ void init_xtrans_block(struct xtrans_block* info, const struct xtrans_params *params, INT64 raw_offset, unsigned dsize);
+ void copy_line_to_xtrans(struct xtrans_block* info, int cur_line, int cur_block, int cur_block_width);
+ void xtrans_decode_block(struct xtrans_block* info, const struct xtrans_params * params, int cur_line);
+
// LibRaw demosaic packs functions
// AMaZe
int LinEqSolve(int, float*, float*, float*);
View
@@ -225,6 +225,10 @@ class DllDef LibRaw
virtual void lin_interpolate_loop(int code[16][16][32],int size);
virtual void scale_colors_loop(float scale_mul[4]);
+ // Fujifilm compressed decoder public interface (to make parallel decoder)
+ virtual void xtrans_decode_loop(const struct xtrans_params* common_info, int count, INT64* offsets, unsigned *sizes);
+ void xtrans_decode_strip(const struct xtrans_params* info_common, int cur_block, INT64 raw_offset, unsigned size);
+
int FCF(int row,int col) {
int rr,cc;
if (libraw_internal_data.unpacker_data.fuji_layout) {
@@ -87,8 +87,9 @@ class DllDef LibRaw_abstract_datastream
virtual int eof() = 0;
virtual void * make_jas_stream() = 0;
virtual int jpeg_src(void *) { return -1; }
- /* Make buffer from current offset */
-
+ /* reimplement in subclass to use parallel access in xtrans_load_raw() if OpenMP is not used */
+ virtual int lock() { return 1;} /* success */
+ virtual void unlock(){}
/* subfile parsing not implemented in base class */
virtual const char* fname(){ return NULL;};
#if defined(_WIN32) && !defined(__MINGW32__) && defined(_MSC_VER) && (_MSC_VER > 1310)
@@ -98,7 +99,6 @@ class DllDef LibRaw_abstract_datastream
virtual int subfile_open(const char*) { return -1;}
virtual void subfile_close() { }
-
virtual int tempbuffer_open(void*, size_t);
virtual void tempbuffer_close();
@@ -141,10 +141,9 @@ typedef struct
int hasselblad_parser_flag;
long long posRAFData;
unsigned lenRAFData;
+ int fuji_total_lines, fuji_total_blocks, fuji_block_width, fuji_bits;
}unpacker_data_t;
-
-
typedef struct
{
internal_data_t internal_data;
View
@@ -207,44 +207,44 @@ typedef struct
int CanonColorDataSubVer;
int SpecularWhiteLevel;
int AverageBlackLevel;
-// metering
+/* metering */
short MeteringMode;
short SpotMeteringMode;
uchar FlashMeteringMode;
short FlashExposureLock;
short ExposureMode;
short AESetting;
uchar HighlightTonePriority;
-// stabilization
+/* stabilization */
short ImageStabilization;
-// focus
+/* focus */
short FocusMode;
short AFPoint;
short FocusContinuous;
short AFPointsInFocus30D;
uchar AFPointsInFocus1D[8];
- ushort AFPointsInFocus5D; // bytes in reverse
-// AFInfo
+ ushort AFPointsInFocus5D; /* bytes in reverse*/
+/* AFInfo */
ushort AFAreaMode;
ushort NumAFPoints;
ushort ValidAFPoints;
ushort AFImageWidth;
ushort AFImageHeight;
- short AFAreaWidths[61]; // cycle to NumAFPoints
- short AFAreaHeights[61]; // --''--
- short AFAreaXPositions[61]; // --''--
- short AFAreaYPositions[61]; // --''--
- short AFPointsInFocus[4]; // cycle to floor((NumAFPoints+15)/16)
- short AFPointsSelected[4]; // --''--
+ short AFAreaWidths[61]; /* cycle to NumAFPoints */
+ short AFAreaHeights[61]; /* --''-- */
+ short AFAreaXPositions[61]; /* --''-- */
+ short AFAreaYPositions[61]; /* --''-- */
+ short AFPointsInFocus[4]; /* cycle to floor((NumAFPoints+15)/16) */
+ short AFPointsSelected[4]; /* --''-- */
ushort PrimaryAFPoint;
-// flash
+/* flash */
short FlashMode;
short FlashActivity;
short FlashBits;
short ManualFlashOutput;
short FlashOutput;
short FlashGuideNumber;
-// drive
+/* drive */
short ContinuousDrive;
} libraw_canon_makernotes_t;
@@ -269,11 +269,11 @@ typedef struct
double ExposureBracketValue;
ushort ActiveDLighting;
ushort ShootingMode;
-// stabilization
+/* stabilization */
uchar ImageStabilization[7];
uchar VibrationReduction;
uchar VRMode;
-// focus
+/* focus */
char FocusMode[7];
uchar AFPoint;
ushort AFPointsInFocus;
@@ -289,7 +289,7 @@ typedef struct
ushort AFAreaWidth;
ushort AFAreaHeight;
uchar ContrastDetectAFInFocus;
-// flash
+/* flash */
char FlashSetting[13];
char FlashType[20];
uchar FlashExposureCompensation[4];
@@ -600,6 +600,18 @@ typedef struct
} libraw_data_t;
+struct xtrans_params
+{
+ char *q_table; /* quantization table */
+ int q_point[5]; /* quantization points */
+ int max_bits;
+ int min_value;
+ int raw_bits;
+ int total_values;
+ int maxDiff;
+ ushort line_width;
+};
+
#ifdef __cplusplus
}
#endif
@@ -630,6 +642,4 @@ typedef struct
#endif
#endif
-
-
#endif
View
@@ -74,6 +74,7 @@ typedef unsigned __int64 uint64_t;
#include "dng_info.h"
#endif
+#include "libraw_xtrans_compressed.cpp"
#ifdef __cplusplus
extern "C"
@@ -600,6 +601,10 @@ int LibRaw::get_decoder_info(libraw_decoder_info_t* d_info)
d_info->decoder_name = "canon_600_load_raw()";
d_info->decoder_flags = LIBRAW_DECODER_FIXEDMAXC;
}
+ else if (load_raw == &LibRaw::xtrans_compressed_load_raw)
+ {
+ d_info->decoder_name = "xtrans_compressed_load_raw()";
+ }
else if (load_raw == &LibRaw::canon_load_raw)
{
d_info->decoder_name = "canon_load_raw()";
@@ -1682,6 +1687,13 @@ int LibRaw::open_datastream(LibRaw_abstract_datastream *stream)
identify();
+ // 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)
+ parse_xtrans_header();
+ }
+
// Fix DNG white balance if needed
if(imgdata.idata.dng_version && (imgdata.idata.filters == 0) && imgdata.idata.colors > 1 && imgdata.idata.colors < 5)
{
@@ -4484,7 +4496,7 @@ static const char *static_camera_list[] =
"FujiFilm F800EXR",
"FujiFilm F900EXR",
"FujiFilm X-Pro1",
-"FujiFilm X-Pro2 (uncompressed RAW only)",
+"FujiFilm X-Pro2",
"FujiFilm X-S1",
"FujiFilm XQ1",
"FujiFilm XQ2",
Oops, something went wrong.

0 comments on commit aeab4d8

Please sign in to comment.