Commit 786c0e75 authored by Mikhail Karpenko's avatar Mikhail Karpenko

Fix formatting

Fix source code formatting with 'uncrustify' command-line utility
parent 045b76e0
This diff is collapsed.
...@@ -13,17 +13,17 @@ ...@@ -13,17 +13,17 @@
#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 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){x;fflush(debug_file);}} #define D0(x) { if (debug_file) { x; fflush(debug_file); } }
#define D1(x) {if (debug_file && (debug_level > 0)){x;fflush(debug_file);}} #define D1(x) { if (debug_file && (debug_level > 0)) { x; fflush(debug_file); } }
#define D2(x) {if (debug_file && (debug_level > 1)){x;fflush(debug_file);}} #define D2(x) { if (debug_file && (debug_level > 1)) { x; fflush(debug_file); } }
#define D3(x) {if (debug_file && (debug_level > 2)){x;fflush(debug_file);}} #define D3(x) { if (debug_file && (debug_level > 2)) { x; fflush(debug_file); } }
#define D4(x) {if (debug_file && (debug_level > 3)){x;fflush(debug_file);}} #define D4(x) { if (debug_file && (debug_level > 3)) { x; fflush(debug_file); } }
#define D5(x) {if (debug_file && (debug_level > 4)){x;fflush(debug_file);}} #define D5(x) { if (debug_file && (debug_level > 4)) { x; fflush(debug_file); } }
#define D6(x) {if (debug_file && (debug_level > 5)){x;fflush(debug_file);}} #define D6(x) { if (debug_file && (debug_level > 5)) { x; fflush(debug_file); } }
//#define DD(x) //#define DD(x)
#define DD(x) {if (debug_file){fprintf(debug_file,"%s:%d:",__FILE__,__LINE__);x;fflush(debug_file);}} #define DD(x) { if (debug_file) { fprintf(debug_file, "%s:%d:", __FILE__, __LINE__); x; fflush(debug_file); } }
// HEADER_SIZE is defined to be larger than actual header (later - with EXIF) to use compile-time buffer // HEADER_SIZE is defined to be larger than actual header (later - with EXIF) to use compile-time buffer
#define JPEG_HEADER_MAXSIZE 0x300 // will not change #define JPEG_HEADER_MAXSIZE 0x300 // will not change
...@@ -32,43 +32,43 @@ ...@@ -32,43 +32,43 @@
/* /*
#define Exif_Photo_DateTimeOriginal 0x19003 #define Exif_Photo_DateTimeOriginal 0x19003
#define Exif_GPSInfo_GPSLatitudeRef 0x20001 #define Exif_GPSInfo_GPSLatitudeRef 0x20001
#define Exif_GPSInfo_GPSLatitude 0x20002 #define Exif_GPSInfo_GPSLatitude 0x20002
#define Exif_GPSInfo_GPSLongitudeRef 0x20003 #define Exif_GPSInfo_GPSLongitudeRef 0x20003
#define Exif_GPSInfo_GPSLongitude 0x20004 #define Exif_GPSInfo_GPSLongitude 0x20004
#define Exif_GPSInfo_GPSAltitudeRef 0x20005 #define Exif_GPSInfo_GPSAltitudeRef 0x20005
#define Exif_GPSInfo_GPSAltitude 0x20006 #define Exif_GPSInfo_GPSAltitude 0x20006
#define Exif_GPSInfo_GPSTimeStamp 0x20007 #define Exif_GPSInfo_GPSTimeStamp 0x20007
#define Exif_GPSInfo_GPSDateStamp 0x2001D #define Exif_GPSInfo_GPSDateStamp 0x2001D
#define Exif_GPSInfo_CompassDirectionRef 0x20010 #define Exif_GPSInfo_CompassDirectionRef 0x20010
#define Exif_GPSInfo_CompassDirection 0x20011 #define Exif_GPSInfo_CompassDirection 0x20011
#define Exif_GPSInfo_CompassPitchRef 0x20013 #define Exif_GPSInfo_CompassPitchRef 0x20013
#define Exif_GPSInfo_CompassPitch 0x20014 #define Exif_GPSInfo_CompassPitch 0x20014
#define Exif_GPSInfo_CompassRollRef 0x20015 #define Exif_GPSInfo_CompassRollRef 0x20015
#define Exif_GPSInfo_CompassRoll 0x20016 #define Exif_GPSInfo_CompassRoll 0x20016
*/ */
/* /*
/// Exif data (variable, stored with each frame) used for KML (not only) /// Exif data (variable, stored with each frame) used for KML (not only)
#define Exif_Image_ImageDescription_Index 0x00 #define Exif_Image_ImageDescription_Index 0x00
#define Exif_Photo_DateTimeOriginal_Index 0x01 #define Exif_Photo_DateTimeOriginal_Index 0x01
#define Exif_Photo_SubSecTimeOriginal_Index 0x02 #define Exif_Photo_SubSecTimeOriginal_Index 0x02
#define Exif_GPSInfo_GPSLatitudeRef_Index 0x03 #define Exif_GPSInfo_GPSLatitudeRef_Index 0x03
#define Exif_GPSInfo_GPSLatitude_Index 0x04 #define Exif_GPSInfo_GPSLatitude_Index 0x04
#define Exif_GPSInfo_GPSLongitudeRef_Index 0x05 #define Exif_GPSInfo_GPSLongitudeRef_Index 0x05
#define Exif_GPSInfo_GPSLongitude_Index 0x06 #define Exif_GPSInfo_GPSLongitude_Index 0x06
#define Exif_GPSInfo_GPSAltitudeRef_Index 0x07 #define Exif_GPSInfo_GPSAltitudeRef_Index 0x07
#define Exif_GPSInfo_GPSAltitude_Index 0x08 #define Exif_GPSInfo_GPSAltitude_Index 0x08
#define Exif_GPSInfo_GPSTimeStamp_Index 0x09 #define Exif_GPSInfo_GPSTimeStamp_Index 0x09
#define Exif_GPSInfo_GPSDateStamp_Index 0x0a #define Exif_GPSInfo_GPSDateStamp_Index 0x0a
#define Exif_GPSInfo_CompassDirectionRef_Index 0x0b #define Exif_GPSInfo_CompassDirectionRef_Index 0x0b
#define Exif_GPSInfo_CompassDirection_Index 0x0c #define Exif_GPSInfo_CompassDirection_Index 0x0c
#define Exif_GPSInfo_CompassPitchRef_Index 0x0d #define Exif_GPSInfo_CompassPitchRef_Index 0x0d
#define Exif_GPSInfo_CompassPitch_Index 0x0e #define Exif_GPSInfo_CompassPitch_Index 0x0e
#define Exif_GPSInfo_CompassRollRef_Index 0x0f #define Exif_GPSInfo_CompassRollRef_Index 0x0f
#define Exif_GPSInfo_CompassRoll_Index 0x10 #define Exif_GPSInfo_CompassRoll_Index 0x10
#define ExifKmlNumber 0x11 #define ExifKmlNumber 0x11
*/ */
typedef struct { typedef struct {
int segment_duration; int segment_duration;
int segment_length; int segment_length;
...@@ -89,7 +89,7 @@ typedef struct { ...@@ -89,7 +89,7 @@ typedef struct {
struct interframe_params_t frame_params; struct interframe_params_t frame_params;
struct interframe_params_t this_frame_params; struct interframe_params_t this_frame_params;
int jpeg_len; int jpeg_len;
int frame_period ; //!in microseconds (1/10 of what is needed for the Ogm header) int frame_period; //!in microseconds (1/10 of what is needed for the Ogm header)
int width; int width;
int height; int height;
int starting; int starting;
...@@ -153,7 +153,7 @@ typedef struct { ...@@ -153,7 +153,7 @@ typedef struct {
int kml_period; //! generate PhotoOverlay for each kml_period seconds; int kml_period; //! generate PhotoOverlay for each kml_period seconds;
int kml_last_ts; //! last generated kml file timestamp int kml_last_ts; //! last generated kml file timestamp
int kml_last_uts; //! last generated kml file timestamp, microseconds int kml_last_uts; //! last generated kml file timestamp, microseconds
struct exif_dir_table_t kml_exif[ExifKmlNumber] ; //! store locations of the fields needed for KML generations in the Exif block struct exif_dir_table_t kml_exif[ExifKmlNumber]; //! store locations of the fields needed for KML generations in the Exif block
} camogm_state; } camogm_state;
......
/*!*************************************************************************** /*!***************************************************************************
*! FILE NAME : camogm_jpeg.c *! FILE NAME : camogm_jpeg.c
*! DESCRIPTION: Provides writing to series of individual JPEG files for camogm *! DESCRIPTION: Provides writing to series of individual JPEG files for camogm
*! Copyright (C) 2007 Elphel, Inc. *! Copyright (C) 2007 Elphel, Inc.
*! -----------------------------------------------------------------------------** *! -----------------------------------------------------------------------------**
*! This program is free software: you can redistribute it and/or modify *! This program is free software: you can redistribute it and/or modify
*! it under the terms of the GNU General Public License as published by *! it under the terms of the GNU General Public License as published by
*! the Free Software Foundation, either version 3 of the License, or *! the Free Software Foundation, either version 3 of the License, or
*! (at your option) any later version. *! (at your option) any later version.
*! *!
*! This program is distributed in the hope that it will be useful, *! This program is distributed in the hope that it will be useful,
*! but WITHOUT ANY WARRANTY; without even the implied warranty of *! but WITHOUT ANY WARRANTY; without even the implied warranty of
*! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
*! GNU General Public License for more details. *! GNU General Public License for more details.
*! *!
*! You should have received a copy of the GNU General Public License *! You should have received a copy of the GNU General Public License
*! along with this program. If not, see <http://www.gnu.org/licenses/>. *! along with this program. If not, see <http://www.gnu.org/licenses/>.
*! -----------------------------------------------------------------------------** *! -----------------------------------------------------------------------------**
*! *!
*! $Log: camogm_jpeg.c,v $ *! $Log: camogm_jpeg.c,v $
*! Revision 1.2 2009/02/25 17:50:51 spectr_rain *! Revision 1.2 2009/02/25 17:50:51 spectr_rain
*! removed deprecated dependency *! removed deprecated dependency
*! *!
*! Revision 1.1.1.1 2008/11/27 20:04:01 elphel *! Revision 1.1.1.1 2008/11/27 20:04:01 elphel
*! *!
*! *!
*! Revision 1.3 2008/04/11 23:09:33 elphel *! Revision 1.3 2008/04/11 23:09:33 elphel
*! modified to handle kml generation *! modified to handle kml generation
*! *!
*! Revision 1.2 2007/11/19 03:23:21 elphel *! Revision 1.2 2007/11/19 03:23:21 elphel
*! 7.1.5.5 Added support for *.mov files in camogm. *! 7.1.5.5 Added support for *.mov files in camogm.
*! *!
*! Revision 1.1 2007/11/16 08:49:57 elphel *! Revision 1.1 2007/11/16 08:49:57 elphel
*! Initial release of camogm - program to record video/image to the camera hard drive (or other storage) *! Initial release of camogm - program to record video/image to the camera hard drive (or other storage)
*! *!
*/ */
//!Not all are needed, just copied from the camogm.c //!Not all are needed, just copied from the camogm.c
#include <unistd.h> #include <unistd.h>
#include <stdio.h> #include <stdio.h>
...@@ -64,64 +64,71 @@ ...@@ -64,64 +64,71 @@
#include "camogm_jpeg.h" #include "camogm_jpeg.h"
#include "camogm.h" #include "camogm.h"
//! may add something - called first time format is changed to this one (only once) recording is stopped //! may add something - called first time format is changed to this one (only once) recording is stopped
int camogm_init_jpeg(void) { int camogm_init_jpeg(void)
{
return 0; return 0;
} }
void camogm_free_jpeg(void) { void camogm_free_jpeg(void)
{
} }
int camogm_start_jpeg(void) { int camogm_start_jpeg(void)
{
//!TODO: make directory if it does not exist (find the last "/" in the state->path //!TODO: make directory if it does not exist (find the last "/" in the state->path
char * slash; char * slash;
int rslt; int rslt;
strcpy (state->path,state->path_prefix); //!make state->path a directory name (will be replaced when the frames will be written)
slash=strrchr(state->path,'/'); strcpy(state->path, state->path_prefix); //!make state->path a directory name (will be replaced when the frames will be written)
D2(fprintf (debug_file, "camogm_start_jpeg\n")); slash = strrchr(state->path, '/');
D2(fprintf(debug_file, "camogm_start_jpeg\n"));
if (slash) { if (slash) {
D3(fprintf (debug_file, "Full path %s\n", state->path)); D3(fprintf(debug_file, "Full path %s\n", state->path));
slash[0]='\0'; //! truncate path to the directory name slash[0] = '\0'; //! truncate path to the directory name
D3(fprintf (debug_file, "directory path %s\n", state->path)); D3(fprintf(debug_file, "directory path %s\n", state->path));
rslt=mkdir(state->path, 0777); rslt = mkdir(state->path, 0777);
D3(fprintf (debug_file, "mkdir (%s, 0777) returned %d, errno=%d\n", state->path, rslt, errno)); D3(fprintf(debug_file, "mkdir (%s, 0777) returned %d, errno=%d\n", state->path, rslt, errno));
if ((rslt<0) && (errno != EEXIST)) { // already exists is OK if ((rslt < 0) && (errno != EEXIST)) { // already exists is OK
D0(fprintf (debug_file, "Error creating directory %s, errno=%d\n", state->path, errno)); D0(fprintf(debug_file, "Error creating directory %s, errno=%d\n", state->path, errno));
return -CAMOGM_FRAME_FILE_ERR; return -CAMOGM_FRAME_FILE_ERR;
} }
} }
return 0; return 0;
} }
int camogm_frame_jpeg(void){ int camogm_frame_jpeg(void)
int i,j; {
int i, j;
// int fd; // int fd;
ssize_t iovlen,l; ssize_t iovlen, l;
struct iovec chunks_iovec[7]; struct iovec chunks_iovec[7];
l=0;
for (i=0; i< (state->chunk_index)-1; i++) { l = 0;
chunks_iovec[i].iov_base=state->packetchunks[i+1].chunk; for (i = 0; i < (state->chunk_index) - 1; i++) {
chunks_iovec[i].iov_len= state->packetchunks[i+1].bytes; chunks_iovec[i].iov_base = state->packetchunks[i + 1].chunk;
l+=chunks_iovec[i].iov_len; chunks_iovec[i].iov_len = state->packetchunks[i + 1].bytes;
l += chunks_iovec[i].iov_len;
} }
sprintf(state->path,"%s%010ld_%06ld.jpeg",state->path_prefix,state->this_frame_params.timestamp_sec,state->this_frame_params.timestamp_usec); sprintf(state->path, "%s%010ld_%06ld.jpeg", state->path_prefix, state->this_frame_params.timestamp_sec, state->this_frame_params.timestamp_usec);
// if ((devfd = open("/dev/fpgaio", O_RDWR))<0) {printf("error opening /dev/fpgaio\r\n"); return -1;} // if ((devfd = open("/dev/fpgaio", O_RDWR))<0) {printf("error opening /dev/fpgaio\r\n"); return -1;}
//_1__12_Error opening /tmp/z/video1195147018_273452.jpeg for writing //_1__12_Error opening /tmp/z/video1195147018_273452.jpeg for writing
if (((state->ivf=open(state->path,O_RDWR | O_CREAT, 0777)))<0){ if (((state->ivf = open(state->path, O_RDWR | O_CREAT, 0777))) < 0) {
D0(fprintf (debug_file, "Error opening %s for writing, returned %d, errno=%d\n", state->path,state->ivf,errno)); D0(fprintf(debug_file, "Error opening %s for writing, returned %d, errno=%d\n", state->path, state->ivf, errno));
return -CAMOGM_FRAME_FILE_ERR; return -CAMOGM_FRAME_FILE_ERR;
} }
iovlen=writev(state->ivf,chunks_iovec, (state->chunk_index)-1); iovlen = writev(state->ivf, chunks_iovec, (state->chunk_index) - 1);
if (iovlen < l) { if (iovlen < l) {
j=errno; j = errno;
D0(fprintf(debug_file,"writev error %d (returned %d, expected %d)\n",j,iovlen,l)); D0(fprintf(debug_file, "writev error %d (returned %d, expected %d)\n", j, iovlen, l));
close (state->ivf); close(state->ivf);
return -CAMOGM_FRAME_FILE_ERR; return -CAMOGM_FRAME_FILE_ERR;
} }
close (state->ivf); close(state->ivf);
return 0; return 0;
} }
int camogm_end_jpeg(void){ int camogm_end_jpeg(void)
{
return 0; return 0;
} }
This diff is collapsed.
...@@ -15,13 +15,13 @@ void camogm_free_kml(void); ...@@ -15,13 +15,13 @@ void camogm_free_kml(void);
/* /*
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.2"> <kml xmlns="http://earth.google.com/kml/2.2">
<Document> <Document>
<PhotoOverlay> <PhotoOverlay>
<TimeStamp> <TimeStamp>
<when>2007-01-14T21:05:02Z</when> <when>2007-01-14T21:05:02Z</when>
...@@ -73,9 +73,9 @@ void camogm_free_kml(void); ...@@ -73,9 +73,9 @@ void camogm_free_kml(void);
<coordinates>...</coordinates> <!-- lon,lat[,alt] --> <coordinates>...</coordinates> <!-- lon,lat[,alt] -->
</Point> </Point>
<shape>rectangle</shape> <!-- kml:shape --> <shape>rectangle</shape> <!-- kml:shape -->
</PhotoOverlay> </PhotoOverlay>
<Camera id="ID"> <Camera id="ID">
<longitude>0</longitude> <!-- kml:angle180 --> <longitude>0</longitude> <!-- kml:angle180 -->
<latitude>0</latitude> <!-- kml:angle90 --> <latitude>0</latitude> <!-- kml:angle90 -->
<altitude>0</altitude> <!-- double --> <altitude>0</altitude> <!-- double -->
...@@ -85,4 +85,4 @@ void camogm_free_kml(void); ...@@ -85,4 +85,4 @@ void camogm_free_kml(void);
<altitudeMode>clampToGround</altitudeMode> <altitudeMode>clampToGround</altitudeMode>
<!-- kml:altitudeModeEnum: relativeToGround, clampToGround, or absolute --> <!-- kml:altitudeModeEnum: relativeToGround, clampToGround, or absolute -->
</Camera> </Camera>
*/ */
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment