-rw-r--r-- | noncore/multimedia/camera/cmd/capture.cpp | 3 | ||||
-rw-r--r-- | noncore/multimedia/camera/gui/mainwindow.cpp | 2 | ||||
-rw-r--r-- | noncore/multimedia/camera/lib/avi.c | 1 |
3 files changed, 5 insertions, 1 deletions
diff --git a/noncore/multimedia/camera/cmd/capture.cpp b/noncore/multimedia/camera/cmd/capture.cpp index 688622b..6b8c63c 100644 --- a/noncore/multimedia/camera/cmd/capture.cpp +++ b/noncore/multimedia/camera/cmd/capture.cpp @@ -142,51 +142,54 @@ int main( int argc, char** argv ) while ( i < argc ) { // check for filename if ( argv[i][0] != '-' ) { if ( argc != i+1 ) { usage(); return -1; } else { c->name = argv[i]; break; } } else { i++; if ( argc == i ) { usage(); return -1; } switch ( argv[i-1][1] ) { case 'x': c->width = QString( argv[i] ).toInt(); break; case 'y': c->height = QString( argv[i] ).toInt(); break; case 'z': c->zoom = QString( argv[i] ).toInt(); break; case 'o': c->format = QString( argv[i] ); break; case 'q': c->quality = QString( argv[i] ).toInt(); break; case 'f': c->flip = QString( argv[i] )[0]; break; default: usage(); return -1; } i++; } #undef I_HATE_WRITING_HARDCODED_PARSES } if ( !ZCameraIO::instance()->isOpen() ) { printf( "Error: Can't detect your camera. Exiting.\n" ); return -1; } c->checkSettings(); c->capture(); + + delete c; + delete a; return 0; } diff --git a/noncore/multimedia/camera/gui/mainwindow.cpp b/noncore/multimedia/camera/gui/mainwindow.cpp index 7f2a9bd..bde448d 100644 --- a/noncore/multimedia/camera/gui/mainwindow.cpp +++ b/noncore/multimedia/camera/gui/mainwindow.cpp @@ -501,97 +501,97 @@ void CameraMainWindow::startVideoCapture() { ODevice::inst()->playTouchSound(); ODevice::inst()->setLedState( Led_Mail, Led_BlinkSlow ); _capturefd = ::open( CAPTUREFILE, O_WRONLY | O_CREAT | O_TRUNC ); if ( _capturefd == -1 ) { owarn << "can't open capture file: " << strerror(errno) << oendl; return; } _capturebuf = new unsigned char[captureX*captureY*2]; _capturing = true; _videopics = 0; _framerate = 0; updateCaption(); _time.start(); preview->setRefreshingRate( 1000 ); startTimer( 100 ); // too fast but that is ok } void CameraMainWindow::timerEvent( QTimerEvent* ) { if ( !_capturing ) { odebug << "timer event in CameraMainWindow without capturing video ?" << oendl; return; } odebug << "timer event during video - now capturing frame #" << _videopics+1 << oendl; ZCameraIO::instance()->captureFrame( captureX, captureY, zoom, _capturebuf ); _videopics++; ::write( _capturefd, _capturebuf, captureX*captureY*2 ); setCaption( QString().sprintf( "Capturing %dx%d @ %.2f fps %d", captureX, captureY, 1000.0 / (_time.elapsed()/_videopics), _videopics ) ); } void CameraMainWindow::stopVideoCapture() { killTimers(); ODevice::inst()->playTouchSound(); ODevice::inst()->setLedState( Led_Mail, Led_Off ); _capturing = false; updateCaption(); ::close( _capturefd ); - _framerate = 1000.0 / (_time.elapsed()/_videopics); + _framerate = static_cast<int>( 1000.0 / (_time.elapsed()/_videopics) ); QString name; if ( outputTo == "Documents Folder" ) { name.sprintf( "%s/Documents/video/%s/", (const char*) QDir::homeDirPath(), (const char*) captureFormat.lower() ); if ( !QDir( name ).exists() ) { odebug << "creating directory " << name << oendl; QString msg = "mkdir -p " + name; system( msg.latin1() ); } } else name = outputTo; name.append( "/" ); // sure is sure and safe is safe ;-) name.append( prefix ); if ( appendSettings ) name.append( QString().sprintf( "_%d_%d_q%d_%dfps", captureX, captureY, quality, _framerate ) ); name.append( QString().sprintf( "-%d.%s", _videos++, (const char*) captureFormat.lower() ) ); postProcessVideo( CAPTUREFILE, name ); #ifndef QT_NO_DEBUG preview->setRefreshingRate( 1500 ); #else preview->setRefreshingRate( 200 ); #endif //delete[] _capturebuf; //FIXME: close memory leak } void CameraMainWindow::postProcessVideo( const QString& infile, const QString& outfile ) { odebug << "post processing " << infile << " --> " << outfile << oendl; preview->setRefreshingRate( 0 ); /* unsigned char buf[153600]; int fd = ::open( "/var/compile/opie/noncore/multimedia/camera/capture-320x240.dat", O_RDONLY ); ::read( fd, &buf, 153600 ); QImage i; bufferToImage( 240, 320, (unsigned char*) &buf, &i ); QPixmap p; p.convertFromImage( i ); preview->setPixmap( p ); imageToFile( &i, "/tmp/tmpfile", "JPEG", 100 ); diff --git a/noncore/multimedia/camera/lib/avi.c b/noncore/multimedia/camera/lib/avi.c index 77aba33..d99c016 100644 --- a/noncore/multimedia/camera/lib/avi.c +++ b/noncore/multimedia/camera/lib/avi.c @@ -1,68 +1,69 @@ /********************************************************************** ** Copyright (C) 2003 Michael 'Mickey' Lauer. All rights reserved. ** Based on work from Andrew Tridgell and the jpegtoavi project ** ** This file is part of Opie Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** **********************************************************************/ #include "avi.h" #include <string.h> #include <stdio.h> +#include <stdlib.h> int nframes; int totalsize; unsigned int* sizes; void fprint_quartet(int fd, unsigned int i) { char data[4]; data[0] = (char) i%0x100; i /= 0x100; data[1] = (char) i%0x100; i /= 0x100; data[2] = (char) i%0x100; i /= 0x100; data[3] = (char) i%0x100; write( fd, &data, 4 ); } // start writing an AVI file void avi_start(int fd, int frames) { int ofs = sizeof(struct riff_head)+ sizeof(struct list_head)+ sizeof(struct avi_head)+ sizeof(struct list_head)+ sizeof(struct stream_head)+ sizeof(struct frame_head)+ sizeof(struct list_head)+ sizeof(struct dmlh_head)+ sizeof(struct list_head); printf( "avi_start: frames = %d\n", frames ); lseek(fd, ofs, SEEK_SET); nframes = 0; totalsize = 0; sizes = (unsigned int*) calloc( sizeof(unsigned int), frames ); // hold size of each frame } // add a jpeg frame to an AVI file void avi_add(int fd, u8 *buf, int size) { struct db_head db = {"00db", 0}; |