-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
video_export: increment number frame index first
Actually the value+1 (so 1 for first frame) is can be incremented directly, this also removes the need to increment it in failed paths. Here the behavior has been inconsistent, because if queue was full, the index was incremented but on incompatible description it wasn't. Now it is always incremented.
- Loading branch information
1 parent
3efd418
commit af19124
Showing
1 changed file
with
9 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
* @author Martin Pulec <[email protected]> | ||
*/ | ||
/* | ||
* Copyright (c) 2012-2016 CESNET, z. s. p. o. | ||
* Copyright (c) 2012-2024 CESNET, z. s. p. o. | ||
* All rights reserved. | ||
* | ||
* Redistribution and use in source and binary forms, with or without | ||
|
@@ -214,6 +214,7 @@ void video_export(struct video_export *s, struct video_frame *frame) | |
} | ||
|
||
assert(frame != NULL); | ||
s->total += 1; | ||
|
||
if(s->saved_desc.width == 0) { | ||
s->saved_desc = video_desc_from_frame(frame); | ||
|
@@ -235,10 +236,14 @@ void video_export(struct video_export *s, struct video_frame *frame) | |
entry->next = NULL; | ||
|
||
if(frame->tile_count == 1) { | ||
snprintf(entry->filename, 512, "%s/%08d.%s", s->path, s->total + 1, get_codec_file_extension(frame->color_spec)); | ||
snprintf(entry->filename, 512, "%s/%08d.%s", s->path, | ||
s->total, | ||
get_codec_file_extension(frame->color_spec)); | ||
} else { | ||
// add also tile index | ||
snprintf(entry->filename, 512, "%s/%08d_%d.%s", s->path, s->total + 1, i, get_codec_file_extension(frame->color_spec)); | ||
snprintf(entry->filename, 512, "%s/%08d_%d.%s", s->path, | ||
s->total, i, | ||
get_codec_file_extension(frame->color_spec)); | ||
} | ||
memcpy(entry->data, frame->tiles[i].data, entry->data_len); | ||
|
||
|
@@ -248,7 +253,7 @@ void video_export(struct video_export *s, struct video_frame *frame) | |
if(s->queue_len >= MAX_QUEUE_SIZE) { | ||
fprintf(stderr, "[Video export] Maximal queue size (%d) exceeded, not saving frame %d.\n", | ||
MAX_QUEUE_SIZE, | ||
s->total++); // we increment total size to keep the index | ||
s->total); // we increment total size to keep the index | ||
pthread_mutex_unlock(&s->lock); | ||
free(entry->data); | ||
free(entry); | ||
|
@@ -267,7 +272,5 @@ void video_export(struct video_export *s, struct video_frame *frame) | |
|
||
platform_sem_post(&s->semaphore); | ||
} | ||
|
||
s->total += 1; | ||
} | ||
|