-rw-r--r-- | noncore/multimedia/camera/avi.c | 3 | ||||
-rw-r--r-- | noncore/multimedia/camera/mainwindow.cpp | 10 |
2 files changed, 9 insertions, 4 deletions
diff --git a/noncore/multimedia/camera/avi.c b/noncore/multimedia/camera/avi.c index 0c757c9..77aba33 100644 --- a/noncore/multimedia/camera/avi.c +++ b/noncore/multimedia/camera/avi.c | |||
@@ -23,201 +23,202 @@ int nframes; | |||
23 | int totalsize; | 23 | int totalsize; |
24 | unsigned int* sizes; | 24 | unsigned int* sizes; |
25 | 25 | ||
26 | void fprint_quartet(int fd, unsigned int i) | 26 | void fprint_quartet(int fd, unsigned int i) |
27 | { | 27 | { |
28 | char data[4]; | 28 | char data[4]; |
29 | 29 | ||
30 | data[0] = (char) i%0x100; | 30 | data[0] = (char) i%0x100; |
31 | i /= 0x100; | 31 | i /= 0x100; |
32 | data[1] = (char) i%0x100; | 32 | data[1] = (char) i%0x100; |
33 | i /= 0x100; | 33 | i /= 0x100; |
34 | data[2] = (char) i%0x100; | 34 | data[2] = (char) i%0x100; |
35 | i /= 0x100; | 35 | i /= 0x100; |
36 | data[3] = (char) i%0x100; | 36 | data[3] = (char) i%0x100; |
37 | 37 | ||
38 | write( fd, &data, 4 ); | 38 | write( fd, &data, 4 ); |
39 | } | 39 | } |
40 | 40 | ||
41 | // start writing an AVI file | 41 | // start writing an AVI file |
42 | 42 | ||
43 | void avi_start(int fd, int frames) | 43 | void avi_start(int fd, int frames) |
44 | { | 44 | { |
45 | int ofs = sizeof(struct riff_head)+ | 45 | int ofs = sizeof(struct riff_head)+ |
46 | sizeof(struct list_head)+ | 46 | sizeof(struct list_head)+ |
47 | sizeof(struct avi_head)+ | 47 | sizeof(struct avi_head)+ |
48 | sizeof(struct list_head)+ | 48 | sizeof(struct list_head)+ |
49 | sizeof(struct stream_head)+ | 49 | sizeof(struct stream_head)+ |
50 | sizeof(struct frame_head)+ | 50 | sizeof(struct frame_head)+ |
51 | sizeof(struct list_head)+ | 51 | sizeof(struct list_head)+ |
52 | sizeof(struct dmlh_head)+ | 52 | sizeof(struct dmlh_head)+ |
53 | sizeof(struct list_head); | 53 | sizeof(struct list_head); |
54 | 54 | ||
55 | printf( "avi_start: frames = %d\n", frames ); | 55 | printf( "avi_start: frames = %d\n", frames ); |
56 | 56 | ||
57 | lseek(fd, ofs, SEEK_SET); | 57 | lseek(fd, ofs, SEEK_SET); |
58 | 58 | ||
59 | nframes = 0; | 59 | nframes = 0; |
60 | totalsize = 0; | 60 | totalsize = 0; |
61 | 61 | ||
62 | sizes = (unsigned int*) calloc( sizeof(unsigned int), frames ); // hold size of each frame | 62 | sizes = (unsigned int*) calloc( sizeof(unsigned int), frames ); // hold size of each frame |
63 | } | 63 | } |
64 | 64 | ||
65 | // add a jpeg frame to an AVI file | 65 | // add a jpeg frame to an AVI file |
66 | void avi_add(int fd, u8 *buf, int size) | 66 | void avi_add(int fd, u8 *buf, int size) |
67 | { | 67 | { |
68 | struct db_head db = {"00db", 0}; | 68 | struct db_head db = {"00db", 0}; |
69 | 69 | ||
70 | printf( "avi_add: nframes = %d, totalsize = %d, size = %d\n", nframes, totalsize, size ); | 70 | printf( "avi_add: nframes = %d, totalsize = %d, size = %d\n", nframes, totalsize, size ); |
71 | 71 | ||
72 | // overwrite JFIF type with AVI1 | 72 | // overwrite JFIF type with AVI1 |
73 | buf[6]='A'; | 73 | buf[6]='A'; |
74 | buf[7]='V'; | 74 | buf[7]='V'; |
75 | buf[8]='I'; | 75 | buf[8]='I'; |
76 | buf[9]='1'; | 76 | buf[9]='1'; |
77 | 77 | ||
78 | while( size%4 ) size++; // align 0 modulo 4*/ | 78 | while( size%4 ) size++; // align 0 modulo 4*/ |
79 | db.size = size; | 79 | db.size = size; |
80 | 80 | ||
81 | write( fd, &db, sizeof(db) ); | 81 | write( fd, &db, sizeof(db) ); |
82 | write( fd, buf, size ); | 82 | write( fd, buf, size ); |
83 | 83 | ||
84 | sizes[nframes] = size; | 84 | sizes[nframes] = size; |
85 | 85 | ||
86 | nframes++; | 86 | nframes++; |
87 | totalsize += size; // total frame size | 87 | totalsize += size; // total frame size |
88 | } | 88 | } |
89 | 89 | ||
90 | // finish writing the AVI file - filling in the header | 90 | // finish writing the AVI file - filling in the header |
91 | void avi_end(int fd, int width, int height, int fps) | 91 | void avi_end(int fd, int width, int height, int fps) |
92 | { | 92 | { |
93 | struct idx1_head idx = {"idx1", 16*nframes }; | 93 | struct idx1_head idx = {"idx1", 16*nframes }; |
94 | struct db_head db = {"00db", 0}; | 94 | struct db_head db = {"00db", 0}; |
95 | struct riff_head rh = { "RIFF", 0, "AVI "}; | 95 | struct riff_head rh = { "RIFF", 0, "AVI "}; |
96 | struct list_head lh1 = {"LIST", 0, "hdrl"}; | 96 | struct list_head lh1 = {"LIST", 0, "hdrl"}; |
97 | struct avi_head ah; | 97 | struct avi_head ah; |
98 | struct list_head lh2 = {"LIST", 0, "strl"}; | 98 | struct list_head lh2 = {"LIST", 0, "strl"}; |
99 | struct stream_head sh; | 99 | struct stream_head sh; |
100 | struct frame_head fh; | 100 | struct frame_head fh; |
101 | struct list_head lh3 = {"LIST", 0, "odml" }; | 101 | struct list_head lh3 = {"LIST", 0, "odml" }; |
102 | struct dmlh_head dh = {"dmlh", 4, nframes }; | 102 | struct dmlh_head dh = {"dmlh", 4, nframes }; |
103 | struct list_head lh4 = {"LIST", 0, "movi"}; | 103 | struct list_head lh4 = {"LIST", 0, "movi"}; |
104 | int i; | 104 | int i; |
105 | unsigned int offset = 4; | 105 | unsigned int offset = 4; |
106 | 106 | ||
107 | printf( "avi_end: nframes = %d, fps = %d\n", nframes, fps ); | 107 | printf( "avi_end: nframes = %d, fps = %d\n", nframes, fps ); |
108 | 108 | ||
109 | // write index | 109 | // write index |
110 | 110 | ||
111 | write(fd, &idx, sizeof(idx)); | 111 | write(fd, &idx, sizeof(idx)); |
112 | 112 | ||
113 | for ( i = 0; i < nframes; i++ ) | 113 | for ( i = 0; i < nframes; i++ ) |
114 | { | 114 | { |
115 | write(fd, &db, 4 ); // only need the 00db | 115 | write(fd, &db, 4 ); // only need the 00db |
116 | fprint_quartet( fd, 18 ); // ??? | 116 | fprint_quartet( fd, 18 ); // ??? |
117 | fprint_quartet( fd, offset ); | 117 | fprint_quartet( fd, offset ); |
118 | fprint_quartet( fd, sizes[i] ); | 118 | fprint_quartet( fd, sizes[i] ); |
119 | offset += sizes[i]; | 119 | offset += sizes[i] + 8; //+8 (for the additional header) |
120 | } | 120 | } |
121 | 121 | ||
122 | free( sizes ); | 122 | free( sizes ); |
123 | 123 | ||
124 | bzero( &ah, sizeof(ah) ); | 124 | bzero( &ah, sizeof(ah) ); |
125 | strcpy(ah.avih, "avih"); | 125 | strcpy(ah.avih, "avih"); |
126 | ah.time = 1000000 / fps; | 126 | ah.time = 1000000 / fps; |
127 | ah.maxbytespersec = 1000000.0*(totalsize/nframes)/ah.time; | 127 | ah.maxbytespersec = 1000000.0*(totalsize/nframes)/ah.time; |
128 | ah.nframes = nframes; | ||
128 | ah.numstreams = 1; | 129 | ah.numstreams = 1; |
129 | ah.flags = AVIF_HASINDEX; | 130 | ah.flags = AVIF_HASINDEX; |
130 | ah.width = width; | 131 | ah.width = width; |
131 | ah.height = height; | 132 | ah.height = height; |
132 | 133 | ||
133 | bzero(&sh, sizeof(sh)); | 134 | bzero(&sh, sizeof(sh)); |
134 | strcpy(sh.strh, "strh"); | 135 | strcpy(sh.strh, "strh"); |
135 | strcpy(sh.vids, "vids"); | 136 | strcpy(sh.vids, "vids"); |
136 | strcpy(sh.codec, "MJPG"); | 137 | strcpy(sh.codec, "MJPG"); |
137 | sh.scale = ah.time; | 138 | sh.scale = ah.time; |
138 | sh.rate = 1000000; | 139 | sh.rate = 1000000; |
139 | sh.length = nframes; | 140 | sh.length = nframes; |
140 | 141 | ||
141 | bzero(&fh, sizeof(fh)); | 142 | bzero(&fh, sizeof(fh)); |
142 | strcpy(fh.strf, "strf"); | 143 | strcpy(fh.strf, "strf"); |
143 | fh.width = width; | 144 | fh.width = width; |
144 | fh.height = height; | 145 | fh.height = height; |
145 | fh.planes = 1; | 146 | fh.planes = 1; |
146 | fh.bitcount = 24; | 147 | fh.bitcount = 24; |
147 | strcpy(fh.codec,"MJPG"); | 148 | strcpy(fh.codec,"MJPG"); |
148 | fh.unpackedsize = 3*width*height; | 149 | fh.unpackedsize = 3*width*height; |
149 | 150 | ||
150 | rh.size = sizeof(lh1)+sizeof(ah)+sizeof(lh2)+sizeof(sh)+ | 151 | rh.size = sizeof(lh1)+sizeof(ah)+sizeof(lh2)+sizeof(sh)+ |
151 | sizeof(fh)+sizeof(lh3)+sizeof(dh)+sizeof(lh4)+ | 152 | sizeof(fh)+sizeof(lh3)+sizeof(dh)+sizeof(lh4)+ |
152 | nframes*sizeof(struct db_head)+ | 153 | nframes*sizeof(struct db_head)+ |
153 | totalsize + sizeof(struct idx1_head)+ (16*nframes) +4; // FIXME:16 bytes per nframe // the '4' - what for??? | 154 | totalsize + sizeof(struct idx1_head)+ (16*nframes) +4; // FIXME:16 bytes per nframe // the '4' - what for??? |
154 | 155 | ||
155 | lh1.size = 4+sizeof(ah)+sizeof(lh2)+sizeof(sh)+sizeof(fh)+sizeof(lh3)+sizeof(dh); | 156 | lh1.size = 4+sizeof(ah)+sizeof(lh2)+sizeof(sh)+sizeof(fh)+sizeof(lh3)+sizeof(dh); |
156 | ah.size = sizeof(ah)-8; | 157 | ah.size = sizeof(ah)-8; |
157 | lh2.size = 4+sizeof(sh)+sizeof(fh)+sizeof(lh3)+sizeof(dh); //4+sizeof(sh)+sizeof(fh); | 158 | lh2.size = 4+sizeof(sh)+sizeof(fh)+sizeof(lh3)+sizeof(dh); //4+sizeof(sh)+sizeof(fh); |
158 | sh.size = sizeof(sh)-8; | 159 | sh.size = sizeof(sh)-8; |
159 | fh.size = sizeof(fh)-8; | 160 | fh.size = sizeof(fh)-8; |
160 | fh.size2 = fh.size; | 161 | fh.size2 = fh.size; |
161 | lh3.size = 4+sizeof(dh); | 162 | lh3.size = 4+sizeof(dh); |
162 | lh4.size = 4+ nframes*sizeof(struct db_head)+ totalsize; | 163 | lh4.size = 4+ nframes*sizeof(struct db_head)+ totalsize; |
163 | 164 | ||
164 | lseek(fd, 0, SEEK_SET); | 165 | lseek(fd, 0, SEEK_SET); |
165 | 166 | ||
166 | write(fd, &rh, sizeof(rh)); | 167 | write(fd, &rh, sizeof(rh)); |
167 | write(fd, &lh1, sizeof(lh1)); | 168 | write(fd, &lh1, sizeof(lh1)); |
168 | write(fd, &ah, sizeof(ah)); | 169 | write(fd, &ah, sizeof(ah)); |
169 | write(fd, &lh2, sizeof(lh2)); | 170 | write(fd, &lh2, sizeof(lh2)); |
170 | write(fd, &sh, sizeof(sh)); | 171 | write(fd, &sh, sizeof(sh)); |
171 | write(fd, &fh, sizeof(fh)); | 172 | write(fd, &fh, sizeof(fh)); |
172 | write(fd, &lh3, sizeof(lh3)); | 173 | write(fd, &lh3, sizeof(lh3)); |
173 | write(fd, &dh, sizeof(dh)); | 174 | write(fd, &dh, sizeof(dh)); |
174 | write(fd, &lh4, sizeof(lh4)); | 175 | write(fd, &lh4, sizeof(lh4)); |
175 | } | 176 | } |
176 | 177 | ||
177 | 178 | ||
178 | /* NOTE: This is not a general purpose routine - it is meant to only | 179 | /* NOTE: This is not a general purpose routine - it is meant to only |
179 | cope with AVIs saved using the other functions in this file | 180 | cope with AVIs saved using the other functions in this file |
180 | void avi_explode(char *fname) | 181 | void avi_explode(char *fname) |
181 | { | 182 | { |
182 | struct riff_head rh; | 183 | struct riff_head rh; |
183 | struct list_head lh1; | 184 | struct list_head lh1; |
184 | struct avi_head ah; | 185 | struct avi_head ah; |
185 | struct list_head lh2; | 186 | struct list_head lh2; |
186 | struct stream_head sh; | 187 | struct stream_head sh; |
187 | struct frame_head fh; | 188 | struct frame_head fh; |
188 | struct list_head lh3; | 189 | struct list_head lh3; |
189 | int hsize, qsize; | 190 | int hsize, qsize; |
190 | u16 *htables = jpeg_huffman_tables(&hsize); | 191 | u16 *htables = jpeg_huffman_tables(&hsize); |
191 | u16 *qtables = jpeg_quantisation_tables(&qsize, image_quality); | 192 | u16 *qtables = jpeg_quantisation_tables(&qsize, image_quality); |
192 | int fd, i; | 193 | int fd, i; |
193 | 194 | ||
194 | fd = open(fname,O_RDONLY); | 195 | fd = open(fname,O_RDONLY); |
195 | if (fd == -1) { | 196 | if (fd == -1) { |
196 | perror(fname); | 197 | perror(fname); |
197 | return; | 198 | return; |
198 | } | 199 | } |
199 | 200 | ||
200 | read(fd, &rh, sizeof(rh)); | 201 | read(fd, &rh, sizeof(rh)); |
201 | read(fd, &lh1, sizeof(lh1)); | 202 | read(fd, &lh1, sizeof(lh1)); |
202 | read(fd, &ah, sizeof(ah)); | 203 | read(fd, &ah, sizeof(ah)); |
203 | read(fd, &lh2, sizeof(lh2)); | 204 | read(fd, &lh2, sizeof(lh2)); |
204 | read(fd, &sh, sizeof(sh)); | 205 | read(fd, &sh, sizeof(sh)); |
205 | read(fd, &fh, sizeof(fh)); | 206 | read(fd, &fh, sizeof(fh)); |
206 | read(fd, &lh3, sizeof(lh3)); | 207 | read(fd, &lh3, sizeof(lh3)); |
207 | 208 | ||
208 | for (i=0; ; i++) { | 209 | for (i=0; ; i++) { |
209 | u8 buf[500*1024]; | 210 | u8 buf[500*1024]; |
210 | struct db_head db; | 211 | struct db_head db; |
211 | char fname[100]; | 212 | char fname[100]; |
212 | int fd2; | 213 | int fd2; |
213 | 214 | ||
214 | if (read(fd, &db, sizeof(db)) != sizeof(db) || | 215 | if (read(fd, &db, sizeof(db)) != sizeof(db) || |
215 | read(fd, buf, db.size) != db.size) break; | 216 | read(fd, buf, db.size) != db.size) break; |
216 | 217 | ||
217 | snprintf(fname, sizeof(fname)-1,"frame.%d", i); | 218 | snprintf(fname, sizeof(fname)-1,"frame.%d", i); |
218 | 219 | ||
219 | fd2 = open(fname,O_WRONLY|O_CREAT, 0644); | 220 | fd2 = open(fname,O_WRONLY|O_CREAT, 0644); |
220 | if (fd2 == -1) { | 221 | if (fd2 == -1) { |
221 | perror(fname); | 222 | perror(fname); |
222 | continue; | 223 | continue; |
223 | } | 224 | } |
diff --git a/noncore/multimedia/camera/mainwindow.cpp b/noncore/multimedia/camera/mainwindow.cpp index e27a50e..7e60e16 100644 --- a/noncore/multimedia/camera/mainwindow.cpp +++ b/noncore/multimedia/camera/mainwindow.cpp | |||
@@ -403,149 +403,153 @@ void CameraMainWindow::stopVideoCapture() | |||
403 | ODevice::inst()->setLedState( Led_Mail, Led_Off ); | 403 | ODevice::inst()->setLedState( Led_Mail, Led_Off ); |
404 | _capturing = false; | 404 | _capturing = false; |
405 | updateCaption(); | 405 | updateCaption(); |
406 | ::close( _capturefd ); | 406 | ::close( _capturefd ); |
407 | _framerate = 1000.0 / (_time.elapsed()/_videopics); | 407 | _framerate = 1000.0 / (_time.elapsed()/_videopics); |
408 | 408 | ||
409 | postProcessVideo( CAPTUREFILE, QString().sprintf( "/tmp/video-%d_%d_%d_q%d-%dfps.avi", _videos++, captureX, captureY, quality, _framerate ) ); | 409 | postProcessVideo( CAPTUREFILE, QString().sprintf( "/tmp/video-%d_%d_%d_q%d-%dfps.avi", _videos++, captureX, captureY, quality, _framerate ) ); |
410 | 410 | ||
411 | #ifndef QT_NO_DEBUG | 411 | #ifndef QT_NO_DEBUG |
412 | preview->setRefreshingRate( 1500 ); | 412 | preview->setRefreshingRate( 1500 ); |
413 | #else | 413 | #else |
414 | preview->setRefreshingRate( 200 ); | 414 | preview->setRefreshingRate( 200 ); |
415 | #endif | 415 | #endif |
416 | 416 | ||
417 | //delete[] _capturebuf; //FIXME: close memory leak | 417 | //delete[] _capturebuf; //FIXME: close memory leak |
418 | } | 418 | } |
419 | 419 | ||
420 | void CameraMainWindow::postProcessVideo( const QString& infile, const QString& outfile ) | 420 | void CameraMainWindow::postProcessVideo( const QString& infile, const QString& outfile ) |
421 | { | 421 | { |
422 | preview->setRefreshingRate( 0 ); | 422 | preview->setRefreshingRate( 0 ); |
423 | 423 | ||
424 | /* | 424 | /* |
425 | unsigned char buf[153600]; | 425 | unsigned char buf[153600]; |
426 | 426 | ||
427 | int fd = ::open( "/var/compile/opie/noncore/multimedia/camera/capture-320x240.dat", O_RDONLY ); | 427 | int fd = ::open( "/var/compile/opie/noncore/multimedia/camera/capture-320x240.dat", O_RDONLY ); |
428 | ::read( fd, &buf, 153600 ); | 428 | ::read( fd, &buf, 153600 ); |
429 | QImage i; | 429 | QImage i; |
430 | bufferToImage( 240, 320, (unsigned char*) &buf, &i ); | 430 | bufferToImage( 240, 320, (unsigned char*) &buf, &i ); |
431 | QPixmap p; | 431 | QPixmap p; |
432 | p.convertFromImage( i ); | 432 | p.convertFromImage( i ); |
433 | preview->setPixmap( p ); | 433 | preview->setPixmap( p ); |
434 | imageToFile( &i, "/tmp/tmpfile", "JPEG", 100 ); | 434 | imageToFile( &i, "/tmp/tmpfile", "JPEG", 100 ); |
435 | return; | 435 | return; |
436 | */ | 436 | */ |
437 | 437 | ||
438 | QDialog* fr = new QDialog( this, "splash", false, QWidget::WStyle_StaysOnTop ); //, false, QWidget::WStyle_NoBorder | QWidget::WStyle_Customize ); | 438 | QDialog* fr = new QDialog( this, "splash", false, QWidget::WStyle_StaysOnTop ); //, false, QWidget::WStyle_NoBorder | QWidget::WStyle_Customize ); |
439 | fr->setCaption( "Please wait..." ); | 439 | fr->setCaption( "Please wait..." ); |
440 | QVBoxLayout* box = new QVBoxLayout( fr, 2, 2 ); | 440 | QVBoxLayout* box = new QVBoxLayout( fr, 2, 2 ); |
441 | QProgressBar* bar = new QProgressBar( fr ); | 441 | QProgressBar* bar = new QProgressBar( fr ); |
442 | bar->setCenterIndicator( true ); | 442 | bar->setCenterIndicator( true ); |
443 | bar->setTotalSteps( _videopics-1 ); | 443 | bar->setTotalSteps( _videopics-1 ); |
444 | QLabel* label = new QLabel( "Post processing frame bla/bla", fr ); | 444 | QLabel* label = new QLabel( "Post processing frame bla/bla", fr ); |
445 | box->addWidget( bar ); | 445 | box->addWidget( bar ); |
446 | box->addWidget( label ); | 446 | box->addWidget( label ); |
447 | fr->show(); | 447 | fr->show(); |
448 | label->show(); | 448 | label->show(); |
449 | bar->show(); | 449 | bar->show(); |
450 | fr->repaint(); | 450 | fr->repaint(); |
451 | qApp->processEvents(); | 451 | qApp->processEvents(); |
452 | 452 | ||
453 | // open files | 453 | // open files |
454 | 454 | ||
455 | int infd = ::open( (const char*) infile, O_RDONLY ); | 455 | int infd = ::open( (const char*) infile, O_RDONLY ); |
456 | if ( infd == -1 ) | 456 | if ( infd == -1 ) |
457 | { | 457 | { |
458 | owarn << "couldn't open capture file: " << strerror(errno) << oendl; | 458 | owarn << "couldn't open capture file: " << strerror(errno) << oendl; |
459 | return; | 459 | return; |
460 | } | 460 | } |
461 | 461 | ||
462 | int outfd = ::open( (const char*) outfile, O_CREAT | O_WRONLY | O_TRUNC, 0644 ); | 462 | int outfd = ::open( (const char*) outfile, O_CREAT | O_WRONLY | O_TRUNC, 0644 ); |
463 | if ( outfd == -1 ) | 463 | if ( outfd == -1 ) |
464 | { | 464 | { |
465 | owarn << "couldn't open output file: " << strerror(errno) << oendl; | 465 | owarn << "couldn't open output file: " << strerror(errno) << oendl; |
466 | return; | 466 | return; |
467 | } | 467 | } |
468 | 468 | ||
469 | int framesize = captureX*captureY*2; | 469 | int framesize = captureX*captureY*2; |
470 | 470 | ||
471 | unsigned char* inbuffer = new unsigned char[ framesize ]; | 471 | unsigned char* inbuffer = new unsigned char[ framesize ]; |
472 | QImage image; | 472 | QImage image; |
473 | 473 | ||
474 | avi_start( outfd, _videopics ); // write preambel | 474 | avi_start( outfd, _videopics ); // write preambel |
475 | 475 | ||
476 | // post process | 476 | // post process |
477 | 477 | ||
478 | for ( int i = 0; i < _videopics; ++i ) | 478 | for ( int i = 0; i < _videopics; ++i ) |
479 | { | 479 | { |
480 | odebug << "processing frame " << i << oendl; | 480 | odebug << "processing frame " << i << oendl; |
481 | 481 | ||
482 | // <gui> | 482 | // <gui> |
483 | label->setText( QString().sprintf( "Post processing frame %d / %d", i+1, _videopics ) ); | 483 | label->setText( QString().sprintf( "Post processing frame %d / %d", i+1, _videopics ) ); |
484 | bar->setProgress( i ); | 484 | bar->setProgress( i ); |
485 | bar->repaint(); | 485 | bar->repaint(); |
486 | qApp->processEvents(); | 486 | qApp->processEvents(); |
487 | // </gui> | 487 | // </gui> |
488 | 488 | ||
489 | int read = ::read( infd, inbuffer, framesize ); | 489 | int read = ::read( infd, inbuffer, framesize ); |
490 | odebug << "read " << read << " bytes" << oendl; | 490 | odebug << "read " << read << " bytes" << oendl; |
491 | bufferToImage( captureX, captureY, inbuffer, &image ); | 491 | bufferToImage( captureX, captureY, inbuffer, &image ); |
492 | 492 | ||
493 | QPixmap p; | 493 | QPixmap p; |
494 | p.convertFromImage( image ); | 494 | p.convertFromImage( image ); |
495 | preview->setPixmap( p ); | 495 | preview->setPixmap( p ); |
496 | preview->repaint(); | 496 | preview->repaint(); |
497 | qApp->processEvents(); | 497 | qApp->processEvents(); |
498 | 498 | ||
499 | #ifndef QT_NO_DEBUG | ||
500 | QString tmpfilename; | ||
501 | tmpfilename.sprintf( "/tmp/test/%04d.jpg", i ); | ||
502 | #else | ||
499 | QString tmpfilename( "/tmp/tempfile" ); | 503 | QString tmpfilename( "/tmp/tempfile" ); |
500 | //tmpfilename.sprintf( "/tmp/test/%d.jpg", i ); | 504 | #endif |
501 | 505 | ||
502 | imageToFile( &image, tmpfilename, "JPEG", quality ); | 506 | imageToFile( &image, tmpfilename, "JPEG", quality ); |
503 | 507 | ||
504 | QFile framefile( tmpfilename ); | 508 | QFile framefile( tmpfilename ); |
505 | if ( !framefile.open( IO_ReadOnly ) ) | 509 | if ( !framefile.open( IO_ReadOnly ) ) |
506 | { | 510 | { |
507 | oerr << "can't process file: %s" << strerror(errno) << oendl; | 511 | oerr << "can't process file: %s" << strerror(errno) << oendl; |
508 | return; // TODO: clean up temp ressources | 512 | return; // TODO: clean up temp ressources |
509 | } | 513 | } |
510 | 514 | ||
511 | int filesize = framefile.size(); | 515 | int filesize = framefile.size(); |
512 | odebug << "filesize for frame " << i << " = " << filesize << oendl; | 516 | odebug << "filesize for frame " << i << " = " << filesize << oendl; |
513 | 517 | ||
514 | unsigned char* tempbuffer = new unsigned char[ filesize ]; | 518 | unsigned char* tempbuffer = new unsigned char[ filesize ]; |
515 | framefile.readBlock( (char*) tempbuffer, filesize ); | 519 | framefile.readBlock( (char*) tempbuffer, filesize ); |
516 | avi_add( outfd, tempbuffer, filesize ); | 520 | avi_add( outfd, tempbuffer, filesize ); |
517 | delete tempbuffer; | 521 | delete tempbuffer; |
518 | framefile.close(); | 522 | framefile.close(); |
519 | } | 523 | } |
520 | 524 | ||
521 | avi_end( outfd, captureX, captureY, _framerate ); | 525 | avi_end( outfd, captureX, captureY, _framerate ); |
522 | 526 | ||
523 | fr->hide(); | 527 | fr->hide(); |
524 | delete fr; | 528 | delete fr; |
525 | 529 | ||
526 | updateCaption(); | 530 | updateCaption(); |
527 | 531 | ||
528 | } | 532 | } |
529 | 533 | ||
530 | 534 | ||
531 | void CameraMainWindow::updateCaption() | 535 | void CameraMainWindow::updateCaption() |
532 | { | 536 | { |
533 | if ( !_capturing ) | 537 | if ( !_capturing ) |
534 | setCaption( QString().sprintf( "Opie-Camera: %dx%d %s q%d z%d (%s)", captureX, captureY, (const char*) captureFormat.lower(), quality, zoom, (const char*) flip ) ); | 538 | setCaption( QString().sprintf( "Opie-Camera: %dx%d %s q%d z%d (%s)", captureX, captureY, (const char*) captureFormat.lower(), quality, zoom, (const char*) flip ) ); |
535 | else | 539 | else |
536 | setCaption( "Opie-Camera: => CAPTURING <=" ); | 540 | setCaption( "Opie-Camera: => CAPTURING <=" ); |
537 | } | 541 | } |
538 | 542 | ||
539 | 543 | ||
540 | #ifndef QT_NO_DEBUG | 544 | #ifndef QT_NO_DEBUG |
541 | void CameraMainWindow::doSomething() | 545 | void CameraMainWindow::doSomething() |
542 | { | 546 | { |
543 | captureX = 240; | 547 | captureX = 240; |
544 | captureY = 320; | 548 | captureY = 320; |
545 | _videopics = 176; | 549 | _videopics = 50; |
546 | _framerate = 5; | 550 | _framerate = 5; |
547 | postProcessVideo( "/var/compile/opie/noncore/multimedia/camera/capture-320x240.dat", | 551 | postProcessVideo( "/var/compile/opie/noncore/multimedia/camera/capture.dat", |
548 | "/tmp/output.avi" ); | 552 | "/tmp/output.avi" ); |
549 | } | 553 | } |
550 | #endif | 554 | #endif |
551 | 555 | ||