Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
elphel-apps-camogm
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Elphel
elphel-apps-camogm
Commits
ce5e176f
Commit
ce5e176f
authored
May 08, 2019
by
Andrey Filippov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding tiff mode
parent
125b5ed8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
12 deletions
+35
-12
camogm.c
src/camogm.c
+33
-11
camogm.h
src/camogm.h
+2
-1
No files found.
src/camogm.c
View file @
ce5e176f
...
...
@@ -71,6 +71,9 @@ char trailer[TRAILER_SIZE] = { 0xff, 0xd9 };
const
char
*
exifFileNames
[]
=
{
DEV393_PATH
(
DEV393_EXIF0
),
DEV393_PATH
(
DEV393_EXIF1
),
DEV393_PATH
(
DEV393_EXIF2
),
DEV393_PATH
(
DEV393_EXIF3
)
};
const
char
*
tiffFileNames
[]
=
{
DEV393_PATH
(
DEV393_TIFF0
),
DEV393_PATH
(
DEV393_TIFF1
),
DEV393_PATH
(
DEV393_TIFF2
),
DEV393_PATH
(
DEV393_TIFF3
)
};
const
char
*
headFileNames
[]
=
{
DEV393_PATH
(
DEV393_JPEGHEAD0
),
DEV393_PATH
(
DEV393_JPEGHEAD1
),
DEV393_PATH
(
DEV393_JPEGHEAD2
),
DEV393_PATH
(
DEV393_JPEGHEAD3
)
...
...
@@ -528,6 +531,7 @@ int sendImageFrame(camogm_state *state)
int
timestamp_start
;
int
*
ifp_this
=
(
int
*
)
&
(
state
->
this_frame_params
[
state
->
port_num
]);
int
fp
;
int
fd_exif_tiff
;
// switching between TIFF and Exif depending on coloe mode
int
port
=
state
->
port_num
;
struct
timeval
start_time
,
end_time
;
...
...
@@ -621,12 +625,13 @@ int sendImageFrame(camogm_state *state)
D3
(
fprintf
(
debug_file
,
"_4_"
));
if
(
state
->
exif
)
{
D3
(
fprintf
(
debug_file
,
"_5_"
));
fd_exif_tiff
=
(
state
->
this_frame_params
[
port
].
color
==
COLORMODE_RAW
)
?
state
->
fd_tiff
[
port
]
:
state
->
fd_exif
[
port
];
// update the Exif header with the current frame metadata
state
->
exifSize
[
port
]
=
lseek
(
state
->
fd_exif
[
port
]
,
1
,
SEEK_END
);
// at the beginning of page 1 - position == page length
state
->
exifSize
[
port
]
=
lseek
(
fd_exif_tiff
,
1
,
SEEK_END
);
// at the beginning of page 1 - position == page length
if
(
state
->
exifSize
[
port
]
>
0
)
{
//state->this_frame_params.meta_index
lseek
(
state
->
fd_exif
[
port
]
,
state
->
this_frame_params
[
port
].
meta_index
,
SEEK_END
);
// select meta page to use (matching frame)
rslt
=
read
(
state
->
fd_exif
[
port
]
,
state
->
ed
[
port
],
state
->
exifSize
[
port
]);
lseek
(
fd_exif_tiff
,
state
->
this_frame_params
[
port
].
meta_index
,
SEEK_END
);
// select meta page to use (matching frame)
rslt
=
read
(
fd_exif_tiff
,
state
->
ed
[
port
],
state
->
exifSize
[
port
]);
if
(
rslt
<
0
)
rslt
=
0
;
state
->
exifSize
[
port
]
=
rslt
;
}
else
state
->
exifSize
[
port
]
=
0
;
...
...
@@ -638,14 +643,21 @@ int sendImageFrame(camogm_state *state)
state
->
chunk_index
=
0
;
state
->
packetchunks
[
state
->
chunk_index
].
bytes
=
1
;
state
->
packetchunks
[
state
->
chunk_index
++
].
chunk
=
&
frame_packet_type
;
if
(
state
->
exif
>
0
)
{
// insert Exif
if
(
state
->
exif
>
0
)
{
// insert Exif
/Tiff
D3
(
fprintf
(
debug_file
,
"_7_"
));
state
->
packetchunks
[
state
->
chunk_index
].
bytes
=
2
;
state
->
packetchunks
[
state
->
chunk_index
++
].
chunk
=
state
->
jpegHeader
[
port
];
state
->
packetchunks
[
state
->
chunk_index
].
bytes
=
state
->
exifSize
[
port
];
state
->
packetchunks
[
state
->
chunk_index
++
].
chunk
=
state
->
ed
[
port
];
state
->
packetchunks
[
state
->
chunk_index
].
bytes
=
state
->
head_size
[
port
]
-
2
;
state
->
packetchunks
[
state
->
chunk_index
++
].
chunk
=
&
(
state
->
jpegHeader
[
port
][
2
]);
if
(
state
->
this_frame_params
[
port
].
color
==
COLORMODE_RAW
)
{
// Tiff
D3
(
fprintf
(
debug_file
,
"_8a_"
));
state
->
packetchunks
[
state
->
chunk_index
].
bytes
=
state
->
exifSize
[
port
];
// Tiff Header length
state
->
packetchunks
[
state
->
chunk_index
++
].
chunk
=
state
->
ed
[
port
];
// Tiff Header
}
else
{
// JPEG/JP4
state
->
packetchunks
[
state
->
chunk_index
].
bytes
=
2
;
state
->
packetchunks
[
state
->
chunk_index
++
].
chunk
=
state
->
jpegHeader
[
port
];
state
->
packetchunks
[
state
->
chunk_index
].
bytes
=
state
->
exifSize
[
port
];
state
->
packetchunks
[
state
->
chunk_index
++
].
chunk
=
state
->
ed
[
port
];
state
->
packetchunks
[
state
->
chunk_index
].
bytes
=
state
->
head_size
[
port
]
-
2
;
state
->
packetchunks
[
state
->
chunk_index
++
].
chunk
=
&
(
state
->
jpegHeader
[
port
][
2
]);
}
}
else
{
D3
(
fprintf
(
debug_file
,
"_8_"
));
state
->
packetchunks
[
state
->
chunk_index
].
bytes
=
state
->
head_size
[
port
];
...
...
@@ -653,7 +665,7 @@ int sendImageFrame(camogm_state *state)
}
D3
(
fprintf
(
debug_file
,
"_9_"
));
/* J
PEG
image data may be split in two segments (rolled over buffer end) - process both variants */
/* J
peg/Tiff
image data may be split in two segments (rolled over buffer end) - process both variants */
if
((
state
->
cirbuf_rp
[
port
]
+
state
->
jpeg_len
)
>
state
->
circ_buff_size
[
port
])
{
// two segments
/* copy from the beginning of the frame to the end of the buffer */
D3
(
fprintf
(
debug_file
,
"_10_"
));
...
...
@@ -1523,6 +1535,8 @@ void clean_up(camogm_state *state)
for
(
int
port
=
0
;
port
<
SENSOR_PORTS
;
port
++
)
{
if
(
is_fd_valid
(
state
->
fd_exif
[
port
]))
close
(
state
->
fd_exif
[
port
]);
if
(
is_fd_valid
(
state
->
fd_tiff
[
port
]))
close
(
state
->
fd_tiff
[
port
]);
if
(
is_fd_valid
(
state
->
fd_head
[
port
]))
close
(
state
->
fd_head
[
port
]);
if
(
is_fd_valid
(
state
->
fd_circ
[
port
]))
...
...
@@ -1993,6 +2007,14 @@ int open_files(camogm_state *state)
return
-
1
;
}
// open Tiff header file
state
->
fd_tiff
[
port
]
=
open
(
tiffFileNames
[
port
],
O_RDONLY
);
if
(
state
->
fd_tiff
[
port
]
<
0
)
{
// check control OK
D0
(
fprintf
(
debug_file
,
"Error opening %s
\n
"
,
tiffFileNames
[
port
]));
clean_up
(
state
);
return
-
1
;
}
// open JPEG header file
state
->
fd_head
[
port
]
=
open
(
headFileNames
[
port
],
O_RDWR
);
if
(
state
->
fd_head
[
port
]
<
0
)
{
// check control OK
...
...
src/camogm.h
View file @
ce5e176f
...
...
@@ -182,6 +182,7 @@ typedef struct {
int
fd_head
[
SENSOR_PORTS
];
///< file descriptor for JPEG header
int
fd_fparmsall
[
SENSOR_PORTS
];
///< file descriptor for sensor/compressor parameters
int
fd_exif
[
SENSOR_PORTS
];
///< file descriptor for Exif data
int
fd_tiff
[
SENSOR_PORTS
];
///< file descriptor for Tiff data
int
head_size
[
SENSOR_PORTS
];
///< JPEG header size
unsigned
char
jpegHeader
[
SENSOR_PORTS
][
JPEG_HEADER_MAXSIZE
];
int
metadata_start
;
...
...
@@ -205,7 +206,7 @@ typedef struct {
int
ivf
;
///< video file (jpeg, mov - open)
int
last
;
///< last packet in a file
int
exif
;
///< flag indicating that Exif headers should be calculated and included in each frame
int
exif
;
///< flag indicating that Exif
(or Tiff for raw data)
headers should be calculated and included in each frame
int
exifSize
[
SENSOR_PORTS
];
///< signed
unsigned
char
ed
[
SENSOR_PORTS
][
MAX_EXIF_SIZE
];
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment