Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Panasonic v8 decoder and support for DC-S5M2 and DC-S5M2X #7018

Merged
merged 2 commits into from
Jun 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
127 changes: 118 additions & 9 deletions rtengine/dcraw.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6458,16 +6458,123 @@ int CLASS parse_tiff_ifd (int base)
FORC3 cam_mul[c] = get2();
break;
case 45:
if (pana_raw && len == 1 && type == 3)
{
RT_pana_info.encoding = get2();
}
break;
if (pana_raw && len == 1 && type == 3) {
RT_pana_info.encoding = get2();
}
break;
case 46:
if (type != 7 || fgetc(ifp) != 0xff || fgetc(ifp) != 0xd8) break;
thumb_offset = ftell(ifp) - 2;
thumb_length = len;
break;
if (type != 7 || fgetc(ifp) != 0xff || fgetc(ifp) != 0xd8) break;
thumb_offset = ftell(ifp) - 2;
thumb_length = len;
break;
case 57:
if (pana_raw && len == 26 && type == 7) {
ushort cnt = get2();
if (cnt > 6) cnt = 6;
for (i = 0; i < cnt; i++)
RT_pana_info.v8tags.tag39[i] = get4();
}
break;
case 58:
if (pana_raw && type == 7 && len == 26) {
ushort cnt = get2();
if (cnt > 6) cnt = 6;
for (i = 0; i < cnt; i++) {
get2();
RT_pana_info.v8tags.tag3A[i] = get2();
}
}
break;
case 59:
if (pana_raw && type == 3 && len == 1)
RT_pana_info.v8tags.tag3B = get2();
break;
case 60:
case 61:
case 62:
case 63:
if (pana_raw && type == 3 && len == 1)
RT_pana_info.v8tags.initial[tag - 0x3c] = get2();
break;
case 64:
if (pana_raw && type == 7 && len == 70) {
ushort count = get2();
if (count > 17) count = 17;
for (i = 0; i < count; i++) {
ushort v1 = get2();
if (v1 > 16u) v1 = 16u;
RT_pana_info.v8tags.tag40a[i] = v1;
ushort v2 = get2();
if (v2 > 0xfffu) v2 = 0xfffu;
RT_pana_info.v8tags.tag40b[i] = v2;
}
}
break;
case 65:
if (pana_raw && type == 7 && len == 36) {
ushort count = get2();
if (count > 17) count = 17;
for (i = 0; i < count; i++) {
ushort v1 = get2();
if (v1 > 0x40u) v1 = 64;
RT_pana_info.v8tags.tag41[i] = v1;
}
}
break;
case 66:
if (pana_raw && type == 3 && len == 1) {
ushort val = get2();
if (val > 5) val = 5;
RT_pana_info.v8tags.stripe_count = val;
}
break;
case 67:
if (pana_raw && type == 3 && len == 1) {
ushort val = get2();
if (val > 5) val = 5;
RT_pana_info.v8tags.tag43 = val;
}
break;
case 68:
if (pana_raw && type == 7 && len == 50) {
ushort count = get2();
if (count > 5) count = 5;
for (i = 0; i < count; i++)
RT_pana_info.v8tags.stripe_offsets[i] = get4();
}
break;
case 69:
if (pana_raw && type == 7 && len == 50) {
ushort count = get2();
if (count > 5) count = 5;
for (i = 0; i < count; i++)
RT_pana_info.v8tags.stripe_left[i] = get4();
}
break;
case 70:
if (pana_raw && type == 7 && len == 50) {
ushort count = get2();
if (count > 5) count = 5;
for (i = 0; i < count; i++)
RT_pana_info.v8tags.stripe_compressed_size[i] = get4();
}
break;
case 71:
if (pana_raw && type == 7 && len == 26) {
ushort count = get2();
if (count > 5) count = 5;
for (i = 0; i < count; i++)
RT_pana_info.v8tags.stripe_width[i] = get2();
}
break;
case 72:
if (pana_raw && type == 7 && len == 26) {
ushort count = get2();
if (count > 5) count = 5;
for (i = 0; i < count; i++)
RT_pana_info.v8tags.stripe_height[i] = get2();
}
break;
case 61440: /* Fuji HS10 table */
fseek (ifp, get4()+base, SEEK_SET);
parse_tiff_ifd (base);
Expand Down Expand Up @@ -8889,6 +8996,8 @@ void CLASS adobe_coeff (const char *make, const char *model)
{ 7610,-2780,-576,-4614,12195,2733,-1375,2393,6490 } },
{ "Panasonic DMC-G8", 15, 0xfff, /* G8, G80, G81, G85 */
{ 7610,-2780,-576,-4614,12195,2733,-1375,2393,6490 } },
{ "Panasonic DC-S5M2", 0, 0, /* DC-S5M2, DC-S5M2X */
{ 10308,-4206,-783,-4088,12102,2229,-125,1051,5912 } },
{ "Panasonic DC-G9M2", 0, 0,
{ 8325,-3456,-623,-4330,12089,2528,-860,2646,5984 } },
{ "Panasonic DC-G9", 15, 0xfff,
Expand Down
38 changes: 30 additions & 8 deletions rtengine/dcraw.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,12 +192,6 @@ class DCraw
std::string RT_software;
double RT_baseline_exposure;

struct PanasonicRW2Info {
ushort bpp;
ushort encoding;
PanasonicRW2Info(): bpp(0), encoding(0) {}
};
PanasonicRW2Info RT_pana_info;
std::vector<GainMap> gainMaps;

public:
Expand Down Expand Up @@ -229,6 +223,29 @@ class DCraw
short CR3_CTMDtag;
};

struct PanasonicRW2Info {
struct v8_tags_t
{
uint32_t tag39[6];
uint16_t tag3A[6];
uint16_t tag3B;
uint16_t initial[4];
uint16_t tag40a[17], tag40b[17], tag41[17];
uint16_t stripe_count; // 0x42
uint16_t tag43;
int64_t stripe_offsets[5]; //0x44
uint16_t stripe_left[5]; // 0x45
uint32_t stripe_compressed_size[5]; //0x46
uint16_t stripe_width[5]; //0x47
uint16_t stripe_height[5];
};

ushort bpp;
ushort encoding;
v8_tags_t v8tags;
PanasonicRW2Info(): bpp(0), encoding(0), v8tags{} {}
};

bool isBayer() const
{
return (filters != 0 && filters != 9);
Expand All @@ -250,9 +267,11 @@ class DCraw

protected:
CanonCR3Data RT_canon_CR3_data;

CanonLevelsData RT_canon_levels_data;

PanasonicRW2Info RT_pana_info;

float cam_mul[4], pre_mul[4], cmatrix[3][4], rgb_cam[3][4];

void (DCraw::*write_thumb)();
Expand Down Expand Up @@ -411,7 +430,9 @@ void fuji_decode_strip (fuji_compressed_params* params, int cur_block, INT64 raw
void fuji_compressed_load_raw();
void fuji_decode_loop(fuji_compressed_params* common_info, int count, INT64* raw_block_offsets, unsigned *block_sizes, uchar *q_bases);
void parse_fuji_compressed_header();
void fuji_14bit_load_raw();
void fuji_14bit_load_raw();
void pana8_decode_loop(void *data);
bool pana8_decode_strip(void* data, int stream);
void pentax_load_raw();
void nikon_load_raw();
int nikon_is_compressed();
Expand Down Expand Up @@ -503,6 +524,7 @@ class pana_bits_t{

void panasonicC6_load_raw();
void panasonicC7_load_raw();
void panasonicC8_load_raw();

void canon_rmf_load_raw();
void panasonic_load_raw();
Expand Down
Loading
Loading