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
a54d1b82
Commit
a54d1b82
authored
May 27, 2023
by
Andrey Filippov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Some bugs fixed, better buffer overrun handling
parent
6cffcbe2
Changes
4
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
115 additions
and
83 deletions
+115
-83
camogm.c
src/camogm.c
+79
-53
camogm.h
src/camogm.h
+8
-6
camogm_align.c
src/camogm_align.c
+7
-5
camogm_jpeg.c
src/camogm_jpeg.c
+21
-19
No files found.
src/camogm.c
View file @
a54d1b82
This diff is collapsed.
Click to expand it.
src/camogm.h
View file @
a54d1b82
...
@@ -43,6 +43,7 @@
...
@@ -43,6 +43,7 @@
#define CAMOGM_FORMAT_OGM 1 ///< output as Ogg Media file
#define CAMOGM_FORMAT_OGM 1 ///< output as Ogg Media file
#define CAMOGM_FORMAT_JPEG 2 ///< output as individual JPEG files
#define CAMOGM_FORMAT_JPEG 2 ///< output as individual JPEG files
#define CAMOGM_FORMAT_MOV 3 ///< output as Apple Quicktime
#define CAMOGM_FORMAT_MOV 3 ///< output as Apple Quicktime
#define CAMOGM_MIN_BUF_FRAMES 2 ///< buffer should accomodate at list this number of frames
#define D(x) { if (debug_file && debug_level) { x; fflush(debug_file); } }
#define D(x) { if (debug_file && debug_level) { x; fflush(debug_file); } }
#define D0(x) { if (debug_file) { pthread_mutex_lock(&print_mutex); x; fflush(debug_file); pthread_mutex_unlock(&print_mutex); } }
#define D0(x) { if (debug_file) { pthread_mutex_lock(&print_mutex); x; fflush(debug_file); pthread_mutex_unlock(&print_mutex); } }
...
@@ -194,6 +195,7 @@ typedef struct {
...
@@ -194,6 +195,7 @@ typedef struct {
int
fd_exif
[
SENSOR_PORTS
];
///< file descriptor for Exif data
int
fd_exif
[
SENSOR_PORTS
];
///< file descriptor for Exif data
int
fd_tiff
[
SENSOR_PORTS
];
///< file descriptor for Tiff data
int
fd_tiff
[
SENSOR_PORTS
];
///< file descriptor for Tiff data
int
head_size
[
SENSOR_PORTS
];
///< JPEG header size
int
head_size
[
SENSOR_PORTS
];
///< JPEG header size
int
image_size
[
SENSOR_PORTS
];
///< last image size in bytes
unsigned
char
jpegHeader
[
SENSOR_PORTS
][
JPEG_HEADER_MAXSIZE
];
unsigned
char
jpegHeader
[
SENSOR_PORTS
][
JPEG_HEADER_MAXSIZE
];
int
metadata_start
;
int
metadata_start
;
struct
interframe_params_t
frame_params
[
SENSOR_PORTS
];
struct
interframe_params_t
frame_params
[
SENSOR_PORTS
];
...
...
src/camogm_align.c
View file @
a54d1b82
...
@@ -368,6 +368,8 @@ void align_frame(camogm_state *state)
...
@@ -368,6 +368,8 @@ void align_frame(camogm_state *state)
// total_sz = get_size_from(chunks, 0, 0, INCLUDE_REM) + rbuff->iov_len;
// total_sz = get_size_from(chunks, 0, 0, INCLUDE_REM) + rbuff->iov_len;
total_sz
=
get_size_from_paged
(
state
,
0
,
INCLUDE_REM
)
+
rbuff
->
iov_len
;
total_sz
=
get_size_from_paged
(
state
,
0
,
INCLUDE_REM
)
+
rbuff
->
iov_len
;
//port_num
state
->
image_size
[
state
->
port_num
]
=
total_sz
;
D4
(
fprintf
(
debug_file
,
"total_sz = %d, rbuff->iov_len=%d
\n
"
,
total_sz
,
(
int
)(
rbuff
->
iov_len
)));
D4
(
fprintf
(
debug_file
,
"total_sz = %d, rbuff->iov_len=%d
\n
"
,
total_sz
,
(
int
)(
rbuff
->
iov_len
)));
if
(
total_sz
<
PHY_BLOCK_SIZE
)
{
if
(
total_sz
<
PHY_BLOCK_SIZE
)
{
/* the frame length is less than sector size, delay this frame */
/* the frame length is less than sector size, delay this frame */
...
...
src/camogm_jpeg.c
View file @
a54d1b82
...
@@ -319,6 +319,7 @@ int camogm_frame_jpeg(camogm_state *state)
...
@@ -319,6 +319,7 @@ int camogm_frame_jpeg(camogm_state *state)
state
->
rawdev
.
last_jpeg_size
=
l
;
state
->
rawdev
.
last_jpeg_size
=
l
;
close
(
state
->
ivf
);
close
(
state
->
ivf
);
}
else
{
}
else
{
D3
(
fprintf
(
debug_file
,
"_12.7_ camogm_frame_jpeg(): %ld.%06ld:%d @ %06d
\n
"
,
state
->
this_frame_params
[
port
].
timestamp_sec
,
state
->
this_frame_params
[
port
].
timestamp_usec
,
port
,
get_fpga_usec
(
state
->
fd_fparmsall
[
0
],
0
)));
D6
(
fprintf
(
debug_file
,
"
\n
dump iovect array for port %u
\n
"
,
state
->
port_num
));
D6
(
fprintf
(
debug_file
,
"
\n
dump iovect array for port %u
\n
"
,
state
->
port_num
));
for
(
int
i
=
0
;
i
<
state
->
chunk_index
-
1
;
i
++
)
{
for
(
int
i
=
0
;
i
<
state
->
chunk_index
-
1
;
i
++
)
{
D6
(
fprintf
(
debug_file
,
"ptr: %p, length: %ld
\n
"
,
state
->
packetchunks
[
i
+
1
].
chunk
,
state
->
packetchunks
[
i
+
1
].
bytes
));
D6
(
fprintf
(
debug_file
,
"ptr: %p, length: %ld
\n
"
,
state
->
packetchunks
[
i
+
1
].
chunk
,
state
->
packetchunks
[
i
+
1
].
bytes
));
...
@@ -495,13 +496,14 @@ void *jpeg_writer(void *thread_args)
...
@@ -495,13 +496,14 @@ void *jpeg_writer(void *thread_args)
if
(
state
->
writer_params
.
lba_current
+
blocks_write
<=
state
->
writer_params
.
lba_end
)
{
// almost always - single write
if
(
state
->
writer_params
.
lba_current
+
blocks_write
<=
state
->
writer_params
.
lba_end
)
{
// almost always - single write
state
->
writer_params
.
lba_current
+=
blocks_write
;
state
->
writer_params
.
lba_current
+=
blocks_write
;
// D6(fprintf(debug_file, "_w02_: starting writev @ %06d\n",get_fpga_usec(state->fd_fparmsall[0], 0)));
// D6(fprintf(debug_file, "_w02_: starting writev @ %06d\n",get_fpga_usec(state->fd_fparmsall[0], 0)));
D6
(
dbg_us1
=
get_fpga_usec
(
state
->
fd_fparmsall
[
0
],
0
);
fprintf
(
debug_file
,
"_w02_: starting writev @ %06d
\n
"
,
dbg_us1
));
D3
(
dbg_us1
=
get_fpga_usec
(
state
->
fd_fparmsall
[
0
],
0
));
D6
(
fprintf
(
debug_file
,
"_w02_: starting writev @ %06d
\n
"
,
dbg_us1
));
state
->
writer_params
.
writev_run
=
true
;
state
->
writer_params
.
writev_run
=
true
;
pthread_cond_signal
(
&
params
->
main_cond
);
pthread_cond_signal
(
&
params
->
main_cond
);
iovlen
=
writev
(
state
->
writer_params
.
blockdev_fd
,
chunks_iovec
[
wpage
],
chunk_index
);
iovlen
=
writev
(
state
->
writer_params
.
blockdev_fd
,
chunks_iovec
[
wpage
],
chunk_index
);
state
->
writer_params
.
writev_run
=
false
;
state
->
writer_params
.
writev_run
=
false
;
// D6(fprintf(debug_file, "_w03_: finished writev @ %06d\n",get_fpga_usec(state->fd_fparmsall[0], 0)));
// D6(fprintf(debug_file, "_w03_: finished writev @ %06d\n",get_fpga_usec(state->fd_fparmsall[0], 0)));
D6
(
dbg_us
=
get_fpga_usec
(
state
->
fd_fparmsall
[
0
],
0
);
fprintf
(
debug_file
,
"_w03_: finished writev @ %06d (+ %06d, +%06d)
\n
"
,
dbg_us
,
(
dbg_us
-
dbg_us1
),
(
dbg_us
-
dbg_us2
));
dbg_us2
=
dbg_us
);
D3
(
dbg_us
=
get_fpga_usec
(
state
->
fd_fparmsall
[
0
],
0
);
fprintf
(
debug_file
,
"_w03_: finished writev @ %06d (+ %06d, +%06d)
\n
"
,
dbg_us
,
(
dbg_us
-
dbg_us1
),
(
dbg_us
-
dbg_us2
));
dbg_us2
=
dbg_us
);
if
(
iovlen
<
l
)
{
if
(
iovlen
<
l
)
{
D0
(
fprintf
(
debug_file
,
"writev error: %s (returned %i, expected %i)
\n
"
,
strerror
(
errno
),
iovlen
,
l
));
D0
(
fprintf
(
debug_file
,
"writev error: %s (returned %i, expected %i)
\n
"
,
strerror
(
errno
),
iovlen
,
l
));
state
->
writer_params
.
last_ret_val
=
-
CAMOGM_FRAME_FILE_ERR
;
state
->
writer_params
.
last_ret_val
=
-
CAMOGM_FRAME_FILE_ERR
;
...
...
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