Skip to content

Commit

Permalink
Merge pull request #97 from gabilan/binary_file_format
Browse files Browse the repository at this point in the history
Improve serialization performance by creating a simple binary format for transform files.
  • Loading branch information
georgmartius authored Nov 6, 2020
2 parents af75891 + c0d0d3a commit d847ad0
Show file tree
Hide file tree
Showing 11 changed files with 355 additions and 42 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ include (GNUInstallDirs)
find_package(OpenMP)

set(MAJOR_VERSION 1)
set(MINOR_VERSION 1)
set(MINOR_VERSION 2)
set(PATCH_VERSION 0)
set(VIDSTAB_VERSION ${MAJOR_VERSION}.${MINOR_VERSION}${PATCH_VERSION})

Expand Down
4 changes: 4 additions & 0 deletions src/motiondetect.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ int vsMotionDetectInit(VSMotionDetect* md, const VSMotionDetectConfig* conf, con
md->hasSeenOneFrame = 0;
md->frameNum = 0;

if(md->serializationMode != ASCII_SERIALIZATION_MODE && md->serializationMode != BINARY_SERIALIZATION_MODE) {
md->serializationMode = BINARY_SERIALIZATION_MODE;
}

// TODO: get rid of shakiness parameter in the long run
md->conf.shakiness = VS_MIN(10,VS_MAX(1,md->conf.shakiness));
md->conf.accuracy = VS_MIN(15,VS_MAX(1,md->conf.accuracy));
Expand Down
6 changes: 6 additions & 0 deletions src/motiondetect.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@
#include "vsvector.h"
#include "frameinfo.h"

#define ASCII_SERIALIZATION_MODE 1
#define BINARY_SERIALIZATION_MODE 2

typedef struct _vsmotiondetectconfig {
/* meta parameter for maxshift and fieldsize between 1 and 15 */
int shakiness;
Expand Down Expand Up @@ -81,6 +84,7 @@ typedef struct _vsmotiondetect {
VSFrame prev; // frame buffer for last frame (copied)
short hasSeenOneFrame; // true if we have a valid previous frame
int initialized; // 1 if initialized and 2 if configured
int serializationMode; // 1 if ascii and 2 if binary

int frameNum;
} VSMotionDetect;
Expand All @@ -91,6 +95,8 @@ static const char vs_motiondetect_help[] = ""
" (translation, rotation) about subsequent frames."
" See also transform.\n"
"Options\n"
" 'fileformat' the type of file format used to write the transforms\n"
" 1: ascii (human readable) file format 2: binary (smaller) file format\n"
" 'result' path to the file used to write the transforms\n"
" (def:inputfile.stab)\n"
" 'shakiness' how shaky is the video and how quick is the camera?\n"
Expand Down
Loading

0 comments on commit d847ad0

Please sign in to comment.